Search in sources :

Example 6 with Theme

use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.

the class ViewUserDialogFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    isInShowViewUser = true;
    if (tfMain == null)
        tfMain = ResourcesCompat.getFont(getContext(), R.font.main_font);
    rootView = new FrameLayout(getContext());
    dataRootView = new LinearLayout(getContext());
    dataRootView.setOrientation(LinearLayout.VERTICAL);
    rootView.addView(dataRootView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT, Gravity.CENTER));
    if (G.themeColor == Theme.DARK) {
        rootView.setBackgroundColor(new Theme().getPrimaryDarkColor(getContext()));
    } else {
        rootView.setBackgroundColor(Theme.getInstance().getDividerColor(getContext()));
    }
    HelperToolbar helperToolbar = HelperToolbar.create();
    View toolBar = helperToolbar.setContext(getContext()).setLogoShown(true).setListener(this).setDefaultTitle(G.selectedLanguage.equals("fa") ? getString(R.string.story_viewed_by) + " " + HelperCalander.convertToUnicodeFarsiNumber(String.valueOf(count)) + " " + getString(R.string.story_person) : getString(R.string.story_viewed_by) + " " + count).getView();
    dataRootView.addView(toolBar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER | Gravity.TOP, 0, 0, 0, 0));
    recyclerView = new RecyclerView(getContext());
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    dataRootView.addView(recyclerView, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, 0, 1F, Gravity.CENTER));
    progressBar = new ProgressBar(getContext());
    progressBar.setVisibility(View.GONE);
    rootView.addView(progressBar, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER | Gravity.BOTTOM));
    listAdapter = new ListAdapter();
    listAdapter.setContext(getContext());
    return rootView;
}
Also used : FrameLayout(android.widget.FrameLayout) Theme(net.iGap.module.Theme) RecyclerView(androidx.recyclerview.widget.RecyclerView) HelperToolbar(net.iGap.helper.HelperToolbar) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) ImageLoadingView(net.iGap.story.liststories.ImageLoadingView) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) RecyclerListView(net.iGap.module.customView.RecyclerListView) ProgressBar(android.widget.ProgressBar) LinearLayout(android.widget.LinearLayout) Nullable(androidx.annotation.Nullable)

Example 7 with Theme

use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.

the class MainFragment method isUpdateAvailable.

