Search in sources :

Example 6 with HelperFragment

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

the class IGashtLocationListFragment 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()).setLeftIcon(R.string.icon_back).setRightIcons(R.string.icon_time).setLogoShown(true).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.locationListView.addItemDecoration(new DividerItemDecoration(binding.locationListView.getContext(), DividerItemDecoration.VERTICAL));
    binding.locationListView.setAdapter(new IGashtLocationListAdapter(viewModel.getSelectedProvinceName(), new IGashtLocationListAdapter.onLocationItemClickListener() {

        @Override
        public void buyTicket(int position) {
            viewModel.buyTicket(position);
        }

        @Override
        public void onItem(int position) {
            viewModel.buyTicket(position);
        }
    }));
    viewModel.getLocationList().observe(getViewLifecycleOwner(), data -> {
        if (binding.locationListView.getAdapter() instanceof IGashtLocationListAdapter && data != null) {
            ((IGashtLocationListAdapter) binding.locationListView.getAdapter()).setItems(data);
        }
    });
    viewModel.getGoToLocationDetail().observe(getViewLifecycleOwner(), isGo -> {
        if (getActivity() != null && isGo != null) {
            if (isGo) {
                new HelperFragment(getActivity().getSupportFragmentManager()).setFragment(new IGashtLocationDetailFragment()).setReplace(false).load(true);
            } else {
                Toast.makeText(getActivity(), R.string.error, Toast.LENGTH_SHORT).show();
            }
        }
    });
}
Also used : ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) HelperFragment(net.iGap.helper.HelperFragment) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) View(android.view.View) IGashtLocationListAdapter(net.iGap.adapter.igahst.IGashtLocationListAdapter)

Example 7 with HelperFragment

use of net.iGap.helper.HelperFragment 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 8 with HelperFragment

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

the class InternetFragment method initForm.

