diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadScene.java
index 0050a7540..4b659080f 100644
--- a/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadScene.java
+++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadScene.java
@@ -23,7 +23,6 @@ import android.content.Intent;
import android.content.res.Resources;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
-import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.View;
import android.view.ViewGroup;
@@ -200,6 +199,7 @@ public class DownloadScene extends AppbarScene implements DrawerProvider,
mRightDrawerView.setPlusVisibility(View.GONE);
mRightDrawerView.setHelper(this);
mRightDrawerView.showRecyclerView(false);
+ mRightDrawerView.addOnChildAttachStateChangeListener(new DownloadLabelStateChangeListener());
updateTitle();
@@ -372,23 +372,16 @@ public class DownloadScene extends AppbarScene implements DrawerProvider,
@Override
public void onClick(View v) {
-
- Log.d("TAG", "mDeleteListener 1");
-
if (mRecyclerView.inCustomChoice()) {
return;
}
- Log.d("TAG", "mDeleteListener 2");
-
int position = getAdapterPosition(v);
if (position >= 0) {
// Add to cache
DownloadInfo info = mDownloadInfos.get(position);
mGidPositionMap.add(info.galleryBase.gid, position);
- Log.d("TAG", "mDeleteListener 3");
-
// Delete
DownloadManager.getInstance().deleteDownloadInfo(info);
}
@@ -415,6 +408,20 @@ public class DownloadScene extends AppbarScene implements DrawerProvider,
return position;
}
+ private void updateActivated() {
+ EasyRecyclerView recyclerView = mRightDrawerView.getRecyclerView();
+
+ for (int i = 0, n = recyclerView.getChildCount(); i < n; i++) {
+ View view = recyclerView.getChildAt(i);
+ int position = recyclerView.getChildAdapterPosition(view);
+ if (mActivatedLabelPosition >= 0 && mActivatedLabelPosition == position) {
+ view.setActivated(true);
+ } else {
+ view.setActivated(false);
+ }
+ }
+ }
+
@Override
public void onReceive(int id, Object obj) {
if (id == Constants.MESSENGER_ID_UPDATE_DOWNLOAD) {
@@ -487,6 +494,7 @@ public class DownloadScene extends AppbarScene implements DrawerProvider,
mActivatedLabel = LABEL_DEFAULT;
mActivatedLabelPosition = INDEX_DEFAULT;
updateTitle();
+ updateActivated();
mDownloadInfos = DownloadManager.getInstance().getDownloadList(null);
mGidPositionMap.clear();
@@ -511,6 +519,7 @@ public class DownloadScene extends AppbarScene implements DrawerProvider,
// Update activated info
if (fromPosition == mActivatedLabelPosition) {
mActivatedLabelPosition = toPosition;
+ updateActivated();
}
}
break;
@@ -914,6 +923,7 @@ public class DownloadScene extends AppbarScene implements DrawerProvider,
mDownloadInfos = DownloadManager.getInstance().getDownloadList(mActivatedLabel);
}
updateTitle();
+ updateActivated();
mGidPositionMap.clear();
mAdapter.notifyDataSetChanged();
@@ -956,4 +966,22 @@ public class DownloadScene extends AppbarScene implements DrawerProvider,
return mLabels == null ? 0 : mLabels.size();
}
}
+
+ public class DownloadLabelStateChangeListener implements RecyclerView.OnChildAttachStateChangeListener {
+
+ @Override
+ public void onChildViewAttachedToWindow(View view) {
+ int position = mRightDrawerView.getChildAdapterPosition(view);
+ if (position == mActivatedLabelPosition) {
+ view.setActivated(true);
+ } else {
+ view.setActivated(false);
+ }
+ }
+
+ @Override
+ public void onChildViewDetachedFromWindow(View view) {
+
+ }
+ }
}
diff --git a/app/src/main/java/com/hippo/ehviewer/widget/AppbarRecyclerView.java b/app/src/main/java/com/hippo/ehviewer/widget/AppbarRecyclerView.java
index d0744abac..1ddadcc49 100644
--- a/app/src/main/java/com/hippo/ehviewer/widget/AppbarRecyclerView.java
+++ b/app/src/main/java/com/hippo/ehviewer/widget/AppbarRecyclerView.java
@@ -113,6 +113,10 @@ public class AppbarRecyclerView extends LinearLayout implements View.OnClickList
mRecyclerView.setAdapter(adapter);
}
+ public void addOnChildAttachStateChangeListener(RecyclerView.OnChildAttachStateChangeListener listener) {
+ mRecyclerView.addOnChildAttachStateChangeListener(listener);
+ }
+
public void showTip(boolean animation) {
mViewTransition.showView(0, animation);
}
@@ -125,6 +129,14 @@ public class AppbarRecyclerView extends LinearLayout implements View.OnClickList
mRecyclerView.setOnItemClickListener(listener);
}
+ public int getChildAdapterPosition(View view) {
+ return mRecyclerView.getChildAdapterPosition(view);
+ }
+
+ public EasyRecyclerView getRecyclerView() {
+ return mRecyclerView;
+ }
+
public void setFitPaddingBottom(int fitPaddingBottom) {
mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop(),
mRecyclerView.getPaddingRight(), mOriginalPaddingBottom + fitPaddingBottom);
diff --git a/app/src/main/java/com/hippo/widget/recyclerview/EasyRecyclerView.java b/app/src/main/java/com/hippo/widget/recyclerview/EasyRecyclerView.java
index e74ac74e5..fe757d1f1 100644
--- a/app/src/main/java/com/hippo/widget/recyclerview/EasyRecyclerView.java
+++ b/app/src/main/java/com/hippo/widget/recyclerview/EasyRecyclerView.java
@@ -110,8 +110,6 @@ public class EasyRecyclerView extends RecyclerView {
private SparseBooleanArray mTempCheckStates;
- private FixCheckedHelper mFixCheckedHelper;
-
/**
* Running count of how many items are currently checked
*/
@@ -415,6 +413,18 @@ public class EasyRecyclerView extends RecyclerView {
}
}
+ @Override
+ public void onChildAttachedToWindow(View child) {
+ super.onChildAttachedToWindow(child);
+
+ if (mCheckStates != null) {
+ int position = getChildAdapterPosition(child);
+ if (position >= 0) {
+ setViewChecked(child, mCheckStates.get(position));
+ }
+ }
+ }
+
/**
* Returns the number of items currently selected. This will only be valid
* if the choice mode is not {@link #CHOICE_MODE_NONE} (default).
@@ -676,10 +686,6 @@ public class EasyRecyclerView extends RecyclerView {
if (mCheckedIdStates == null && mAdapter != null && mAdapter.hasStableIds()) {
mCheckedIdStates = new LongSparseArray<>(0);
}
- if (mFixCheckedHelper == null) {
- mFixCheckedHelper = new FixCheckedHelper();
- addOnChildAttachStateChangeListener(mFixCheckedHelper);
- }
// Modal multi-choice mode only has choices when the mode is active. Clear them.
if (mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL) {
clearChoices();
@@ -1352,22 +1358,6 @@ public class EasyRecyclerView extends RecyclerView {
boolean beforeDrawSelector(int position);
}
- public class FixCheckedHelper implements OnChildAttachStateChangeListener {
-
- @Override
- public void onChildViewAttachedToWindow(View view) {
- int position = getChildAdapterPosition(view);
- if (position >= 0) {
- setViewChecked(view, mCheckStates.get(position));
- }
- }
-
- @Override
- public void onChildViewDetachedFromWindow(View view) {
-
- }
- }
-
/**
* A MultiChoiceModeListener receives events for {@link android.widget.AbsListView#CHOICE_MODE_MULTIPLE_MODAL}.
* It acts as the {@link android.support.v7.view.ActionMode.Callback} for the selection mode and also receives
diff --git a/app/src/main/res/color/appbar_recycler_view_item_text.xml b/app/src/main/res/color/appbar_recycler_view_item_text.xml
new file mode 100644
index 000000000..88aeba196
--- /dev/null
+++ b/app/src/main/res/color/appbar_recycler_view_item_text.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/appbar_recycler_view_item_background.xml b/app/src/main/res/drawable/appbar_recycler_view_item_background.xml
new file mode 100644
index 000000000..8777a7404
--- /dev/null
+++ b/app/src/main/res/drawable/appbar_recycler_view_item_background.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/item_appbar_recycler_view.xml b/app/src/main/res/layout/item_appbar_recycler_view.xml
index bf53a1035..191e1bb0f 100644
--- a/app/src/main/res/layout/item_appbar_recycler_view.xml
+++ b/app/src/main/res/layout/item_appbar_recycler_view.xml
@@ -22,6 +22,6 @@
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:minHeight="48dp"
- android:textColor="@color/secondary_text_light"
+ android:textColor="@color/appbar_recycler_view_item_text"
android:textSize="@dimen/text_little_small"
- android:background="@android:color/white"/>
+ android:background="@drawable/appbar_recycler_view_item_background"/>