@Override
public void isUpdateAvailable() {
    try {
        if (getActivity() != null && !getActivity().isFinishing()) {
            getActivity().runOnUiThread(() -> {
                if (getActivity().hasWindowFocus()) {
                    new MaterialDialog.Builder(getActivity()).title(R.string.igap_update).titleColor(new Theme().getAccentColor(getActivity())).titleGravity(GravityEnum.CENTER).buttonsGravity(GravityEnum.CENTER).content(R.string.new_version_avilable).contentGravity(GravityEnum.CENTER).negativeText(R.string.ignore).negativeColor(new Theme().getAccentColor(getActivity())).onNegative((dialog, which) -> dialog.dismiss()).positiveText(R.string.startUpdate).onPositive((dialog, which) -> {
                        try {
                            String url = BuildConfig.UPDATE_LINK;
                            Intent i = new Intent(Intent.ACTION_VIEW);
                            i.setData(Uri.parse(url));
                            startActivity(i);
                            dialog.dismiss();
                        } catch (Exception e) {
                            e.printStackTrace();
                            Toast.makeText(getActivity(), R.string.need_browser, Toast.LENGTH_SHORT).show();
                        }
                    }).show();
                }
            });
        }
    } catch (Exception e) {
        HelperLog.getInstance().setErrorLog(e);
    }
}
Also used : AsyncTransaction(net.iGap.helper.AsyncTransaction) Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) ToolbarItem(net.iGap.messenger.ui.toolBar.ToolbarItem) Drawable(android.graphics.drawable.Drawable) G.isAppRtl(net.iGap.G.isAppRtl) GroupChatRole(net.iGap.module.enums.GroupChatRole) Fragment(androidx.fragment.app.Fragment) RoomListCell(net.iGap.adapter.items.cells.RoomListCell) CallActivity(net.iGap.activities.CallActivity) ContextCompat(androidx.core.content.ContextCompat) HelperFragment(net.iGap.helper.HelperFragment) Log(android.util.Log) OnDateChanged(net.iGap.observers.interfaces.OnDateChanged) HelperTracker(net.iGap.helper.HelperTracker) Realm(io.realm.Realm) BuildConfig(net.iGap.BuildConfig) NumberTextView(net.iGap.messenger.ui.toolBar.NumberTextView) RealmRoom(net.iGap.realm.RealmRoom) CHAT(net.iGap.proto.ProtoGlobal.Room.Type.CHAT) CHANNEL(net.iGap.proto.ProtoGlobal.Room.Type.CHANNEL) Nullable(androidx.annotation.Nullable) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) HelperPreferences(net.iGap.helper.HelperPreferences) SHP_SETTING(net.iGap.module.SHP_SETTING) AlphaAnimation(android.view.animation.AlphaAnimation) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) EventManager(net.iGap.observers.eventbus.EventManager) Config(net.iGap.Config) ActivityMain(net.iGap.activities.ActivityMain) RoomListAdapter(net.iGap.adapter.RoomListAdapter) OnVersionCallBack(net.iGap.observers.interfaces.OnVersionCallBack) StatusBarUtil(net.iGap.module.StatusBarUtil) ArrayList(java.util.ArrayList) OnRemoveFragment(net.iGap.observers.interfaces.OnRemoveFragment) Toast(android.widget.Toast) ConnectionState(net.iGap.module.enums.ConnectionState) HelperGetAction(net.iGap.helper.HelperGetAction) LayoutCreator(net.iGap.helper.LayoutCreator) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) FragmentMediaContainer(net.iGap.messenger.ui.components.FragmentMediaContainer) ToolBarMenuSubItem(net.iGap.messenger.ui.toolBar.ToolBarMenuSubItem) Gravity(android.view.Gravity) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) DbManager(net.iGap.module.accountManager.DbManager) EditText(android.widget.EditText) ValueAnimator(android.animation.ValueAnimator) LinearLayout(android.widget.LinearLayout) AppUtils(net.iGap.module.AppUtils) Date(java.util.Date) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) Animator(android.animation.Animator) Theme(net.iGap.module.Theme) G(net.iGap.G) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) Locale(java.util.Locale) View(android.view.View) Animation(android.view.animation.Animation) RecyclerView(androidx.recyclerview.widget.RecyclerView) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) HelperGetDataFromOtherApp(net.iGap.helper.HelperGetDataFromOtherApp) ObjectAnimator(android.animation.ObjectAnimator) PassCode(net.iGap.model.PassCode) FragmentTransaction(androidx.fragment.app.FragmentTransaction) Objects(java.util.Objects) HelperLog(net.iGap.helper.HelperLog) List(java.util.List) TextView(android.widget.TextView) MusicPlayer(net.iGap.module.MusicPlayer) ClientGetRoomListResponse(net.iGap.response.ClientGetRoomListResponse) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) OnSetActionInRoom(net.iGap.observers.interfaces.OnSetActionInRoom) NotNull(org.jetbrains.annotations.NotNull) EditorInfo(android.view.inputmethod.EditorInfo) Snackbar(com.google.android.material.snackbar.Snackbar) Context(android.content.Context) ResourcesCompat(androidx.core.content.res.ResourcesCompat) GravityEnum(com.afollestad.materialdialogs.GravityEnum) Intent(android.content.Intent) Lifecycle(androidx.lifecycle.Lifecycle) SuppressLint(android.annotation.SuppressLint) GoToChatActivity(net.iGap.helper.GoToChatActivity) AnimatorSet(android.animation.AnimatorSet) RatingDialog(net.iGap.fragments.populaChannel.RatingDialog) RealmRoomMessage(net.iGap.realm.RealmRoomMessage) Build(android.os.Build) ToolbarItems(net.iGap.messenger.ui.toolBar.ToolbarItems) ActivityEnterPassCode(net.iGap.activities.ActivityEnterPassCode) ScanCodeQRCodePaymentFragment(net.iGap.fragments.qrCodePayment.fragments.ScanCodeQRCodePaymentFragment) IconView(net.iGap.messenger.ui.components.IconView) Color(android.graphics.Color) ProtoGlobal(net.iGap.proto.ProtoGlobal) R(net.iGap.R) ChannelChatRole(net.iGap.module.enums.ChannelChatRole) RequestClientGetRoomList(net.iGap.request.RequestClientGetRoomList) GROUP(net.iGap.proto.ProtoGlobal.Room.Type.GROUP) Theme(net.iGap.module.Theme) Intent(android.content.Intent)

