Java Code Examples for com.afollestad.materialdialogs.MaterialDialog#ListCallback

The following examples show how to use com.afollestad.materialdialogs.MaterialDialog#ListCallback . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DialogUtils.java    From io16experiment-master with Apache License 2.0 6 votes vote down vote up
/**
 * Create an item dialog
 *
 * @param activity
 * @param titleId
 * @param items
 * @param listCallback
 * @param callback
 * @return
 */
public static MaterialDialog createItemDialog(Activity activity, int titleId, int items, MaterialDialog.ListCallback listCallback,
                                              MaterialDialog.SingleButtonCallback callback) {
    Typeface typeface = Typeface.createFromAsset(activity.getAssets(), Constants.APP_FONT);

    MaterialDialog.Builder builder = new MaterialDialog.Builder(activity)
            .items(items)
            .itemsCallback(listCallback)
            .onNegative(callback)
            .negativeText(R.string.dialog_cancel)
            .typeface(typeface, typeface);

    if (titleId > DialogUtils.DEFAULT_TITLE_ID) {
        builder.title(titleId);
    }

    return builder.build();
}
 
Example 2
Source File: WelcomeFragment.java    From io16experiment-master with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    MainActivity.hide();

    MaterialDialog.ListCallback listCallback = new MaterialDialog.ListCallback() {
        @Override
        public void onSelection(MaterialDialog dialog, View view, int position, CharSequence text) {
            switch (position) {
                case 0:
                    mCallbacks.onGetStarted();
                    break;
                case 1:
                    mCallbacks.onDiscover(Constants.Source.WELCOME);
                    break;
            }
        }
    };

    DialogUtils.createItemDialog(mActivity, DialogUtils.DEFAULT_TITLE_ID, R.array.get_started_options,
            listCallback, null).show();
}
 
Example 3
Source File: LinksHelper.java    From redgram-for-reddit with GNU General Public License v3.0 6 votes vote down vote up
public static MaterialDialog.ListCallback getShareCallback(Context context, PostItem item) {
    return new MaterialDialog.ListCallback() {
        @Override
        public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence charSequence) {
            String urlToShare = "";
            if (charSequence.toString().equalsIgnoreCase("Link")) {
                urlToShare = item.getUrl();
            }

            if (charSequence.toString().equalsIgnoreCase("Comments")) {
                urlToShare = "https://reddit.com/" + item.getPermalink();
            }

            LinksHelper.callShareDialog(context, urlToShare);
        }
    };
}
 
Example 4
Source File: DialogHelper.java    From openlauncher with Apache License 2.0 5 votes vote down vote up
public static void selectActionDialog(final Context context, MaterialDialog.ListCallback callback) {
    MaterialDialog.Builder builder = new MaterialDialog.Builder(context);
    builder.title(R.string.action)
            .items(R.array.entries__gesture_action)
            .itemsCallback(callback)
            .show();
}
 
Example 5
Source File: DialogHelper.java    From openlauncher with Apache License 2.0 5 votes vote down vote up
public static void selectDesktopActionDialog(final Context context, MaterialDialog.ListCallback callback) {
    MaterialDialog.Builder builder = new MaterialDialog.Builder(context);
    builder.title(R.string.action)
            .items(R.array.entries__desktop_actions)
            .itemsCallback(callback)
            .show();
}
 
Example 6
Source File: DialogHelper.java    From openlauncher with Apache License 2.0 5 votes vote down vote up
public static void selectGestureDialog(final Context context, String title, MaterialDialog.ListCallback callback) {
    MaterialDialog.Builder builder = new MaterialDialog.Builder(context);
    builder.title(title)
            .items(R.array.entries__gesture)
            .itemsCallback(callback)
            .show();
}
 
