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));
}
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();
}
}
Aggregations