Example 8 with Theme

use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.

the class FragmentiGapMap method onViewCreated.

@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    HelperTracker.sendTracker(HelperTracker.TRACKER_NEARBY_PAGE);
    G.onLocationChanged = this;
    G.onGetNearbyCoordinate = this;
    G.onMapRegisterState = this;
    G.onMapClose = this;
    G.onGeoGetComment = this;
    G.onMapUsersGet = this;
    attentionDialog();
    map = view.findViewById(R.id.map);
    initToolbar(view);
    startMap(view);
    // clickDrawMarkActive();
    fabStateSwitcher = view.findViewById(R.id.st_fab_state);
    /*  fabStateSwitcher.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor(G.fabBottom)));
        fabStateSwitcher.setColorFilter(Color.WHITE);*/
    fabStateSwitcher.setBackgroundTintColor();
    fabStateSwitcher.setFabSize();
    fabStateSwitcher.setStateChangeListener(new StateChangeListener() {

        @Override
        public void onMenuOpened() {
        }

        @Override
        public void onMenuClosed() {
            isMenuButtonAddShown = false;
        }
    });
    btnOrginView = view.findViewById(R.id.ac_fab_orgin);
    btnOrginView.setBackgroundTintList(ColorStateList.valueOf(new Theme().getPrimaryColor(getContext())));
    btnOrginView.setOnClickListener(view12 -> {
        deleteMapFileCash();
        if (getActivity() != null && isAdded()) {
            changeState = getActivity().getSharedPreferences("KEY_SWITCH_MAP_STATE", Context.MODE_PRIVATE).getBoolean("state", false);
            if (!changeState) {
                deleteMapFileCash();
                getActivity().getSharedPreferences("KEY_SWITCH_MAP_STATE", Context.MODE_PRIVATE).edit().putBoolean("state", true).apply();
                new HelperFragment(G.currentActivity.getSupportFragmentManager(), FragmentiGapMap.getInstance()).setImmediateRemove(true).remove();
                new HelperFragment(G.currentActivity.getSupportFragmentManager(), FragmentiGapMap.getInstance()).load();
            }
        }
        if (fabStateSwitcher.isMenuOpened()) {
            fabStateSwitcher.toggleMenu();
        }
    });
    btnSatelliteView = view.findViewById(R.id.ac_fab_satellite);
    btnSatelliteView.setBackgroundTintList(ColorStateList.valueOf(new Theme().getPrimaryColor(getContext())));
    btnSatelliteView.setOnClickListener(view1 -> {
        if (getActivity() != null && isAdded()) {
            changeState = getActivity().getSharedPreferences("KEY_SWITCH_MAP_STATE", Context.MODE_PRIVATE).getBoolean("state", false);
            if (changeState) {
                deleteMapFileCash();
                getActivity().getSharedPreferences("KEY_SWITCH_MAP_STATE", Context.MODE_PRIVATE).edit().putBoolean("state", false).apply();
                new HelperFragment(getActivity().getSupportFragmentManager(), FragmentiGapMap.getInstance()).setImmediateRemove(true).remove();
                if (getActivity() != null) {
                    new HelperFragment(getActivity().getSupportFragmentManager(), FragmentiGapMap.getInstance()).load();
                }
            }
        }
        if (fabStateSwitcher.isMenuOpened()) {
            fabStateSwitcher.toggleMenu();
        }
    });
    fabStateSwitcher.fabMenu.setOnClickListener(v -> fabStateSwitcher.toggleMenu());
    /* if (HelperCalander.isPersianUnicode)
            fabStateSwitcher.chanegMenuItem(false);
        else
            fabStateSwitcher.chanegMenuItem(true);*/
    /* fabStateSwitcher.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View view) {

                dialog = new MaterialDialog.Builder(G.fragmentActivity).customView(R.layout.chat_popup_dialog_custom, true).build();
                View v = dialog.getCustomView();
                */
    /* DialogAnimation.animationUp(dialog);*/
    /*
                dialog.getWindow().setLayout(ViewMaker.dpToPx(220), WindowManager.LayoutParams.WRAP_CONTENT);
                DisplayMetrics displayMetrics = new DisplayMetrics();
                getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
                int height = displayMetrics.heightPixels;
                int width = displayMetrics.widthPixels;

                WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes();


                if (G.selectedLanguage.equals("en")) {
                    wmlp.gravity = Gravity.TOP | Gravity.LEFT;

                    wmlp.x = ViewMaker.dpToPx(10);   //x position
                } else {
                    wmlp.gravity = Gravity.TOP | Gravity.RIGHT;
                    wmlp.x = ViewMaker.dpToPx(10);   //x position
                }


                int s = getActivity().getChangingConfigurations();


              */
    /*  if (orientation==0){
                   if (G.isLandscape)
                       wmlp.y = ViewMaker.dpToPx(160);
                       else
                       wmlp.y = ViewMaker.dpToPx(400);

                }else */
    /*
                if (orientation == 1 || orientation == 0) {
                    //Do some stuff
                    wmlp.y = ViewMaker.dpToPx(400);   //y

                } else if (orientation == 2) {
                    //Do some stuff
                    wmlp.y = ViewMaker.dpToPx(160);   //y
                }

                dialog.show();


                ViewGroup root1 = (ViewGroup) v.findViewById(R.id.dialog_root_item1_notification);
                ViewGroup root2 = (ViewGroup) v.findViewById(R.id.dialog_root_item2_notification);
                ViewGroup root3 = (ViewGroup) v.findViewById(R.id.dialog_root_item3_notification);

                root1.setVisibility(View.GONE);
                root2.setVisibility(View.VISIBLE);
                root3.setVisibility(View.VISIBLE);

                TextView txtItem1 = (TextView) v.findViewById(R.id.dialog_text_item1_notification);
                TextView icon1 = (TextView) v.findViewById(R.id.dialog_icon_item1_notification);
                txtItem1.setText(G.fragmentActivity.getResources().getString(R.string.satellite_view));
                icon1.setText(G.fragmentActivity.getResources().getString(R.string.md_nearby));

                TextView txtItem2 = (TextView) v.findViewById(R.id.dialog_text_item2_notification);
                TextView icon2 = (TextView) v.findViewById(R.id.dialog_icon_item2_notification);
                txtItem2.setText(G.fragmentActivity.getResources().getString(R.string.default_view));
                icon2.setText(G.fragmentActivity.getResources().getString(R.string.md_map));


                TextView txtItem3 = (TextView) v.findViewById(R.id.dialog_text_item3_notification);
                TextView icon3 = (TextView) v.findViewById(R.id.dialog_icon_item3_notification);
                txtItem3.setText(G.fragmentActivity.getResources().getString(R.string.satellite_view));
                icon3.setText(G.fragmentActivity.getResources().getString(R.string.md_satellite_variant));

                root1.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        dialog.dismiss();
                        fabGps.setVisibility(View.GONE);
                        fabStateSwitcher.setVisibility(View.GONE);
                        rippleMoreMap.setVisibility(View.GONE);
                        page = pageUserList;
                        try {
                            new HelperFragment(FragmentMapUsers.newInstance()).setResourceContainer(R.id.mapContainer_main).setReplace(false).load();
                        } catch (Exception e) {
                            e.getStackTrace();
                        }
                    }
                });

                root2.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        dialog.dismiss();


                        if (isAdded()) {
                            changeState = getActivity().getSharedPreferences("KEY_SWITCH_MAP_STATE", Context.MODE_PRIVATE)
                                    .getBoolean("state", false);


                            if (changeState) {
                                deleteMapFileCash();
                                getActivity().getSharedPreferences("KEY_SWITCH_MAP_STATE", Context.MODE_PRIVATE).edit().putBoolean("state", false).apply();

                                new HelperFragment(FragmentiGapMap.getInstance()).remove();

                                new HelperFragment(FragmentiGapMap.getInstance()).load();
                            }

                        }

                    }
                });

                root3.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        dialog.dismiss();

                        dialog.dismiss();

                        deleteMapFileCash();
                        if (isAdded()) {
                            changeState = getActivity().getSharedPreferences("KEY_SWITCH_MAP_STATE", Context.MODE_PRIVATE)
                                    .getBoolean("state", false);


                            if (!changeState) {
                                deleteMapFileCash();
                                getActivity().getSharedPreferences("KEY_SWITCH_MAP_STATE", Context.MODE_PRIVATE).edit().putBoolean("state", true).apply();

                                new HelperFragment(FragmentiGapMap.getInstance()).remove();

                                new HelperFragment(FragmentiGapMap.getInstance()).load();
                            }

                        }
                    }
                });







               */
    /* SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
                //Configuration.getInstance().load(this, PreferenceManager.getDefaultSharedPreferences(this));
                Configuration.getInstance().load(getActivity(), PreferenceManager.getDefaultSharedPreferences(getActivity()));*/
    /*

                //   map.onDetach();

          */
    /*      if (changeState)
                    changeState = false;
                else
                    changeState = true;


                map.invalidate();

                startMap(view);*/
    /*


                // setTile(false);

            }
        });*/
    page = 1;
    new RequestGeoGetComment().getComment(AccountManager.getInstance().getCurrentUser().getId());
}
Also used : RequestGeoGetComment(net.iGap.request.RequestGeoGetComment) StateChangeListener(net.iGap.libs.floatingAddButton.StateChangeListener) Theme(net.iGap.module.Theme) HelperFragment(net.iGap.helper.HelperFragment)

