Search in sources :

Example 16 with ToolbarListener

use of net.iGap.observers.interfaces.ToolbarListener in project iGap-Android by KianIranian-STDG.

the class FragmentCreateChannel method onViewCreated.

@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    // to disable swipe in channel creation mode
    getSwipeBackLayout().setEnableGesture(false);
    binding.fchLayoutToolbar.addView(HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLogoShown(true).setRightIcons(R.string.icon_sent).setLeftIcon(R.string.icon_back).setDefaultTitle(getString(R.string.new_channel)).setListener(new ToolbarListener() {

        @Override
        public void onLeftIconClickListener(View view) {
            if (getActivity() != null) {
                getActivity().onBackPressed();
            }
        }

        @Override
        public void onRightIconClickListener(View view) {
            viewModel.onClickFinish();
        }
    }).getView());
    viewModel.getRoom.observe(getViewLifecycleOwner(), roomId -> {
        if (getActivity() != null && roomId != null) {
            Fragment fragment = ContactGroupFragment.newInstance();
            Bundle bundle = new Bundle();
            bundle.putLong("RoomId", roomId);
            bundle.putString("TYPE", ProtoGlobal.Room.Type.CHANNEL.toString());
            bundle.putBoolean("NewRoom", true);
            fragment.setArguments(bundle);
            new HelperFragment(getActivity().getSupportFragmentManager(), fragment).setReplace(false).load();
        }
    });
    viewModel.getShowErrorMessage().observe(getViewLifecycleOwner(), errorMessageId -> {
        if (errorMessageId != null) {
            HelperError.showSnackMessage(getString(errorMessageId), false);
        }
    });
    viewModel.getCopyChannelLink().observe(getViewLifecycleOwner(), channelLink -> {
        if (getActivity() != null && channelLink != null) {
            ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("LINK_CHANNEL", channelLink);
            clipboard.setPrimaryClip(clip);
            Toast.makeText(getActivity(), R.string.copy_link_title, Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : ClipboardManager(android.content.ClipboardManager) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) Bundle(android.os.Bundle) HelperFragment(net.iGap.helper.HelperFragment) View(android.view.View) Fragment(androidx.fragment.app.Fragment) HelperFragment(net.iGap.helper.HelperFragment) ClipData(android.content.ClipData)

Example 17 with ToolbarListener

use of net.iGap.observers.interfaces.ToolbarListener in project iGap-Android by KianIranian-STDG.

the class DailNumberFragment method onViewCreated.

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

        @Override
        public void onLeftIconClickListener(View view) {
            if (getActivity() != null) {
                getActivity().onBackPressed();
            }
        }
    });
    binding.toolbar.addView(t.getView());
}
Also used : ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) HelperToolbar(net.iGap.helper.HelperToolbar) View(android.view.View)

Example 18 with ToolbarListener

use of net.iGap.observers.interfaces.ToolbarListener in project iGap-Android by KianIranian-STDG.

the class EditGroupFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    viewModel.onCreateFragment(this);
    HelperToolbar mHelperToolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLogoShown(true).setLeftIcon(R.string.icon_back).setRightIcons(R.string.icon_sent).setDefaultTitle(G.context.getResources().getString(R.string.tab_edit)).setListener(new ToolbarListener() {

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

        @Override
        public void onRightIconClickListener(View view) {
            viewModel.setData(binding.groupNameEditText.getEditableText().toString(), binding.groupDescriptionEditText.getEditableText().toString());
            hideKeyboard();
        }
    });
    binding.toolbar.addView(mHelperToolbar.getView());
    // mHelperToolbar.getTextViewLogo().setText(R.string.tab_edit);
    attachFile = new AttachFile(G.fragmentActivity);
    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.goToPermissionPage.observe(getViewLifecycleOwner(), new Observer<Boolean>() {

        @Override
        public void onChanged(@Nullable Boolean b) {
        }
    });
    viewModel.goBack.observe(getViewLifecycleOwner(), aBoolean -> popBackStackFragment());
    viewModel.showSelectImageDialog.observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean != null && aBoolean) {
            startDialogSelectPicture();
        }
    });
    viewModel.closePageImediatly.observe(getViewLifecycleOwner(), isClose -> {
        if (isClose == null || !isClose)
            return;
        popBackStackFragment();
    });
    viewModel.showDialogChatHistory.observe(getViewLifecycleOwner(), aBoolean -> {
        if (getActivity() != null && aBoolean != null && aBoolean) {
            showDialog();
        }
    });
    viewModel.goToModeratorPage.observe(getViewLifecycleOwner(), aBoolean -> showListForCustomRole(ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.MODERATOR.toString()));
    viewModel.initEmoji.observe(getViewLifecycleOwner(), aBoolean -> {
    // if (aBoolean != null) {
    // emojiPopup.toggle();
    // }
    });
    viewModel.showDialogLeaveGroup.observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean != null && aBoolean) {
            groupLeft();
        }
    });
    viewModel.goToRoomListPage.observe(getViewLifecycleOwner(), go -> {
        if (getActivity() instanceof ActivityMain && go != null && go) {
            ((ActivityMain) getActivity()).removeAllFragmentFromMain();
        }
    });
    viewModel.getOnGroupAvatarUpdated().observe(getViewLifecycleOwner(), roomId -> {
        if (roomId != null && roomId == viewModel.roomId) {
            setAvatar();
        }
    });
    // setUpEmojiPopup();
    setAvatar();
}
Also used : ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) ActivityMain(net.iGap.activities.ActivityMain) AttachFile(net.iGap.module.AttachFile) HelperToolbar(net.iGap.helper.HelperToolbar) View(android.view.View)

