Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
huxq17 committed May 16, 2017
1 parent 9c42335 commit 3b2d529
Show file tree
Hide file tree
Showing 18 changed files with 474 additions and 241 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ android {
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
// compile project(':library')
compile 'com.huxq17.xrefreshview:xrefreshview:3.6.9'
compile project(':library')
// compile 'com.huxq17.xrefreshview:xrefreshview:3.6.9'
//依赖下面的库
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@
<activity android:name=".activity.GridViewActivity" />
<activity android:name=".activity.ListViewActivity" />
<activity android:name=".activity.WebViewActivity" />
<activity android:name=".activity.LinearRecyclerViewActivity" />
<activity android:name=".activity.BannerRecyclerViewActivity" />
<activity android:name=".activity.recyclerview.LinearRecyclerViewActivity" />
<activity android:name=".activity.recyclerview.BannerRecyclerViewActivity" />
<activity android:name=".activity.ScrollViewActivity" />
<activity android:name=".activity.HeadAdActivity" />
<activity android:name=".activity.RainDropActivity" />
<activity android:name=".activity.RecyclerViewsActivity" />
<activity android:name=".activity.GridRecyclerViewActivity" />
<activity android:name=".activity.StaggeredRecyclerViewActivity" />
<activity android:name=".activity.SilenceRecyclerViewActivity" />
<activity android:name=".activity.recyclerview.GridRecyclerViewActivity" />
<activity android:name=".activity.recyclerview.StaggeredRecyclerViewActivity" />
<activity android:name=".activity.recyclerview.SilenceRecyclerViewActivity" />
<activity android:name=".activity.NotFullScreenActivity" />
<activity android:name=".activity.EmptyViewActivity" />
<activity android:name=".activity.MultiItemRecyclerViewActivity" />
<activity android:name=".activity.ShowFooterRecyclerViewActivity" />
<activity android:name=".activity.recyclerview.MultiItemRecyclerViewActivity" />
<activity android:name=".activity.recyclerview.ShowFooterWhenNoMoreDataRecyclerViewActivity" />
<activity android:name=".activity.NotFullScreenWithoutFooterActivity" />
<activity android:name=".activity.SmileViewActivity" />
<activity android:name=".activity.WithoutBaseAdapterRecyclerViewActivity" />
<activity android:name=".activity.recyclerview.WithoutBaseAdapterRecyclerViewActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void onCreate(Bundle savedInstanceState) {
android.R.layout.simple_list_item_1, str_name);
gv.setAdapter(adapter);
xRefreshView.setPinnedTime(1000);
// xRefreshView.setAutoLoadMore(true);
xRefreshView.setAutoLoadMore(false);
// xRefreshView.setCustomHeaderView(new CustomHeader(this));
// xRefreshView.setCustomHeaderView(new XRefreshViewHeader(this));
xRefreshView.setMoveForHorizontal(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
import android.view.View;

import com.andview.example.R;
import com.andview.example.activity.recyclerview.BannerRecyclerViewActivity;
import com.andview.example.activity.recyclerview.GridRecyclerViewActivity;
import com.andview.example.activity.recyclerview.LinearRecyclerViewActivity;
import com.andview.example.activity.recyclerview.MultiItemRecyclerViewActivity;
import com.andview.example.activity.recyclerview.ShowFooterWhenNoMoreDataRecyclerViewActivity;
import com.andview.example.activity.recyclerview.SilenceRecyclerViewActivity;
import com.andview.example.activity.recyclerview.StaggeredRecyclerViewActivity;
import com.andview.example.activity.recyclerview.WithoutBaseAdapterRecyclerViewActivity;

public class RecyclerViewsActivity extends Activity {

Expand Down Expand Up @@ -39,6 +47,9 @@ public void onClick(View v) {
case R.id.bt_without_baseRecyclerAdapter:
intent = new Intent(this, WithoutBaseAdapterRecyclerViewActivity.class);
break;
case R.id.bt_showFooter_noMoreData:
intent = new Intent(this, ShowFooterWhenNoMoreDataRecyclerViewActivity.class);
break;
default:
break;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.andview.example.activity;
package com.andview.example.activity.recyclerview;

import android.app.Activity;
import android.os.Bundle;
Expand Down Expand Up @@ -67,6 +67,7 @@ protected void onCreate(Bundle savedInstanceState) {
xRefreshView.setAutoLoadMore(false);
xRefreshView.setPinnedTime(1000);
xRefreshView.setMoveForHorizontal(true);
xRefreshView.setPullLoadEnable(true);
// recyclerviewAdapter.setHeaderView(headerView, recyclerView);
adapter.setCustomLoadMoreView(new XRefreshViewFooter(this));
// xRefreshView1.setPullRefreshEnable(false);
Expand All @@ -88,9 +89,9 @@ public void run() {
//模拟数据加载失败的情况
Random random = new Random();
boolean success = random.nextBoolean();
if(success){
if (success) {
xRefreshView.stopRefresh();
}else{
} else {
xRefreshView.stopRefresh(false);
}
//或者
Expand All @@ -103,6 +104,8 @@ public void run() {
public void onLoadMore(boolean isSilence) {
new Handler().postDelayed(new Runnable() {
public void run() {
if(xRefreshView.hasLoadCompleted()){
}
for (int i = 0; i < 6; i++) {
adapter.insert(new Person("More ", "21"),
adapter.getAdapterItemCount());
Expand All @@ -112,7 +115,7 @@ public void run() {
xRefreshView.setLoadComplete(true);
} else {
// 刷新完成必须调用此方法停止加载
xRefreshView.stopLoadMore();
xRefreshView.stopLoadMore(false);
}
}
}, 1000);
Expand All @@ -121,7 +124,7 @@ public void run() {
}

private void initData() {
for (int i = 0; i < 3; i++) {
for (int i = 0; i < 10; i++) {
Person person = new Person("name" + i, "" + i);
personList.add(person);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.andview.example.activity;
package com.andview.example.activity.recyclerview;

import android.app.Activity;
import android.os.Bundle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.andview.example.activity;
package com.andview.example.activity.recyclerview;

import android.app.Activity;
import android.os.Bundle;
Expand Down Expand Up @@ -59,8 +59,19 @@ protected void onCreate(Bundle savedInstanceState) {
xRefreshView.enableRecyclerViewPullUp(true);
xRefreshView.enablePullUpWhenLoadCompleted(true);
//设置静默加载时提前加载的item个数
// xRefreshView1.setPreLoadCount(4);
// xefreshView1.setPreLoadCount(4);
//设置Recyclerview的滑动监听
xRefreshView.setOnRecyclerViewScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
}

@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
}
});
xRefreshView.setXRefreshViewListener(new SimpleXRefreshListener() {

@Override
Expand Down Expand Up @@ -113,7 +124,7 @@ public void run() {
}

private void initData() {
for (int i = 0; i < 30; i++) {
for (int i = 0; i < 15; i++) {
Person person = new Person("name" + i, "" + i);
personList.add(person);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.andview.example.activity;
package com.andview.example.activity.recyclerview;

import android.app.Activity;
import android.os.Bundle;
Expand Down
Loading

0 comments on commit 3b2d529

Please sign in to comment.