Search in sources :

Example 1 with EndlessRecyclerViewScrollListener

use of net.iGap.module.EndlessRecyclerViewScrollListener in project iGap-Android by KianIranian-STDG.

the class MplTransactionFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    setUpViews();
    viewModel.getMplTransactionLiveData().observe(getViewLifecycleOwner(), mplTransaction -> {
        if (mplTransaction != null) {
            if (mplTransaction.size() > 0) {
                adapter.setTransAction(mplTransaction);
                start = adapter.getItemCount();
                end = start + MplTransactionViewModel.PAGINATION_LIMIT;
                page++;
            }
        }
    });
    viewModel.getProgressMutableLiveData().observe(getViewLifecycleOwner(), progress -> {
        if (progress != null)
            swipeRefreshLayout.setRefreshing(progress);
    });
    recyclerView.addOnScrollListener(new EndlessRecyclerViewScrollListener(layoutManager) {

        @Override
        public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
            viewModel.getMorePageOffset(start, end);
        }
    });
    swipeRefreshLayout.setOnRefreshListener(() -> {
        viewModel.getFirstPageMplTransactionList(viewModel.getType());
    });
    adapter.setCallBack(token -> {
        if (token != null)
            new HelperFragment(getFragmentManager(), MplTransactionInfoFragment.getInstance(token)).setReplace(false).load();
    });
    typeAllTv.setOnClickListener(v -> {
        setEnableButton(typeAllTv, typeBillTv, typeCardToCardTv, typeSalesTv, typeTopUpTv);
        viewModel.getFirstPageMplTransactionList(ProtoGlobal.MplTransaction.Type.NONE);
    });
    typeBillTv.setOnClickListener(v -> {
        setEnableButton(typeBillTv, typeAllTv, typeCardToCardTv, typeSalesTv, typeTopUpTv);
        viewModel.getFirstPageMplTransactionList(ProtoGlobal.MplTransaction.Type.BILL);
    });
    typeCardToCardTv.setOnClickListener(v -> {
        setEnableButton(typeCardToCardTv, typeAllTv, typeBillTv, typeSalesTv, typeTopUpTv);
        viewModel.getFirstPageMplTransactionList(ProtoGlobal.MplTransaction.Type.CARD_TO_CARD);
    });
    typeSalesTv.setOnClickListener(v -> {
        setEnableButton(typeSalesTv, typeAllTv, typeBillTv, typeCardToCardTv, typeTopUpTv);
        viewModel.getFirstPageMplTransactionList(ProtoGlobal.MplTransaction.Type.SALES);
    });
    typeTopUpTv.setOnClickListener(v -> {
        setEnableButton(typeTopUpTv, typeAllTv, typeBillTv, typeCardToCardTv, typeSalesTv);
        viewModel.getFirstPageMplTransactionList(ProtoGlobal.MplTransaction.Type.TOPUP);
    });
}
Also used : EndlessRecyclerViewScrollListener(net.iGap.module.EndlessRecyclerViewScrollListener) RecyclerView(androidx.recyclerview.widget.RecyclerView) HelperFragment(net.iGap.helper.HelperFragment)

Example 2 with EndlessRecyclerViewScrollListener

use of net.iGap.module.EndlessRecyclerViewScrollListener in project iGap-Android by KianIranian-STDG.

