Search in sources :

Example 1 with OnItemClickedListener

use of im.actor.sdk.view.adapters.OnItemClickedListener in project actor-platform by actorapp.

the class GlobalSearchBaseFragment method showSearch.

private void showSearch() {
    if (isSearchVisible) {
        return;
    }
    isSearchVisible = true;
    searchDisplay = messenger().buildSearchDisplayList();
    searchDisplay.setBindHook(new BindedDisplayList.BindHook<SearchEntity>() {

        @Override
        public void onScrolledToEnd() {
            scrolledToEnd = true;
            checkGlobalSearch();
        }

        @Override
        public void onItemTouched(SearchEntity item) {
        }
    });
    searchAdapter = new SearchAdapter(getActivity(), searchDisplay, new OnItemClickedListener<SearchEntity>() {

        @Override
        public void onClicked(SearchEntity item) {
            onPeerPicked(item.getPeer());
            searchMenu.collapseActionView();
        }

        @Override
        public boolean onLongClicked(SearchEntity item) {
            return false;
        }
    });
    HeaderViewRecyclerAdapter recyclerAdapter = new HeaderViewRecyclerAdapter(searchAdapter);
    View header = new View(getActivity());
    header.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(0)));
    header.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    recyclerAdapter.addHeaderView(header);
    searchList.setAdapter(recyclerAdapter);
    RecyclerView.ItemAnimator animator = searchList.getItemAnimator();
    if (animator instanceof SimpleItemAnimator) {
        ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
    }
    searchDisplay.addListener(searchListener);
    showView(searchHintView, false);
    goneView(searchEmptyView, false);
    showView(searchContainer, false);
    Fragment parent = getParentFragment();
    if (parent != null && parent instanceof GlobalSearchStateDelegate) {
        ((GlobalSearchStateDelegate) parent).onGlobalSearchStarted();
    }
}
Also used : SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) SearchView(android.support.v7.widget.SearchView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) BaseFragment(im.actor.sdk.controllers.BaseFragment) Fragment(android.support.v4.app.Fragment) BindedDisplayList(im.actor.runtime.generic.mvvm.BindedDisplayList) HeaderViewRecyclerAdapter(im.actor.sdk.view.adapters.HeaderViewRecyclerAdapter) SearchEntity(im.actor.core.entity.SearchEntity) PeerSearchEntity(im.actor.core.entity.PeerSearchEntity) OnItemClickedListener(im.actor.sdk.view.adapters.OnItemClickedListener) FrameLayout(android.widget.FrameLayout) RecyclerView(android.support.v7.widget.RecyclerView)

Example 2 with OnItemClickedListener

use of im.actor.sdk.view.adapters.OnItemClickedListener in project actor-platform by actorapp.

the class InviteFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View res = inflater.inflate(R.layout.fragment_list, container, false);
    res.findViewById(R.id.listView).setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    emptyText = (TextView) res.findViewById(R.id.emptyView);
    emptyText.setTextColor(ActorSDK.sharedActor().style.getTextSecondaryColor());
    emptyText.setText(R.string.progress_common);
    collection = (RecyclerListView) res.findViewById(R.id.listView);
    AndroidPhoneBook phoneBookLoader = new AndroidPhoneBook();
    phoneBookLoader.useDelay(false);
    res.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    phoneBookLoader.loadPhoneBook(contacts -> {
        if (contacts.size() > 0) {
            getActivity().runOnUiThread(() -> {
                InviteFragment.this.contacts = contacts;
                adapter = new InviteAdapter(getActivity(), contacts, new OnItemClickedListener<PhoneBookContact>() {

                    @Override
                    public void onClicked(PhoneBookContact item) {
                        onItemClicked(item);
                    }

                    @Override
                    public boolean onLongClicked(PhoneBookContact item) {
                        return false;
                    }
                });
                collection.setAdapter(adapter);
                hideView(emptyText);
                showView(collection);
                showMenu();
            });
        }
    });
    return res;
}
Also used : PhoneBookContact(im.actor.core.entity.PhoneBookContact) OnItemClickedListener(im.actor.sdk.view.adapters.OnItemClickedListener) TextView(android.widget.TextView) RecyclerListView(im.actor.sdk.view.adapters.RecyclerListView) View(android.view.View) AndroidPhoneBook(im.actor.sdk.core.AndroidPhoneBook)

Aggregations

View (android.view.View)2 TextView (android.widget.TextView)2 OnItemClickedListener (im.actor.sdk.view.adapters.OnItemClickedListener)2 Fragment (android.support.v4.app.Fragment)1 RecyclerView (android.support.v7.widget.RecyclerView)1 SearchView (android.support.v7.widget.SearchView)1 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)1 FrameLayout (android.widget.FrameLayout)1 PeerSearchEntity (im.actor.core.entity.PeerSearchEntity)1 PhoneBookContact (im.actor.core.entity.PhoneBookContact)1 SearchEntity (im.actor.core.entity.SearchEntity)1 BindedDisplayList (im.actor.runtime.generic.mvvm.BindedDisplayList)1 BaseFragment (im.actor.sdk.controllers.BaseFragment)1 AndroidPhoneBook (im.actor.sdk.core.AndroidPhoneBook)1 HeaderViewRecyclerAdapter (im.actor.sdk.view.adapters.HeaderViewRecyclerAdapter)1 RecyclerListView (im.actor.sdk.view.adapters.RecyclerListView)1