Search in sources :

Example 1 with UsersAdapter

use of com.fastaccess.ui.adapter.UsersAdapter in project FastHub by k0shk0sh.

the class ProfileFollowersFragment method onFragmentCreated.

@Override
protected void onFragmentCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    if (getArguments() == null) {
        throw new NullPointerException("Bundle is null, username is required");
    }
    stateLayout.setEmptyText(R.string.no_followers);
    stateLayout.setOnReloadListener(this);
    refresh.setOnRefreshListener(this);
    recycler.setEmptyView(stateLayout, refresh);
    getLoadMore().initialize(getPresenter().getCurrentPage(), getPresenter().getPreviousTotal());
    adapter = new UsersAdapter(getPresenter().getFollowers());
    adapter.setListener(getPresenter());
    recycler.setAdapter(adapter);
    recycler.addOnScrollListener(getLoadMore());
    recycler.addKeyLineDivider();
    if (getPresenter().getFollowers().isEmpty() && !getPresenter().isApiCalled()) {
        onRefresh();
    }
    fastScroller.attachRecyclerView(recycler);
}
Also used : UsersAdapter(com.fastaccess.ui.adapter.UsersAdapter)

Example 2 with UsersAdapter

use of com.fastaccess.ui.adapter.UsersAdapter in project FastHub by k0shk0sh.

the class ReactionsDialogFragment method onFragmentCreated.

@Override
protected void onFragmentCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    toolbar.setNavigationIcon(R.drawable.ic_clear);
    toolbar.setNavigationOnClickListener(v -> dismiss());
    stateLayout.setEmptyText(R.string.no_reactions);
    stateLayout.setOnReloadListener(v -> getPresenter().onCallApi(1, null));
    refresh.setOnRefreshListener(() -> getPresenter().onCallApi(1, null));
    recycler.setEmptyView(stateLayout, refresh);
    adapter = new UsersAdapter(getPresenter().getUsers());
    getLoadMore().initialize(getPresenter().getCurrentPage(), getPresenter().getPreviousTotal());
    recycler.setAdapter(adapter);
    recycler.addOnScrollListener(getLoadMore());
    if (savedInstanceState == null) {
        getPresenter().onFragmentCreated(getArguments());
    }
    toolbar.setTitle(SpannableBuilder.builder().append(getString(R.string.reactions)).append(" ").append(CommentsHelper.getEmoji(getPresenter().getReactionType())));
    fastScroller.attachRecyclerView(recycler);
}
Also used : UsersAdapter(com.fastaccess.ui.adapter.UsersAdapter)

Example 3 with UsersAdapter

use of com.fastaccess.ui.adapter.UsersAdapter in project FastHub by k0shk0sh.

the class SearchUsersFragment method onFragmentCreated.

@Override
protected void onFragmentCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    stateLayout.setEmptyText(R.string.no_search_results);
    getLoadMore().initialize(getPresenter().getCurrentPage(), getPresenter().getPreviousTotal());
    stateLayout.setOnReloadListener(this);
    refresh.setOnRefreshListener(this);
    recycler.setEmptyView(stateLayout, refresh);
    adapter = new UsersAdapter(getPresenter().getUsers());
    adapter.setListener(getPresenter());
    recycler.setAdapter(adapter);
    recycler.addKeyLineDivider();
    if (savedInstanceState != null) {
        if (!InputHelper.isEmpty(searchQuery) && getPresenter().getUsers().isEmpty() && !getPresenter().isApiCalled()) {
            onRefresh();
        }
    }
    if (InputHelper.isEmpty(searchQuery)) {
        stateLayout.showEmptyState();
    }
    fastScroller.attachRecyclerView(recycler);
}
Also used : UsersAdapter(com.fastaccess.ui.adapter.UsersAdapter)

Example 4 with UsersAdapter

use of com.fastaccess.ui.adapter.UsersAdapter in project FastHub by k0shk0sh.

the class RepoMiscDialogFragment method onFragmentCreated.

