Search in sources :

Example 21 with ToolbarListener

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

the class FragmentGallery method initToolbar.

private void initToolbar(View view) {
    ViewGroup lytToolbar = view.findViewById(R.id.toolbar);
    String toolbarTitle = "";
    if (mGalleryMode == GalleryMode.PHOTO) {
        toolbarTitle = getString(R.string.gallery);
    } else if (mGalleryMode == GalleryMode.VIDEO) {
        toolbarTitle = getString(R.string.videos);
    } else {
        toolbarTitle = getString(R.string.audios);
    }
    mHelperToolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLeftIcon(R.string.icon_back).setLogoShown(true).setIGapLogoCheck(false).setDefaultTitle(isSubFolder ? mFolderName : toolbarTitle).setListener(new ToolbarListener() {

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

        @Override
        public void onRightIconClickListener(View view) {
            if (isSubFolder) {
                if (mGalleryMode == GalleryMode.PHOTO) {
                    checkPhotoMultiSelectAndSendToEdit();
                } else {
                    checkVideoMultiSelectAndSendToEdit();
                }
            } else if (mGalleryMode == GalleryMode.MUSIC) {
                if (mGalleryMusicAdapter.getMusicsItem().size() != 0) {
                    showSortDialog();
                } else {
                    if (getContext() != null)
                        Toast.makeText(getContext(), getString(R.string.no_item), Toast.LENGTH_SHORT).show();
                }
            }
        /* else {
                            openAndroidOsGallery();
                        }*/
        }
    });
    if (!isReturnResultDirectly) {
        if (mGalleryMode == GalleryMode.MUSIC) {
            mHelperToolbar.setRightIcons(R.string.icon_other_vertical_dots);
        } else if (isSubFolder) {
            mHelperToolbar.setRightIcons(R.string.icon_new_conversation);
        }
    }
    lytToolbar.addView(mHelperToolbar.getView());
}
Also used : ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) ViewGroup(android.view.ViewGroup) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 22 with ToolbarListener

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

the class FragmentMapUsers method initComponent.

private void initComponent(View view) {
    ((ActivityMain) G.fragmentActivity).setOnBackPressedListener(FragmentMapUsers.this, false);
    HelperToolbar toolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLeftIcon(R.string.icon_back).setLogoShown(true).setDefaultTitle(getString(R.string.igap_nearby)).setListener(new ToolbarListener() {

        @Override
        public void onLeftIconClickListener(View view) {
            if (ActivityMain.onBackPressedListener != null) {
                ActivityMain.onBackPressedListener.doBack();
            }
            popBackStackFragment();
        }
    });
    ViewGroup layoutToolbar = view.findViewById(R.id.fmu_toolbar);
    layoutToolbar.addView(toolbar.getView());
    imvNothingFound = view.findViewById(R.id.sfl_imv_nothing_found);
    txtEmptyListComment = view.findViewById(R.id.sfl_txt_empty_list_comment);
    mRecyclerView = view.findViewById(R.id.rcy_map_user);
    mRecyclerView.setItemAnimator(null);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(G.fragmentActivity));
    DbManager.getInstance().doRealmTransaction(realm -> {
        realm.where(RealmGeoNearbyDistance.class).findAll().deleteAllFromRealm();
    });
    mAdapter = new MapUserAdapter(DbManager.getInstance().doRealmTask(realm -> {
        return realm.where(RealmGeoNearbyDistance.class).findAll();
    }), true);
    // fastAdapter
    // mAdapter = new MapUserAdapterA();
    mRecyclerView.setAdapter(mAdapter);
    if (mAdapter.getItemCount() > 0) {
        imvNothingFound.setVisibility(View.GONE);
        txtEmptyListComment.setVisibility(View.GONE);
    } else {
        imvNothingFound.setVisibility(View.VISIBLE);
        txtEmptyListComment.setVisibility(View.VISIBLE);
    }
    mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {

        @Override
        public void onItemRangeInserted(int positionStart, int itemCount) {
            super.onItemRangeInserted(positionStart, itemCount);
            if (mAdapter.getItemCount() > 0) {
                imvNothingFound.setVisibility(View.GONE);
                txtEmptyListComment.setVisibility(View.GONE);
            } else {
                imvNothingFound.setVisibility(View.VISIBLE);
                txtEmptyListComment.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public void onItemRangeRemoved(int positionStart, int itemCount) {
            super.onItemRangeRemoved(positionStart, itemCount);
            if (mAdapter.getItemCount() > 0) {
                imvNothingFound.setVisibility(View.GONE);
                txtEmptyListComment.setVisibility(View.GONE);
            } else {
                imvNothingFound.setVisibility(View.VISIBLE);
                txtEmptyListComment.setVisibility(View.VISIBLE);
            }
        }
    });
}
Also used : ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) ActivityMain(net.iGap.activities.ActivityMain) ViewGroup(android.view.ViewGroup) RecyclerView(androidx.recyclerview.widget.RecyclerView) HelperToolbar(net.iGap.helper.HelperToolbar) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) RippleView(net.iGap.libs.rippleeffect.RippleView) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) CircleImageView(net.iGap.module.CircleImageView) TextView(android.widget.TextView) RealmGeoNearbyDistance(net.iGap.realm.RealmGeoNearbyDistance)