Example 7
Source File: DownloadManager.java    From OneTapVideoDownload with GNU General Public License v3.0 5 votes vote down vote up
public MaterialDialog.ListCallback getOptionCallback(final int index) {
    final DownloadHandler downloadHandler = mDownloadHandlers.get(index).second;
    return new MaterialDialog.ListCallback() {
        @Override
        public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
            Context context = dialog.getContext();
            int resId = downloadHandler.findIdByString(context, (String) text);
            if (resId == -1) {
                return;
            }

            downloadHandler.handleOptionClicks(context, resId);
        }
    };
}
 
Example 8
Source File: LinksHelper.java    From redgram-for-reddit with GNU General Public License v3.0 5 votes vote down vote up
public static void showExternalDialog(DialogUtil dialogUtil, String title, MaterialDialog.ListCallback callback) {
    dialogUtil.build()
            .title(title)
            .items(R.array.shareOptions)
            .itemsCallback(callback)
            .show();
}
 
Example 9
Source File: LinksHelper.java    From redgram-for-reddit with GNU General Public License v3.0 5 votes vote down vote up
public static MaterialDialog.ListCallback getBrowseCallback(Context context, PostItem item) {
    return (materialDialog, view, i, charSequence) -> {
        Uri urlToOpen = getUriToOpen(item, charSequence);
        if (urlToOpen != null) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, urlToOpen);
            context.startActivity(browserIntent);
        }
    };
}
 
Example 10
Source File: LinksHelper.java    From redgram-for-reddit with GNU General Public License v3.0 5 votes vote down vote up
public static MaterialDialog.ListCallback getCopyCallback(Context context, ToastHandler toastHandler, PostItem item) {
    return (materialDialog, view, i, charSequence) -> {
        Uri urlToOpen = getUriToOpen(item, charSequence);
        if (urlToOpen != null) {
            ClipboardManager clipboard = (ClipboardManager)
                    context.getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newUri(context.getContentResolver(), "URI", urlToOpen);
            clipboard.setPrimaryClip(clip);
            toastHandler.showToast("Link Copied", Toast.LENGTH_SHORT);
        }
    };
}
 
Example 11
Source File: LinksContainerView.java    From redgram-for-reddit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void sharePost(int position) {
    PostItem item = getItem(position);
    MaterialDialog.ListCallback callback = LinksHelper.getShareCallback(context, item);
    LinksHelper.showExternalDialog(dialogUtil, "Share" ,callback);
}
 
Example 12
Source File: LinksContainerView.java    From redgram-for-reddit with GNU General Public License v3.0 4 votes vote down vote up
private void buildBrowserDialog(int position) {
    PostItem item = getItem(position);
    MaterialDialog.ListCallback callback = LinksHelper.getBrowseCallback(context, item);
    LinksHelper.showExternalDialog(dialogUtil, "Open in Browser",callback);
}
 
Example 13
Source File: LinksContainerView.java    From redgram-for-reddit with GNU General Public License v3.0 4 votes vote down vote up
private void buildCopyDialog(int position) {
    PostItem item = getItem(position);
    MaterialDialog.ListCallback callback = LinksHelper.getCopyCallback(context, app.getToastHandler(), item);
    LinksHelper.showExternalDialog(dialogUtil, "Copy" ,callback);
}
 
Example 14
Source File: ThreadActivity.java    From redgram-for-reddit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void sharePost() {
    MaterialDialog.ListCallback callback = LinksHelper.getShareCallback(this, postItem);
    LinksHelper.showExternalDialog(dialogUtil, "Share" , callback);
}
 
Example 15
Source File: ThreadActivity.java    From redgram-for-reddit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void openInBrowser() {
    MaterialDialog.ListCallback callback = LinksHelper.getBrowseCallback(this, postItem);
    LinksHelper.showExternalDialog(dialogUtil, "Open in Browser" ,callback);
}
 
Example 16
Source File: ThreadActivity.java    From redgram-for-reddit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void copyItemLink() {
    MaterialDialog.ListCallback callback = LinksHelper.getCopyCallback(this, app.getToastHandler(), postItem);
    LinksHelper.showExternalDialog(dialogUtil, "Copy" ,callback);
}