Search in sources :

Example 1 with Account

use of com.keylesspalace.tusky.entity.Account 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 2 with Account

use of com.keylesspalace.tusky.entity.Account 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)

Example 3 with Account

use of com.keylesspalace.tusky.entity.Account in project Tusky by tuskyapp.

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 = 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 : Context(android.content.Context) Bundle(android.os.Bundle) FooterViewHolder(com.keylesspalace.tusky.adapter.FooterViewHolder) Intent(android.content.Intent) NonNull(android.support.annotation.NonNull) AccountActionListener(com.keylesspalace.tusky.interfaces.AccountActionListener) Response(retrofit2.Response) Drawable(android.graphics.drawable.Drawable) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) Inject(javax.inject.Inject) FollowRequestsAdapter(com.keylesspalace.tusky.adapter.FollowRequestsAdapter) R(com.keylesspalace.tusky.R) View(android.view.View) Account(com.keylesspalace.tusky.entity.Account) Log(android.util.Log) ThemeUtils(com.keylesspalace.tusky.util.ThemeUtils) AccountAdapter(com.keylesspalace.tusky.adapter.AccountAdapter) MutesAdapter(com.keylesspalace.tusky.adapter.MutesAdapter) LayoutInflater(android.view.LayoutInflater) BaseActivity(com.keylesspalace.tusky.BaseActivity) BlocksAdapter(com.keylesspalace.tusky.adapter.BlocksAdapter) HttpHeaderLink(com.keylesspalace.tusky.util.HttpHeaderLink) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Relationship(com.keylesspalace.tusky.entity.Relationship) ViewGroup(android.view.ViewGroup) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) FollowAdapter(com.keylesspalace.tusky.adapter.FollowAdapter) Callback(retrofit2.Callback) MastodonApi(com.keylesspalace.tusky.network.MastodonApi) EndlessOnScrollListener(com.keylesspalace.tusky.view.EndlessOnScrollListener) Nullable(android.support.annotation.Nullable) Snackbar(android.support.design.widget.Snackbar) AccountActivity(com.keylesspalace.tusky.AccountActivity) Injectable(com.keylesspalace.tusky.di.Injectable) Call(retrofit2.Call) Account(com.keylesspalace.tusky.entity.Account) BlocksAdapter(com.keylesspalace.tusky.adapter.BlocksAdapter) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 4 with Account

use of com.keylesspalace.tusky.entity.Account in project Tusky by tuskyapp.

the class AccountListFragment method onMuteSuccess.

private void onMuteSuccess(boolean muted, final String id, final int position) {
    if (muted) {
        return;
    }
    final MutesAdapter mutesAdapter = (MutesAdapter) adapter;
    final Account unmutedUser = mutesAdapter.removeItem(position);
    View.OnClickListener listener = v -> {
        mutesAdapter.addItem(unmutedUser, position);
        onMute(true, id, position);
    };
    Snackbar.make(recyclerView, R.string.confirmation_unmuted, Snackbar.LENGTH_LONG).setAction(R.string.action_undo, listener).show();
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) FooterViewHolder(com.keylesspalace.tusky.adapter.FooterViewHolder) Intent(android.content.Intent) NonNull(android.support.annotation.NonNull) AccountActionListener(com.keylesspalace.tusky.interfaces.AccountActionListener) Response(retrofit2.Response) Drawable(android.graphics.drawable.Drawable) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) Inject(javax.inject.Inject) FollowRequestsAdapter(com.keylesspalace.tusky.adapter.FollowRequestsAdapter) R(com.keylesspalace.tusky.R) View(android.view.View) Account(com.keylesspalace.tusky.entity.Account) Log(android.util.Log) ThemeUtils(com.keylesspalace.tusky.util.ThemeUtils) AccountAdapter(com.keylesspalace.tusky.adapter.AccountAdapter) MutesAdapter(com.keylesspalace.tusky.adapter.MutesAdapter) LayoutInflater(android.view.LayoutInflater) BaseActivity(com.keylesspalace.tusky.BaseActivity) BlocksAdapter(com.keylesspalace.tusky.adapter.BlocksAdapter) HttpHeaderLink(com.keylesspalace.tusky.util.HttpHeaderLink) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Relationship(com.keylesspalace.tusky.entity.Relationship) ViewGroup(android.view.ViewGroup) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) FollowAdapter(com.keylesspalace.tusky.adapter.FollowAdapter) Callback(retrofit2.Callback) MastodonApi(com.keylesspalace.tusky.network.MastodonApi) EndlessOnScrollListener(com.keylesspalace.tusky.view.EndlessOnScrollListener) Nullable(android.support.annotation.Nullable) Snackbar(android.support.design.widget.Snackbar) AccountActivity(com.keylesspalace.tusky.AccountActivity) Injectable(com.keylesspalace.tusky.di.Injectable) Call(retrofit2.Call) Account(com.keylesspalace.tusky.entity.Account) MutesAdapter(com.keylesspalace.tusky.adapter.MutesAdapter) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 5 with Account

use of com.keylesspalace.tusky.entity.Account in project Tusky by tuskyapp.

the class AccountAdapter method addItems.

public void addItems(List<Account> newAccounts, @Nullable String fromId) {
    if (fromId != null) {
        bottomId = fromId;
    }
    int end = accountList.size();
    Account last = accountList.get(end - 1);
    if (last != null && !findAccount(newAccounts, last.getId())) {
        accountList.addAll(newAccounts);
        notifyItemRangeInserted(end, newAccounts.size());
    }
}
Also used : Account(com.keylesspalace.tusky.entity.Account)

Aggregations

Account (com.keylesspalace.tusky.entity.Account)14 View (android.view.View)8 RecyclerView (android.support.v7.widget.RecyclerView)5 Context (android.content.Context)4 Nullable (android.support.annotation.Nullable)4 ImageView (android.widget.ImageView)4 Intent (android.content.Intent)3 NonNull (android.support.annotation.NonNull)3 LayoutInflater (android.view.LayoutInflater)3 TextView (android.widget.TextView)3 BaseActivity (com.keylesspalace.tusky.BaseActivity)3 AccountAdapter (com.keylesspalace.tusky.adapter.AccountAdapter)3 BlocksAdapter (com.keylesspalace.tusky.adapter.BlocksAdapter)3 MutesAdapter (com.keylesspalace.tusky.adapter.MutesAdapter)3 EndlessOnScrollListener (com.keylesspalace.tusky.view.EndlessOnScrollListener)3 Call (retrofit2.Call)3 Callback (retrofit2.Callback)3 Response (retrofit2.Response)3 Drawable (android.graphics.drawable.Drawable)2 Bundle (android.os.Bundle)2