use of androidx.swiperefreshlayout.widget.SwipeRefreshLayout in project IITB-App by wncc.
the class NewsFragment method onStart.
@Override
public void onStart() {
super.onStart();
Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle("News");
Utils.setSelectedMenuItem(getActivity(), R.id.nav_news);
setHasOptionsMenu(true);
updateData();
postType = NewsArticle.class;
adapterType = NewsAdapter.class;
recyclerView = getActivity().findViewById(R.id.news_recycler_view);
swipeRefreshLayout = getActivity().findViewById(R.id.news_swipe_refresh_layout);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
updateData();
}
});
}
use of androidx.swiperefreshlayout.widget.SwipeRefreshLayout in project IITB-App by wncc.
the class PlacementBlogFragment method onStart.
@Override
public void onStart() {
super.onStart();
Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle("Placement Blog");
Utils.setSelectedMenuItem(getActivity(), R.id.nav_placement_blog);
setHasOptionsMenu(true);
updateData();
postType = PlacementBlogPost.class;
adapterType = PlacementBlogAdapter.class;
recyclerView = getActivity().findViewById(R.id.placement_feed_recycler_view);
swipeRefreshLayout = getActivity().findViewById(R.id.placement_feed_swipe_refresh_layout);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
updateData();
}
});
}
use of androidx.swiperefreshlayout.widget.SwipeRefreshLayout in project IITB-App by wncc.
the class TrainingBlogFragment method onStart.
@Override
public void onStart() {
super.onStart();
Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle("Internship Blog");
Utils.setSelectedMenuItem(getActivity(), R.id.nav_training_blog);
setHasOptionsMenu(true);
updateData();
postType = TrainingBlogPost.class;
adapterType = TrainingBlogAdapter.class;
recyclerView = getActivity().findViewById(R.id.training_feed_recycler_view);
swipeRefreshLayout = getActivity().findViewById(R.id.training_feed_swipe_refresh_layout);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
updateData();
}
});
}
use of androidx.swiperefreshlayout.widget.SwipeRefreshLayout in project SherlockAdapter by EvilBT.
the class MultiItemActivity method initView.
private void initView() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mGridLayoutManager = new GridLayoutManager(this, 3);
mStaggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
final SwipeRefreshLayout refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh);
mRecyclerView = (RecyclerView) findViewById(R.id.list);
mRecyclerView.setLayoutManager(mGridLayoutManager);
mIsGrid = true;
mAdapter = new MyMultiAdapter();
mRecyclerView.setAdapter(mAdapter);
mAdapter.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(@NonNull View view, final int adapterPosition) {
new AlertDialog.Builder(MultiItemActivity.this).setTitle("是否删除第" + adapterPosition + "项").setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mAdapter.removeData(adapterPosition);
}
}).setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).create().show();
return true;
}
});
mData = new ArrayList<>();
initGridData();
refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
refreshLayout.postDelayed(new Runnable() {
@Override
public void run() {
mAdapter.setData(mData);
refreshLayout.setRefreshing(false);
}
}, 500);
}
});
}
use of androidx.swiperefreshlayout.widget.SwipeRefreshLayout in project SherlockAdapter by EvilBT.
the class AutoLoadMoreActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.act_auto_load_more);
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
mAdapter = new AutoLoadAdapter(this);
recyclerView.setAdapter(mAdapter);
final SwipeRefreshLayout refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh);
mAdapter.setAlwaysShowHead(true);
mAdapter.setAlwaysShowFoot(true);
mAdapter.addHeadLayout(R.layout.item_head);
mAdapter.addFootLayout(R.layout.item_foot2);
// 模拟数据
data = new ArrayList<>();
for (int i = 0; i < mTitles.length; i++) {
ImageCard card = new ImageCard(mImageResId[i], mTitles[i]);
data.add(card);
}
refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
// 模拟刷新
recyclerView.postDelayed(new Runnable() {
@Override
public void run() {
refreshLayout.setRefreshing(false);
mAdapter.setData(data);
}
}, 500);
}
});
// 必须设置事件监听与开启auto
mAdapter.openAutoLoadMore(true);
mAdapter.setOnLoadMoreListener(new OnLoadMoreListener() {
@Override
public void onLoadMore() {
Log.d("Sherlock", "加载更多");
// 模拟加载更多
recyclerView.postDelayed(new Runnable() {
@Override
public void run() {
if (mState == LOAD_ADD) {
mAdapter.addData(data);
} else if (mState == LOAD_COMPLETED) {
mAdapter.loadCompleted();
} else if (mState == LOAD_FAILED) {
mAdapter.loadFailed();
}
}
}, 800);
}
});
findViewById(R.id.action_add).setOnClickListener(this);
findViewById(R.id.action_failed).setOnClickListener(this);
findViewById(R.id.action_completed).setOnClickListener(this);
findViewById(R.id.action_empty).setOnClickListener(this);
findViewById(R.id.action_close).setOnClickListener(this);
mShowHead = (CheckBox) findViewById(R.id.cb_show_head);
mShowFoot = (CheckBox) findViewById(R.id.cb_show_foot);
mShowHead.setChecked(true);
mShowFoot.setChecked(true);
mShowHead.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mAdapter.setAlwaysShowHead(isChecked);
}
});
mShowFoot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mAdapter.setAlwaysShowFoot(isChecked);
}
});
}
Aggregations