use of com.shizhefei.test.models.enties.MovieAmount in project MVCHelper by LuckyJayce.
the class ListTaskActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ultrarecyclerview);
PtrClassicFrameLayout mPtrFrameLayout = (PtrClassicFrameLayout) findViewById(R.id.rotate_header_list_view_frame);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
taskHelper = new TaskHelper<>(new MemoryCacheStore(200));
// 注册全局的task执行回调
taskHelper.registerCallBack(new ICallback<MovieAmount>() {
@Override
public void onPreExecute(Object task) {
Log.d("pppp", "task:" + task);
}
@Override
public void onProgress(Object task, int percent, long current, long total, Object extraData) {
}
@Override
public void onPostExecute(Object task, Code code, Exception exception, MovieAmount movieAmount) {
Log.d("pppp", "task:" + task + " code:" + code);
}
});
mvcHelper = new MVCUltraHelper<>(mPtrFrameLayout);
// 设置数据源
mvcHelper.setDataSource(new MoviesDataSource());
// 设置适配器
mvcHelper.setAdapter(new MoviesAdapter(taskHelper));
// 加载数据
mvcHelper.refresh();
}
use of com.shizhefei.test.models.enties.MovieAmount in project MVCHelper by LuckyJayce.
the class MovieAmountTask2 method execute.
@Override
public RequestHandle execute(final ResponseSender<MovieAmount> sender) throws Exception {
final AsyncTask<Void, Void, Void> asyncTask = new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
Thread.sleep(2000);
Random random = new Random();
int commentCount = random.nextInt(100);
int playCount = random.nextInt(1000) + 10;
long updateTime = System.currentTimeMillis();
sender.sendData(new MovieAmount(name, commentCount, playCount, name + " " + DateFormat.format("dd kk:mm:ss", updateTime)));
} catch (Exception e) {
e.printStackTrace();
sender.sendError(e);
}
return null;
}
};
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
asyncTask.execute();
}
return new RequestHandle() {
@Override
public void cancle() {
asyncTask.cancel(true);
}
@Override
public boolean isRunning() {
return false;
}
};
}
use of com.shizhefei.test.models.enties.MovieAmount in project MVCHelper by LuckyJayce.
the class MovieAmountTask method execute.
@Override
public MovieAmount execute(ProgressSender progressSender) throws Exception {
Thread.sleep(2000);
Random random = new Random();
int commentCount = random.nextInt(100);
int playCount = random.nextInt(1000) + 10;
long updateTime = System.currentTimeMillis();
return new MovieAmount(name, commentCount, playCount, name + " " + DateFormat.format("dd kk:mm:ss", updateTime));
}
Aggregations