Search in sources :

Example 61 with Adapter

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;
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 62 with Adapter

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();
}
Also used : MenuItem(android.view.MenuItem) Intent(android.content.Intent) Spanned(android.text.Spanned) PopupMenu(android.support.v7.widget.PopupMenu)

Example 63 with Adapter

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;
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) Drawable(android.graphics.drawable.Drawable) TimelineAdapter(com.keylesspalace.tusky.adapter.TimelineAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TimelineReceiver(com.keylesspalace.tusky.receiver.TimelineReceiver)

Example 64 with Adapter

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);
}
Also used : Account(com.keylesspalace.tusky.entity.Account) EndlessOnScrollListener(com.keylesspalace.tusky.view.EndlessOnScrollListener) TabLayout(android.support.design.widget.TabLayout) BaseActivity(com.keylesspalace.tusky.BaseActivity) RecyclerView(android.support.v7.widget.RecyclerView) AccountAdapter(com.keylesspalace.tusky.adapter.AccountAdapter)

Example 65 with Adapter

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();
}
Also used : Account(com.keylesspalace.tusky.entity.Account) BlocksAdapter(com.keylesspalace.tusky.adapter.BlocksAdapter) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)688 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)612 View (android.view.View)593 TextView (android.widget.TextView)245 ArrayList (java.util.ArrayList)179 Intent (android.content.Intent)148 ImageView (android.widget.ImageView)132 Toolbar (android.support.v7.widget.Toolbar)118 GridLayoutManager (android.support.v7.widget.GridLayoutManager)111 AdapterView (android.widget.AdapterView)109 ViewGroup (android.view.ViewGroup)97 AlertDialog (android.support.v7.app.AlertDialog)91 Bundle (android.os.Bundle)85 ListView (android.widget.ListView)85 BindView (butterknife.BindView)85 Nullable (android.support.annotation.Nullable)78 DialogInterface (android.content.DialogInterface)71 Context (android.content.Context)65 ArrayAdapter (android.widget.ArrayAdapter)65 LayoutInflater (android.view.LayoutInflater)64