Example 23 with ToolbarListener

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

the class FragmentSecurityRecovery method onViewCreated.

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

        @Override
        public void onLeftIconClickListener(View view) {
            closeKeyboard(view);
            if (page == Security.SETTING) {
                pageSetting();
            } else {
                pageRegister();
            }
        }

        @Override
        public void onRightIconClickListener(View v) {
            closeKeyboard(v);
            if (rootRecoveryEmail.getVisibility() == View.VISIBLE) {
                if (edtSetRecoveryEmail.length() > 0) {
                    setLoaderState(true);
                    new RequestUserTwoStepVerificationRecoverPasswordByToken().recoveryPasswordByToken(edtSetRecoveryEmail.getText().toString(), new TwoStepVerificationRecoverPasswordByToken() {

                        @Override
                        public void recoveryByEmail(String tokenR) {
                            setLoaderState(false);
                            if (getActivity() instanceof ActivityRegistration) {
                                openMainActivity(tokenR);
                            } else if (getActivity() instanceof ActivityMain) {
                                backToSettings();
                            }
                        }

                        @Override
                        public void errorRecoveryByEmail(int major, int minor) {
                            setLoaderState(false);
                        }
                    });
                } else {
                    error(G.fragmentActivity.getResources().getString(R.string.please_enter_code));
                }
            } else {
                if (edtSetRecoveryAnswerPassOne.length() > 0 && edtSetRecoveryAnswerPassTwo.length() > 0) {
                    setLoaderState(true);
                    new RequestUserTwoStepVerificationRecoverPasswordByAnswers().RecoveryPasswordByAnswer(edtSetRecoveryAnswerPassOne.getText().toString(), edtSetRecoveryAnswerPassTwo.getText().toString(), new TwoStepVerificationRecoverPasswordByAnswersCallback() {

                        @Override
                        public void recoveryByQuestion(String tokenR) {
                            setLoaderState(false);
                            // Todo:fixed it and move to repository
                            if (getActivity() instanceof ActivityRegistration) {
                                openMainActivity(tokenR);
                            } else if (getActivity() instanceof ActivityMain) {
                                backToSettings();
                            }
                        }

                        @Override
                        public void errorRecoveryByQuestion(int major, int minor) {
                            setLoaderState(false);
                        }
                    });
                } else {
                    error(G.fragmentActivity.getResources().getString(R.string.please_complete_all_item));
                }
            }
        }
    });
    ViewGroup toolbarLayout = view.findViewById(R.id.fsr_layout_toolbar);
    toolbarLayout.addView(mHelperToolbar.getView());
    new RequestUserTwoStepVerificationRequestRecoveryToken().requestRecoveryToken();
    Bundle bundle = this.getArguments();
    if (bundle != null) {
        page = (Security) bundle.get("PAGE");
        questionOne = bundle.getString("QUESTION_ONE");
        questionTwo = bundle.getString("QUESTION_TWO");
        txtPaternEmail = bundle.getString("PATERN_EMAIL");
        isRecoveryByEmail = bundle.getBoolean("IS_EMAIL");
        isConfirmedRecoveryEmail = bundle.getBoolean("IS_CONFIRM_EMAIL");
    }
    view.findViewById(R.id.rootRecoveryPassword).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
        }
    });
    pbLoading = view.findViewById(R.id.pbLoading);
    rootRecoveryEmail = view.findViewById(R.id.rootRecoveryEmailPassword);
    rootRecoveryQuestionPassword = view.findViewById(R.id.rootRecoveryQuestionPassword);
    txtSetRecoveryByQuestion = view.findViewById(R.id.txtSetRecoveryByQuestion);
    txtSetRecoveryByEmail = view.findViewById(R.id.txtSetRecoveryByEmail);
    if (!isConfirmedRecoveryEmail) {
        txtSetRecoveryByEmail.setVisibility(View.GONE);
    }
    txtSetRecoveryQuestionPassOne = view.findViewById(R.id.txtSetRecoveryQuestionPassOne);
    txtSetRecoveryQuestionPassTwo = view.findViewById(R.id.txtSetRecoveryQuestionPassTwo);
    txtSetRecoveryQuestionPassOne.setText(questionOne);
    txtSetRecoveryQuestionPassTwo.setText(questionTwo);
    TextView txtResendConfirmEmail = view.findViewById(R.id.txtResendConfirmEmail);
    txtResendConfirmEmail.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new RequestUserTwoStepVerificationRequestRecoveryToken().requestRecoveryToken();
            closeKeyboard(v);
            HelperError.showSnackMessage(G.fragmentActivity.getResources().getString(R.string.resend_verify_email_code), false);
        }
    });
    edtSetRecoveryAnswerPassOne = view.findViewById(R.id.edtSetRecoveryAnswerPassOne);
    edtSetRecoveryAnswerPassTwo = view.findViewById(R.id.edtSetRecoveryAnswerPassTwo);
    edtSetRecoveryEmail = view.findViewById(R.id.edtSetRecoveryEmail);
    edtSetRecoveryEmail.setHint("");
    if (page == Security.REGISTER) {
        G.onRecoveryEmailToken = new OnRecoveryEmailToken() {

            @Override
            public void getEmailPatern(final String patern) {
                G.handler.post(new Runnable() {

                    @Override
                    public void run() {
                        edtSetRecoveryEmail.setHint(patern);
                    }
                });
            }
        };
    }
    if (isRecoveryByEmail) {
        rootRecoveryEmail.setVisibility(View.VISIBLE);
        rootRecoveryQuestionPassword.setVisibility(View.GONE);
    } else {
        rootRecoveryQuestionPassword.setVisibility(View.VISIBLE);
        rootRecoveryEmail.setVisibility(View.GONE);
    }
    txtSetRecoveryByEmail.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            rootRecoveryQuestionPassword.setVisibility(View.GONE);
            rootRecoveryEmail.setVisibility(View.VISIBLE);
        }
    });
    txtSetRecoveryByQuestion.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            rootRecoveryEmail.setVisibility(View.GONE);
            rootRecoveryQuestionPassword.setVisibility(View.VISIBLE);
        }
    });
    if (page == Security.SETTING) {
        G.onRecoverySecurityPassword = new OnRecoverySecurityPassword() {

            @Override
            public void getEmailPatern(final String patern) {
                G.handler.post(new Runnable() {

                    @Override
                    public void run() {
                        edtSetRecoveryEmail.setHint(patern);
                    }
                });
            }
        };
    }
}
Also used : OnRecoverySecurityPassword(net.iGap.observers.interfaces.OnRecoverySecurityPassword) RequestUserTwoStepVerificationRecoverPasswordByToken(net.iGap.request.RequestUserTwoStepVerificationRecoverPasswordByToken) ViewGroup(android.view.ViewGroup) Bundle(android.os.Bundle) RequestUserTwoStepVerificationRecoverPasswordByAnswers(net.iGap.request.RequestUserTwoStepVerificationRecoverPasswordByAnswers) View(android.view.View) TextView(android.widget.TextView) ActivityRegistration(net.iGap.activities.ActivityRegistration) OnRecoveryEmailToken(net.iGap.observers.interfaces.OnRecoveryEmailToken) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) ActivityMain(net.iGap.activities.ActivityMain) RequestUserTwoStepVerificationRecoverPasswordByToken(net.iGap.request.RequestUserTwoStepVerificationRecoverPasswordByToken) TwoStepVerificationRecoverPasswordByToken(net.iGap.observers.interfaces.TwoStepVerificationRecoverPasswordByToken) RequestUserTwoStepVerificationRequestRecoveryToken(net.iGap.request.RequestUserTwoStepVerificationRequestRecoveryToken) TextView(android.widget.TextView) TwoStepVerificationRecoverPasswordByAnswersCallback(net.iGap.observers.interfaces.TwoStepVerificationRecoverPasswordByAnswersCallback)