private void initForm() {
    DbManager.getInstance().doRealmTask(realm -> {
        RealmRegisteredInfo userInfo = realm.where(RealmRegisteredInfo.class).findFirst();
        if (userInfo != null) {
            userNumber = userInfo.getPhoneNumber();
            if (phoneNumber != null && !phoneNumber.isEmpty() && !phoneNumber.equals("0")) {
                setPhoneNumberEditText(phoneNumber);
                if (peerId != 0) {
                    avatarHandler.getAvatar(new ParamWithAvatarType(avatar, peerId).avatarType(AvatarHandler.AvatarType.ROOM).showMain());
                }
            }
            if (phoneNumber != null && phoneNumber.equals("0")) {
                avatar.setVisibility(View.GONE);
                editTextNumber.setHint(getActivity().getString(R.string.please_enter_phone_number));
                removeButton.setText(R.string.icon_edit);
            } else {
                avatar.setVisibility(View.GONE);
                setPhoneNumberEditText(userNumber);
            }
            if (editTextNumber.getText() != null && editTextNumber.getText().length() == 11) {
                hideKeyboard();
            }
            editTextNumber.setSelection(editTextNumber.getText() == null ? 0 : editTextNumber.getText().length());
        }
    });
    operatorAdapter = new OperatorAdapter(getContext(), operators, operatorName -> {
        if (currentConfigData != null) {
            changeOperator(currentConfigData.getOperator());
        } else {
            operatorAdapter.setCheckedRadioButton(null);
            HelperError.showSnackMessage(getActivity().getString(R.string.please_enter_phone_number), false);
        }
    });
    lstOperator.setAdapter(operatorAdapter);
    detectOperatorByNumber(editTextNumber.getText().toString());
    chargeApi = new RetrofitFactory().getChargeRetrofit();
    editTextNumber.addTextChangedListener(editTextNumberWatcher());
    removeButton.setOnClickListener(removeNumberClicked());
    frameContact.setOnClickListener(v -> onContactNumberButtonClick());
    frameHistory.setOnClickListener(v -> onHistoryNumberButtonClick());
    radioGroup.setOnCheckedChangeListener((group, checkedId) -> InternetFragment.this.changeSimType());
    goNextButton.setOnClickListener(v -> {
        RadioButton radioButton = radioGroup.findViewById(radioGroup.getCheckedRadioButtonId());
        if (radioButton != null) {
            if (currentSimType == null) {
                showError(getActivity().getString(R.string.invalid_sim_type));
                return;
            }
            if (editTextNumber.getText() == null) {
                editTextNumber.setError(getString(R.string.phone_number_is_not_valid));
                return;
            }
            String rechargeableNumber = editTextNumber.getText().toString().trim();
            if (!isNumeric(rechargeableNumber) || rechargeableNumber.length() < 11) {
                editTextNumber.setError(getString(R.string.phone_number_is_not_valid));
                return;
            }
            if (!isNumberFromIran(rechargeableNumber)) {
                editTextNumber.setError(getString(R.string.phone_number_is_not_valid));
                return;
            }
            int packageType = historyNumber != null ? Integer.parseInt(historyNumber.getPackageType()) : -1;
            new HelperFragment(getActivity().getSupportFragmentManager(), PaymentInternetFragment.newInstance(userNumber, rechargeableNumber, currentOperator.getKey(), currentSimType, packageType)).setAnimated(false).setReplace(false).load();
        } else {
            showError(getActivity().getString(R.string.sim_type_not_choosed));
        }
    });
    progressBar.setVisibility(View.GONE);
    scrollView.setVisibility(View.VISIBLE);
}
Also used : Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) HandShakeCallback(net.iGap.observers.interfaces.HandShakeCallback) FrameLayout(android.widget.FrameLayout) RadioButton(android.widget.RadioButton) FavoriteNumber(net.iGap.model.paymentPackage.FavoriteNumber) ConfigData(net.iGap.model.paymentPackage.ConfigData) Theme(net.iGap.module.Theme) G(net.iGap.G) HelperPermission(net.iGap.helper.HelperPermission) HelperPermission.showDeniedPermissionMessage(net.iGap.helper.HelperPermission.showDeniedPermissionMessage) View(android.view.View) ChargeContactNumberAdapter(net.iGap.adapter.payment.ChargeContactNumberAdapter) HelperError(net.iGap.helper.HelperError) RecyclerView(androidx.recyclerview.widget.RecyclerView) HelperFragment(net.iGap.helper.HelperFragment) OperatorAdapter(net.iGap.adapter.OperatorAdapter) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) HelperString.isNumeric(net.iGap.helper.HelperString.isNumeric) AppCompatEditText(androidx.appcompat.widget.AppCompatEditText) BaseFragment(net.iGap.fragments.BaseFragment) ViewGroup(android.view.ViewGroup) PaymentRepository(net.iGap.repository.PaymentRepository) List(java.util.List) Nullable(androidx.annotation.Nullable) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) InternetHistoryPackageAdapter(net.iGap.adapter.payment.InternetHistoryPackageAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) PackageChargeType(net.iGap.model.paymentPackage.PackageChargeType) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) NotNull(org.jetbrains.annotations.NotNull) Call(retrofit2.Call) TextWatcher(android.text.TextWatcher) AndroidUtils(net.iGap.module.AndroidUtils) ResourcesCompat(androidx.core.content.res.ResourcesCompat) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) Response(retrofit2.Response) RadioGroup(android.widget.RadioGroup) Editable(android.text.Editable) ArrayList(java.util.ArrayList) MaterialButton(com.google.android.material.button.MaterialButton) LayoutCreator(net.iGap.helper.LayoutCreator) TokenContainer(net.iGap.api.apiService.TokenContainer) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar) Config(net.iGap.model.paymentPackage.Config) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) ContactNumber(net.iGap.adapter.payment.ContactNumber) LayoutInflater(android.view.LayoutInflater) Operator(net.iGap.model.paymentPackage.Operator) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) IOException(java.io.IOException) CircleImageView(net.iGap.module.CircleImageView) PhoneContactProvider(net.iGap.controllers.PhoneContactProvider) Gravity(android.view.Gravity) GetFavoriteNumber(net.iGap.model.paymentPackage.GetFavoriteNumber) ChargeApi(net.iGap.api.ChargeApi) RetrofitFactory(net.iGap.api.apiService.RetrofitFactory) Callback(retrofit2.Callback) ScrollView(android.widget.ScrollView) R(net.iGap.R) DbManager(net.iGap.module.accountManager.DbManager) EditText(android.widget.EditText) OperatorAdapter(net.iGap.adapter.OperatorAdapter) RetrofitFactory(net.iGap.api.apiService.RetrofitFactory) RadioButton(android.widget.RadioButton) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) HelperFragment(net.iGap.helper.HelperFragment) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo)

Example 9 with HelperFragment

use of net.iGap.helper.HelperFragment 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 10 with HelperFragment

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

the class BaseViewHolder method actionPage.

private static void actionPage(String value, FragmentActivity activity, boolean haveNext) {
    try {
        // this is because in some times not set correct value in server when change or add new item
        DiscoveryFragment discoveryFragment = DiscoveryFragment.newInstance(Integer.valueOf(value));
        discoveryFragment.setNeedToCrawl(haveNext);
        new HelperFragment(activity.getSupportFragmentManager(), discoveryFragment).setReplace(false).load(false);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : HelperFragment(net.iGap.helper.HelperFragment) JSONException(org.json.JSONException) IOException(java.io.IOException) DiscoveryFragment(net.iGap.fragments.discovery.DiscoveryFragment)

Aggregations

HelperFragment (net.iGap.helper.HelperFragment)93 Bundle (android.os.Bundle)32 View (android.view.View)31 Fragment (androidx.fragment.app.Fragment)25 IOException (java.io.IOException)18 ArrayList (java.util.ArrayList)15 RecyclerView (androidx.recyclerview.widget.RecyclerView)14 ToolbarListener (net.iGap.observers.interfaces.ToolbarListener)14 ViewGroup (android.view.ViewGroup)13 NonNull (androidx.annotation.NonNull)13 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)13 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)13 Theme (net.iGap.module.Theme)13 R (net.iGap.R)12 OnGetPermission (net.iGap.observers.interfaces.OnGetPermission)12 LayoutInflater (android.view.LayoutInflater)11 TextView (android.widget.TextView)11 Nullable (androidx.annotation.Nullable)11 HelperString (net.iGap.helper.HelperString)10 BackDrawable (net.iGap.messenger.ui.toolBar.BackDrawable)10