Search in sources :

Example 1 with BottomSheetItemClickCallback

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

the class FragmentiGapMap method initToolbar.

private void initToolbar(View view) {
    mHelperToolbar = new Toolbar(getContext());
    mHelperToolbar.setTitle(getString(R.string.igap_nearby));
    mHelperToolbar.setBackIcon(new BackDrawable(false));
    mHelperToolbar.addItem(toolbarDotsTag, R.string.icon_other_vertical_dots, Color.WHITE);
    mHelperToolbar.setListener(i -> {
        switch(i) {
            case -1:
                // after return to FragmentMapUsers from FragmentContactsProfile don't execute this block
                if (getActivity() != null && getActivity().getSupportFragmentManager().getFragments().get(getActivity().getSupportFragmentManager().getFragments().size() - 1) != null && getActivity().getSupportFragmentManager().getFragments().get(getActivity().getSupportFragmentManager().getFragments().size() - 1).getClass().getName().equals(FragmentContactsProfile.class.getName())) {
                    return;
                }
                if (rippleMoreMap.getVisibility() == View.GONE || fabGps.getVisibility() == View.GONE) {
                    rippleMoreMap.setVisibility(View.VISIBLE);
                    fabGps.show();
                    fabStateSwitcher.setVisibility(View.VISIBLE);
                }
                if (!isBackPress) {
                    // getActivity().getSupportFragmentManager().popBackStack();
                    G.fragmentActivity.onBackPressed();
                }
                closeKeyboard(view);
                isBackPress = false;
                page = pageiGapMap;
                break;
            case toolbarDotsTag:
                if (getActivity() != null) {
                    List<Integer> items = new ArrayList<>();
                    items.add(R.string.list_user_map);
                    items.add(R.string.nearby);
                    if (getActivity().getSharedPreferences(SHP_SETTING.FILE_NAME, MODE_PRIVATE).getBoolean(SHP_SETTING.REGISTER_STATUS, false)) {
                        items.add(R.string.map_registration);
                    } else {
                        items.add(R.string.map_registration_enable);
                    }
                    dialog = new TopSheetDialog(getActivity()).setListDataWithResourceId(items, -1, new BottomSheetItemClickCallback() {

                        @Override
                        public void onClick(int position) {
                            if (items.get(position) == R.string.list_user_map) {
                                fabGps.hide();
                                fabStateSwitcher.setVisibility(View.GONE);
                                rippleMoreMap.setVisibility(View.GONE);
                                page = pageUserList;
                                try {
                                    if (getActivity() != null) {
                                        new HelperFragment(getActivity().getSupportFragmentManager(), FragmentMapUsers.newInstance()).setResourceContainer(R.id.mapContainer_main).setReplace(false).load();
                                    }
                                } catch (Exception e) {
                                    e.getStackTrace();
                                }
                            } else if (items.get(position) == R.string.nearby) {
                                if (location != null && !isSendRequestGeoCoordinate) {
                                    new RequestGeoGetNearbyCoordinate().getNearbyCoordinate(location.getLatitude(), location.getLongitude());
                                    showProgress(true);
                                    isSendRequestGeoCoordinate = true;
                                }
                            } else if (items.get(position) == R.string.map_registration) {
                                new MaterialDialog.Builder(getActivity()).title(R.string.Visible_Status_title_dialog_invisible).content(R.string.Visible_Status_text_dialog_invisible).positiveText(R.string.yes).onPositive(new MaterialDialog.SingleButtonCallback() {

                                    @Override
                                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                        new RequestGeoRegister().register(false);
                                    }
                                }).negativeText(R.string.no).onNegative(new MaterialDialog.SingleButtonCallback() {

                                    @Override
                                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                    }
                                }).show();
                            } else if (items.get(position) == R.string.map_registration_enable) {
                                if (!isGpsOn) {
                                    try {
                                        startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
                                    } catch (ActivityNotFoundException e) {
                                        e.printStackTrace();
                                    }
                                } else {
                                    new MaterialDialog.Builder(getContext()).title(R.string.Visible_Status_title_dialog).content(R.string.Visible_Status_text_dialog).positiveText(R.string.yes).onPositive(new MaterialDialog.SingleButtonCallback() {

                                        @Override
                                        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                            if (getRequestManager().isUserLogin()) {
                                                new RequestGeoRegister().register(true);
                                            } else {
                                                toggleGps.setChecked(false);
                                                showSnackBar(getString(R.string.please_check_your_connenction));
                                            }
                                        }
                                    }).negativeText(R.string.no).onNegative((dialog, which) -> toggleGps.setChecked(false)).show();
                                }
                            }
                        }
                    });
                    dialog.show();
                }
                break;
        }
    });
    ViewGroup layoutToolbar = view.findViewById(R.id.fm_layout_toolbar);
    layoutToolbar.addView(mHelperToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
}
Also used : TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) BottomSheetItemClickCallback(net.iGap.module.dialog.BottomSheetItemClickCallback) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) Intent(android.content.Intent) RequestGeoRegister(net.iGap.request.RequestGeoRegister) ActivityNotFoundException(android.content.ActivityNotFoundException) ActivityNotFoundException(android.content.ActivityNotFoundException) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(androidx.annotation.NonNull) HelperFragment(net.iGap.helper.HelperFragment) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar) RequestGeoGetNearbyCoordinate(net.iGap.request.RequestGeoGetNearbyCoordinate)

