use of me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter in project SmoothRefreshLayout by dkzwm.
the class TestQQActivityStyleActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_qq_activity_style);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.test_qq_activity_style);
mRecyclerView = findViewById(R.id.recyclerView_test_qq_activity_style);
mRadioGroup = findViewById(R.id.radioGroup_test_qq_activity_style_container);
mRadioButtonNormal = findViewById(R.id.radioButton_test_qq_activity_style_normal);
mRadioButtonActivity = findViewById(R.id.radioButton_test_qq_activity_style_activity);
mRadioGroup.setOnCheckedChangeListener(this);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setHasFixedSize(true);
mAdapter = new RecyclerViewAdapter(this, getLayoutInflater());
mRecyclerView.setAdapter(mAdapter);
mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_qq_activity_style);
mClassicHeader = new ClassicHeader(this);
mClassicHeader.setLastUpdateTimeKey("header_last_update_time");
mClassicFooter = new ClassicFooter(this);
mClassicFooter.setLastUpdateTimeKey("footer_last_update_time");
mRefreshLayout.setHeaderView(mClassicHeader);
mRefreshLayout.setFooterView(mClassicFooter);
mRefreshLayout.setEnableKeepRefreshView(true);
mRefreshLayout.setDisableLoadMore(false);
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.addOnUIPositionChangedListener(new SmoothRefreshLayout.OnUIPositionChangedListener() {
@Override
public void onChanged(byte status, IIndicator indicator) {
if (mRefreshLayout.isInStartPosition()) {
mRadioGroup.setEnabled(true);
mRadioButtonNormal.setEnabled(true);
mRadioButtonActivity.setEnabled(true);
} else {
mRadioGroup.setEnabled(false);
mRadioButtonNormal.setEnabled(false);
mRadioButtonActivity.setEnabled(false);
}
}
});
mRefreshLayout.autoRefresh(false);
}
use of me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter in project SmoothRefreshLayout by dkzwm.
the class TestNestedActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_nested);
final Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.drawable.arrow_back_white_72x72);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
mRecyclerView = findViewById(R.id.recyclerView_test_nested);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setHasFixedSize(true);
mAdapter = new RecyclerViewAdapter(this, getLayoutInflater());
mRecyclerView.setAdapter(mAdapter);
mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_nested);
mRefreshLayout.setDisableLoadMore(false);
mRefreshLayout.materialStyle();
mRefreshLayout.setOnRefreshListener(new SmoothRefreshLayout.OnRefreshListener() {
@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();
}
}, isRefresh ? 2000 : 10000);
}
@Override
public void onRefreshComplete(boolean isSuccessful) {
}
});
mRefreshLayout.getDefaultHeader().setPadding(0, PixelUtl.dp2px(this, 80), 0, PixelUtl.dp2px(this, 10));
mRefreshLayout.setLoadMoreScrollTargetView(mRecyclerView);
mRefreshLayout.setLifecycleObserver(new QuickConfigAppBarUtil());
mRefreshLayout.autoRefresh(false);
}
use of me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter in project SmoothRefreshLayout by dkzwm.
the class WithRecyclerViewInCoordinatorLayoutActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_with_recyclerview_in_coordinatorlayout);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.drawable.arrow_back_white_72x72);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
mRecyclerView = findViewById(R.id.recyclerView_with_recyclerView_in_coordinatorLayout);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setHasFixedSize(true);
mAdapter = new RecyclerViewAdapter(this, getLayoutInflater());
mRecyclerView.setAdapter(mAdapter);
mRefreshLayout = findViewById(R.id.smoothRefreshLayout_with_recyclerView_in_coordinatorLayout);
mRefreshLayout.setEnableKeepRefreshView(true);
mRefreshLayout.setDisableLoadMore(false);
mRefreshLayout.setOnRefreshListener(new SmoothRefreshLayout.OnRefreshListener() {
@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);
}
@Override
public void onRefreshComplete(boolean isSuccessful) {
}
});
mRefreshLayout.autoRefresh(false);
}
use of me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter 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.sample.adapter.RecyclerViewAdapter 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