@Override public void onBuildLongClicked(final BuildViewHolder buildViewHolder) { Context context = getActivity(); final MaterialSimpleListAdapter adapter = new MaterialSimpleListAdapter(new MaterialSimpleListAdapter.Callback() { @Override public void onMaterialListItemSelected(MaterialDialog dialog, int index, MaterialSimpleListItem item) { long buildId = buildViewHolder.viewModel.getBuildId(); switch (index) { case 0: editBuild(buildId); break; case 1: confirmDeleteBuild(buildId); break; case 2: exportBuild(buildId); break; default: Timber.e("Unknown context menu item selected, index = " + index); break; } dialog.dismiss(); } }); adapter.add(new MaterialSimpleListItem.Builder(context) .content(R.string.menu_edit_build) .build()); adapter.add(new MaterialSimpleListItem.Builder(context) .content(R.string.menu_delete_build) .build()); adapter.add(new MaterialSimpleListItem.Builder(context) .content(R.string.menu_export_build) .build()); new MaterialDialog.Builder(context) .title(buildViewHolder.viewModel.getName()) .adapter(adapter, null) .show(); }
@ReactMethod public void list(ReadableMap options, final Callback callback) { final MaterialSimpleListAdapter simpleListAdapter = new MaterialSimpleListAdapter(getCurrentActivity()); ReadableArray arr = options.getArray("items"); for(int i = 0; i < arr.size(); i++){ simpleListAdapter.add(new MaterialSimpleListItem.Builder(getCurrentActivity()) .content(arr.getString(i)) .build()); } final MaterialDialog.Builder adapter = new MaterialDialog.Builder(getCurrentActivity()) .title(options.hasKey("title") ? options.getString("title") : "") .adapter(simpleListAdapter, new MaterialDialog.ListCallback() { @Override public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) { callback.invoke(which, text); if (simple != null) { simple.dismiss(); } } }) .autoDismiss(true); UiThreadUtil.runOnUiThread(new Runnable() { public void run() { if (simple != null) { simple.dismiss(); } simple = adapter.build(); simple.show(); } }); }
public static MaterialDialog showProFeatures(final Context context) { final MaterialSimpleListAdapter adapter = new MaterialSimpleListAdapter(context); adapter.add(new MaterialSimpleListItem.Builder(context) .content(context.getResources().getString(R.string.pro_feature_1)) .icon(new IconicsDrawable(context).icon(GoogleMaterial.Icon.gmd_visibility_off).color(Color.GRAY).sizeDp(18)) .backgroundColor(Color.WHITE) .build()); adapter.add(new MaterialSimpleListItem.Builder(context) .content(context.getResources().getString(R.string.pro_feature_2)) .icon(new IconicsDrawable(context).icon(GoogleMaterial.Icon.gmd_list).color(Color.GRAY).sizeDp(18)) .backgroundColor(Color.WHITE) .build()); adapter.add(new MaterialSimpleListItem.Builder(context) .content(context.getResources().getString(R.string.pro_feature_3)) .icon(new IconicsDrawable(context).icon(GoogleMaterial.Icon.gmd_phonelink_erase).color(Color.GRAY).sizeDp(18)) .backgroundColor(Color.WHITE) .build()); adapter.add(new MaterialSimpleListItem.Builder(context) .content(context.getResources().getString(R.string.pro_feature_4)) .icon(new IconicsDrawable(context).icon(GoogleMaterial.Icon.gmd_delete).color(Color.GRAY).sizeDp(18)) .backgroundColor(Color.WHITE) .build()); MaterialDialog.Builder materialBuilder = new MaterialDialog.Builder(context) .title(context.getResources().getString(R.string.action_buy) + " (" + context.getResources().getString(R.string.action_buy_description) + ")") .icon(ContextCompat.getDrawable(context, R.mipmap.ic_launcher_pro)) .adapter(adapter, new MaterialDialog.ListCallback() { @Override public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence charSequence) {} }) .positiveText(context.getResources().getString(R.string.action_buy) + " ($1.43)") .negativeText(context.getResources().getString(R.string.button_later)) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { UtilsApp.goToGooglePlay(context, MLManagerApplication.getProPackage()); } }); return materialBuilder.show(); }
public void onClick() { TextContentView textContent = mBalloonTheme.getTextContentView(); if (textContent == null) return; // Check for links. If none, do nothing; if 1, open it; if >1, ask user to pick one final URLSpan[] spans = textContent.getUrls(); if (spans.length == 0) { // show the message details dialog MessageUtils.showMessageDetails(getContext(), mMessage, mPeer, mDisplayName); } else if (spans.length == 1) { // show link opener spans[0].onClick(textContent); } else { // complex stuff (media) URLSpanAdapterCallback click = new URLSpanAdapterCallback(textContent); final MaterialSimpleListAdapter adapter = new MaterialSimpleListAdapter(click); for (URLSpan span : spans) { MaterialSimpleListItem.Builder builder = new MaterialSimpleListItem.Builder(getContext()) .tag(span); try { String url = span.getURL(); Uri uri = Uri.parse(url); final String telPrefix = "tel:"; if (url.startsWith(telPrefix)) { // TODO handle country code url = url.substring(telPrefix.length()); } builder.content(url); Drawable d = getContext().getPackageManager().getActivityIcon( new Intent(Intent.ACTION_VIEW, uri)); if (d != null) { builder.icon(d).iconPadding(10); } } catch (android.content.pm.PackageManager.NameNotFoundException ex) { // it's ok if we're unable to set the drawable for this view - the user // can still use it } adapter.add(builder.build()); } new MaterialDialog.Builder(getContext()) .title(R.string.chooser_select_link) .cancelable(true) .adapter(adapter, null) .negativeText(android.R.string.cancel) .onNegative(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); } }) .show(); } }