the class ViewUserDialogFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    EventManager.getInstance(AccountManager.selectedAccount).addObserver(EventManager.STORY_USER_INFO, this);
    EventManager.getInstance(AccountManager.selectedAccount).addObserver(EventManager.STORY_VIEWS_FETCHED, this);
    userId = new ArrayList<>();
    storyIdList = new ArrayList<>();
    createdAtList = new ArrayList<>();
    displayNameList = new ArrayList<>();
    Collections.sort(userIdList);
    for (int i = 0; i < userIdList.size(); i++) {
        userId.add(userIdList.get(i).userId);
        storyIdList.add(userIdList.get(i).id);
        createdAtList.add(userIdList.get(i).createdTime);
        displayNameList.add(userIdList.get(i).displayName);
    }
    mOffset = userId.size();
    this.storyId = userIdList.get(0).id;
    G.onUserInfoResponse = new OnUserInfoResponse() {

        @Override
        public void onUserInfo(ProtoGlobal.RegisteredUser user, String identity) {
        }

        @Override
        public void onUserInfoTimeOut() {
        }

        @Override
        public void onUserInfoError(int majorCode, int minorCode) {
        }
    };
    recyclerView.setAdapter(listAdapter);
    listAdapter.addRow();
    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(layoutManager);
    EndlessRecyclerViewScrollListener scrollListener = new EndlessRecyclerViewScrollListener(layoutManager) {

        @Override
        public void onLoadMore(int iPage, int totalItemsCount, RecyclerView view) {
            Log.e("fkldsjfklsjjf", "onLoadMore: ");
            if (!storyViewListFetched && mOffset > 0 && userIdList.size() < count) {
                progressBar.setVisibility(View.VISIBLE);
                AbstractObject req = null;
                IG_RPC.Story_Get_Own_Story_Views story_get_own_story_views = new IG_RPC.Story_Get_Own_Story_Views();
                story_get_own_story_views.offset = mOffset;
                story_get_own_story_views.limit = 50;
                req = story_get_own_story_views;
                MessageDataStorage.getInstance(AccountManager.selectedAccount).getRequestManager().sendRequest(req, (response, error) -> {
                    if (error == null) {
                        IG_RPC.Res_Story_Get_Own_Story_Views res = (IG_RPC.Res_Story_Get_Own_Story_Views) response;
                        mOffset += 50;
                        if (res.groupedViews.size() > 0) {
                            MessageDataStorage.getInstance(AccountManager.selectedAccount).updateOwnViews(res.groupedViews);
                        } else if (userIdList.size() >= count) {
                            storyViewListFetched = true;
                        } else {
                            progressBar.setVisibility(View.GONE);
                        }
                    } else {
                        progressBar.setVisibility(View.GONE);
                    }
                });
            }
        }
    };
    recyclerView.addOnScrollListener(scrollListener);
// recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
// private boolean scrollUpdated;
// private boolean scrollingManually;
// private int prevTop;
// private int prevPosition;
// 
// @Override
// public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
// super.onScrollStateChanged(recyclerView, newState);
// scrollingManually = newState == RecyclerView.SCROLL_STATE_DRAGGING;
// }
// 
// @Override
// public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
// super.onScrolled(recyclerView, dx, dy);
// 
// LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
// firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
// View view = layoutManager.getChildAt(0);
// if (firstVisibleItemPosition > 0 && view != null) {
// firstVisibleItemPositionOffset = view.getTop();
// }
// 
// if (!storyListFetched) {
// if (mOffset > 0) {
// int lastVisiblePosition = ((LinearLayoutManager) recyclerView.getLayoutManager()).findLastVisibleItemPosition();
// if (lastVisiblePosition + 10 >= mOffset) {
// AbstractObject req = null;
// IG_RPC.Story_Get_Own_Story_Views story_get_own_story_views = new IG_RPC.Story_Get_Own_Story_Views();
// story_get_own_story_views.offset = mOffset;
// story_get_own_story_views.limit = 50;
// req = story_get_own_story_views;
// MessageDataStorage.getInstance(AccountManager.selectedAccount).getRequestManager().sendRequest(req, (response, error) -> {
// if (error == null) {
// IG_RPC.Res_Story_Get_Own_Story_Views res = (IG_RPC.Res_Story_Get_Own_Story_Views) response;
// mOffset += res.groupedViews.size();
// MessageDataStorage.getInstance(AccountManager.selectedAccount).updateOwnViews(res.groupedViews);
// 
// } else {
// }
// });
// }
// }
// }
// 
// int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
// if (firstVisibleItem != RecyclerView.NO_POSITION) {
// RecyclerView.ViewHolder holder = recyclerView.findViewHolderForAdapterPosition(firstVisibleItem);
// if (holder != null && holder.getAdapterPosition() != 0) {
// int firstViewTop = holder.itemView.getTop();
// boolean goingDown;
// boolean changed = true;
// if (prevPosition == firstVisibleItem) {
// final int topDelta = prevTop - firstViewTop;
// goingDown = firstViewTop < prevTop;
// changed = Math.abs(topDelta) > 1;
// } else {
// goingDown = firstVisibleItem > prevPosition;
// }
// prevPosition = firstVisibleItem;
// prevTop = firstViewTop;
// scrollUpdated = true;
// }
// }
// }
// });
}
Also used : IG_RPC(net.iGap.network.IG_RPC) ProtoGlobal(net.iGap.proto.ProtoGlobal) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) OnUserInfoResponse(net.iGap.observers.interfaces.OnUserInfoResponse) EndlessRecyclerViewScrollListener(net.iGap.module.EndlessRecyclerViewScrollListener) AbstractObject(net.iGap.network.AbstractObject) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 3 with EndlessRecyclerViewScrollListener

