Skip to content

Commit

Permalink
Merge pull request WuXiaolong#18 from ding102992/master
Browse files Browse the repository at this point in the history
Add footer view animator.
  • Loading branch information
WuXiaolong authored Jun 15, 2016
2 parents 7709330 + d2bdade commit 90291ab
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 74 deletions.
5 changes: 1 addition & 4 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.wuxiaolong.pullloadmorerecyclerview;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.DefaultItemAnimator;
Expand All @@ -11,6 +13,7 @@
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
Expand All @@ -20,6 +23,7 @@
* github:https://github.com/WuXiaolong/PullLoadMoreRecyclerView
* weibo:http://weibo.com/u/2175011601
*/
@SuppressWarnings("unused")
public class PullLoadMoreRecyclerView extends LinearLayout {
private RecyclerView mRecyclerView;
private SwipeRefreshLayout mSwipeRefreshLayout;
Expand Down Expand Up @@ -65,6 +69,7 @@ private void initView(Context context) {
mEmptyViewContainer = (FrameLayout) view.findViewById(R.id.emptyView);

loadMoreText = (TextView) view.findViewById(R.id.loadMoreText);

mFooterView.setVisibility(View.GONE);
mEmptyViewContainer.setVisibility(View.GONE);

Expand Down Expand Up @@ -198,11 +203,7 @@ protected void onDetachedFromWindow() {
public class onTouchRecyclerView implements OnTouchListener {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (isRefresh || isLoadMore) {
return true;
} else {
return false;
}
return isRefresh || isLoadMore;
}
}

Expand Down Expand Up @@ -259,7 +260,12 @@ public void refresh() {

public void loadMore() {
if (mPullLoadMoreListener != null && hasMore) {
mFooterView.setVisibility(View.VISIBLE);
mFooterView.animate().translationY(0).setDuration(300).setInterpolator(new AccelerateDecelerateInterpolator()).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mFooterView.setVisibility(View.VISIBLE);
}
}).start();
invalidate();
mPullLoadMoreListener.onLoadMore();

Expand All @@ -269,10 +275,10 @@ public void loadMore() {

public void setPullLoadMoreCompleted() {
isRefresh = false;
mSwipeRefreshLayout.setRefreshing(false);
setRefreshing(false);

isLoadMore = false;
mFooterView.setVisibility(View.GONE);
mFooterView.animate().translationY(mFooterView.getHeight()).setDuration(300).setInterpolator(new AccelerateDecelerateInterpolator()).start();

}

Expand Down
37 changes: 16 additions & 21 deletions library/src/main/res/layout/footer_layout.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:gravity="center"
android:background="#cfff"
android:orientation="horizontal">

<LinearLayout
android:layout_width="match_parent"
<ProgressBar
android:id="@+id/loadMoreProgressBar"
style="@android:style/Widget.ProgressBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
android:layout_marginRight="10dp" />

<ProgressBar
android:id="@+id/loadMoreProgressBar"
style="@android:style/Widget.ProgressBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp" />

<TextView
android:id="@+id/loadMoreText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="@string/load_more_text" />
</LinearLayout>
<TextView
android:id="@+id/loadMoreText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="@string/load_more_text" />
</LinearLayout>
10 changes: 6 additions & 4 deletions library/src/main/res/layout/pull_loadmore_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@
android:layout_height="match_parent">


<LinearLayout
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
android:layout_height="match_parent" />

<include
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/footerView"
layout="@layout/footer_layout" />

Expand All @@ -25,5 +27,5 @@
layout="@layout/empty_layout"/>


</LinearLayout>
</FrameLayout>
</android.support.v4.widget.SwipeRefreshLayout>

0 comments on commit 90291ab

Please sign in to comment.