From f7d19f2cf94263aedd9e173e19bf52816725fd17 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sun, 4 Jan 2015 13:56:47 -0800 Subject: #438 Add dialog to lookup missing artists --- res/menu/similar_artists.xml | 8 ++++ res/values/strings.xml | 1 + .../dsub/fragments/SimilarArtistFragment.java | 52 ++++++++++++++-------- src/github/daneren2005/dsub/util/Util.java | 7 ++- 4 files changed, 49 insertions(+), 19 deletions(-) create mode 100644 res/menu/similar_artists.xml diff --git a/res/menu/similar_artists.xml b/res/menu/similar_artists.xml new file mode 100644 index 00000000..bffa1837 --- /dev/null +++ b/res/menu/similar_artists.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index ebffb19b..314fc9bf 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -105,6 +105,7 @@ Set Rating Last.FM Top Tracks Similar Artists + Show missing Playlists Update Information diff --git a/src/github/daneren2005/dsub/fragments/SimilarArtistFragment.java b/src/github/daneren2005/dsub/fragments/SimilarArtistFragment.java index 8fdd6994..26d7fb5e 100644 --- a/src/github/daneren2005/dsub/fragments/SimilarArtistFragment.java +++ b/src/github/daneren2005/dsub/fragments/SimilarArtistFragment.java @@ -15,44 +15,33 @@ package github.daneren2005.dsub.fragments; -import android.os.Build; +import android.app.AlertDialog; import android.os.Bundle; -import android.support.v4.widget.SwipeRefreshLayout; -import android.util.Log; +import android.text.method.LinkMovementMethod; import android.view.ContextMenu; -import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; -import android.view.ViewGroup; -import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.ArrayAdapter; -import android.widget.LinearLayout; -import android.widget.ListView; import android.widget.TextView; + import github.daneren2005.dsub.R; import github.daneren2005.dsub.domain.Artist; import github.daneren2005.dsub.domain.ArtistInfo; -import github.daneren2005.dsub.domain.Indexes; -import github.daneren2005.dsub.domain.MusicDirectory; -import github.daneren2005.dsub.domain.MusicFolder; import github.daneren2005.dsub.service.MusicService; -import github.daneren2005.dsub.service.MusicServiceFactory; -import github.daneren2005.dsub.util.BackgroundTask; import github.daneren2005.dsub.util.Constants; import github.daneren2005.dsub.util.ProgressListener; -import github.daneren2005.dsub.util.TabBackgroundTask; import github.daneren2005.dsub.util.Util; import github.daneren2005.dsub.view.ArtistAdapter; -import java.io.Serializable; -import java.util.ArrayList; +import java.net.URLEncoder; import java.util.List; public class SimilarArtistFragment extends SelectListFragment { private static final String TAG = SimilarArtistFragment.class.getSimpleName(); + private ArtistInfo info; private String artistId; @Override @@ -63,6 +52,21 @@ public class SimilarArtistFragment extends SelectListFragment { artistId = getArguments().getString(Constants.INTENT_EXTRA_NAME_ARTIST); } + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if(super.onOptionsItemSelected(item)) { + return true; + } + + switch (item.getItemId()) { + case R.id.menu_show_missing: + showMissingArtists(); + break; + } + + return false; + } + @Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); @@ -100,7 +104,7 @@ public class SimilarArtistFragment extends SelectListFragment { @Override public int getOptionsMenu() { - return R.menu.empty; + return R.menu.similar_artists; } @Override @@ -110,7 +114,7 @@ public class SimilarArtistFragment extends SelectListFragment { @Override public List getObjects(MusicService musicService, boolean refresh, ProgressListener listener) throws Exception { - ArtistInfo info = musicService.getArtistInfo(artistId, refresh, context, listener); + info = musicService.getArtistInfo(artistId, refresh, context, listener); return info.getSimilarArtists(); } @@ -118,4 +122,16 @@ public class SimilarArtistFragment extends SelectListFragment { public int getTitleResource() { return R.string.menu_similar_artists; } + + private void showMissingArtists() { + StringBuilder b = new StringBuilder(); + + for(String name: info.getMissingArtists()) { + b.append("

" + name + "

"); + } + + Util.showHTMLDialog(context, R.string.menu_similar_artists, b.toString()); + + // Util.info(context, R.string.menu_similar_artists, b.toString()); + } } diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java index ae0d668c..f899b9e4 100644 --- a/src/github/daneren2005/dsub/util/Util.java +++ b/src/github/daneren2005/dsub/util/Util.java @@ -1040,10 +1040,13 @@ public final class Util { ((TextView)dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); } public static void showHTMLDialog(Context context, int title, int message) { + showHTMLDialog(context, title, context.getResources().getString(message)); + } + public static void showHTMLDialog(Context context, int title, String message) { AlertDialog dialog = new AlertDialog.Builder(context) .setIcon(android.R.drawable.ic_dialog_info) .setTitle(title) - .setMessage(Html.fromHtml(context.getResources().getString(message))) + .setMessage(Html.fromHtml(message)) .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int i) { @@ -1051,6 +1054,8 @@ public final class Util { } }) .show(); + + ((TextView)dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); } public static void sleepQuietly(long millis) { -- cgit v1.2.3