use of me.dkzwm.widget.srl.RefreshingListenerAdapter in project SmoothRefreshLayout by dkzwm.
the class TestNextRefreshAtOnceActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_refresh);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.enable_next_pull_to_refresh_at_once);
mTextView = findViewById(R.id.textView_test_refresh_desc);
mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_refresh);
MaterialHeader header = new MaterialHeader(this);
header.setPadding(0, PixelUtl.dp2px(this, 20), 0, PixelUtl.dp2px(this, 20));
mRefreshLayout.setHeaderView(header);
mRefreshLayout.setDisableLoadMore(true);
mRefreshLayout.setEnableNextPtrAtOnce(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);
}
}, 2000);
}
});
mRefreshLayout.autoRefresh(true);
}
use of me.dkzwm.widget.srl.RefreshingListenerAdapter in project SmoothRefreshLayout by dkzwm.
the class TestPullToRefreshActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_refresh);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.pull_to_refresh);
mTextView = findViewById(R.id.textView_test_refresh_desc);
mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_refresh);
MaterialHeader header = new MaterialHeader(this);
header.setPadding(0, PixelUtl.dp2px(this, 20), 0, PixelUtl.dp2px(this, 20));
mRefreshLayout.setHeaderView(header);
mRefreshLayout.setEnablePullToRefresh(true);
mRefreshLayout.setDisableLoadMore(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);
}
}, 2000);
}
});
mRefreshLayout.autoRefresh(false);
}
use of me.dkzwm.widget.srl.RefreshingListenerAdapter in project SmoothRefreshLayout by dkzwm.
the class NestedPageFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_nested_page, container, false);
RecyclerView recyclerView = view.findViewById(R.id.recyclerView_nested_page);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setHasFixedSize(true);
mAdapter = new RecyclerViewAdapter(getActivity(), inflater);
recyclerView.setAdapter(mAdapter);
mRefreshLayout = view.findViewById(R.id.smoothRefreshLayout_nested_page);
mRefreshLayout.setDisableLoadMore(false);
mRefreshLayout.materialStyle();
mRefreshLayout.setEnableNextPtrAtOnce(false);
mRefreshLayout.setDisableWhenAnotherDirectionMove(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, 20);
mCount += 20;
mAdapter.updateData(list);
} else {
List<String> list = DataUtil.createList(mCount, 20);
mCount += 20;
mAdapter.appendData(list);
}
mRefreshLayout.refreshComplete();
}
}, 2000);
}
});
mRefreshLayout.setBackgroundColor(mColor);
mRefreshLayout.autoRefresh(true);
return view;
}
Aggregations