Add ViewTransition for ContentLayout
This commit is contained in:
1 parent
bc800b5a1b
commit
4800f99529
3 files changed
+33
-25
No files matched your search
@@ -169,7 +169,7 @@ public class GalleryListScene extends Scene implements SearchBar.Helper,
|
||||
|
||||
// When scene start
|
||||
if (savedInstanceState == null) {
|
||||
mGalleryListHelper.refresh();
|
||||
mGalleryListHelper.firstRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ import android.widget.FrameLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hippo.effect.ViewTransition;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.util.IntIdGenerator;
|
||||
import com.hippo.util.LayoutManagerUtils;
|
||||
import com.hippo.util.UiUtils;
|
||||
import com.hippo.util.ViewUtils;
|
||||
import com.hippo.widget.Snackbar;
|
||||
import com.hippo.widget.recyclerview.EasyRecyclerView;
|
||||
import com.hippo.widget.refreshlayout.RefreshLayout;
|
||||
@@ -40,7 +40,7 @@ import java.util.List;
|
||||
public class ContentLayout extends FrameLayout {
|
||||
|
||||
private ProgressBar mProgressBar;
|
||||
private ViewGroup mItView;
|
||||
private ViewGroup mTipView;
|
||||
private RefreshLayout mRefreshLayout;
|
||||
private EasyRecyclerView mRecyclerView;
|
||||
private View mImageView;
|
||||
@@ -70,12 +70,12 @@ public class ContentLayout extends FrameLayout {
|
||||
LayoutInflater.from(context).inflate(R.layout.widget_content_layout, this);
|
||||
|
||||
mProgressBar = (ProgressBar) getChildAt(0);
|
||||
mItView = (ViewGroup) getChildAt(1);
|
||||
mTipView = (ViewGroup) getChildAt(1);
|
||||
mRefreshLayout = (RefreshLayout) getChildAt(2);
|
||||
mSnackbar = (Snackbar) getChildAt(3);
|
||||
mRecyclerView = (EasyRecyclerView) mRefreshLayout.getChildAt(1);
|
||||
mImageView = mItView.getChildAt(0);
|
||||
mTextView = (TextView) mItView.getChildAt(1);
|
||||
mImageView = mTipView.getChildAt(0);
|
||||
mTextView = (TextView) mTipView.getChildAt(1);
|
||||
|
||||
//
|
||||
mRecyclerViewOriginTop = mRecyclerView.getPaddingTop();
|
||||
@@ -134,7 +134,7 @@ public class ContentLayout extends FrameLayout {
|
||||
public static final int TYPE_SOMEWHERE = 5;
|
||||
|
||||
private ProgressBar mProgressBar;
|
||||
private ViewGroup mItView;
|
||||
private ViewGroup mTipView;
|
||||
private RefreshLayout mRefreshLayout;
|
||||
private EasyRecyclerView mRecyclerView;
|
||||
private View mImageView;
|
||||
@@ -142,6 +142,8 @@ public class ContentLayout extends FrameLayout {
|
||||
private Snackbar mSnackbar;
|
||||
private RecyclerView.LayoutManager mLayoutManager;
|
||||
|
||||
private ViewTransition mViewTransition;
|
||||
|
||||
private RecyclerView.OnScrollListener mOnScrollListener = new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy){
|
||||
@@ -190,7 +192,7 @@ public class ContentLayout extends FrameLayout {
|
||||
|
||||
private void init(ContentLayout contentLayout) {
|
||||
mProgressBar = contentLayout.mProgressBar;
|
||||
mItView = contentLayout.mItView;
|
||||
mTipView = contentLayout.mTipView;
|
||||
mRefreshLayout = contentLayout.mRefreshLayout;
|
||||
mSnackbar = contentLayout.mSnackbar;
|
||||
mRecyclerView = contentLayout.mRecyclerView;
|
||||
@@ -198,6 +200,8 @@ public class ContentLayout extends FrameLayout {
|
||||
mTextView = contentLayout.mTextView;
|
||||
mLayoutManager = generateLayoutManager();
|
||||
|
||||
mViewTransition = new ViewTransition(mRefreshLayout, mProgressBar, mTipView);
|
||||
|
||||
mRecyclerView.setLayoutManager(mLayoutManager);
|
||||
mRecyclerView.setAdapter(this);
|
||||
mRecyclerView.addOnScrollListener(mOnScrollListener);
|
||||
@@ -211,26 +215,23 @@ public class ContentLayout extends FrameLayout {
|
||||
|
||||
protected abstract RecyclerView.LayoutManager generateLayoutManager();
|
||||
|
||||
public void showContent() {
|
||||
mViewTransition.showView(0);
|
||||
}
|
||||
|
||||
public void showProgressBar() {
|
||||
ViewUtils.setVisibility(mProgressBar, View.VISIBLE);
|
||||
ViewUtils.setVisibility(mItView, View.GONE);
|
||||
ViewUtils.setVisibility(mRefreshLayout, View.GONE);
|
||||
showProgressBar(true);
|
||||
}
|
||||
|
||||
public void showProgressBar(boolean animation) {
|
||||
mViewTransition.showView(1, animation);
|
||||
}
|
||||
|
||||
public void showText(CharSequence text) {
|
||||
ViewUtils.setVisibility(mProgressBar, View.GONE);
|
||||
ViewUtils.setVisibility(mItView, View.VISIBLE);
|
||||
ViewUtils.setVisibility(mRefreshLayout, View.GONE);
|
||||
|
||||
mViewTransition.showView(2);
|
||||
mTextView.setText(text);
|
||||
}
|
||||
|
||||
public void showContent() {
|
||||
ViewUtils.setVisibility(mProgressBar, View.GONE);
|
||||
ViewUtils.setVisibility(mItView, View.GONE);
|
||||
ViewUtils.setVisibility(mRefreshLayout, View.VISIBLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IndexOutOfBoundsException
|
||||
* if {@code location < 0 || location >= size()}
|
||||
@@ -375,12 +376,16 @@ public class ContentLayout extends FrameLayout {
|
||||
getPageData(mCurrentTaskId, mCurrentTaskType, mCurrentTaskPage);
|
||||
}
|
||||
|
||||
public void firstRefresh() {
|
||||
showProgressBar(false);
|
||||
doRefresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show progress bar first, than do refresh
|
||||
*/
|
||||
public void refresh() {
|
||||
showProgressBar();
|
||||
mRefreshLayout.setHeaderRefreshing(true);
|
||||
doRefresh();
|
||||
}
|
||||
|
||||
@@ -412,6 +417,9 @@ public class ContentLayout extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload data to layout. Maybe do it when change item view style
|
||||
*/
|
||||
public void reload() {
|
||||
notifyDataSetChanged();
|
||||
mCurrentPage = mFirstPage;
|
||||
|
||||
@@ -32,11 +32,11 @@
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
<com.hippo.widget.SimpleImageView
|
||||
android:layout_width="180dp"
|
||||
android:layout_height="180dp"
|
||||
android:background="@drawable/ic_sad"
|
||||
android:layout_gravity="center_horizontal"/>
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:src="@drawable/ic_sad"/>
|
||||
|
||||
<TextView
|
||||
style="@style/TextAppearance.AppCompat.Medium"
|
||||
|
||||
Reference in new issue
Block a user