Search in sources :

Example 6 with ToolbarListener

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

the class IGashtProvinceFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    binding.toolbar.addView(HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLogoShown(true).setLeftIcon(R.string.icon_back).setRightIcons(R.string.icon_time).setListener(new ToolbarListener() {

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

        @Override
        public void onRightIconClickListener(View view) {
            if (getActivity() != null) {
                new HelperFragment(getActivity().getSupportFragmentManager(), new IGashtHistoryPlaceListFragment()).setReplace(false).load(true);
            }
        }
    }).getView());
    binding.provinceSearchText.setOnItemClickListener((parent, view1, position, id) -> viewModel.setSelectedLocation(position));
    viewModel.getGoToShowLocationListPage().observe(getViewLifecycleOwner(), isGo -> {
        ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(view.getWindowToken(), 0);
        if (getActivity() != null && isGo != null) {
            if (isGo) {
                new HelperFragment(getActivity().getSupportFragmentManager(), new IGashtLocationListFragment()).setReplace(false).load(true);
            } else {
                Toast.makeText(getContext(), R.string.select_province, Toast.LENGTH_SHORT).show();
            }
        }
    });
    viewModel.getProvinceListResult().observe(getViewLifecycleOwner(), data -> {
        if (data != null) {
            binding.provinceSearchText.setAdapter(new ProvinceSuggestionListAdapter(getContext(), data));
        }
    });
    viewModel.getClearEditText().observe(getViewLifecycleOwner(), isClear -> {
        if (isClear != null && isClear) {
            binding.provinceSearchText.requestFocus();
            binding.provinceSearchText.setText("");
        }
    });
}
Also used : ProvinceSuggestionListAdapter(net.iGap.adapter.igahst.ProvinceSuggestionListAdapter) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) InputMethodManager(android.view.inputmethod.InputMethodManager) HelperFragment(net.iGap.helper.HelperFragment) View(android.view.View)

Example 7 with ToolbarListener

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

the class ShowBillInquiryFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    binding.toolbar.addView(HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLogoShown(true).setDefaultTitle(getString(getArguments() != null ? getArguments().getInt("titleRes") : R.string.bills_inquiry)).setLeftIcon(R.string.icon_back).setListener(new ToolbarListener() {

        @Override
        public void onLeftIconClickListener(View view) {
            popBackStackFragment();
        }
    }).getView());
    viewModel.getShowErrorMessage().observe(getViewLifecycleOwner(), errorMessageResId -> {
        if (errorMessageResId != null) {
            HelperError.showSnackMessage(getString(errorMessageResId), false);
        }
    });
    viewModel.getGoBack().observe(getViewLifecycleOwner(), isGoBack -> {
        if (isGoBack != null && isGoBack) {
            popBackStackFragment();
        }
    });
}
Also used : ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) View(android.view.View)

Example 8 with ToolbarListener

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

the class StickerSettingFragment method setupViews.

