Search in sources :

Example 26 with HelperToolbar

use of net.iGap.helper.HelperToolbar in project iGap-Android by KianIranian-STDG.

the class NewsGroupListFrag method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    HelperToolbar mHelperToolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLeftIcon(R.string.icon_back).setListener(new ToolbarListener() {

        @Override
        public void onLeftIconClickListener(View view) {
            popBackStackFragment();
        }
    }).setDefaultTitle(getResources().getString(R.string.news_groupTitle)).setLogoShown(true);
    LinearLayout toolbarLayout = binding.toolbar;
    toolbarLayout.addView(mHelperToolbar.getView());
    binding.rcGroup.setHasFixedSize(true);
    GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 3);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    binding.rcGroup.setLayoutManager(layoutManager);
    binding.pullToRefresh.setOnRefreshListener(() -> {
        viewModel.getData();
        binding.noItemInListError.setVisibility(View.GONE);
    });
    viewModel.getData();
    onErrorObserver();
    onDataChanged();
    onProgress();
}
Also used : ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) HelperToolbar(net.iGap.helper.HelperToolbar) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 27 with HelperToolbar

use of net.iGap.helper.HelperToolbar in project iGap-Android by KianIranian-STDG.

the class ContactGroupFragment method onViewCreated.

@Override
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    progressDialog = new ProgressDialog(getContext());
    // to disable swipe in channel creation mode
    if (typeCreate != null) {
        if (typeCreate.equals("CHANNEL"))
            getSwipeBackLayout().setEnableGesture(false);
    }
    selectedContacts.clear();
    G.onContactsGetList = this;
    // some times touch screen remind lock so this method do unlock
    hideProgressBar();
    Bundle bundle = this.getArguments();
    if (bundle != null) {
        roomId = bundle.getLong("RoomId");
        typeCreate = bundle.getString("TYPE");
    }
    HelperToolbar mHelperToolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLeftIcon(R.string.icon_back).setRightIcons(R.string.icon_sent).setDefaultTitle(G.context.getResources().getString(R.string.new_group)).setListener(this).setLogoShown(true);
    LinearLayout toolbarLayout = view.findViewById(R.id.fcg_layout_toolbar);
    toolbarLayout.addView(mHelperToolbar.getView());
    /**
     * for some problem in theme we created 2 layout and check theme then add at run time
     * library does not support change text color or background color at run time until 1.0.8
     */
    ViewGroup layoutChips = view.findViewById(R.id.fcg_layout_search);
    // todo:// use material chips
    if (G.themeColor == Theme.DARK) {
        layoutChips.addView(getLayoutInflater().inflate(R.layout.item_chips_layout_dark, null));
    } else {
        layoutChips.addView(getLayoutInflater().inflate(R.layout.item_chips_layout, null));
    }
    if (typeCreate.equals("CHANNEL")) {
        mHelperToolbar.setDefaultTitle(G.context.getResources().getString(R.string.new_channel));
    }
    chipsInput = view.findViewById(R.id.chips_input);
    // get our recyclerView and do basic setup
    RecyclerView rv = view.findViewById(R.id.fcg_recycler_view_add_item_to_group);
    rv.setLayoutManager(new ScrollingLinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false, 1000));
    rv.setItemAnimator(new DefaultItemAnimator());
    itemAdapter = new ItemAdapter();
    fastAdapter = FastAdapter.with(itemAdapter);
    fastAdapter.withSelectable(true);
    fastAdapter.setHasStableIds(true);
    rv.setAdapter(fastAdapter);
    addItems();
    FastScroller fastScroller = view.findViewById(R.id.fast_scroller);
    fastScroller.setRecyclerView(rv);
    itemAdapter.getItemFilter().withFilterPredicate(new IItemAdapter.Predicate<ContactItemGroup>() {

        @Override
        public boolean filter(ContactItemGroup item, CharSequence constraint) {
            return !item.mContact.displayName.toLowerCase().startsWith(String.valueOf(constraint).toLowerCase());
        }
    });
    fastAdapter.withOnClickListener(new OnClickListener<ContactItemGroup>() {

        @Override
        public boolean onClick(View v, IAdapter adapter, ContactItemGroup item, int position) {
            if (item.mContact.isSelected) {
                chipsInput.removeChipByLabel(item.mContact.displayName);
                selectedContacts.remove(item.mContact);
            } else {
                Uri uri = null;
                if (item.mContact.avatar != null && item.mContact.avatar.getFile() != null && item.mContact.avatar.getFile().getLocalThumbnailPath() != null) {
                    uri = Uri.fromFile(new File(item.mContact.avatar.getFile().getLocalThumbnailPath()));
                }
                if (uri == null) {
                    Drawable d = new BitmapDrawable(getResources(), net.iGap.helper.HelperImageBackColor.drawAlphabetOnPicture((int) G.context.getResources().getDimension(R.dimen.dp60), item.mContact.initials, item.mContact.color));
                    chipsInput.addChip(item.mContact.peerId, d, item.mContact.displayName, "");
                } else {
                    chipsInput.addChip(item.mContact.peerId, uri, item.mContact.displayName, "");
                }
            }
            if (isRemove) {
                notifyAdapter(item, position);
            }
            return false;
        }
    });
    chipsInput.addChipsListener(new ChipsInput.ChipsListener() {

        @Override
        public void onChipAdded(ChipInterface chip, int newSize) {
            try {
                if (chip != null) {
                    ContactItemGroup contactInfo = ((ContactItemGroup) fastAdapter.getItem(fastAdapter.getPosition((Long) chip.getId())));
                    selectedContacts.add(contactInfo.mContact);
                    notifyAdapter(contactInfo, fastAdapter.getPosition((Long) chip.getId()));
                    isRemove = false;
                }
            } catch (Exception e) {
            }
        }

        @Override
        public void onChipRemoved(ChipInterface chip, int newSize) {
            if (chip.getId() != null) {
                ContactItemGroup contactInfo = ((ContactItemGroup) fastAdapter.getItem(fastAdapter.getPosition((Long) chip.getId())));
                notifyAdapter(contactInfo, fastAdapter.getPosition((Long) chip.getId()));
                isRemove = false;
                selectedContacts.remove(contactInfo.mContact);
            }
        }

        @Override
        public void onTextChanged(CharSequence text) {
        // text changed
        }
    });
    initContactRemoveListener();
    // restore selections (this has to be done after the items were added
    fastAdapter.withSavedInstanceState(savedInstanceState);
}
Also used : ScrollingLinearLayoutManager(net.iGap.module.ScrollingLinearLayoutManager) FastScroller(net.iGap.module.scrollbar.FastScroller) ProgressDialog(net.iGap.messenger.ui.components.ProgressDialog) Uri(android.net.Uri) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) ContactItemGroup(net.iGap.adapter.items.ContactItemGroup) ChipsInput(com.pchmn.materialchips.ChipsInput) IItemAdapter(com.mikepenz.fastadapter.IItemAdapter) HelperToolbar(net.iGap.helper.HelperToolbar) IAdapter(com.mikepenz.fastadapter.IAdapter) ItemAdapter(com.mikepenz.fastadapter.adapters.ItemAdapter) IItemAdapter(com.mikepenz.fastadapter.IItemAdapter) ChipInterface(com.pchmn.materialchips.model.ChipInterface) Bundle(android.os.Bundle) ViewGroup(android.view.ViewGroup) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RecyclerView(androidx.recyclerview.widget.RecyclerView) File(java.io.File) LinearLayout(android.widget.LinearLayout)

