use of me.yluo.ruisiapp.adapter.PostListAdapter in project Ruisi by freedom10086.
the class PostsActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
datas = new ArrayList<>();
setContentView(R.layout.activity_posts);
if (getIntent().getExtras() != null) {
FID = getIntent().getExtras().getInt("FID");
TITLE = getIntent().getExtras().getString("TITLE");
}
initToolBar(true, TITLE);
myToolbar = findViewById(R.id.myToolBar);
btnRefresh = findViewById(R.id.btn);
mRecyclerView = findViewById(R.id.recycler_view);
tab = findViewById(R.id.tab);
refreshLayout = findViewById(R.id.refresh_layout);
refreshLayout.setColorSchemeResources(R.color.red_light, R.color.green_light, R.color.blue_light, R.color.orange_light);
int top = DimmenUtils.dip2px(this, 60);
refreshLayout.setProgressViewOffset(true, top, top + 60);
isHideZhiding = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("setting_hide_zhidin", true);
if (getType() == PostListAdapter.TYPE_IMAGE) {
isEnableLoadMore = false;
mLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
mRecyclerView.setHasFixedSize(false);
addToolbarMenu(R.drawable.ic_column_change_24dp).setOnClickListener(this);
} else {
mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.addItemDecoration(new MyListDivider(this, MyListDivider.VERTICAL));
mRecyclerView.addOnScrollListener(new LoadMoreListener((LinearLayoutManager) mLayoutManager, this, 8));
addToolbarMenu(R.drawable.ic_edit).setOnClickListener(this);
}
tab.addTab(tab.newTab().setText("最新"));
tab.addTab(tab.newTab().setText("热门"));
tab.addTab(tab.newTab().setText("热帖"));
tab.addTab(tab.newTab().setText("精华"));
adapter = new PostListAdapter(this, datas, getType());
if (getType() == PostListAdapter.TYPE_IMAGE) {
adapter.setEnablePlaceHolder(false);
}
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(adapter);
myDB = new MyDB(this);
datas.clear();
btnRefresh.setOnClickListener(v -> refresh());
init();
// 子类实现获取数据
getData();
}
Aggregations