mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Persist scrolling after configuration change
This commit is contained in:
@@ -40,7 +40,7 @@ public class BundleSavedState extends View.BaseSavedState
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
final Bundle bundle;
|
public final Bundle bundle;
|
||||||
|
|
||||||
public BundleSavedState(Parcelable superState, Bundle bundle)
|
public BundleSavedState(Parcelable superState, Bundle bundle)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,12 +20,14 @@
|
|||||||
package org.isoron.uhabits.activities.habits.list.views;
|
package org.isoron.uhabits.activities.habits.list.views;
|
||||||
|
|
||||||
import android.content.*;
|
import android.content.*;
|
||||||
|
import android.os.*;
|
||||||
import android.support.annotation.*;
|
import android.support.annotation.*;
|
||||||
import android.support.v7.widget.*;
|
import android.support.v7.widget.*;
|
||||||
import android.support.v7.widget.helper.*;
|
import android.support.v7.widget.helper.*;
|
||||||
import android.util.*;
|
import android.util.*;
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
|
|
||||||
|
import org.isoron.uhabits.activities.common.views.*;
|
||||||
import org.isoron.uhabits.activities.habits.list.controllers.*;
|
import org.isoron.uhabits.activities.habits.list.controllers.*;
|
||||||
import org.isoron.uhabits.activities.habits.list.model.*;
|
import org.isoron.uhabits.activities.habits.list.model.*;
|
||||||
import org.isoron.uhabits.models.*;
|
import org.isoron.uhabits.models.*;
|
||||||
@@ -127,7 +129,7 @@ public class HabitCardListView extends RecyclerView
|
|||||||
public void setDataOffset(int dataOffset)
|
public void setDataOffset(int dataOffset)
|
||||||
{
|
{
|
||||||
this.dataOffset = dataOffset;
|
this.dataOffset = dataOffset;
|
||||||
for(HabitCardViewHolder holder : attachedHolders)
|
for (HabitCardViewHolder holder : attachedHolders)
|
||||||
{
|
{
|
||||||
HabitCardView cardView = (HabitCardView) holder.itemView;
|
HabitCardView cardView = (HabitCardView) holder.itemView;
|
||||||
cardView.setDataOffset(dataOffset);
|
cardView.setDataOffset(dataOffset);
|
||||||
@@ -148,6 +150,23 @@ public class HabitCardListView extends RecyclerView
|
|||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRestoreInstanceState(Parcelable state)
|
||||||
|
{
|
||||||
|
BundleSavedState bss = (BundleSavedState) state;
|
||||||
|
dataOffset = bss.bundle.getInt("dataOffset");
|
||||||
|
super.onRestoreInstanceState(bss.getSuperState());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Parcelable onSaveInstanceState()
|
||||||
|
{
|
||||||
|
Parcelable superState = super.onSaveInstanceState();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putInt("dataOffset", dataOffset);
|
||||||
|
return new BundleSavedState(superState, bundle);
|
||||||
|
}
|
||||||
|
|
||||||
protected void setupCardViewController(@NonNull HabitCardViewHolder holder)
|
protected void setupCardViewController(@NonNull HabitCardViewHolder holder)
|
||||||
{
|
{
|
||||||
HabitCardView cardView = (HabitCardView) holder.itemView;
|
HabitCardView cardView = (HabitCardView) holder.itemView;
|
||||||
@@ -193,7 +212,7 @@ public class HabitCardListView extends RecyclerView
|
|||||||
{
|
{
|
||||||
int position = holder.getAdapterPosition();
|
int position = holder.getAdapterPosition();
|
||||||
if (controller != null) controller.onItemLongClick(position);
|
if (controller != null) controller.onItemLongClick(position);
|
||||||
if(adapter.isSortable()) touchHelper.startDrag(holder);
|
if (adapter.isSortable()) touchHelper.startDrag(holder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user