use of me.dkzwm.widget.srl.RefreshingListenerAdapter in project SmoothRefreshLayout by dkzwm.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mRefreshLayout = findViewById(R.id.smoothRefreshLayout_main);
// 设置刷新回调
mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {
@Override
public void onRefreshBegin(boolean isRefresh) {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mRefreshLayout.refreshComplete(800);
}
}, 4000);
}
});
mRefreshLayout.addOnUIPositionChangedListener(new SmoothRefreshLayout.OnUIPositionChangedListener() {
@Override
public void onChanged(byte status, IIndicator indicator) {
if (!mRefreshLayout.isOverScrolling() && mRefreshLayout.isMovingFooter()) {
mRefreshLayout.resetScrollerInterpolator();
}
}
});
mRefreshLayout.setDisableLoadMore(false);
mRefreshLayout.setDisablePerformLoadMore(true);
mRefreshLayout.setEnableHideFooterView(true);
mRefreshLayout.getDefaultHeader().setWaveColor(ContextCompat.getColor(this, R.color.colorPrimary));
mRefreshLayout.getDefaultHeader().setBackgroundColor(ContextCompat.getColor(this, R.color.colorAccent));
mRefreshLayout.getDefaultHeader().setStyle(IRefreshView.STYLE_PIN);
// 自动刷新
mRefreshLayout.autoRefresh(Constants.ACTION_AT_ONCE, true);
findViewById(R.id.imageView_main_bottom_icon).setOnClickListener(this);
findViewById(R.id.button_main_with_frameLayout).setOnClickListener(this);
findViewById(R.id.button_main_with_listView).setOnClickListener(this);
findViewById(R.id.button_main_with_gridView).setOnClickListener(this);
findViewById(R.id.button_main_with_recyclerView).setOnClickListener(this);
findViewById(R.id.button_main_with_recyclerView_in_coordinatorLayout).setOnClickListener(this);
findViewById(R.id.button_main_test_enable_next_pull_to_refresh_at_once).setOnClickListener(this);
findViewById(R.id.button_main_test_material_style).setOnClickListener(this);
findViewById(R.id.button_main_test_nested).setOnClickListener(this);
findViewById(R.id.button_main_test_pull_to_refresh).setOnClickListener(this);
findViewById(R.id.button_main_test_release_to_refresh).setOnClickListener(this);
findViewById(R.id.button_main_with_viewPager).setOnClickListener(this);
findViewById(R.id.button_main_with_webView).setOnClickListener(this);
findViewById(R.id.button_main_with_textView).setOnClickListener(this);
findViewById(R.id.button_main_test_over_scroll).setOnClickListener(this);
findViewById(R.id.button_main_test_two_level_refresh).setOnClickListener(this);
findViewById(R.id.button_main_test_QQ_activity_style).setOnClickListener(this);
findViewById(R.id.button_main_test_QQ_web_style).setOnClickListener(this);
findViewById(R.id.button_main_test_nested_view_pager).setOnClickListener(this);
findViewById(R.id.button_main_test_base_recyclerView_adapter).setOnClickListener(this);
findViewById(R.id.button_main_test_nested_horizontal_views).setOnClickListener(this);
findViewById(R.id.button_main_test_horizontal_refresh).setOnClickListener(this);
findViewById(R.id.button_main_test_horizontal_recyclerView).setOnClickListener(this);
findViewById(R.id.button_main_test_multi_direction_views).setOnClickListener(this);
findViewById(R.id.button_main_test_scroll_to_auto_refresh).setOnClickListener(this);
findViewById(R.id.button_main_test_scale_effect).setOnClickListener(this);
findViewById(R.id.button_main_test_horizontal_scale_effect).setOnClickListener(this);
mButtonDebug = findViewById(R.id.button_main_debug);
mButtonDebug.setOnClickListener(this);
}
use of me.dkzwm.widget.srl.RefreshingListenerAdapter in project SmoothRefreshLayout by dkzwm.
the class TestBaseRecyclerViewAdapterActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.test_base_recyclerView_adapter);
setContentView(R.layout.activity_test_base_recyclerview_adapter);
mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_base_recyclerView_adapter);
ClassicHeader classicHeader = new ClassicHeader(this);
classicHeader.setLastUpdateTimeKey("header_last_update_time");
mRefreshLayout.setHeaderView(classicHeader);
mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {
@Override
public void onRefreshBegin(boolean isRefresh) {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mCount = 0;
List<String> list = DataUtil.createList(mCount, 20);
mCount += 20;
mAdapter.setNewData(list);
mRefreshLayout.refreshComplete();
}
}, 2000);
}
});
mAdapter = new LoadMoreRecyclerViewAdapter(this);
mAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
@Override
public void onLoadMoreRequested() {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
List<String> list = DataUtil.createList(mCount, 20);
mCount += 20;
mAdapter.addData(list);
mAdapter.loadMoreComplete();
mRefreshLayout.refreshComplete();
}
}, 2000);
}
}, mRecyclerView);
mRefreshLayout.setOnHeaderEdgeDetectCallBack(new SmoothRefreshLayout.OnHeaderEdgeDetectCallBack() {
@Override
public boolean isNotYetInEdgeCannotMoveHeader(SmoothRefreshLayout parent, @Nullable View child, @Nullable IRefreshView header) {
return ScrollCompat.canChildScrollUp(mRecyclerView);
}
});
mRefreshLayout.setOnFooterEdgeDetectCallBack(new SmoothRefreshLayout.OnFooterEdgeDetectCallBack() {
@Override
public boolean isNotYetInEdgeCannotMoveFooter(SmoothRefreshLayout parent, @Nullable View child, @Nullable IRefreshView footer) {
return ScrollCompat.canChildScrollDown(mRecyclerView);
}
});
mRefreshLayout.autoRefresh(true);
mRecyclerView = findViewById(R.id.recyclerView_test_base_recyclerView_adapter);
mRecyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setAdapter(mAdapter);
mRefreshLayout.setLoadMoreScrollTargetView(mRecyclerView);
}
use of me.dkzwm.widget.srl.RefreshingListenerAdapter in project SmoothRefreshLayout by dkzwm.
the class TestScrollToAutoRefreshActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_scroll_to_auto_refresh);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.test_scroll_to_auto_refresh);
RecyclerView recyclerView = findViewById(R.id.recyclerView_test_scroll_to_auto_refresh);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setHasFixedSize(true);
mAdapter = new RecyclerViewAdapter(this, getLayoutInflater());
recyclerView.setAdapter(mAdapter);
mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_scroll_to_auto_refresh);
mRefreshLayout.setDisableLoadMore(false);
mRefreshLayout.materialStyle();
mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {
@Override
public void onRefreshBegin(final boolean isRefresh) {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
if (isRefresh) {
mCount = 0;
List<String> list = DataUtil.createList(mCount, 20);
mCount += 20;
mAdapter.updateData(list);
} else {
List<String> list = DataUtil.createList(mCount, 20);
mCount += 20;
mAdapter.appendData(list);
}
mRefreshLayout.refreshComplete();
}
}, 2000);
}
});
mRefreshLayout.setEnableSmoothRollbackWhenCompleted(true);
mRefreshLayout.autoRefresh(false);
mAutoRefreshUtil = new QuickConfigAutoRefreshUtil(recyclerView);
mRefreshLayout.setLifecycleObserver(mAutoRefreshUtil);
findViewById(R.id.button_test_scroll_to_auto_refresh_left).setOnClickListener(this);
findViewById(R.id.button_test_scroll_to_auto_refresh_right).setOnClickListener(this);
}
use of me.dkzwm.widget.srl.RefreshingListenerAdapter in project SmoothRefreshLayout by dkzwm.
the class WithFrameLayoutActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_with_framelayout);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.with_frameLayout);
mRefreshLayout = findViewById(R.id.smoothRefreshLayout_with_frameLayout);
mTextView = findViewById(R.id.textView_with_frameLayout_desc);
mTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(WithFrameLayoutActivity.this, "Clicked", Toast.LENGTH_SHORT).show();
}
});
mTextView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Toast.makeText(WithFrameLayoutActivity.this, "LongClicked", Toast.LENGTH_SHORT).show();
return true;
}
});
WaveTextRefreshView refreshView = new WaveTextRefreshView(this);
refreshView.setIncrementalY(.5f);
mRefreshLayout.setHeaderView(refreshView);
mRefreshLayout.setRatioToKeep(1);
mRefreshLayout.setRatioOfHeaderToRefresh(1);
mRefreshLayout.setEnableOverScroll(false);
mRefreshLayout.setEnableKeepRefreshView(true);
mRefreshLayout.setEnableInterceptEventWhileLoading(true);
mRefreshLayout.setDisableLoadMore(false);
mRefreshLayout.setDisablePerformLoadMore(true);
mRefreshLayout.setEnableHideFooterView(true);
mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {
@Override
public void onRefreshBegin(boolean isRefresh) {
mCount++;
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mRefreshLayout.refreshComplete();
String times = getString(R.string.number_of_refresh) + mCount;
mTextView.setText(times);
}
}, 8000);
}
});
mRefreshLayout.autoRefresh(true);
}
use of me.dkzwm.widget.srl.RefreshingListenerAdapter in project SmoothRefreshLayout by dkzwm.
the class WithRecyclerViewActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_with_recyclerview);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.with_recyclerView);
mRecyclerView = findViewById(R.id.recyclerView_with_recyclerView);
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3));
mRecyclerView.setHasFixedSize(true);
mAdapter = new RecyclerViewAdapter(this, getLayoutInflater());
mRecyclerView.setAdapter(mAdapter);
mRefreshLayout = findViewById(R.id.smoothRefreshLayout_with_recyclerView);
mRefreshLayout.setDisableLoadMore(false);
mRefreshLayout.materialStyle();
mRefreshLayout.setEnableAutoLoadMore(true);
mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {
@Override
public void onRefreshBegin(final boolean isRefresh) {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
if (isRefresh) {
mCount = 0;
List<String> list = DataUtil.createList(mCount, 15);
mCount += 15;
mAdapter.updateData(list);
} else {
List<String> list = DataUtil.createList(mCount, 15);
mCount += 15;
mAdapter.appendData(list);
}
mRefreshLayout.refreshComplete();
}
}, 2000);
}
});
mRefreshLayout.setEnableSmoothRollbackWhenCompleted(true);
mRefreshLayout.autoRefresh(false);
}
Aggregations