diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2016-11-01 19:35:43 +0100 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2016-11-01 19:43:23 +0100 |
commit | 8a626faf73070085e2f520247a5f701c4f125c10 (patch) | |
tree | f40d66b1e86550159f4e1bfd3ceacb78fabed9de /app/src/main/java/de/danoeh/antennapod/dialog | |
parent | cfef273eba571d1f781e256a8521ea176b7b2797 (diff) | |
download | AntennaPod-8a626faf73070085e2f520247a5f701c4f125c10.zip |
Add ability to rename feeds
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/dialog')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/dialog/RenameFeedDialog.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/RenameFeedDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/RenameFeedDialog.java new file mode 100644 index 000000000..31a544582 --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/dialog/RenameFeedDialog.java @@ -0,0 +1,44 @@ +package de.danoeh.antennapod.dialog; + +import android.app.Activity; +import android.text.InputType; + +import com.afollestad.materialdialogs.MaterialDialog; + +import java.lang.ref.WeakReference; + +import de.danoeh.antennapod.core.feed.Feed; +import de.danoeh.antennapod.core.storage.DBWriter; + +public class RenameFeedDialog { + + private final WeakReference<Activity> activityRef; + private final Feed feed; + + public RenameFeedDialog(Activity activity, Feed feed) { + this.activityRef = new WeakReference<>(activity); + this.feed = feed; + } + + public void show() { + Activity activity = activityRef.get(); + if(activity == null) { + return; + } + new MaterialDialog.Builder(activity) + .title(de.danoeh.antennapod.core.R.string.rename_feed_label) + .inputType(InputType.TYPE_CLASS_TEXT) + .input(feed.getTitle(), feed.getTitle(), true, (dialog, input) -> { + feed.setCustomTitle(input.toString()); + DBWriter.setFeedCustomTitle(feed); + dialog.dismiss(); + }) + .neutralText(de.danoeh.antennapod.core.R.string.reset) + .onNeutral((dialog, which) -> dialog.getInputEditText().setText(feed.getFeedTitle())) + .negativeText(de.danoeh.antennapod.core.R.string.cancel_label) + .onNegative((dialog, which) -> dialog.dismiss()) + .autoDismiss(false) + .show(); + } + +} |