diff --git a/app/build.gradle b/app/build.gradle index 29e302c23..f7cfd8d8b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -49,7 +49,6 @@ dependencies { compile 'com.android.support:appcompat-v7:23.0.0' compile 'de.greenrobot:greendao:1.3.7' compile 'com.squareup.leakcanary:leakcanary-android:1.3.1' - compile 'com.google.android.gms:play-services-analytics:7.8.0' compile fileTree(dir: 'libs', include: ['*.jar']) compile project(':unifile') compile project(':vectorold') diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 54aed3f4b..3882477ab 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -41,3 +41,6 @@ -keepclassmembers class * extends com.hippo.scene.preference.PreferenceBase { public static android.support.v7.widget.RecyclerView$ViewHolder createViewHolder(android.content.Context, android.view.ViewGroup); } + +# API 23 remove most stuff in org.apache.http +-dontwarn org.apache.http.** 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 ff42f1bb4..e68e84f7b 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 @@ -32,6 +32,7 @@ import android.widget.Toast; import com.hippo.animation.SimpleAnimatorListener; import com.hippo.conaco.Conaco; +import com.hippo.effect.ViewTransition; import com.hippo.ehviewer.Constants; import com.hippo.ehviewer.EhApplication; import com.hippo.ehviewer.EhCacheKeyFactory; @@ -71,6 +72,7 @@ public class DownloadScene extends AppbarScene implements DrawerProvider, private static long ANIMATE_TIME = 300l; + private View mTip; private EasyRecyclerView mRecyclerView; private FabLayout mFabLayout; private View mStart; @@ -80,6 +82,8 @@ public class DownloadScene extends AppbarScene implements DrawerProvider, private View mCheckAll; private View mMainFab; + private ViewTransition mViewTransition; + private DownloadAdapter mAdapter; private List mDownloadInfos; @@ -106,15 +110,14 @@ public class DownloadScene extends AppbarScene implements DrawerProvider, private void initLabels() { Resources resources = getContext().getResources(); mLabels = DBUtils.getAllDownloadLabel(); - mLabels.add(0, resources.getString(R.string.download_tag_default)); - mLabels.add(0, resources.getString(R.string.download_tag_all)); + mLabels.add(0, resources.getString(R.string.download_label_default)); + mLabels.add(0, resources.getString(R.string.download_label_all)); } @Override protected void onInit() { super.onInit(); - mActivatedLabel = LABEL_DEFAULT; mActivatedLabelPosition = INDEX_DEFAULT; mDownloadInfos = DownloadManager.getInstance().getDownloadList(null); @@ -136,9 +139,9 @@ public class DownloadScene extends AppbarScene implements DrawerProvider, private void updateTitle() { String label; if (mActivatedLabel == LABEL_ALL) { - label = getContext().getResources().getString(R.string.download_tag_all); + label = getContext().getResources().getString(R.string.download_label_all); } else if (mActivatedLabel == LABEL_DEFAULT) { - label = getContext().getResources().getString(R.string.download_tag_default); + label = getContext().getResources().getString(R.string.download_label_default); } else { label = mActivatedLabel; } @@ -155,6 +158,7 @@ public class DownloadScene extends AppbarScene implements DrawerProvider, initLabels(); + mTip = findViewById(R.id.tip); mRecyclerView = (EasyRecyclerView) findViewById(R.id.recycler_view); mFabLayout = (FabLayout) findViewById(R.id.fab_layout); mMainFab = mFabLayout.getPrimaryFab(); @@ -197,6 +201,13 @@ public class DownloadScene extends AppbarScene implements DrawerProvider, mRightDrawerView.showRecyclerView(false); updateTitle(); + + mViewTransition = new ViewTransition(mTip, mRecyclerView); + if (mAdapter.getItemCount() == 0) { + mViewTransition.showView(0, false); + } else { + mViewTransition.showView(1, false); + } } @Override @@ -408,38 +419,48 @@ public class DownloadScene extends AppbarScene implements DrawerProvider, return; } - int mix = (int) obj; - int ops = DownloadManager.getOps(mix); - int gid = DownloadManager.getGid(mix); + try { + int mix = (int) obj; + int ops = DownloadManager.getOps(mix); + int gid = DownloadManager.getGid(mix); - if (ops == DownloadManager.OPS_ALL_CHANGE || - ops == DownloadManager.OPS_REMOVE) { - // OPS_REMOVE can't find position by gid, just notifyDataSetChanged - mGidPositionMap.clear(); - mAdapter.notifyDataSetChanged(); - return; - } else if (ops == DownloadManager.OPS_ADD) { - // Add break list, need clean gid position map - mGidPositionMap.clear(); - } - - int position = getPositionForGid(gid); - if (position == -1) { - if (mLastUpdateSize != mAdapter.getItemCount()) { - // Can't get position, notifyDataSetChanged for safe + if (ops == DownloadManager.OPS_ALL_CHANGE || + ops == DownloadManager.OPS_REMOVE) { + // OPS_REMOVE can't find position by gid, just notifyDataSetChanged + mGidPositionMap.clear(); mAdapter.notifyDataSetChanged(); + return; + } else if (ops == DownloadManager.OPS_ADD) { + // Add break list, need clean gid position map + mGidPositionMap.clear(); + } + + int position = getPositionForGid(gid); + if (position == -1) { + if (mLastUpdateSize != mAdapter.getItemCount()) { + // Can't get position, notifyDataSetChanged for safe + mAdapter.notifyDataSetChanged(); + } + return; + } + + if (ops == DownloadManager.OPS_ADD) { + mAdapter.notifyItemInserted(position); + } else if (ops == DownloadManager.OPS_UPDATE) { + RecyclerView.ViewHolder holder = mRecyclerView.findViewHolderForAdapterPosition(position); + if (holder != null) { + bindHolder((DownloadHolder) holder, mDownloadInfos.get(position)); + } + } + } finally { + // Try to show tip + if (mAdapter.getItemCount() == 0) { + mViewTransition.showView(0, true); + } else { + mViewTransition.showView(1, true); } - return; } - if (ops == DownloadManager.OPS_ADD) { - mAdapter.notifyItemInserted(position); - } else if (ops == DownloadManager.OPS_UPDATE) { - RecyclerView.ViewHolder holder = mRecyclerView.findViewHolderForAdapterPosition(position); - if (holder != null) { - bindHolder((DownloadHolder) holder, mDownloadInfos.get(position)); - } - } } else if (id == Constants.MESSENGER_ID_MODIFY_DOWNLOAD_LABEL_FROM_SCENE || id == Constants.MESSENGER_ID_MODIFY_DOWNLOAD_LABEL_FROM_MANAGER) { AssertUtils.assertInstanceof("Messenger obj must be DownloadLabelOps", obj, DownloadManager.DownloadLabelModify.class); @@ -465,6 +486,13 @@ public class DownloadScene extends AppbarScene implements DrawerProvider, mGidPositionMap.clear(); mAdapter.notifyDataSetChanged(); mRecyclerView.scrollToPosition(0); + + // Try to show tip + if (mAdapter.getItemCount() == 0) { + mViewTransition.showView(0, true); + } else { + mViewTransition.showView(1, true); + } } break; case DownloadManager.DownloadLabelModify.OPS_MOVE: @@ -536,6 +564,13 @@ public class DownloadScene extends AppbarScene implements DrawerProvider, if (!infos.isEmpty()) { DownloadManager.getInstance().moveDownloadInfo(infos, label); mAdapter.notifyDataSetChanged(); + + // Try to show tip + if (mAdapter.getItemCount() == 0) { + mViewTransition.showView(0, true); + } else { + mViewTransition.showView(1, true); + } } return true; } @@ -581,7 +616,7 @@ public class DownloadScene extends AppbarScene implements DrawerProvider, } if (mActivatedLabelPosition != INDEX_DEFAULT) { hasDefaultLabel = true; - labels.add(getResources().getString(R.string.download_tag_default)); + labels.add(getResources().getString(R.string.download_label_default)); } if (labels.isEmpty()) { @@ -861,6 +896,13 @@ public class DownloadScene extends AppbarScene implements DrawerProvider, mGidPositionMap.clear(); mAdapter.notifyDataSetChanged(); + // Try to show tip + if (mAdapter.getItemCount() == 0) { + mViewTransition.showView(0, true); + } else { + mViewTransition.showView(1, true); + } + mRecyclerView.scrollToPosition(0); ((ContentActivity) getStageActivity()).closeDrawers(); } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java index d86cc793f..47eaeaa29 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java @@ -559,7 +559,7 @@ public class GalleryDetailScene extends Scene implements View.OnClickListener, private String[] getLabels() { List labels = DBUtils.getAllDownloadLabel(); - labels.add(0, getContext().getResources().getString(R.string.download_tag_default)); + labels.add(0, getContext().getResources().getString(R.string.download_label_default)); return labels.toArray(new String[labels.size()]); } diff --git a/app/src/main/res/layout/scene_download.xml b/app/src/main/res/layout/scene_download.xml index 45e8d262c..ae305eadc 100644 --- a/app/src/main/res/layout/scene_download.xml +++ b/app/src/main/res/layout/scene_download.xml @@ -20,6 +20,31 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + + + + + + + Incomplete - All - Default + Download list is empty + All + Default Keyword Search diff --git a/vectorold b/vectorold index ad4a29839..f6690cb1c 160000 --- a/vectorold +++ b/vectorold @@ -1 +1 @@ -Subproject commit ad4a29839224f22ef160732e8fc67e3b4a8913cc +Subproject commit f6690cb1c4b1236551e261ddc6a2e598102e7f2e