@Override
public void setupViews() {
    RecyclerView recyclerView = rootView.findViewById(R.id.rv_removeSticker);
    LinearLayout linearLayout = rootView.findViewById(R.id.ll_stickerSetting_toolBar);
    HelperToolbar helperToolbar = HelperToolbar.create().setLeftIcon(R.string.icon_back).setLogoShown(true).setDefaultTitle(getResources().getString(R.string.sticker_setting)).setListener(new ToolbarListener() {

        @Override
        public void onLeftIconClickListener(View view) {
            finish();
        }
    }).setContext(getContext());
    linearLayout.addView(helperToolbar.getView());
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    viewModel.getStickersLiveData().observe(getViewLifecycleOwner(), structIGStickerGroups -> adapter.updateAdapter(structIGStickerGroups));
    adapter.setListener(new RemoveStickerAdapter.RemoveStickerDialogListener() {

        @Override
        public void onStickerClick(StructIGStickerGroup stickerGroup) {
            openFragmentAddStickerToFavorite(stickerGroup);
        }

        @Override
        public void onRemoveStickerClick(StructIGStickerGroup stickerGroup, int pos, RemoveStickerAdapter.ProgressStatus progressStatus) {
            if (getContext() != null) {
                new MaterialDialog.Builder(getContext()).title(getResources().getString(R.string.remove_sticker)).content(getResources().getString(R.string.remove_sticker_text)).positiveText(getString(R.string.yes)).negativeText(getString(R.string.no)).onPositive((dialog, which) -> {
                    progressStatus.setVisibility(true);
                    viewModel.removeStickerFromMySticker(stickerGroup, (response, error) -> {
                        if (error == null) {
                            adapter.removeItem(pos);
                        } else {
                            progressStatus.setVisibility(false);
                        }
                    });
                    dialog.dismiss();
                }).show();
            }
        }
    });
    viewModel.getRemoveStickerLiveData().observe(getViewLifecycleOwner(), removedItemPosition -> adapter.removeItem(removedItemPosition));
    TextView removeRecentTv = rootView.findViewById(R.id.tv_stickerSetting_clearRecent);
    removeRecentTv.setOnClickListener(v -> onClearRecentStickerClicked());
    ProgressBar progressBar = rootView.findViewById(R.id.pb_stickerSetting_clearRecent);
    viewModel.getClearRecentStickerLiveData().observe(getViewLifecycleOwner(), progressBar::setVisibility);
    TextView clearInternalStorage = rootView.findViewById(R.id.tv_stickerSetting_clearStorage);
    clearInternalStorage.setOnClickListener(v -> viewModel.clearStickerFromInternalStorage());
    TextView storageSize = rootView.findViewById(R.id.tv_stickerSetting_clearStorageSize);
    viewModel.getStickerFileSizeLiveData().observe(getViewLifecycleOwner(), storageSize::setText);
    TextView clearFavoriteStickerTv = rootView.findViewById(R.id.tv_stickerSetting_clearFavorite);
    clearFavoriteStickerTv.setOnClickListener(v -> onClearFavoriteStickerClicked());
    ProgressBar clearFavoriteStickerPb = rootView.findViewById(R.id.pb_stickerSetting_clearFavorite);
    TextView clearRecentEmojiTv = rootView.findViewById(R.id.tv_stickerSetting_clearEmoji);
    clearRecentEmojiTv.setOnClickListener(v -> onClearRecentEmojiClicked());
    ImageView emptyIv = rootView.findViewById(R.id.iv_stickerSetting_empty);
    TextView emptyTv = rootView.findViewById(R.id.tv_stickerSetting_empty);
    TextView headerTv = rootView.findViewById(R.id.tv_stickerSetting_header);
    viewModel.getEmptyRecentStickerLiveData().observe(getViewLifecycleOwner(), visibility -> {
        emptyIv.setVisibility(visibility);
        emptyTv.setVisibility(visibility);
    });
    viewModel.getRecyclerVisibilityRecentStickerLiveData().observe(getViewLifecycleOwner(), visibility -> {
        recyclerView.setVisibility(visibility);
        headerTv.setVisibility(visibility);
    });
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) StructIGStickerGroup(net.iGap.fragments.emoji.struct.StructIGStickerGroup) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) HelperToolbar(net.iGap.helper.HelperToolbar) ImageView(android.widget.ImageView) ProgressBar(android.widget.ProgressBar) LinearLayout(android.widget.LinearLayout)

Example 9 with ToolbarListener

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