Example 28 with HelperToolbar

use of net.iGap.helper.HelperToolbar in project iGap-Android by KianIranian-STDG.

the class EditChannelFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    avatarHandler.getAvatar(new ParamWithAvatarType(binding.channelAvatar, viewModel.roomId).avatarType(AvatarHandler.AvatarType.ROOM).showMain());
    viewModel.onCreateFragment(this);
    HelperToolbar mHelperToolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLogoShown(true).setDefaultTitle(getContext().getResources().getString(R.string.tab_edit)).setLeftIcon(R.string.icon_back).setRightIcons(R.string.icon_sent).setListener(new ToolbarListener() {

        @Override
        public void onLeftIconClickListener(View view) {
            popBackStackFragment();
        }

        @Override
        public void onRightIconClickListener(View view) {
            viewModel.setData(binding.channelNameEditText.getEditableText().toString(), binding.groupDescriptionEditText.getEditableText().toString());
            hideKeyboard();
        }
    });
    binding.toolbar.addView(mHelperToolbar.getView());
    viewModel.goToMembersPage.observe(getViewLifecycleOwner(), b -> {
        if (b != null && b) {
            showListForCustomRole(ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.ALL.toString());
        }
    });
    viewModel.goToAdministratorPage.observe(getViewLifecycleOwner(), b -> {
        if (b != null && b) {
            showListForCustomRole(ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.ADMIN.toString());
        }
    });
    viewModel.goToModeratorPage.observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean != null && aBoolean) {
            showListForCustomRole(ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.MODERATOR.toString());
        }
    });
    viewModel.closePageImediatly.observe(getViewLifecycleOwner(), isClose -> {
        if (isClose == null || !isClose)
            return;
        popBackStackFragment();
    });
    viewModel.initEmoji.observe(getViewLifecycleOwner(), aBoolean -> {
    // if (aBoolean != null) {
    // emojiPopup.toggle();
    // }
    });
    viewModel.showDialogLeaveGroup.observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean != null && aBoolean) {
        /*groupLeft();*/
        }
    });
    viewModel.showSelectImageDialog.observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean != null && aBoolean) {
            startDialogSelectPicture();
        }
    });
    viewModel.showConvertChannelDialog.observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean != null) {
            showPopUp(aBoolean);
        }
    });
    viewModel.showDeleteChannelDialog.observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean != null) {
            deleteChannel(aBoolean);
        }
    });
    viewModel.goBack.observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean != null && aBoolean) {
            popBackStackFragment();
        }
    });
    viewModel.goToChatRoom.observe(getViewLifecycleOwner(), go -> {
        if (getActivity() instanceof ActivityMain && go != null && go) {
            ((ActivityMain) getActivity()).removeAllFragmentFromMain();
        /*new HelperFragment(getActivity().getSupportFragmentManager()).popBackStack(3);*/
        }
    });
    viewModel.onSignClickListener.observe(getViewLifecycleOwner(), isClicked -> {
        binding.signedMessage.setChecked(!binding.signedMessage.isChecked());
    });
    viewModel.onReactionMessageClickListener.observe(getViewLifecycleOwner(), isClicked -> {
        binding.rateMessage.setChecked(!binding.rateMessage.isChecked());
    });
    viewModel.getChannelAvatarUpdatedLiveData().observe(getViewLifecycleOwner(), roomId -> {
        if (roomId != null && roomId == viewModel.roomId)
            avatarHandler.getAvatar(new ParamWithAvatarType(binding.channelAvatar, viewModel.roomId).avatarType(AvatarHandler.AvatarType.ROOM).showMain());
    });
    viewModel.showChangeUsername.observe(getViewLifecycleOwner(), username -> {
        if (username != null) {
            setUsername(username);
        }
    });