Example 9 with Theme

use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.

the class DiscoveryFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    HelperTracker.sendTracker(HelperTracker.TRACKER_DISCOVERY_PAGE);
    page = getArguments().getInt("page");
    if (getContext() != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        StatusBarUtil.setColor(getActivity(), new Theme().getPrimaryDarkColor(getContext()), 50);
    }
    // uncomment this lines after added small avatar and discovery setting
    discoveryToolbar = new Toolbar(getContext());
    discoveryToolbar.setTitle(G.isAppRtl ? R.string.logo_igap_fa : R.string.logo_igap_en);
    if (page != 0) {
        discoveryToolbar.setBackIcon(new BackDrawable(false));
    } else {
        discoveryToolbar.addItem(codeScannerTag, R.string.icon_QR_code, Color.WHITE);
        passCodeItem = discoveryToolbar.addItem(passCodeTag, R.string.icon_lock, Color.WHITE);
    }
    checkPassCodeVisibility();
    discoveryToolbar.setListener(i -> {
        switch(i) {
            case -1:
                popBackStackFragment();
                break;
            case codeScannerTag:
                onCodeScannerClickListener();
                break;
            case passCodeTag:
                if (passCodeItem == null) {
                    return;
                }
                if (ActivityMain.isLock) {
                    passCodeItem.setIcon(R.string.icon_unlock);
                    ActivityMain.isLock = false;
                    HelperPreferences.getInstance().putBoolean(SHP_SETTING.FILE_NAME, SHP_SETTING.KEY_LOCK_STARTUP_STATE, false);
                } else {
                    passCodeItem.setIcon(R.string.icon_lock);
                    ActivityMain.isLock = true;
                    HelperPreferences.getInstance().putBoolean(SHP_SETTING.FILE_NAME, SHP_SETTING.KEY_LOCK_STARTUP_STATE, true);
                }
                checkPassCodeVisibility();
                break;
        }
    });
    ViewGroup layoutToolbar = view.findViewById(R.id.fd_layout_toolbar);
    layoutToolbar.addView(discoveryToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
    pullToRefresh = view.findViewById(R.id.pullToRefresh);
    emptyRecycle = view.findViewById(R.id.emptyRecycle);
    rcDiscovery = view.findViewById(R.id.rcDiscovery);
    rcDiscovery.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            // Ensure you call it only once
            rcDiscovery.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            // Here you can get the size :)
            if (rcDiscovery.getAdapter() instanceof DiscoveryAdapter) {
                ((DiscoveryAdapter) rcDiscovery.getAdapter()).setWidth(rcDiscovery.getWidth());
            }
        }
    });
    /**
     *detect scroll down or up for tapcell send request
     */
    pullToRefresh.setOnRefreshListener(() -> {
        scroll = 1;
        setRefreshing(true);
        boolean isSend = updateOrFetchRecycleViewData();
        rcDiscovery.addOnScrollListener(new RecyclerView.OnScrollListener() {

            @Override
            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                if (dy <= 0) {
                    return;
                } else {
                    if (scroll == 1)
                        BottomNavigationFragment.isShowedAdd = false;
                }
                scroll++;
            }
        });
        if (!isSend) {
            setRefreshing(false);
            HelperError.showSnackMessage(getString(R.string.wallet_error_server), false);
        }
    });
    emptyRecycle.setOnClickListener(v -> {
        boolean isSend = updateOrFetchRecycleViewData();
        if (!isSend) {
            HelperError.showSnackMessage(getString(R.string.wallet_error_server), false);
        }
    });
    // load user avatar in toolbar
    // avatarHandler.getAvatar(new ParamWithAvatarType(mHelperToolbar.getAvatarSmall(), G.userId).avatarType(AvatarHandler.AvatarType.USER).showMain());
    rcDiscovery.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
    rcDiscovery.setAdapter(new DiscoveryAdapter(getActivity(), rcDiscovery.getWidth(), discoveryArrayList));
    if (discoveryArrayList == null) {
        tryToUpdateOrFetchRecycleViewData(0);
    }
    if (needToReload) {
        updateOrFetchRecycleViewData();
    }
}
Also used : ViewGroup(android.view.ViewGroup) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Theme(net.iGap.module.Theme) RecyclerView(androidx.recyclerview.widget.RecyclerView) ViewTreeObserver(android.view.ViewTreeObserver) DiscoveryAdapter(net.iGap.adapter.items.discovery.DiscoveryAdapter) HelperToolbar(net.iGap.helper.HelperToolbar) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar)