use of net.iGap.module.EndlessRecyclerViewScrollListener 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)

Example 4 with EndlessRecyclerViewScrollListener

use of net.iGap.module.EndlessRecyclerViewScrollListener in project iGap-Android by KianIranian-STDG.

the class FragmentShowMember method initComponent.

private void initComponent(View view) {
    mHelperToolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLeftIcon(R.string.icon_back).setLogoShown(true).setSearchBoxShown(true).setListener(this);
    LinearLayout layoutToolbar = view.findViewById(R.id.fcm_layout_toolbar);
    layoutToolbar.addView(mHelperToolbar.getView());
    mBtnAdd = view.findViewById(R.id.fcm_lbl_add);
    realmRoom = DbManager.getInstance().doRealmTask(realm -> {
        return realm.where(RealmRoom.class).equalTo("id", mRoomID).findFirst();
    });
    if (selectedRole.equals(ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.ALL.toString())) {
        if (isGroup) {
            mHelperToolbar.setDefaultTitle(context.getResources().getString(R.string.member));
            mBtnAdd.setText(context.getResources().getString(R.string.add_new_member));
        } else {
            mHelperToolbar.setDefaultTitle(context.getResources().getString(R.string.subscriber));
            mBtnAdd.setText(context.getResources().getString(R.string.add_new_subscriber));
        }
        if (!isShowAddButton) {
            mBtnAdd.setVisibility(View.GONE);
            view.findViewById(R.id.fcm_splitter_add).setVisibility(View.GONE);
        }
        mBtnAdd.setVisibility(realmRoomAccess != null && realmRoomAccess.isCanAddNewMember() ? View.VISIBLE : View.GONE);
    } else if (selectedRole.equals(ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.ADMIN.toString())) {
        mHelperToolbar.setDefaultTitle(context.getResources().getString(R.string.list_admin));
        mBtnAdd.setText(context.getResources().getString(R.string.add_admin));
        mBtnAdd.setVisibility(realmRoomAccess != null && realmRoomAccess.isCanAddNewAdmin() ? View.VISIBLE : View.GONE);
        if (realmRoom != null) {
            if (realmRoom.getGroupRoom() != null && realmRoom.getGroupRoom().getRole() == GroupChatRole.OWNER) {
                mBtnAdd.setVisibility(View.VISIBLE);
            }
            if (realmRoom.getChannelRoom() != null && realmRoom.getChannelRoom().getRole() == ChannelChatRole.OWNER) {
                mBtnAdd.setVisibility(View.VISIBLE);
            }
        }
    } else if (selectedRole.equals(ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.MODERATOR.toString())) {
        mHelperToolbar.setDefaultTitle(context.getResources().getString(R.string.list_modereator));
        mBtnAdd.setText(context.getResources().getString(R.string.add_modereator));
        mBtnAdd.setVisibility(View.GONE);
        if (realmRoom != null) {
            if (realmRoom.getGroupRoom() != null && (realmRoom.getGroupRoom().getRole() == GroupChatRole.OWNER || realmRoom.getGroupRoom().getRole() == GroupChatRole.ADMIN)) {
                mBtnAdd.setVisibility(View.VISIBLE);
            }
            if (realmRoom.getChannelRoom() != null && (realmRoom.getChannelRoom().getRole() == ChannelChatRole.OWNER || realmRoom.getChannelRoom().getRole() == ChannelChatRole.ADMIN)) {
                mBtnAdd.setVisibility(View.VISIBLE);
            }
        }
    }
    mBtnAdd.setOnClickListener(v -> {
        if (selectedRole.equals(ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.MODERATOR.toString()) || selectedRole.equals(ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.ADMIN.toString())) {
            openFragmentForAdd(ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.ALL.toString(), selectedRole);
        } else if (selectedRole.equals(ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.ALL.toString())) {
            goToAddMember();
        }
    });
    final EditText edtSearch = mHelperToolbar.getEditTextSearch();
    edtSearch.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(final Editable s) {
            RealmResults<RealmMember> searchMember = DbManager.getInstance().doRealmTask(realm -> {
                return RealmMember.filterMember(realm, mRoomID, s.toString(), getUnselectRow(), selectedRole);
            });
            mAdapter = new MemberAdapter(searchMember, roomType, mMainRole, userID);
            mRecyclerView.setAdapter(mAdapter);
        }
    });
    mRecyclerView = view.findViewById(R.id.fcm_recycler_view_show_member);
    mRecyclerView.setItemViewCacheSize(100);
    mRecyclerView.setItemAnimator(null);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(G.fragmentActivity));
    final PreCachingLayoutManager preCachingLayoutManager = new PreCachingLayoutManager(G.fragmentActivity, DeviceUtils.getScreenHeight(G.fragmentActivity));
    mRecyclerView.setLayoutManager(preCachingLayoutManager);
    progressBar = view.findViewById(R.id.fcg_prgWaiting);
    AppUtils.setProgresColler(progressBar);
    // TextView txtNumberOfMember = (TextView) view.findViewById(R.id.fcg_txt_member);
    // if (selectedRole.toString().equals(ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.MODERATOR.toString())) {
    // txtNumberOfMember.setText(G.fragmentActivity.getResources().getString(R.string.list_modereator));
    // } else if (selectedRole.toString().equals(ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.ADMIN.toString())) {
    // txtNumberOfMember.setText(G.fragmentActivity.getResources().getString(R.string.list_admin));
    // } else {
    // txtNumberOfMember.setText(G.fragmentActivity.getResources().getString(member));
    // }
    scrollListener = new EndlessRecyclerViewScrollListener(preCachingLayoutManager) {

        @Override
        public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
            // Triggered only when new data needs to be appended to the list
            // Add whatever code is needed to append new items to the bottom of the list
            loadMoreMember();
        }
    };
    mRecyclerView.addOnScrollListener(scrollListener);
}
Also used : LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) AppUtils(net.iGap.module.AppUtils) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) ProgressBar(android.widget.ProgressBar) LastSeenTimeUtil(net.iGap.module.LastSeenTimeUtil) Theme(net.iGap.module.Theme) G(net.iGap.G) RequestGroupGetMemberList(net.iGap.request.RequestGroupGetMemberList) GroupChatRole(net.iGap.module.enums.GroupChatRole) RealmChannelRoom(net.iGap.realm.RealmChannelRoom) Handler(android.os.Handler) Looper(android.os.Looper) Fragment(androidx.fragment.app.Fragment) View(android.view.View) OnGroupKickMember(net.iGap.observers.interfaces.OnGroupKickMember) HelperError(net.iGap.helper.HelperError) RecyclerView(androidx.recyclerview.widget.RecyclerView) HelperFragment(net.iGap.helper.HelperFragment) RequestGroupAddMember(net.iGap.request.RequestGroupAddMember) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) RealmMember(net.iGap.realm.RealmMember) AsyncTask(android.os.AsyncTask) OnComplete(net.iGap.observers.interfaces.OnComplete) RealmRoom(net.iGap.realm.RealmRoom) RealmGroupRoom(net.iGap.realm.RealmGroupRoom) ViewGroup(android.view.ViewGroup) CHANNEL(net.iGap.proto.ProtoGlobal.Room.Type.CHANNEL) OnGroupGetMemberList(net.iGap.observers.interfaces.OnGroupGetMemberList) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) RealmRecyclerViewAdapter(io.realm.RealmRecyclerViewAdapter) RequestChannelAddMember(net.iGap.request.RequestChannelAddMember) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) TextCell(net.iGap.adapter.items.cells.TextCell) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ProtoGroupGetMemberList(net.iGap.proto.ProtoGroupGetMemberList) NotNull(org.jetbrains.annotations.NotNull) EndlessRecyclerViewScrollListener(net.iGap.module.EndlessRecyclerViewScrollListener) TextWatcher(android.text.TextWatcher) HelperToolbar(net.iGap.helper.HelperToolbar) Context(android.content.Context) RequestChannelGetMemberList(net.iGap.request.RequestChannelGetMemberList) RealmList(io.realm.RealmList) AccountManager(net.iGap.module.accountManager.AccountManager) StructContactInfo(net.iGap.module.structs.StructContactInfo) Dialog(android.app.Dialog) Editable(android.text.Editable) DeviceUtils(net.iGap.module.DeviceUtils) ArrayList(java.util.ArrayList) ProtoChannelGetMemberList(net.iGap.proto.ProtoChannelGetMemberList) LayoutCreator(net.iGap.helper.LayoutCreator) Contacts(net.iGap.module.Contacts) RealmRoomMessage(net.iGap.realm.RealmRoomMessage) RequestUserInfo(net.iGap.request.RequestUserInfo) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) OnSelectedList(net.iGap.observers.interfaces.OnSelectedList) RealmRoomAccess(net.iGap.realm.RealmRoomAccess) LayoutInflater(android.view.LayoutInflater) RealmResults(io.realm.RealmResults) CircleImageView(net.iGap.module.CircleImageView) PreCachingLayoutManager(net.iGap.module.PreCachingLayoutManager) Gravity(android.view.Gravity) ProtoGlobal(net.iGap.proto.ProtoGlobal) R(net.iGap.R) ChannelChatRole(net.iGap.module.enums.ChannelChatRole) OnChannelGetMemberList(net.iGap.observers.interfaces.OnChannelGetMemberList) GROUP(net.iGap.proto.ProtoGlobal.Room.Type.GROUP) DbManager(net.iGap.module.accountManager.DbManager) RequestGroupKickMember(net.iGap.request.RequestGroupKickMember) EditText(android.widget.EditText) RequestChannelKickMember(net.iGap.request.RequestChannelKickMember) EditText(android.widget.EditText) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) PreCachingLayoutManager(net.iGap.module.PreCachingLayoutManager) EndlessRecyclerViewScrollListener(net.iGap.module.EndlessRecyclerViewScrollListener) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) RecyclerView(androidx.recyclerview.widget.RecyclerView) RealmRoom(net.iGap.realm.RealmRoom) LinearLayout(android.widget.LinearLayout) RealmResults(io.realm.RealmResults)