// setEmojiColor();
}
Also used : ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) ActivityMain(net.iGap.activities.ActivityMain) HelperToolbar(net.iGap.helper.HelperToolbar) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) View(android.view.View) TextView(android.widget.TextView)

Example 29 with HelperToolbar

use of net.iGap.helper.HelperToolbar in project iGap-Android by KianIranian-STDG.

the class PurchaseFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    HelperToolbar toolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLeftIcon(R.string.icon_back).setListener(this).setDefaultTitle("لیست دانلود ها");
    LinearLayout toolBarContainer = rootView.findViewById(R.id.ll_purchase_tollBar);
    toolBarContainer.addView(toolbar.getView());
}
Also used : HelperToolbar(net.iGap.helper.HelperToolbar) LinearLayout(android.widget.LinearLayout)

Example 30 with HelperToolbar

use of net.iGap.helper.HelperToolbar in project iGap-Android by KianIranian-STDG.

the class FragmentCPayHistory method initToolbar.

private void initToolbar() {
    HelperToolbar toolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLogoShown(true).setDefaultTitle(getString(R.string.c_pay_title)).setLeftIcon(R.string.icon_back).setListener(this);
    binding.fchToolbar.addView(toolbar.getView());
}
Also used : HelperToolbar(net.iGap.helper.HelperToolbar)

Aggregations

HelperToolbar (net.iGap.helper.HelperToolbar)32 View (android.view.View)21 ToolbarListener (net.iGap.observers.interfaces.ToolbarListener)17 LinearLayout (android.widget.LinearLayout)14 RecyclerView (androidx.recyclerview.widget.RecyclerView)9 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)8 TextView (android.widget.TextView)7 Bundle (android.os.Bundle)6 ViewGroup (android.view.ViewGroup)6 Nullable (androidx.annotation.Nullable)6 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)4 HelperFragment (net.iGap.helper.HelperFragment)4 LayoutInflater (android.view.LayoutInflater)3 FrameLayout (android.widget.FrameLayout)3 ProgressBar (android.widget.ProgressBar)3 NonNull (androidx.annotation.NonNull)3 DataBindingUtil (androidx.databinding.DataBindingUtil)3 ViewModelProviders (androidx.lifecycle.ViewModelProviders)3 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)3 R (net.iGap.R)3