diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-01-04 13:56:47 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-01-04 13:56:47 -0800 |
commit | f7d19f2cf94263aedd9e173e19bf52816725fd17 (patch) | |
tree | 979f75b7873f022bf6094c5c43c04485360a2220 /src/github | |
parent | 323d1d98f373d3cb15f829675333c4dfec61bf2e (diff) | |
download | dsub-f7d19f2cf94263aedd9e173e19bf52816725fd17.tar.gz dsub-f7d19f2cf94263aedd9e173e19bf52816725fd17.tar.bz2 dsub-f7d19f2cf94263aedd9e173e19bf52816725fd17.zip |
#438 Add dialog to lookup missing artists
Diffstat (limited to 'src/github')
-rw-r--r-- | src/github/daneren2005/dsub/fragments/SimilarArtistFragment.java | 52 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/util/Util.java | 7 |
2 files changed, 40 insertions, 19 deletions
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<Artist> { private static final String TAG = SimilarArtistFragment.class.getSimpleName(); + private ArtistInfo info; private String artistId; @Override @@ -64,6 +53,21 @@ public class SimilarArtistFragment extends SelectListFragment<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<Artist> { @Override public int getOptionsMenu() { - return R.menu.empty; + return R.menu.similar_artists; } @Override @@ -110,7 +114,7 @@ public class SimilarArtistFragment extends SelectListFragment<Artist> { @Override public List<Artist> 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<Artist> { public int getTitleResource() { return R.string.menu_similar_artists; } + + private void showMissingArtists() { + StringBuilder b = new StringBuilder(); + + for(String name: info.getMissingArtists()) { + b.append("<h3><a href=\"https://www.google.com/#q=" + URLEncoder.encode(name) + "\">" + name + "</a></h3> "); + } + + 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) { |