Search in sources :

Example 1 with AdapterListContact

use of net.iGap.adapter.AdapterListContact in project iGap-Android by KianIranian-STDG.

the class LocalContactFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    toolbarLayout = rootView.findViewById(R.id.ll_localContact_toolbar);
    loadingPb = rootView.findViewById(R.id.pb_localContact);
    txtNoItem = rootView.findViewById(R.id.txt_no_item);
    toolbarInit();
    // calculate these for recycler pagination
    recyclerRowsHeight = getResources().getDimensionPixelSize(R.dimen.dp60);
    deviceScreenHeight = getDeviceScreenHeight();
    recyclerView = rootView.findViewById(R.id.rv_localContact);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
    recyclerView.setLayoutManager(linearLayoutManager);
    adapterListContact = new AdapterListContact(phoneContactsList, getContext());
    recyclerView.setAdapter(adapterListContact);
    recyclerView.addOnScrollListener(new EndlessRecyclerViewScrollListener(linearLayoutManager) {

        @Override
        public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
            if (!inSearchMode || mHelperToolbar.getEditTextSearch().getText().toString().trim().equals("")) {
                if (Contacts.isEndLocal) {
                    return;
                }
                loadingPb.setVisibility(View.VISIBLE);
                new Contacts.FetchContactForClient().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            }
        }
    });
    mHelperToolbar.getEditTextSearch().setImeOptions(EditorInfo.IME_ACTION_SEARCH);
    mHelperToolbar.getEditTextSearch().setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                cancelSearchTimer();
                String text = mHelperToolbar.getEditTextSearch().getText().toString().trim();
                if (text.equals(""))
                    return true;
                new SearchAsync(text).execute();
                return true;
            }
            return false;
        }
    });
}
Also used : KeyEvent(android.view.KeyEvent) EndlessRecyclerViewScrollListener(net.iGap.module.EndlessRecyclerViewScrollListener) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) HelperString(net.iGap.helper.HelperString) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) AdapterListContact(net.iGap.adapter.AdapterListContact) Point(android.graphics.Point)

Aggregations

Point (android.graphics.Point)1 KeyEvent (android.view.KeyEvent)1 TextView (android.widget.TextView)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 AdapterListContact (net.iGap.adapter.AdapterListContact)1 HelperString (net.iGap.helper.HelperString)1 EndlessRecyclerViewScrollListener (net.iGap.module.EndlessRecyclerViewScrollListener)1