the class ElectricityBillListFrag method onViewCreated.

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

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

        @Override
        public void onRightIconClickListener(View view) {
            List<Integer> items = new ArrayList<>();
            items.add(R.string.elecBill_cell_deleteAccount);
            new TopSheetDialog(getContext()).setListDataWithResourceId(items, -1, position -> {
                if (position == 0) {
                    final MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).title(R.string.elecBill_deleteAccount_title).content(R.string.elecBill_deleteAccount_desc).positiveText(R.string.elecBill_deleteAccount_pos).negativeText(R.string.elecBill_deleteAccount_neg).positiveColor(getContext().getResources().getColor(R.color.red)).widgetColor(new Theme().getAccentColor(getContext())).onPositive((dialog1, which) -> viewModel.deleteAccount()).build();
                    dialog.show();
                }
            }).show();
        }
    }).setLogoShown(true);
    LinearLayout toolbarLayout = binding.Toolbar;
    toolbarLayout.addView(mHelperToolbar.getView());
    binding.billRecycler.setHasFixedSize(true);
    onDataChangedListener();
    viewModel.getBillsList();
}
Also used : TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) NonNull(androidx.annotation.NonNull) ProtoMplGetBillToken(net.iGap.proto.ProtoMplGetBillToken) Theme(net.iGap.module.Theme) ElectricityBillListVM(net.iGap.viewmodel.electricity_bill.ElectricityBillListVM) ArrayList(java.util.ArrayList) MobileDebit(net.iGap.model.bill.MobileDebit) FragmentElecBillListBinding(net.iGap.databinding.FragmentElecBillListBinding) Toast(android.widget.Toast) Map(java.util.Map) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) HelperError(net.iGap.helper.HelperError) HelperFragment(net.iGap.helper.HelperFragment) BillList(net.iGap.model.bill.BillList) DataBindingUtil(androidx.databinding.DataBindingUtil) Debit(net.iGap.model.bill.Debit) LayoutInflater(android.view.LayoutInflater) TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) ViewGroup(android.view.ViewGroup) BaseAPIViewFrag(net.iGap.api.apiService.BaseAPIViewFrag) BillInfo(net.iGap.model.bill.BillInfo) ElectricityBillListAdapter(net.iGap.adapter.electricity_bill.ElectricityBillListAdapter) List(java.util.List) Nullable(androidx.annotation.Nullable) R(net.iGap.R) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Snackbar(com.google.android.material.snackbar.Snackbar) HelperToolbar(net.iGap.helper.HelperToolbar) ServiceDebit(net.iGap.model.bill.ServiceDebit) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) ArrayList(java.util.ArrayList) Theme(net.iGap.module.Theme) HelperToolbar(net.iGap.helper.HelperToolbar) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 10 with ToolbarListener

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

the class ElectricityBillMainFrag method onViewCreated.

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

        @Override
        public void onLeftIconClickListener(View view) {
            popBackStackFragment();
        }
    }).setLogoShown(true);
    LinearLayout toolbarLayout = binding.Toolbar;
    toolbarLayout.addView(mHelperToolbar.getView());
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getContext(), R.array.billsOptions, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    binding.billSpinner.setAdapter(adapter);
    binding.billSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            switch(position) {
                case 0:
                    viewModel.setType(BillInfo.BillType.ELECTRICITY);
                    binding.billIdHolder.setHint(getResources().getString(R.string.elecBill_main_billIDHint));
                    binding.billIdHolder.setCounterMaxLength(13);
                    binding.billQRscan.setEnabled(true);
                    binding.billQRscan.setTextColor(getResources().getColor(R.color.gray));
                    break;
                case 1:
                    viewModel.setType(BillInfo.BillType.GAS);
                    binding.billIdHolder.setHint(getResources().getString(R.string.elecBill_main_billIDHint3));
                    binding.billIdHolder.setCounterMaxLength(12);
                    binding.billQRscan.setEnabled(false);
                    binding.billQRscan.setTextColor(getResources().getColor(R.color.gray_300));
                    break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    binding.modeGroup.setOnCheckedChangeListener((group, checkedId) -> onModeChangeView(checkedId));
    binding.billIdET.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) {
            viewModel.getBillIDErrorEnable().set(false);
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    viewModel.getGoToBillDetailFrag().observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean) {
            viewModel.getProgressVisibility().set(View.GONE);
            new HelperFragment(getFragmentManager(), ElectricityBillPayFrag.newInstance(viewModel.getType(), viewModel.getBillID().get(), null, false)).setReplace(false).load();
        }
    });
}
Also used : View(android.view.View) AdapterView(android.widget.AdapterView) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) AdapterView(android.widget.AdapterView) HelperToolbar(net.iGap.helper.HelperToolbar) HelperFragment(net.iGap.helper.HelperFragment) LinearLayout(android.widget.LinearLayout)

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