Example 24 with ToolbarListener

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

the class FragmentNotification method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    roomId = getArguments().getLong("ID");
    initDataBinding();
    HelperToolbar toolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLeftIcon(R.string.icon_back).setLogoShown(true).setDefaultTitle(getString(R.string.ntg_title_toolbar)).setListener(new ToolbarListener() {

        @Override
        public void onLeftIconClickListener(View view) {
            try {
                popBackStackFragment();
            } catch (IllegalStateException e) {
                e.printStackTrace();
            }
        }
    });
    fragmentNotificationBinding.ntgLayoutToolbar.addView(toolbar.getView());
}
Also used : ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) HelperToolbar(net.iGap.helper.HelperToolbar) View(android.view.View)

Example 25 with ToolbarListener

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

the class FragmentPaymentBill method onViewCreated.

@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    if (isPolice) {
        HelperTracker.sendTracker(HelperTracker.TRACKER_FINE_BILL_PAGE);
    } else {
        HelperTracker.sendTracker(HelperTracker.TRACKER_SERVICE_BILL_PAGE);
    }
    billBinding.fpbLayoutToolbar.addView(HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLogoShown(true).setDefaultTitle(getString(getArguments() != null ? getArguments().getInt("title") : R.string.pay_bills_crime)).setLeftIcon(R.string.icon_back).setListener(new ToolbarListener() {

        @Override
        public void onLeftIconClickListener(View view) {
            popBackStackFragment();
        }
    }).getView());
    viewModel.getShowErrorMessage().observe(getViewLifecycleOwner(), errorMessageId -> {
        if (errorMessageId != null) {
            HelperError.showSnackMessage(getString(errorMessageId), false);
        }
    });
    viewModel.getGoToScannerPage().observe(getViewLifecycleOwner(), isGo -> {
        if (getActivity() != null && isGo != null && isGo) {
            PermissionHelper permissionHelper = new PermissionHelper(getActivity());
            if (permissionHelper.grantCameraPermission()) {
                goToScannerActivity();
            }
        }
    });
    viewModel.getGoBack().observe(getViewLifecycleOwner(), isGoBack -> {
        if (isGoBack != null && isGoBack) {
            popBackStackFragment();
        }
    });
    viewModel.getHideKeyword().observe(getViewLifecycleOwner(), isHide -> {
        if (isHide != null && isHide) {
            hideKeyboard();
        }
    });
    viewModel.getBillTypeImage().observe(getViewLifecycleOwner(), integer -> billBinding.billTypeImage.setImageResource(integer));
}
Also used : ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) PermissionHelper(net.iGap.helper.PermissionHelper) View(android.view.View)

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