Example 2 with BottomSheetItemClickCallback

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

the class HelperUrl method openDialogDigitClick.

private static void openDialogDigitClick(FragmentActivity activity, String text) {
    try {
        if (activity != null) {
            activity.runOnUiThread(() -> {
                List<Integer> items = new ArrayList<>();
                items.add(R.string.copy_item_dialog);
                items.add(R.string.verify_register_call);
                items.add(R.string.add_to_contact);
                items.add(R.string.verify_register_sms);
                new BottomSheetFragment().setListDataWithResourceId(activity, items, -1, new BottomSheetItemClickCallback() {

                    @Override
                    public void onClick(int position) {
                        if (items.get(position) == R.string.copy_item_dialog) {
                            ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(CLIPBOARD_SERVICE);
                            ClipData clip = ClipData.newPlainText("Copied Text", text);
                            clipboard.setPrimaryClip(clip);
                            Toast.makeText(activity, R.string.text_copied, Toast.LENGTH_SHORT).show();
                        } else if (items.get(position) == R.string.verify_register_call) {
                            String uri = "tel:" + text;
                            Intent intent = new Intent(Intent.ACTION_DIAL);
                            intent.setData(Uri.parse(uri));
                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            activity.startActivity(intent);
                        } else if (items.get(position) == R.string.add_to_contact) {
                            FragmentAddContact fragment = FragmentAddContact.newInstance(text, FragmentAddContact.ContactMode.ADD);
                            new HelperFragment(activity.getSupportFragmentManager(), fragment).setReplace(false).load();
                        } else if (items.get(position) == R.string.verify_register_sms) {
                            String uri = "smsto:" + text;
                            Intent intent = new Intent(Intent.ACTION_SENDTO);
                            intent.setData(Uri.parse(uri));
                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            activity.startActivity(intent);
                        }
                    }
                }).show(activity.getSupportFragmentManager(), "bottom sheet");
            });
        }
    } catch (RuntimeException e) {
        e.printStackTrace();
    } catch (Exception e1) {
        e1.printStackTrace();
    }
}
Also used : ClipboardManager(android.content.ClipboardManager) BottomSheetItemClickCallback(net.iGap.module.dialog.BottomSheetItemClickCallback) ArrayList(java.util.ArrayList) CustomTabsIntent(androidx.browser.customtabs.CustomTabsIntent) Intent(android.content.Intent) ActivityNotFoundException(android.content.ActivityNotFoundException) BottomSheetFragment(net.iGap.module.dialog.bottomsheet.BottomSheetFragment) CustomTabsHelperFragment(me.zhanghai.android.customtabshelper.CustomTabsHelperFragment) ClipData(android.content.ClipData) FragmentAddContact(net.iGap.fragments.FragmentAddContact)

Aggregations

ActivityNotFoundException (android.content.ActivityNotFoundException)2 Intent (android.content.Intent)2 ArrayList (java.util.ArrayList)2 BottomSheetItemClickCallback (net.iGap.module.dialog.BottomSheetItemClickCallback)2 ClipData (android.content.ClipData)1 ClipboardManager (android.content.ClipboardManager)1 ViewGroup (android.view.ViewGroup)1 NonNull (androidx.annotation.NonNull)1 CustomTabsIntent (androidx.browser.customtabs.CustomTabsIntent)1 DialogAction (com.afollestad.materialdialogs.DialogAction)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 CustomTabsHelperFragment (me.zhanghai.android.customtabshelper.CustomTabsHelperFragment)1 FragmentAddContact (net.iGap.fragments.FragmentAddContact)1 HelperFragment (net.iGap.helper.HelperFragment)1 BackDrawable (net.iGap.messenger.ui.toolBar.BackDrawable)1 Toolbar (net.iGap.messenger.ui.toolBar.Toolbar)1 BottomSheetFragment (net.iGap.module.dialog.bottomsheet.BottomSheetFragment)1 TopSheetDialog (net.iGap.module.dialog.topsheet.TopSheetDialog)1 RequestGeoGetNearbyCoordinate (net.iGap.request.RequestGeoGetNearbyCoordinate)1 RequestGeoRegister (net.iGap.request.RequestGeoRegister)1