Skip to content

Commit

Permalink
modify interface about refresh and load more event
Browse files Browse the repository at this point in the history
  • Loading branch information
lucklygaj committed Oct 12, 2016
1 parent eb13eff commit 986ef1c
Show file tree
Hide file tree
Showing 10 changed files with 328 additions and 346 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

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

364 changes: 174 additions & 190 deletions .idea/workspace.xml

Large diffs are not rendered by default.

72 changes: 39 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,50 +66,56 @@ task clean(type: Delete) {
</com.ajguan.library.EasyRefreshLayout>
```
* add pull-down refresh funcation
* add EasyEvenr listener

```
easyRefreshLayout.setRefreshListener(new EasyRefreshLayout.OnRefreshListener() {
easyRefreshLayout.addEasyEvent(new EasyRefreshLayout.EasyEvent() {
@Override
public void onLoadMore() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
final List<String> list = new ArrayList<>();
for (int j = 0; j < 5; j++) {
list.add("this is new load data >>>>" + new Date().toLocaleString());
}
//adapter.addData(list);
easyRefreshLayout.loadMoreComplete(new EasyRefreshLayout.Event() {
@Override
public void complete() {
adapter.getData().addAll(list);
adapter.notifyDataSetChanged();
}
}, 500);
}
}, 2000);
}
@Override
public void onRefreshing() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
List<String> list = new ArrayList<>();
for (int i = 0; i < 20; i++) {
list.add("this is refresh data >>>" + new Date().toLocaleString());
}
adapter.setNewData(list);
easyRefreshLayout.refreshComplete();
Toast.makeText(getApplicationContext(), "refresh success", Toast.LENGTH_SHORT).show(); }
},3000);
Toast.makeText(getApplicationContext(), "refresh success", Toast.LENGTH_SHORT).show();
}
}, 1000);
}
});
```

* add pull-up loading funcation
});```
```
easyRefreshLayout.initLoadMore(
new EasyRefreshLayout.LoadMoreEvent() {
@Override
public void onLoadMore() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
final List<String> list = new ArrayList<>();
for (int i = 0; i < 5; i++) {
list.add("EasyRefreshLayout new index :" + i);
}
easyRefreshLayout.loadMoreComplete(new EasyRefreshLayout.Event() {
@Override
public void complete() {
adapter.getData().addAll(list);
adapter.notifyDataSetChanged();
}
}, 1000);
}
}, 2000);
}
}
);
```
* if you need only pull-down refresh funcation
Expand Down
16 changes: 8 additions & 8 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
Expand All @@ -82,6 +74,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
Expand Down
41 changes: 21 additions & 20 deletions app/src/main/java/zaizai/com/View/OnlyLoadingActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.ajguan.library.EasyRefreshLayout;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import zaizai.com.SimpleAdapter;
Expand Down Expand Up @@ -41,33 +42,33 @@ private void initData() {
private void initListener() {
easyRefreshLayout.setEnablePullToRefresh(false);

easyRefreshLayout.initLoadMore(
new EasyRefreshLayout.LoadMoreEvent() {
easyRefreshLayout.addEasyEvent(new EasyRefreshLayout.EasyEvent() {
@Override
public void onLoadMore() {
new Handler().postDelayed(new Runnable() {
@Override
public void onLoadMore() {
new Handler().postDelayed(new Runnable() {
public void run() {
final List<String> list = new ArrayList<>();
for (int i = 0; i < 5; i++) {
list.add("this is new load data >>>>"+new Date().toLocaleString());
}
easyRefreshLayout.loadMoreComplete(new EasyRefreshLayout.Event() {
@Override
public void run() {
final List<String> list = new ArrayList<>();
for (int i = 0; i < 5; i++) {
list.add("EasyRefreshLayout new index :" + i);
}
easyRefreshLayout.loadMoreComplete(new EasyRefreshLayout.Event() {
@Override
public void complete() {
adapter.getData().addAll(list);
adapter.notifyDataSetChanged();
}
}, 1000);

public void complete() {
adapter.getData().addAll(list);
adapter.notifyDataSetChanged();
}
}, 2000);
}, 1000);

}
}, 2000);

}
}
@Override
public void onRefreshing() {

);
}
});
}

private void initView() {
Expand Down
22 changes: 19 additions & 3 deletions app/src/main/java/zaizai/com/View/OnlyRefreshActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.ajguan.R;
import com.ajguan.library.EasyRefreshLayout;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import zaizai.com.SimpleAdapter;
Expand Down Expand Up @@ -41,15 +45,27 @@ private void initData() {

private void initListener() {
easyRefreshLayout.autoRefresh();
easyRefreshLayout.setRefreshListener(new EasyRefreshLayout.OnRefreshListener() {
easyRefreshLayout.addEasyEvent(new EasyRefreshLayout.EasyEvent() {
@Override
public void onLoadMore() {

}

@Override
public void onRefreshing() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
List<String> list = new ArrayList<>();
for (int i = 0; i < 20; i++) {
list.add("this is refresh data >>>" + new Date().toLocaleString());
}
adapter.setNewData(list);
easyRefreshLayout.refreshComplete();
Toast.makeText(getApplicationContext(), "refresh success", Toast.LENGTH_SHORT).show(); }
},3000);
Toast.makeText(getApplicationContext(), "refresh success", Toast.LENGTH_SHORT).show();
}
}, 1000);


}
});
Expand Down
76 changes: 32 additions & 44 deletions app/src/main/java/zaizai/com/View/RefreshLoadingActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;
import android.widget.Toast;

import com.ajguan.R;
import com.ajguan.library.EasyRefreshLayout;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import zaizai.com.SimpleAdapter;
Expand Down Expand Up @@ -40,15 +42,43 @@ private void initData() {
}

private void initListener() {
easyRefreshLayout.setRefreshListener(new EasyRefreshLayout.OnRefreshListener() {
easyRefreshLayout.addEasyEvent(new EasyRefreshLayout.EasyEvent() {
@Override
public void onLoadMore() {

new Handler().postDelayed(new Runnable() {
@Override
public void run() {
final List<String> list = new ArrayList<>();
for (int j = 0; j < 5; j++) {
list.add("this is new load data >>>>" + new Date().toLocaleString());
}

//adapter.addData(list);

easyRefreshLayout.loadMoreComplete(new EasyRefreshLayout.Event() {
@Override
public void complete() {
adapter.getData().addAll(list);
adapter.notifyDataSetChanged();

}
}, 500);

}
}, 2000);


}

@Override
public void onRefreshing() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
List<String> list = new ArrayList<>();
for (int i = 0; i < 20; i++) {
list.add("EasyRefreshLayout index :" + i);
list.add("this is refresh data >>>" + new Date().toLocaleString());
}
adapter.setNewData(list);
easyRefreshLayout.refreshComplete();
Expand All @@ -58,48 +88,6 @@ public void run() {

}
});
easyRefreshLayout.initLoadMore(new EasyRefreshLayout.LoadMoreEvent() {
@Override
public void onLoadMore() {
int i = 0;
switch (i) {
case 0:

case 1:

case 2:
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
final List<String> list = new ArrayList<>();
for (int j = 0; j < 5; j++) {
list.add("EasyRefreshLayout new index :" + j);
}

//adapter.addData(list);

easyRefreshLayout.loadMoreComplete(new EasyRefreshLayout.Event() {
@Override
public void complete() {
adapter.getData().addAll(list);
adapter.notifyDataSetChanged();

}
},500);

}
},2000);
break;
case 3:
easyRefreshLayout.loadMoreFail();
break;
case 4:
easyRefreshLayout.loadNothing();
break;
}

}
});
}

private void initView() {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.android.tools.build:gradle:2.2.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions library/library.iml
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-compat-24.2.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="espresso-core-2.2.2" level="project" />
<orderEntry type="library" exported="" name="support-core-ui-24.2.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="runner-0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="exposed-instrumentation-api-publish-0.5" level="project" />
<orderEntry type="library" exported="" name="support-core-ui-24.2.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="espresso-idling-resource-2.2.2" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-24.2.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="espresso-idling-resource-2.2.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="rules-0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-library-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javax.annotation-api-1.2" level="project" />
Expand Down
Loading

0 comments on commit 986ef1c

Please sign in to comment.