Search in sources :

Example 1 with EditTextDialogBinding

use of de.danoeh.antennapod.databinding.EditTextDialogBinding in project AntennaPod by AntennaPod.

the class AddFeedFragment method showAddViaUrlDialog.

private void showAddViaUrlDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder.setTitle(R.string.add_podcast_by_url);
    View content = View.inflate(getContext(), R.layout.edit_text_dialog, null);
    EditTextDialogBinding alertViewBinding = EditTextDialogBinding.bind(content);
    alertViewBinding.urlEditText.setHint(R.string.add_podcast_by_url_hint);
    ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    String clipboardContent = clipboard.getText() != null ? clipboard.getText().toString() : "";
    if (clipboardContent.trim().startsWith("http")) {
        alertViewBinding.urlEditText.setText(clipboardContent.trim());
    }
    builder.setView(alertViewBinding.getRoot());
    builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> addUrl(alertViewBinding.urlEditText.getText().toString()));
    builder.setNegativeButton(R.string.cancel_label, null);
    builder.show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ClipboardManager(android.content.ClipboardManager) View(android.view.View) EditTextDialogBinding(de.danoeh.antennapod.databinding.EditTextDialogBinding)

Example 2 with EditTextDialogBinding

use of de.danoeh.antennapod.databinding.EditTextDialogBinding in project AntennaPod by AntennaPod.

the class RenameItemDialog method show.

public void show() {
    Activity activity = activityRef.get();
    if (activity == null) {
        return;
    }
    View content = View.inflate(activity, R.layout.edit_text_dialog, null);
    EditTextDialogBinding alertViewBinding = EditTextDialogBinding.bind(content);
    String title = feed != null ? feed.getTitle() : drawerItem.getTitle();
    alertViewBinding.urlEditText.setText(title);
    AlertDialog dialog = new AlertDialog.Builder(activity).setView(content).setTitle(feed != null ? R.string.rename_feed_label : R.string.rename_tag_label).setPositiveButton(android.R.string.ok, (d, input) -> {
        String newTitle = alertViewBinding.urlEditText.getText().toString();
        if (feed != null) {
            feed.setCustomTitle(newTitle);
            DBWriter.setFeedCustomTitle(feed);
        } else {
            renameTag(newTitle);
        }
    }).setNeutralButton(de.danoeh.antennapod.core.R.string.reset, null).setNegativeButton(de.danoeh.antennapod.core.R.string.cancel_label, null).show();
    // To prevent cancelling the dialog on button click
    dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener((view) -> alertViewBinding.urlEditText.setText(title));
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) List(java.util.List) NavDrawerData(de.danoeh.antennapod.core.storage.NavDrawerData) FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) AlertDialog(androidx.appcompat.app.AlertDialog) DBWriter(de.danoeh.antennapod.core.storage.DBWriter) R(de.danoeh.antennapod.R) View(android.view.View) EditTextDialogBinding(de.danoeh.antennapod.databinding.EditTextDialogBinding) WeakReference(java.lang.ref.WeakReference) Activity(android.app.Activity) Feed(de.danoeh.antennapod.model.feed.Feed) ArrayList(java.util.ArrayList) Activity(android.app.Activity) View(android.view.View) EditTextDialogBinding(de.danoeh.antennapod.databinding.EditTextDialogBinding)

Aggregations

View (android.view.View)2 AlertDialog (androidx.appcompat.app.AlertDialog)2 EditTextDialogBinding (de.danoeh.antennapod.databinding.EditTextDialogBinding)2 Activity (android.app.Activity)1 ClipboardManager (android.content.ClipboardManager)1 R (de.danoeh.antennapod.R)1 DBWriter (de.danoeh.antennapod.core.storage.DBWriter)1 NavDrawerData (de.danoeh.antennapod.core.storage.NavDrawerData)1 Feed (de.danoeh.antennapod.model.feed.Feed)1 FeedPreferences (de.danoeh.antennapod.model.feed.FeedPreferences)1 WeakReference (java.lang.ref.WeakReference)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1