Example 5 with EndlessRecyclerViewScrollListener

use of net.iGap.module.EndlessRecyclerViewScrollListener in project iGap-Android by KianIranian-STDG.

the class AddStickersFragment method setupViews.

@Override
public void setupViews() {
    progressBar = rootView.findViewById(R.id.progress_stricker);
    addStickerToolbar = rootView.findViewById(R.id.toolbar2);
    customTextViewMedium = rootView.findViewById(R.id.title);
    buttonBack = rootView.findViewById(R.id.chl_ripple_back_Button);
    if (title == null)
        addStickerToolbar.setVisibility(View.GONE);
    else
        customTextViewMedium.setText(title);
    RecyclerView recyclerView = rootView.findViewById(R.id.rcvSettingPage);
    recyclerView.setAdapter(adapter);
    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(layoutManager);
    EndlessRecyclerViewScrollListener scrollListener = new EndlessRecyclerViewScrollListener(layoutManager) {

        @Override
        public void onLoadMore(int iPage, int totalItemsCount, RecyclerView view) {
            viewModel.onPageEnded();
        }
    };
    buttonBack.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            popBackStackFragment();
        }
    });
    recyclerView.addOnScrollListener(scrollListener);
    adapter.setListener(new AddStickerFragmentAdapter.AddStickerAdapterListener() {

        @Override
        public void onButtonClick(StructIGStickerGroup stickerGroup, AddStickerFragmentAdapter.ProgressStatus progressStatus) {
            viewModel.onItemButtonClicked(stickerGroup, sticker -> {
                if (sticker.getGroupId().equals(stickerGroup.getGroupId())) {
                    progressStatus.setVisibility(sticker.isInUserList());
                }
            });
        }

        @Override
        public void onCellClick(StructIGStickerGroup stickerGroup) {
            viewModel.onItemCellClicked(stickerGroup);
        }

        @Override
        public void onButtonStatusChange(AddStickerFragmentAdapter.ButtonsStatus buttonsStatus) {
            viewModel.getButtonStatusChangedLiveData().observe(getViewLifecycleOwner(), buttonsStatus::changed);
        }
    });
    viewModel.getOpenStickerDetailLiveData().observe(getViewLifecycleOwner(), sticker -> openFragmentAddStickerToFavorite(sticker.getGroupId()));
    viewModel.getLoadMoreProgressLiveData().observe(getViewLifecycleOwner(), visibility -> progressBar.setVisibility(visibility));
    viewModel.getStickerGroupLiveData().observe(getViewLifecycleOwner(), stickerGroup -> adapter.addData(stickerGroup));
}
Also used : RippleView(net.iGap.libs.rippleeffect.RippleView) Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) StructIGStickerGroup(net.iGap.fragments.emoji.struct.StructIGStickerGroup) CustomTextViewMedium(net.iGap.module.CustomTextViewMedium) StructIGStickerCategory(net.iGap.fragments.emoji.struct.StructIGStickerCategory) Nullable(androidx.annotation.Nullable) MyAppBarLayout(net.iGap.module.MyAppBarLayout) ObserverFragment(net.iGap.observers.rx.ObserverFragment) View(android.view.View) RelativeLayout(android.widget.RelativeLayout) ViewModelProviders(androidx.lifecycle.ViewModelProviders) R(net.iGap.R) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) RecyclerView(androidx.recyclerview.widget.RecyclerView) EndlessRecyclerViewScrollListener(net.iGap.module.EndlessRecyclerViewScrollListener) AddStickerViewModel(net.iGap.viewmodel.AddStickerViewModel) EndlessRecyclerViewScrollListener(net.iGap.module.EndlessRecyclerViewScrollListener) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) StructIGStickerGroup(net.iGap.fragments.emoji.struct.StructIGStickerGroup) RippleView(net.iGap.libs.rippleeffect.RippleView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Aggregations

RecyclerView (androidx.recyclerview.widget.RecyclerView)5 EndlessRecyclerViewScrollListener (net.iGap.module.EndlessRecyclerViewScrollListener)5 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)4 Bundle (android.os.Bundle)2 View (android.view.View)2 ProgressBar (android.widget.ProgressBar)2 TextView (android.widget.TextView)2 Nullable (androidx.annotation.Nullable)2 R (net.iGap.R)2 HelperFragment (net.iGap.helper.HelperFragment)2 Dialog (android.app.Dialog)1 Context (android.content.Context)1 Point (android.graphics.Point)1 AsyncTask (android.os.AsyncTask)1 Handler (android.os.Handler)1 Looper (android.os.Looper)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 Gravity (android.view.Gravity)1 KeyEvent (android.view.KeyEvent)1