From 4edc7f082bd59533c8d41de240b41085630a1e20 Mon Sep 17 00:00:00 2001 From: seven332 Date: Sat, 26 Mar 2016 17:02:06 +0800 Subject: [PATCH] Add refresh and go to fab in GalleryListScene --- .../com/hippo/app/EditTextDialogBuilder.java | 5 + .../ehviewer/ui/scene/FavoritesScene.java | 35 +- .../ehviewer/ui/scene/GalleryListScene.java | 324 ++++++++++++++---- .../java/com/hippo/view/ViewTransition.java | 14 + .../java/com/hippo/widget/ContentLayout.java | 43 +-- .../main/res/drawable/v_refresh_dark_x24.xml | 29 ++ .../main/res/layout/scene_gallery_list.xml | 37 +- app/src/main/res/values-zh-rCN/strings.xml | 3 + app/src/main/res/values-zh-rHK/strings.xml | 3 + app/src/main/res/values-zh-rTW/strings.xml | 3 + app/src/main/res/values/pathdata.xml | 1 + app/src/main/res/values/strings.xml | 3 + build.gradle | 2 +- easyrecyclerview | 2 +- 14 files changed, 396 insertions(+), 108 deletions(-) create mode 100644 app/src/main/res/drawable/v_refresh_dark_x24.xml diff --git a/app/src/main/java/com/hippo/app/EditTextDialogBuilder.java b/app/src/main/java/com/hippo/app/EditTextDialogBuilder.java index 14ea6399f..750bc39bf 100644 --- a/app/src/main/java/com/hippo/app/EditTextDialogBuilder.java +++ b/app/src/main/java/com/hippo/app/EditTextDialogBuilder.java @@ -44,10 +44,15 @@ public class EditTextDialogBuilder extends AlertDialog.Builder implements EditTe mTextInputLayout = (TextInputLayout) view; mEditText = (EditText) view.findViewById(R.id.edit_text); mEditText.setText(text); + mEditText.setSelection(mEditText.getText().length()); mEditText.setOnEditorActionListener(this); mTextInputLayout.setHint(hint); } + public EditText getEditText() { + return mEditText; + } + public String getText() { return mEditText.getText().toString(); } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/FavoritesScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/FavoritesScene.java index a5ede528e..b5ca04a4c 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/FavoritesScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/FavoritesScene.java @@ -165,15 +165,6 @@ public class FavoritesScene extends BaseScene implements // For modify action private boolean mModifyAdd; - private final Runnable mReturnSearchBarRunnable = new Runnable() { - @Override - public void run() { - if (mSearchBarMover != null) { - mSearchBarMover.returnSearchBarPosition(); - } - } - }; - private ShowcaseView mShowcaseView; @Override @@ -887,7 +878,6 @@ public class FavoritesScene extends BaseScene implements updateSearchBar(); mHelper.setPages(taskId, result.pages); mHelper.onGetPageData(taskId, result.galleryInfoList); - SimpleHandler.getInstance().post(mReturnSearchBarRunnable); } } @@ -914,7 +904,6 @@ public class FavoritesScene extends BaseScene implements mHelper.setPages(taskId, 1); mHelper.onGetPageData(taskId, list); } - SimpleHandler.getInstance().post(mReturnSearchBarRunnable); } } @@ -1100,14 +1089,6 @@ public class FavoritesScene extends BaseScene implements } } - @Override - protected void onHideRecyclerView() { - super.onHideRecyclerView(); - if (mSearchBarMover != null) { - mSearchBarMover.showSearchBar(); - } - } - @Override protected Context getContext() { return FavoritesScene.this.getContext2(); @@ -1138,6 +1119,22 @@ public class FavoritesScene extends BaseScene implements mAdapter.notifyItemRangeInserted(positionStart, itemCount); } } + + @Override + public void onShowView(View hiddenView, View shownView) { + if (null != mSearchBarMover) { + mSearchBarMover.showSearchBar(); + } + } + + @Override + protected void onScrollToPosition(int postion) { + if (0 == postion) { + if (null != mSearchBarMover) { + mSearchBarMover.showSearchBar(); + } + } + } } private static class AddFavoritesListener extends EhCallback { diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java index 55298ace9..96bf9dd47 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java @@ -32,6 +32,7 @@ import android.support.v4.widget.DrawerLayout; import android.support.v7.app.AlertDialog; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; +import android.text.InputType; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.TextUtils; @@ -41,6 +42,7 @@ import android.view.Gravity; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; +import android.view.ViewConfiguration; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; @@ -79,13 +81,13 @@ import com.hippo.util.ApiHelper; import com.hippo.util.DrawableManager; import com.hippo.view.ViewTransition; import com.hippo.widget.ContentLayout; +import com.hippo.widget.FabLayout; import com.hippo.widget.SearchBarMover; import com.hippo.widget.refreshlayout.RefreshLayout; import com.hippo.yorozuya.AnimationUtils; import com.hippo.yorozuya.AssertUtils; import com.hippo.yorozuya.MathUtils; import com.hippo.yorozuya.SimpleAnimatorListener; -import com.hippo.yorozuya.SimpleHandler; import com.hippo.yorozuya.ViewUtils; import java.lang.annotation.Retention; @@ -95,7 +97,8 @@ import java.util.List; public final class GalleryListScene extends BaseScene implements EasyRecyclerView.OnItemClickListener, EasyRecyclerView.OnItemLongClickListener, SearchBar.Helper, SearchBar.OnStateChangeListener, FastScroller.OnDragHandlerListener, - SearchLayout.Helper, View.OnClickListener, SearchBarMover.Helper { + SearchLayout.Helper, SearchBarMover.Helper, View.OnClickListener, FabLayout.OnClickFabListener, + FabLayout.OnExpandListener { @IntDef({STATE_NORMAL, STATE_SIMPLE_SEARCH, STATE_SEARCH, STATE_SEARCH_SHOW_LIST}) @Retention(RetentionPolicy.SOURCE) @@ -137,7 +140,9 @@ public final class GalleryListScene extends BaseScene @Nullable private SearchBar mSearchBar; @Nullable - private FloatingActionButton mFab; + private View mSearchFab; + @Nullable + private FabLayout mFabLayout; @Nullable private ViewTransition mViewTransition; @Nullable @@ -151,7 +156,45 @@ public final class GalleryListScene extends BaseScene @Nullable private SearchBarMover mSearchBarMover; @Nullable - private Animator.AnimatorListener mFabAnimatorListener; + private AddDeleteDrawable mActionFabDrawable; + + @Nullable + private final Animator.AnimatorListener mActionFabAnimatorListener = new SimpleAnimatorListener() { + @Override + public void onAnimationEnd(Animator animation) { + if (null != mFabLayout) { + mFabLayout.getPrimaryFab().setVisibility(View.INVISIBLE); + } + } + }; + + @Nullable + private final Animator.AnimatorListener mSearchFabAnimatorListener = new SimpleAnimatorListener() { + @Override + public void onAnimationEnd(Animator animation) { + if (null != mSearchFab) { + mSearchFab.setVisibility(View.INVISIBLE); + } + } + }; + + private int mHideActionFabSlop; + private boolean mShowActionFab = true; + + @Nullable + private final RecyclerView.OnScrollListener mOnScrollListener = new RecyclerView.OnScrollListener() { + @Override + public void onScrollStateChanged(RecyclerView recyclerView, int newState) {} + + @Override + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + if (dy >= mHideActionFabSlop) { + hideActionFab(); + } else if (dy < 0) { + showActionFab(); + } + } + }; @State private int mState = STATE_NORMAL; @@ -163,15 +206,6 @@ public final class GalleryListScene extends BaseScene private int mNavCheckedId = 0; - private final Runnable mReturnSearchBarRunnable = new Runnable() { - @Override - public void run() { - if (mSearchBarMover != null) { - mSearchBarMover.returnSearchBarPosition(); - } - } - }; - private ShowcaseView mShowcaseView; @Override @@ -347,6 +381,9 @@ public final class GalleryListScene extends BaseScene AssertUtils.assertNotNull(context); Resources resources = context.getResources(); + mHideActionFabSlop = ViewConfiguration.get(context).getScaledTouchSlop(); + mShowActionFab = true; + View mainLayout = ViewUtils.$$(view, R.id.main_layout); ContentLayout contentLayout = (ContentLayout) ViewUtils.$$(mainLayout, R.id.content_layout); mRecyclerView = contentLayout.getRecyclerView(); @@ -354,7 +391,8 @@ public final class GalleryListScene extends BaseScene RefreshLayout refreshLayout = contentLayout.getRefreshLayout(); mSearchLayout = (SearchLayout) ViewUtils.$$(mainLayout, R.id.search_layout); mSearchBar = (SearchBar) ViewUtils.$$(mainLayout, R.id.search_bar); - mFab = (FloatingActionButton) ViewUtils.$$(mainLayout, R.id.fab); + mFabLayout = (FabLayout) ViewUtils.$$(mainLayout, R.id.fab_layout); + mSearchFab = ViewUtils.$$(mainLayout, R.id.search_fab); int paddingTopSB = resources.getDimensionPixelOffset(R.dimen.list_padding_top_search_bar); int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.list_padding_bottom_fab); @@ -376,6 +414,7 @@ public final class GalleryListScene extends BaseScene mRecyclerView.setOnItemLongClickListener(this); mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop() + paddingTopSB, mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom()); + mRecyclerView.addOnScrollListener(mOnScrollListener); fastScroller.setPadding(fastScroller.getPaddingLeft(), fastScroller.getPaddingTop() + paddingTopSB, fastScroller.getPaddingRight(), fastScroller.getPaddingBottom()); @@ -394,7 +433,17 @@ public final class GalleryListScene extends BaseScene mSearchLayout.setPadding(mSearchLayout.getPaddingLeft(), mSearchLayout.getPaddingTop() + paddingTopSB, mSearchLayout.getPaddingRight(), mSearchLayout.getPaddingBottom() + paddingBottomFab); - mFab.setOnClickListener(this); + mFabLayout.setAutoCancel(true); + mFabLayout.setExpanded(false); + mFabLayout.setHidePrimaryFab(false); + mFabLayout.setOnClickFabListener(this); + mFabLayout.setOnExpandListener(this); + + mActionFabDrawable = new AddDeleteDrawable(context); + mActionFabDrawable.setColor(resources.getColor(R.color.primary_drawable_dark)); + mFabLayout.getPrimaryFab().setImageDrawable(mActionFabDrawable); + + mSearchFab.setOnClickListener(this); mSearchBarMover = new SearchBarMover(this, mSearchBar, mRecyclerView, mSearchLayout); @@ -454,7 +503,6 @@ public final class GalleryListScene extends BaseScene ViewUtils.removeFromParent(mShowcaseView); mShowcaseView = null; } - SimpleHandler.getInstance().removeCallbacks(mReturnSearchBarRunnable); if (null != mSearchBarMover) { mSearchBarMover.cancelAnimation(); mSearchBarMover = null; @@ -473,11 +521,12 @@ public final class GalleryListScene extends BaseScene mAdapter = null; mSearchLayout = null; mSearchBar = null; - mFab = null; + mFabLayout = null; + mSearchFab = null; mViewTransition = null; mLeftDrawable = null; mRightDrawable = null; - mFabAnimatorListener = null; + mActionFabDrawable = null; } private void showQuickSearchTipDialog(final List list, @@ -615,15 +664,6 @@ public final class GalleryListScene extends BaseScene return view; } - @Override - public void onClick(View v) { - if (mFab == v) { - if (mState != STATE_NORMAL && null != mSearchBar) { - mSearchBar.applySearch(); - } - } - } - private boolean checkDoubleClickExit() { if (getStackIndex() != 0) { return false; @@ -646,6 +686,11 @@ public final class GalleryListScene extends BaseScene return; } + if (null != mFabLayout && mFabLayout.isExpanded()) { + mFabLayout.setExpanded(false); + return; + } + boolean handle; switch (mState) { default: @@ -690,6 +735,98 @@ public final class GalleryListScene extends BaseScene return true; } + @Override + public void onClick(View v) { + if (STATE_NORMAL != mState && null != mSearchBar) { + mSearchBar.applySearch(); + } + } + + @Override + public void onClickPrimaryFab(FabLayout view, FloatingActionButton fab) { + if (STATE_NORMAL == mState) { + view.toggle(); + } + } + + private void showGoToDialog() { + Context context = getContext2(); + if (null == context || null == mHelper) { + return; + } + + final int page = mHelper.getPageForTop(); + final int pages = mHelper.getPages(); + String hint = getString(R.string.go_to_hint, page + 1, pages); + final EditTextDialogBuilder builder = new EditTextDialogBuilder(context, null, hint); + builder.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); + final AlertDialog dialog = builder.setTitle(R.string.go_to) + .setPositiveButton(android.R.string.ok, null) + .show(); + dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (null == mHelper) { + dialog.dismiss(); + return; + } + + String text = builder.getText().trim(); + int goTo; + try { + goTo = Integer.parseInt(text) - 1; + } catch (NumberFormatException e){ + builder.setError(getString(R.string.error_invalid_number)); + return; + } + if (goTo < 0 || goTo >= pages) { + builder.setError(getString(R.string.error_out_of_range)); + return; + } + builder.setError(null); + mHelper.goTo(goTo); + dialog.dismiss(); + } + }); + } + + @Override + public void onClickSecondaryFab(FabLayout view, FloatingActionButton fab, int position) { + if (null == mHelper) { + return; + } + + switch (position) { + case 0: // Go to + if (mHelper.canGoTo()) { + showGoToDialog(); + } + break; + case 1: // Refresh + mHelper.refresh(); + break; + } + + view.setExpanded(false); + } + + @Override + public void onExpand(boolean expanded) { + if (null == mActionFabDrawable) { + return; + } + + if (expanded) { + setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.LEFT); + setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT); + mActionFabDrawable.setDelete(ANIMATE_TIME); + } else { + setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.LEFT); + setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT); + mActionFabDrawable.setAdd(ANIMATE_TIME); + } + } + @Override public boolean onItemLongClick(EasyRecyclerView parent, View view, int position, long id) { final Context context = getContext2(); @@ -719,35 +856,94 @@ public final class GalleryListScene extends BaseScene return true; } - private void showFab() { - if (null == mFab) { - return; + private void showActionFab() { + if (null != mFabLayout && STATE_NORMAL == mState && !mShowActionFab) { + mShowActionFab = true; + View fab = mFabLayout.getPrimaryFab(); + fab.setVisibility(View.VISIBLE); + fab.animate().scaleX(1.0f).scaleY(1.0f).setListener(null) + .setDuration(ANIMATE_TIME).setStartDelay(0L) + .setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR).start(); } - - mFab.setVisibility(View.VISIBLE); - mFab.setScaleX(0.0f); - mFab.setScaleY(0.0f); - mFab.animate().scaleX(1.0f).scaleY(1.0f).setListener(null).setDuration(ANIMATE_TIME) - .setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR).start(); } - private void hideFab() { - if (null == mFab) { + private void hideActionFab() { + if (null != mFabLayout && STATE_NORMAL == mState && mShowActionFab) { + mShowActionFab = false; + View fab = mFabLayout.getPrimaryFab(); + fab.animate().scaleX(0.0f).scaleY(0.0f).setListener(mActionFabAnimatorListener) + .setDuration(ANIMATE_TIME).setStartDelay(0L) + .setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR).start(); + } + } + + private void selectSearchFab(boolean animation) { + if (null == mFabLayout || null == mSearchFab) { return; } - if (mFabAnimatorListener == null) { - mFabAnimatorListener = new SimpleAnimatorListener() { - @Override - public void onAnimationEnd(Animator animation) { - if (null != mFab) { - mFab.setVisibility(View.INVISIBLE); - } - } - }; + mShowActionFab = false; + + if (animation) { + View fab = mFabLayout.getPrimaryFab(); + long delay; + if (View.INVISIBLE == fab.getVisibility()) { + delay = 0L; + } else { + delay = ANIMATE_TIME; + fab.animate().scaleX(0.0f).scaleY(0.0f).setListener(mActionFabAnimatorListener) + .setDuration(ANIMATE_TIME).setStartDelay(0L) + .setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR).start(); + } + mSearchFab.setVisibility(View.VISIBLE); + mSearchFab.animate().scaleX(1.0f).scaleY(1.0f).setListener(null) + .setDuration(ANIMATE_TIME).setStartDelay(delay) + .setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR).start(); + } else { + mFabLayout.setExpanded(false, false); + View fab = mFabLayout.getPrimaryFab(); + fab.setVisibility(View.INVISIBLE); + fab.setScaleX(0.0f); + fab.setScaleY(0.0f); + mSearchFab.setVisibility(View.VISIBLE); + mSearchFab.setScaleX(1.0f); + mSearchFab.setScaleX(1.0f); + } + } + + private void selectActionFab(boolean animation) { + if (null == mFabLayout || null == mSearchFab) { + return; + } + + mShowActionFab = true; + + if (animation) { + long delay; + if (View.INVISIBLE == mSearchFab.getVisibility()) { + delay = 0L; + } else { + delay = ANIMATE_TIME; + mSearchFab.animate().scaleX(0.0f).scaleY(0.0f).setListener(mSearchFabAnimatorListener) + .setDuration(ANIMATE_TIME).setStartDelay(0L) + .setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR).start(); + } + View fab = mFabLayout.getPrimaryFab(); + fab.setVisibility(View.VISIBLE); + fab.animate().scaleX(1.0f).scaleY(1.0f).setListener(null) + .setDuration(ANIMATE_TIME).setStartDelay(delay) + .setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR).start(); + + } else { + mFabLayout.setExpanded(false, false); + View fab = mFabLayout.getPrimaryFab(); + fab.setVisibility(View.VISIBLE); + fab.setScaleX(1.0f); + fab.setScaleY(1.0f); + mSearchFab.setVisibility(View.INVISIBLE); + mSearchFab.setScaleX(0.0f); + mSearchFab.setScaleX(0.0f); } - mFab.animate().scaleX(0.0f).scaleY(0.0f).setListener(mFabAnimatorListener) - .setDuration(ANIMATE_TIME).setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR).start(); } private void setState(@State int state) { @@ -769,26 +965,26 @@ public final class GalleryListScene extends BaseScene if (state == STATE_SIMPLE_SEARCH) { mSearchBar.setState(SearchBar.STATE_SEARCH_LIST, animation); mSearchBarMover.returnSearchBarPosition(); - showFab(); + selectSearchFab(animation); } else if (state == STATE_SEARCH) { mViewTransition.showView(1, animation); mSearchLayout.scrollSearchContainerToTop(); mSearchBar.setState(SearchBar.STATE_SEARCH, animation); mSearchBarMover.returnSearchBarPosition(); - showFab(); + selectSearchFab(animation); } else if (state == STATE_SEARCH_SHOW_LIST) { mViewTransition.showView(1, animation); mSearchLayout.scrollSearchContainerToTop(); mSearchBar.setState(SearchBar.STATE_SEARCH_LIST, animation); mSearchBarMover.returnSearchBarPosition(); - showFab(); + selectSearchFab(animation); } break; case STATE_SIMPLE_SEARCH: if (state == STATE_NORMAL) { mSearchBar.setState(SearchBar.STATE_NORMAL, animation); mSearchBarMover.returnSearchBarPosition(); - hideFab(); + selectActionFab(animation); } else if (state == STATE_SEARCH) { mViewTransition.showView(1, animation); mSearchLayout.scrollSearchContainerToTop(); @@ -806,7 +1002,7 @@ public final class GalleryListScene extends BaseScene mViewTransition.showView(0, animation); mSearchBar.setState(SearchBar.STATE_NORMAL, animation); mSearchBarMover.returnSearchBarPosition(); - hideFab(); + selectActionFab(animation); } else if (state == STATE_SIMPLE_SEARCH) { mViewTransition.showView(0, animation); mSearchBar.setState(SearchBar.STATE_SEARCH_LIST, animation); @@ -821,7 +1017,7 @@ public final class GalleryListScene extends BaseScene mViewTransition.showView(0, animation); mSearchBar.setState(SearchBar.STATE_NORMAL, animation); mSearchBarMover.returnSearchBarPosition(); - hideFab(); + selectActionFab(animation); } else if (state == STATE_SIMPLE_SEARCH) { mViewTransition.showView(0, animation); mSearchBar.setState(SearchBar.STATE_SEARCH_LIST, animation); @@ -1077,11 +1273,21 @@ public final class GalleryListScene extends BaseScene } @Override - protected void onHideRecyclerView() { - super.onHideRecyclerView(); - if (mSearchBarMover != null) { + public void onShowView(View hiddenView, View shownView) { + if (null != mSearchBarMover) { mSearchBarMover.showSearchBar(); } + showActionFab(); + } + + @Override + protected void onScrollToPosition(int postion) { + if (0 == postion) { + if (null != mSearchBarMover) { + mSearchBarMover.showSearchBar(); + } + showActionFab(); + } } } @@ -1090,7 +1296,6 @@ public final class GalleryListScene extends BaseScene mHelper.isCurrentTask(taskId)) { mHelper.setPages(taskId, result.pages); mHelper.onGetPageData(taskId, result.galleryInfoList); - SimpleHandler.getInstance().post(mReturnSearchBarRunnable); } } @@ -1106,7 +1311,6 @@ public final class GalleryListScene extends BaseScene mHelper.isCurrentTask(taskId)) { mHelper.setPages(taskId, 1); mHelper.onGetPageData(taskId, result); - SimpleHandler.getInstance().post(mReturnSearchBarRunnable); } } diff --git a/app/src/main/java/com/hippo/view/ViewTransition.java b/app/src/main/java/com/hippo/view/ViewTransition.java index b00f1f57b..30f30b815 100644 --- a/app/src/main/java/com/hippo/view/ViewTransition.java +++ b/app/src/main/java/com/hippo/view/ViewTransition.java @@ -33,6 +33,8 @@ public class ViewTransition { private Animator mAnimator1; private Animator mAnimator2; + private OnShowViewListener mOnShowViewListener; + public ViewTransition(View... views) { if (views.length < 2) { throw new IllegalStateException("You must pass view to ViewTransition"); @@ -47,6 +49,10 @@ public class ViewTransition { showView(0, false); } + public void setOnShowViewListener(OnShowViewListener listener) { + mOnShowViewListener = listener; + } + public int getShownViewIndex() { return mShownView; } @@ -97,6 +103,10 @@ public class ViewTransition { } } + if (null != mOnShowViewListener) { + mOnShowViewListener.onShowView(views[oldShownView], views[shownView]); + } + return true; } else { return false; @@ -128,4 +138,8 @@ public class ViewTransition { oa2.start(); mAnimator2 = oa2; } + + public interface OnShowViewListener { + void onShowView(View hiddenView, View shownView); + } } diff --git a/app/src/main/java/com/hippo/widget/ContentLayout.java b/app/src/main/java/com/hippo/widget/ContentLayout.java index 95cf6e686..49cfea5d1 100644 --- a/app/src/main/java/com/hippo/widget/ContentLayout.java +++ b/app/src/main/java/com/hippo/widget/ContentLayout.java @@ -163,7 +163,7 @@ public class ContentLayout extends FrameLayout { super.onRestoreInstanceState(mContentHelper.restoreInstanceState(state)); } - public abstract static class ContentHelper { + public abstract static class ContentHelper implements ViewTransition.OnShowViewListener { private static final String TAG = ContentHelper.class.getSimpleName(); @@ -287,8 +287,8 @@ public class ContentLayout extends FrameLayout { private final LayoutManagerUtils.OnScrollToPositionListener mOnScrollToPositionListener = new LayoutManagerUtils.OnScrollToPositionListener() { @Override - public void onScrollToPosition() { - ContentHelper.this.onScrollToPosition(); + public void onScrollToPosition(int position) { + ContentHelper.this.onScrollToPosition(position); } }; @@ -307,6 +307,7 @@ public class ContentLayout extends FrameLayout { mTipView.setCompoundDrawables(null, drawable, null, null); mViewTransition = new ViewTransition(mContentView, mProgressView, mTipView); + mViewTransition.setOnShowViewListener(this); mRecyclerView.addOnScrollListener(mOnScrollListener); mRefreshLayout.setOnRefreshListener(mOnRefreshListener); @@ -335,11 +336,10 @@ public class ContentLayout extends FrameLayout { protected abstract void notifyItemRangeInserted(int positionStart, int itemCount); - protected void onScrollToPosition() { - } + protected void onScrollToPosition(int postion) {} - protected void onHideRecyclerView() { - } + @Override + public void onShowView(View hiddenView, View shownView) {} public int getShownViewIndex() { return mViewTransition.getShownViewIndex(); @@ -459,7 +459,7 @@ public class ContentLayout extends FrameLayout { // RecyclerView scroll mRecyclerView.stopScroll(); LayoutManagerUtils.scrollToPositionWithOffset(mRecyclerView.getLayoutManager(), 0, 0); - onScrollToPosition(); + onScrollToPosition(0); } break; case TYPE_PRE_PAGE: @@ -489,7 +489,7 @@ public class ContentLayout extends FrameLayout { // RecyclerView scroll, to top mRecyclerView.stopScroll(); LayoutManagerUtils.scrollToPositionWithOffset(mRecyclerView.getLayoutManager(), 0, 0); - onScrollToPosition(); + onScrollToPosition(0); } } } else { @@ -518,7 +518,7 @@ public class ContentLayout extends FrameLayout { } else { mRecyclerView.stopScroll(); LayoutManagerUtils.scrollToPositionWithOffset(mRecyclerView.getLayoutManager(), 0, 0); - onScrollToPosition(); + onScrollToPosition(0); } } break; @@ -546,7 +546,7 @@ public class ContentLayout extends FrameLayout { // RecyclerView scroll mRecyclerView.stopScroll(); LayoutManagerUtils.scrollToPositionWithOffset(mRecyclerView.getLayoutManager(), oldDataSize, 0); - onScrollToPosition(); + onScrollToPosition(oldDataSize); } } } else { @@ -570,11 +570,10 @@ public class ContentLayout extends FrameLayout { if (mCurrentTaskType == TYPE_NEXT_PAGE_KEEP_POS) { mRecyclerView.stopScroll(); mRecyclerView.smoothScrollBy(0, mNextPageScrollSize); - onScrollToPosition(); } else { mRecyclerView.stopScroll(); LayoutManagerUtils.scrollToPositionWithOffset(mRecyclerView.getLayoutManager(), oldDataSize, 0); - onScrollToPosition(); + onScrollToPosition(oldDataSize); } } break; @@ -618,7 +617,7 @@ public class ContentLayout extends FrameLayout { // RecyclerView scroll mRecyclerView.stopScroll(); LayoutManagerUtils.scrollToPositionWithOffset(mRecyclerView.getLayoutManager(), 0, 0); - onScrollToPosition(); + onScrollToPosition(0); } break; case TYPE_REFRESH_PAGE: @@ -655,7 +654,7 @@ public class ContentLayout extends FrameLayout { if (newIndexEnd > oldIndexEnd && newIndexEnd > 0) { mRecyclerView.stopScroll(); LayoutManagerUtils.scrollToPositionWithOffset(mRecyclerView.getLayoutManager(), newIndexEnd - 1, 0); - onScrollToPosition(); + onScrollToPosition(newIndexEnd - 1); } } break; @@ -697,16 +696,12 @@ public class ContentLayout extends FrameLayout { } public void showProgressBar(boolean animation) { - if (mViewTransition.showView(1, animation)) { - onHideRecyclerView(); - } + mViewTransition.showView(1, animation); } public void showText(CharSequence text) { mTipView.setText(text); - if (mViewTransition.showView(2)) { - onHideRecyclerView(); - } + mViewTransition.showView(2); } public void showEmptyString() { @@ -799,11 +794,11 @@ public class ContentLayout extends FrameLayout { } public int getPageForTop() { - return getPageForPosition(LayoutManagerUtils.getFirstVisibleItemPostion(mRecyclerView.getLayoutManager())); + return getPageForPosition(LayoutManagerUtils.getFirstVisibleItemPosition(mRecyclerView.getLayoutManager())); } public int getPageForBottom() { - return getPageForPosition(LayoutManagerUtils.getLastVisibleItemPostion(mRecyclerView.getLayoutManager())); + return getPageForPosition(LayoutManagerUtils.getLastVisibleItemPosition(mRecyclerView.getLayoutManager())); } public boolean canGoTo() { @@ -825,7 +820,7 @@ public class ContentLayout extends FrameLayout { int position = getPageStart(page); mRecyclerView.stopScroll(); LayoutManagerUtils.scrollToPositionWithOffset(mRecyclerView.getLayoutManager(), position, 0); - onScrollToPosition(); + onScrollToPosition(position); } else if (page == mStartPage - 1) { mRefreshLayout.setFooterRefreshing(false); mRefreshLayout.setHeaderRefreshing(true); diff --git a/app/src/main/res/drawable/v_refresh_dark_x24.xml b/app/src/main/res/drawable/v_refresh_dark_x24.xml new file mode 100644 index 000000000..65ee3831e --- /dev/null +++ b/app/src/main/res/drawable/v_refresh_dark_x24.xml @@ -0,0 +1,29 @@ + + + + + + + + diff --git a/app/src/main/res/layout/scene_gallery_list.xml b/app/src/main/res/layout/scene_gallery_list.xml index 4ac051e0f..52cfe5d10 100644 --- a/app/src/main/res/layout/scene_gallery_list.xml +++ b/app/src/main/res/layout/scene_gallery_list.xml @@ -41,18 +41,49 @@ android:layout_marginTop="8dp"/> + + + + + + + + + + diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 1e162ba13..835fb834f 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -72,6 +72,7 @@ 指定画廊的关键字应该看起来像 \"618395 0439fa3666\" 无法创建临时文件 无法保存图片 + 非法数字 本应用中内容来自互联网,部分内容可能对您的生理及心理造成难以恢复的伤害。本应用作者不会对由本应用造成的后果负责。您是否愿意继续使用该应用? 用户名不可为空 @@ -143,6 +144,8 @@ 已存在相同的快速搜索,名称为“%s”。 已存在相同名称 + 第 %1$d 页,共 %2$d 页 + 2 星 3 星 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 7a6925864..1e0db93b4 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -72,6 +72,7 @@ 指定畫廊的關鍵字應該看起來像 \"618395 0439fa3666\" 無法創建臨時文件 無法保存圖片 + 非法數字 本應用中內容來自互聯網,部分內容可能對您的生理及心理造成難以恢復的傷害。本應用作者不會對由本應用造成的後果負責。您是否願意繼續使用該應用? 用户名不可為空 @@ -143,6 +144,8 @@ 已存在相同的快速搜索,名稱為“%s”。 已存在相同名稱 + 第 %1$d 頁,共 %2$d 頁 + 2 星 3 星 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 36da6c053..f45e3f447 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -72,6 +72,7 @@ 指定畫廊的關鍵字應該看起來像 \"618395 0439fa3666\" 無法建立臨時檔案 無法儲存圖片 + 非法數字 本應用中內容來自網際網路,部分內容可能對您的生理及心理造成難以恢復的傷害。本應用作者不會對由本應用造成的後果負責。您是否願意繼續使用該應用? 使用者名稱不可為空 @@ -143,6 +144,8 @@ 已存在相同的快速搜尋,名稱為“%s”。 已存在相同名稱 + 第 %1$d 頁,共 %2$d 頁 + 2 星 3 星 diff --git a/app/src/main/res/values/pathdata.xml b/app/src/main/res/values/pathdata.xml index e4519f39b..833cb45e2 100644 --- a/app/src/main/res/values/pathdata.xml +++ b/app/src/main/res/values/pathdata.xml @@ -58,6 +58,7 @@ M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z M5,13H19V11H5M3,17H17V15H3M7,7V9H21V7 M2,20L17,10L22,22M14,9L2,8L11,2Z + M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z M12.88,2H4V11L14.97,22.14L24,13.1L12.88,2ZM7.26,5.26C7.96,4.58,9.06,4.58,9.74,5.26C10.42,5.96,10.42,7.06,9.74,7.74S7.94,8.42,7.26,7.74S6.58,5.94,7.26,5.26ZM14.98,19.3L8.76,12.95L14.88,6.83L21.18,13.11L14.98,19.31ZM11.6,21.56L10.23,23L0,12.74V5H2V11.9L11.6,21.56Z M20.46,14.65C21.86,16.15,20.31,18.6,18.32,17.87C19.78,17.57,20.79,16.37,20.46,14.65ZM4.32,17.87C6.32,18.6,7.86,16.17,6.46,14.65C6.79,16.38,5.78,17.55,4.32,17.87ZM16.87,4.3C16.6,3.56,15.87,3,15,3C13.7,3,12.7,4.24,13.1,5.58C14.2,5.18,15.44,4.48,16.87,4.31ZM24,16C24,18.76,21.76,21,19,21C14.96,21,14.84,16.88,12,16.88S9.04,21,5,21C2.24,21,0,18.76,0,16C0,13.87,1.53,11.43,3.94,7.18C5.84,3.81,8.69,5.92,10.76,6.58C11.54,6.85,12.41,6.88,13.24,6.58C15.3,5.92,18.14,3.81,20.06,7.18C22.46,11.43,24,13.88,24,16ZM8,16C8,14.35,6.65,13,5,13S2,14.35,2,16S3.35,19,5,19S8,17.65,8,16ZM13,14C13,13.45,12.55,13,12,13S11,13.45,11,14S11.45,15,12,15S13,14.55,13,14ZM22,16C22,14.35,20.65,13,19,13S16,14.35,16,16S17.35,19,19,19S22,17.65,22,16ZM9,3C8.14,3,7.4,3.55,7.13,4.3C8.56,4.48,9.79,5.2,10.9,5.58C11.3,4.24,10.3,3,9,3Z diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index babe1400e..ba832d720 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -114,6 +114,7 @@ Keyword should looks like \"618395 0439fa3666\" for specify gallery Can\'t create temp file Can\'t save image + Invalid number The content of this application is from the Internet. Some of it may do physical or mental harm to you. You have learnt the risks above and would like to undertake them. Do you want to use this application? Username cannot be an empty string @@ -185,6 +186,8 @@ A duplicate quick search exists. The name is \"%s\". A duplicate name exists + Page %1$d, total %2$d pages + 2 stars 3 stars diff --git a/build.gradle b/build.gradle index e293b0d3e..db868459f 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.0-alpha3' + classpath 'com.android.tools.build:gradle:2.1.0-alpha4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/easyrecyclerview b/easyrecyclerview index 68135c110..8ead137d4 160000 --- a/easyrecyclerview +++ b/easyrecyclerview @@ -1 +1 @@ -Subproject commit 68135c110b0f5b4294c0cf9dd7e3d98326bad71f +Subproject commit 8ead137d467899e51d6a29503904d9c9eea14942