Example 19 with ToolbarListener

use of net.iGap.observers.interfaces.ToolbarListener in project iGap-Android by KianIranian-STDG.

the class FragmentFinancialServices method onViewCreated.

@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    HelperToolbar t = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLeftIcon(R.string.icon_back).setRightIcons(R.string.icon_other_vertical_dots).setLogoShown(true).setDefaultTitle(getString(R.string.financial_services)).setListener(new ToolbarListener() {

        @Override
        public void onLeftIconClickListener(View view) {
            if (getActivity() != null) {
                getActivity().onBackPressed();
            }
        }

        @Override
        public void onRightIconClickListener(View view) {
            showMenu();
        }
    });
    binding.walletPriceView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            // Ensure you call it only once
            binding.walletPriceValue.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            ConstraintSet set = new ConstraintSet();
            set.clone(binding.root);
            set.constrainCircle(binding.walletPointer.getId(), binding.walletPriceView.getId(), binding.walletPriceView.getWidth() / 2, 0);
            set.applyTo(binding.root);
        }
    });
    viewModel.walletPointerPosition.observe(this, integer -> {
        if (integer != null) {
            ConstraintSet set = new ConstraintSet();
            set.clone(binding.root);
            set.constrainCircle(binding.walletPointer.getId(), binding.walletPriceView.getId(), binding.walletPriceView.getWidth() / 2, integer);
            set.applyTo(binding.root);
        }
    });
}
Also used : ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) HelperToolbar(net.iGap.helper.HelperToolbar) ConstraintSet(androidx.constraintlayout.widget.ConstraintSet) View(android.view.View) ViewTreeObserver(android.view.ViewTreeObserver)

Example 20 with ToolbarListener

use of net.iGap.observers.interfaces.ToolbarListener in project iGap-Android by KianIranian-STDG.

the class FragmentData method onViewCreated.

@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    binding.fdLayoutToolbar.addView(HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLogoShown(true).setDefaultTitle(getString(R.string.date)).setLeftIcon(R.string.icon_back).setListener(new ToolbarListener() {

        @Override
        public void onLeftIconClickListener(View view) {
            popBackStackFragment();
        }
    }).getView());
    viewModel.getDateChanged().observe(getViewLifecycleOwner(), isChanged -> {
        if (getActivity() instanceof ActivityMain && isChanged != null && isChanged) {
            Fragment fragment = ((ActivityMain) getActivity()).getFragment(FragmentChatSettings.class.getName());
            if (fragment instanceof FragmentChatSettings) {
                ((FragmentChatSettings) fragment).dateIsChanged();
            }
            popBackStackFragment();
        }
    });
}
Also used : ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) ActivityMain(net.iGap.activities.ActivityMain) View(android.view.View) Fragment(androidx.fragment.app.Fragment)

Aggregations

View (android.view.View)35 ToolbarListener (net.iGap.observers.interfaces.ToolbarListener)35 HelperToolbar (net.iGap.helper.HelperToolbar)18 HelperFragment (net.iGap.helper.HelperFragment)13 LinearLayout (android.widget.LinearLayout)9 TextView (android.widget.TextView)9 Bundle (android.os.Bundle)8 ViewGroup (android.view.ViewGroup)8 RecyclerView (androidx.recyclerview.widget.RecyclerView)8 Fragment (androidx.fragment.app.Fragment)5 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)5 LayoutInflater (android.view.LayoutInflater)4 NonNull (androidx.annotation.NonNull)4 Nullable (androidx.annotation.Nullable)4 DataBindingUtil (androidx.databinding.DataBindingUtil)4 ViewModelProviders (androidx.lifecycle.ViewModelProviders)4 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)4 R (net.iGap.R)4 ActivityMain (net.iGap.activities.ActivityMain)4 AdapterView (android.widget.AdapterView)3