@Override
protected void onFragmentCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    if (getArguments() == null) {
        throw new NullPointerException("Bundle is null, username is required");
    }
    switch(getPresenter().getType()) {
        case RepoMiscMVp.FORKS:
            toolbar.setTitle(R.string.forks);
            stateLayout.setEmptyText(String.format("%s %s", getString(R.string.no), getString(R.string.forks)));
            break;
        case RepoMiscMVp.STARS:
            toolbar.setTitle(R.string.stars);
            stateLayout.setEmptyText(String.format("%s %s", getString(R.string.no), getString(R.string.stars)));
            break;
        case RepoMiscMVp.WATCHERS:
            toolbar.setTitle(R.string.watchers);
            stateLayout.setEmptyText(String.format("%s %s", getString(R.string.no), getString(R.string.watchers)));
            break;
    }
    toolbar.setNavigationIcon(R.drawable.ic_clear);
    toolbar.setNavigationOnClickListener(v -> dismiss());
    stateLayout.setOnReloadListener(v -> getPresenter().onCallApi(1, null));
    refresh.setOnRefreshListener(() -> getPresenter().onCallApi(1, null));
    recycler.setEmptyView(stateLayout, refresh);
    getLoadMore().initialize(getPresenter().getCurrentPage(), getPresenter().getPreviousTotal());
    adapter = new UsersAdapter(getPresenter().getList());
    adapter.setListener(getPresenter());
    recycler.setAdapter(adapter);
    recycler.addOnScrollListener(getLoadMore());
    recycler.addKeyLineDivider();
    if (getPresenter().getList().isEmpty() && !getPresenter().isApiCalled()) {
        getPresenter().onCallApi(1, null);
    }
    fastScroller.attachRecyclerView(recycler);
}
Also used : UsersAdapter(com.fastaccess.ui.adapter.UsersAdapter)

Example 5 with UsersAdapter

use of com.fastaccess.ui.adapter.UsersAdapter in project FastHub by k0shk0sh.

the class FilterIssuesActivity method getAssigneesAdapter.

private UsersAdapter getAssigneesAdapter() {
    if (assigneesAdapter == null) {
        if (!getPresenter().getAssignees().isEmpty()) {
            User user = new User();
            user.setLogin(getString(R.string.clear));
            getPresenter().getAssignees().add(0, user);
        }
        assigneesAdapter = new UsersAdapter(getPresenter().getAssignees(), false, true);
        assigneesAdapter.setListener(new BaseViewHolder.OnItemClickListener<User>() {

            @Override
            public void onItemClick(int position, View v, User item) {
                appendAssignee(item);
            }

            @Override
            public void onItemLongClick(int position, View v, User item) {
            }
        });
    }
    return assigneesAdapter;
}
Also used : UsersAdapter(com.fastaccess.ui.adapter.UsersAdapter) BaseViewHolder(com.fastaccess.ui.widgets.recyclerview.BaseViewHolder) User(com.fastaccess.data.dao.model.User) BindView(butterknife.BindView) ForegroundImageView(com.fastaccess.ui.widgets.ForegroundImageView) FontTextView(com.fastaccess.ui.widgets.FontTextView) View(android.view.View) DynamicRecyclerView(com.fastaccess.ui.widgets.recyclerview.DynamicRecyclerView) SuppressLint(android.annotation.SuppressLint)

Aggregations

UsersAdapter (com.fastaccess.ui.adapter.UsersAdapter)10 SuppressLint (android.annotation.SuppressLint)1 View (android.view.View)1 BindView (butterknife.BindView)1 User (com.fastaccess.data.dao.model.User)1 FontTextView (com.fastaccess.ui.widgets.FontTextView)1 ForegroundImageView (com.fastaccess.ui.widgets.ForegroundImageView)1 BaseViewHolder (com.fastaccess.ui.widgets.recyclerview.BaseViewHolder)1 DynamicRecyclerView (com.fastaccess.ui.widgets.recyclerview.DynamicRecyclerView)1