Add refresh and go to fab in GalleryListScene

This commit is contained in:
seven332 committed 2016-03-26 17:02:06 +08:00
1 parent 3a01dd6b5b
commit 4edc7f082b
14 files changed
+396 -108

No files matched your search

@@ -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();
}
@@ -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<FavoritesScene, Void> {
@@ -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<QuickSearch> 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);
}
}
@@ -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);
}
}
@@ -163,7 +163,7 @@ public class ContentLayout extends FrameLayout {
super.onRestoreInstanceState(mContentHelper.restoreInstanceState(state));
}
public abstract static class ContentHelper<E extends Parcelable> {
public abstract static class ContentHelper<E extends Parcelable> 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);
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2016 Hippo Seven
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/primary_drawable_dark"
android:pathData="@string/pd_refresh"/>
</vector>
+34 -3
View File
@@ -41,18 +41,49 @@
android:layout_marginTop="8dp"/>
<com.hippo.widget.FabLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fab_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingRight="@dimen/corner_fab_margin"
android:paddingBottom="@dimen/corner_fab_margin">
<android.support.design.widget.FloatingActionButton
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
app:srcCompat="@drawable/v_go_to_dark_x24"
app:backgroundTint="?attr/colorPrimary"
style="@style/Widget.Design.FloatingActionButton.Mini"/>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/v_refresh_dark_x24"
app:backgroundTint="?attr/colorPrimary"
style="@style/Widget.Design.FloatingActionButton.Mini"/>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Widget.Design.FloatingActionButton"/>
</com.hippo.widget.FabLayout>
<com.hippo.widget.FabLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingRight="@dimen/corner_fab_margin"
android:paddingBottom="@dimen/corner_fab_margin">
<android.support.design.widget.FloatingActionButton
android:id="@+id/search_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/v_magnify_dark_x24"
android:visibility="invisible"
android:scaleX="0"
android:scaleY="0"
style="@style/Widget.Design.FloatingActionButton"/>
</com.hippo.widget.FabLayout>
@@ -72,6 +72,7 @@
<string name="error_invalid_specify_gallery">指定画廊的关键字应该看起来像 \"618395 0439fa3666\"</string>
<string name="error_cant_create_temp_file">无法创建临时文件</string>
<string name="error_cant_save_image">无法保存图片</string>
<string name="error_invalid_number">非法数字</string>
<string name="app_waring">本应用中内容来自互联网,部分内容可能对您的生理及心理造成难以恢复的伤害。本应用作者不会对由本应用造成的后果负责。您是否愿意继续使用该应用?</string>
<string name="error_username_cannot_empty">用户名不可为空</string>
@@ -143,6 +144,8 @@
<string name="duplicate_quick_search">已存在相同的快速搜索,名称为“%s”。</string>
<string name="duplicate_name">已存在相同名称</string>
<string name="go_to_hint">第 %1$d 页,共 %2$d 页</string>
<!-- search_min_rating -->
<string name="star_2">2 星</string>
<string name="star_3">3 星</string>
@@ -72,6 +72,7 @@
<string name="error_invalid_specify_gallery">指定畫廊的關鍵字應該看起來像 \"618395 0439fa3666\"</string>
<string name="error_cant_create_temp_file">無法創建臨時文件</string>
<string name="error_cant_save_image">無法保存圖片</string>
<string name="error_invalid_number">非法數字</string>
<string name="app_waring">本應用中內容來自互聯網,部分內容可能對您的生理及心理造成難以恢復的傷害。本應用作者不會對由本應用造成的後果負責。您是否願意繼續使用該應用?</string>
<string name="error_username_cannot_empty">用户名不可為空</string>
@@ -143,6 +144,8 @@
<string name="duplicate_quick_search">已存在相同的快速搜索,名稱為“%s”。</string>
<string name="duplicate_name">已存在相同名稱</string>
<string name="go_to_hint">第 %1$d 頁,共 %2$d 頁</string>
<!-- search_min_rating -->
<string name="star_2">2 星</string>
<string name="star_3">3 星</string>
@@ -72,6 +72,7 @@
<string name="error_invalid_specify_gallery">指定畫廊的關鍵字應該看起來像 \"618395 0439fa3666\"</string>
<string name="error_cant_create_temp_file">無法建立臨時檔案</string>
<string name="error_cant_save_image">無法儲存圖片</string>
<string name="error_invalid_number">非法數字</string>
<string name="app_waring">本應用中內容來自網際網路,部分內容可能對您的生理及心理造成難以恢復的傷害。本應用作者不會對由本應用造成的後果負責。您是否願意繼續使用該應用?</string>
<string name="error_username_cannot_empty">使用者名稱不可為空</string>
@@ -143,6 +144,8 @@
<string name="duplicate_quick_search">已存在相同的快速搜尋,名稱為“%s”。</string>
<string name="duplicate_name">已存在相同名稱</string>
<string name="go_to_hint">第 %1$d 頁,共 %2$d 頁</string>
<!-- search_min_rating -->
<string name="star_2">2 星</string>
<string name="star_3">3 星</string>
+1
View File
@@ -58,6 +58,7 @@
<string name="pd_info_outline" translatable="false">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</string>
<string name="pd_clear_all" translatable="false">M5,13H19V11H5M3,17H17V15H3M7,7V9H21V7</string>
<string name="pd_similar" translatable="false">M2,20L17,10L22,22M14,9L2,8L11,2Z</string>
<string name="pd_refresh" translatable="false">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</string>
<string name="pd_big_label" translatable="false">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</string>
<string name="pd_big_search" translatable="false">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</string>
+3
View File
@@ -114,6 +114,7 @@
<string name="error_invalid_specify_gallery">Keyword should looks like \"618395 0439fa3666\" for specify gallery</string>
<string name="error_cant_create_temp_file">Can\'t create temp file</string>
<string name="error_cant_save_image">Can\'t save image</string>
<string name="error_invalid_number">Invalid number</string>
<string name="app_waring">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?</string>
<string name="error_username_cannot_empty">Username cannot be an empty string</string>
@@ -185,6 +186,8 @@
<string name="duplicate_quick_search">A duplicate quick search exists. The name is \"%s\".</string>
<string name="duplicate_name">A duplicate name exists</string>
<string name="go_to_hint">Page %1$d, total %2$d pages</string>
<!-- search_min_rating -->
<string name="star_2">2 stars</string>
<string name="star_3">3 stars</string>
+1 -1
View File
@@ -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