use of android.support.v7.widget.RecyclerView.Adapter in project CloudReader by youlookwhat.
the class CustomFragment method setAdapter.
/**
* 设置adapter
*/
private void setAdapter(GankIoDataBean mCustomBean) {
if (mHeaderView == null) {
mHeaderView = View.inflate(getContext(), R.layout.header_item_gank_custom, null);
bindingView.xrvCustom.addHeaderView(mHeaderView);
}
initHeader(mHeaderView);
boolean isAll = SPUtils.getString("gank_cala", "全部").equals("全部");
mAndroidAdapter.clear();
mAndroidAdapter.setAllType(isAll);
mAndroidAdapter.addAll(mCustomBean.getResults());
bindingView.xrvCustom.setLayoutManager(new LinearLayoutManager(getActivity()));
bindingView.xrvCustom.setAdapter(mAndroidAdapter);
mAndroidAdapter.notifyDataSetChanged();
mIsFirst = false;
}
use of android.support.v7.widget.RecyclerView.Adapter in project Tusky by Vavassor.
the class SFragment method more.
protected void more(final Status status, View view, final AdapterItemRemover adapter, final int position) {
final String id = status.getActionableId();
final String accountId = status.getActionableStatus().account.id;
final String accountUsename = status.getActionableStatus().account.username;
final Spanned content = status.getActionableStatus().content;
final String statusUrl = status.getActionableStatus().url;
PopupMenu popup = new PopupMenu(getContext(), view);
// Give a different menu depending on whether this is the user's own toot or not.
if (loggedInAccountId == null || !loggedInAccountId.equals(accountId)) {
popup.inflate(R.menu.status_more);
} else {
popup.inflate(R.menu.status_more_for_user);
}
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.status_share_content:
{
StringBuilder sb = new StringBuilder();
sb.append(status.account.username);
sb.append(" - ");
sb.append(status.content.toString());
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, sb.toString());
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_status_content_to)));
return true;
}
case R.id.status_share_link:
{
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, statusUrl);
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_status_link_to)));
return true;
}
case R.id.status_mute:
{
mute(accountId);
return true;
}
case R.id.status_block:
{
block(accountId);
return true;
}
case R.id.status_report:
{
openReportPage(accountId, accountUsename, id, content);
return true;
}
case R.id.status_delete:
{
delete(id);
adapter.removeItem(position);
return true;
}
}
return false;
}
});
popup.show();
}
use of android.support.v7.widget.RecyclerView.Adapter in project Tusky by Vavassor.
the class TimelineFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Bundle arguments = getArguments();
kind = Kind.valueOf(arguments.getString("kind"));
if (kind == Kind.TAG || kind == Kind.USER) {
hashtagOrId = arguments.getString("hashtag_or_id");
}
final View rootView = inflater.inflate(R.layout.fragment_timeline, container, false);
// Setup the SwipeRefreshLayout.
Context context = getContext();
swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_refresh_layout);
swipeRefreshLayout.setOnRefreshListener(this);
// Setup the RecyclerView.
recyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_view);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(context);
recyclerView.setLayoutManager(layoutManager);
DividerItemDecoration divider = new DividerItemDecoration(context, layoutManager.getOrientation());
Drawable drawable = ThemeUtils.getDrawable(context, R.attr.status_divider_drawable, R.drawable.status_divider_dark);
divider.setDrawable(drawable);
recyclerView.addItemDecoration(divider);
adapter = new TimelineAdapter(this);
recyclerView.setAdapter(adapter);
timelineReceiver = new TimelineReceiver(adapter);
LocalBroadcastManager.getInstance(context.getApplicationContext()).registerReceiver(timelineReceiver, TimelineReceiver.getFilter(kind));
return rootView;
}
use of android.support.v7.widget.RecyclerView.Adapter in project Tusky by Vavassor.
the class AccountListFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
BaseActivity activity = (BaseActivity) getActivity();
if (jumpToTopAllowed()) {
TabLayout layout = (TabLayout) activity.findViewById(R.id.tab_layout);
onTabSelectedListener = new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
jumpToTop();
}
};
layout.addOnTabSelectedListener(onTabSelectedListener);
}
/* MastodonAPI on the base activity is only guaranteed to be initialised after the parent
* activity is created, so everything needing to access the api object has to be delayed
* until here. */
api = activity.mastodonAPI;
scrollListener = new EndlessOnScrollListener(layoutManager) {
@Override
public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
AccountAdapter adapter = (AccountAdapter) view.getAdapter();
Account account = adapter.getItem(adapter.getItemCount() - 2);
if (account != null) {
fetchAccounts(account.id, null);
} else {
fetchAccounts();
}
}
};
recyclerView.addOnScrollListener(scrollListener);
}
use of android.support.v7.widget.RecyclerView.Adapter in project Tusky by Vavassor.
the class AccountListFragment method onBlockSuccess.
private void onBlockSuccess(boolean blocked, final String id, final int position) {
if (blocked) {
return;
}
final BlocksAdapter blocksAdapter = (BlocksAdapter) adapter;
final Account unblockedUser = blocksAdapter.removeItem(position);
View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View v) {
blocksAdapter.addItem(unblockedUser, position);
onBlock(true, id, position);
}
};
Snackbar.make(recyclerView, R.string.confirmation_unblocked, Snackbar.LENGTH_LONG).setAction(R.string.action_undo, listener).show();
}
Aggregations