Example 10 with Theme

use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.

the class ElectricityBillListFrag method initRecycler.

private void initRecycler(Map<BillList.Bill, Debit> bills) {
    adapter = new ElectricityBillListAdapter(getContext(), bills, (item, btnAction) -> {
        // ServiceDebit temp = viewModel.getmMapData().getValue().get(item);
        switch(btnAction) {
            case PAY:
                ServiceDebit tempService = (ServiceDebit) bills.get(item).getData();
                viewModel.payServiceBill(tempService.getBillID(), tempService.getPaymentID(), tempService.getTotalElectricityBillDebt() != null ? tempService.getTotalElectricityBillDebt() : tempService.getTotalGasBillDebt(), ProtoMplGetBillToken.MplGetBillToken.Type.NONE_VALUE);
                break;
            case EDIT:
                if (item.getBillTitle() == null) {
                    showDialog(getResources().getString(R.string.elecBill_error_title), getResources().getString(R.string.elecBill_error_notPossible), getResources().getString(R.string.ok));
                    return;
                }
                ElectricityBillAddFrag frag = ElectricityBillAddFrag.newInstance(viewModel.getBillInfo(item), true);
                frag.setCompleteListener(new ElectricityBillAddFrag.CompleteListener() {

                    @Override
                    public void loadAgain() {
                        viewModel.getBillsList();
                    }
                });
                frag.show(getFragmentManager(), "BillAddEdit");
                break;
            case DELETE:
                final MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).title(R.string.elecBill_deleteBill_title).content(R.string.elecBill_deleteBill_desc).positiveText(R.string.elecBill_deleteBill_pos).negativeText(R.string.elecBill_deleteBill_neg).positiveColor(getContext().getResources().getColor(R.color.red)).widgetColor(new Theme().getAccentColor(getContext())).onPositive((dialog1, which) -> {
                    viewModel.deleteItem(item);
                    Toast.makeText(getContext(), "Deleted", Toast.LENGTH_SHORT).show();
                }).build();
                dialog.show();
                break;
            case SHOW_DETAIL:
                if (item.getBillTitle() == null) {
                    showDialog(getResources().getString(R.string.elecBill_error_title), getResources().getString(R.string.elecBill_error_notPossible), getResources().getString(R.string.ok));
                    return;
                }
                BillInfo temp = viewModel.getBillInfo(item);
                new HelperFragment(getFragmentManager(), ElectricityBillPayFrag.newInstance(temp.getBillType(), temp.getBillID(), temp.getTitle(), true)).setReplace(false).load();
                break;
            case MID_PAY:
                MobileDebit tempMid = (MobileDebit) bills.get(item).getData();
                viewModel.payServiceBill(tempMid.getMidTerm().getBillID(), tempMid.getMidTerm().getPayID(), tempMid.getMidTerm().getAmount(), ProtoMplGetBillToken.MplGetBillToken.Type.MID_TERM_VALUE);
                break;
            case LAST_PAY:
                MobileDebit tempLast = (MobileDebit) bills.get(item).getData();
                viewModel.payServiceBill(tempLast.getLastTerm().getBillID(), tempLast.getLastTerm().getPayID(), tempLast.getLastTerm().getAmount(), ProtoMplGetBillToken.MplGetBillToken.Type.LAST_TERM_VALUE);
                break;
            case RELOAD:
                viewModel.reloadData(item);
        }
    });
    binding.billRecycler.setAdapter(adapter);
}
Also used : 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) ElectricityBillListAdapter(net.iGap.adapter.electricity_bill.ElectricityBillListAdapter) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ServiceDebit(net.iGap.model.bill.ServiceDebit) Theme(net.iGap.module.Theme) BillInfo(net.iGap.model.bill.BillInfo) HelperFragment(net.iGap.helper.HelperFragment) MobileDebit(net.iGap.model.bill.MobileDebit)

Aggregations

Theme (net.iGap.module.Theme)41 View (android.view.View)22 TextView (android.widget.TextView)21 HelperFragment (net.iGap.helper.HelperFragment)17 LinearLayout (android.widget.LinearLayout)15 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)13 Bundle (android.os.Bundle)12 ViewGroup (android.view.ViewGroup)12 Nullable (androidx.annotation.Nullable)12 RecyclerView (androidx.recyclerview.widget.RecyclerView)12 ArrayList (java.util.ArrayList)12 R (net.iGap.R)11 NonNull (androidx.annotation.NonNull)10 LayoutInflater (android.view.LayoutInflater)9 HelperError (net.iGap.helper.HelperError)9 ParamWithAvatarType (net.iGap.helper.avatar.ParamWithAvatarType)9 Drawable (android.graphics.drawable.Drawable)8 FrameLayout (android.widget.FrameLayout)8 ProgressBar (android.widget.ProgressBar)8 Fragment (androidx.fragment.app.Fragment)8