예제 #1
0
 public void fillView(final Album album, Collection collection) {
   if (collection == null) {
     collection = CollectionManager.getInstance().getCollection(TomahawkApp.PLUGINNAME_HATCHET);
   }
   TextView textView1 = (TextView) findViewById(R.id.textview1);
   textView1.setText(album.getPrettyName());
   TextView textView2 = (TextView) findViewById(R.id.textview2);
   textView2.setText(album.getArtist().getPrettyName());
   ImageView imageView1 = (ImageView) findViewById(R.id.imageview1);
   TomahawkUtils.loadImageIntoImageView(
       TomahawkApp.getContext(), imageView1, album.getImage(), Image.getSmallImageSize(), false);
   final TextView textView3 = (TextView) findViewById(R.id.textview3);
   textView3.setVisibility(View.INVISIBLE);
   collection
       .getAlbumTracks(album)
       .done(
           new DoneCallback<CollectionCursor<Query>>() {
             @Override
             public void onDone(CollectionCursor<Query> cursor) {
               int size = 0;
               if (cursor != null) {
                 size = cursor.size();
                 cursor.close();
               }
               textView3.setVisibility(View.VISIBLE);
               textView3.setText(
                   TomahawkApp.getContext()
                       .getResources()
                       .getQuantityString(R.plurals.songs_with_count, size, size));
             }
           });
 }
예제 #2
0
 public void fillView(Artist artist) {
   TextView textView1 = (TextView) findViewById(R.id.textview1);
   textView1.setText(artist.getPrettyName());
   ImageView imageView1 = (ImageView) findViewById(R.id.imageview1);
   TomahawkUtils.loadImageIntoImageView(
       TomahawkApp.getContext(), imageView1, artist.getImage(), Image.getSmallImageSize(), true);
 }
 /**
  * Load a {@link android.graphics.Bitmap} asynchronously
  *
  * @param context the context needed for fetching resources
  * @param imageView the {@link android.widget.ImageView}, which will be used to show the {@link
  *     android.graphics.Bitmap}
  * @param image the path to load the image from
  * @param width the width in density independent pixels to scale the image down to
  */
 public static void loadImageIntoImageView(
     Context context, ImageView imageView, Image image, int width, boolean isArtistImage) {
   loadImageIntoImageView(context, imageView, image, width, true, isArtistImage);
 }
예제 #4
0
 private static void fillView(
     View view, List<Image> artistImages, int height, boolean isPagerFragment) {
   View v;
   int gridOneResId = isPagerFragment ? R.id.imageview_grid_one_pager : R.id.imageview_grid_one;
   int gridTwoResId = isPagerFragment ? R.id.imageview_grid_two_pager : R.id.imageview_grid_two;
   int gridThreeResId =
       isPagerFragment ? R.id.imageview_grid_three_pager : R.id.imageview_grid_three;
   int gridOneStubId =
       isPagerFragment ? R.id.imageview_grid_one_pager_stub : R.id.imageview_grid_one_stub;
   int gridTwoStubId =
       isPagerFragment ? R.id.imageview_grid_two_pager_stub : R.id.imageview_grid_two_stub;
   int gridThreeStubId =
       isPagerFragment ? R.id.imageview_grid_three_pager_stub : R.id.imageview_grid_three_stub;
   if (artistImages.size() > 2) {
     v = view.findViewById(gridOneResId);
     if (v != null) {
       v.setVisibility(View.GONE);
     }
     v = view.findViewById(gridTwoResId);
     if (v != null) {
       v.setVisibility(View.GONE);
     }
     v = TomahawkUtils.ensureInflation(view, gridThreeStubId, gridThreeResId);
     v.setVisibility(View.VISIBLE);
     TomahawkUtils.loadImageIntoImageView(
         TomahawkApp.getContext(),
         (ImageView) v.findViewById(R.id.imageview1),
         artistImages.get(0),
         Image.getLargeImageSize(),
         false);
     TomahawkUtils.loadImageIntoImageView(
         TomahawkApp.getContext(),
         (ImageView) v.findViewById(R.id.imageview2),
         artistImages.get(1),
         Image.getSmallImageSize(),
         false);
     TomahawkUtils.loadImageIntoImageView(
         TomahawkApp.getContext(),
         (ImageView) v.findViewById(R.id.imageview3),
         artistImages.get(2),
         Image.getSmallImageSize(),
         false);
   } else if (artistImages.size() > 1) {
     v = view.findViewById(gridOneResId);
     if (v != null) {
       v.setVisibility(View.GONE);
     }
     v = view.findViewById(gridThreeResId);
     if (v != null) {
       v.setVisibility(View.GONE);
     }
     v = TomahawkUtils.ensureInflation(view, gridTwoStubId, gridTwoResId);
     v.setVisibility(View.VISIBLE);
     TomahawkUtils.loadImageIntoImageView(
         TomahawkApp.getContext(),
         (ImageView) v.findViewById(R.id.imageview1),
         artistImages.get(0),
         Image.getLargeImageSize(),
         false);
     TomahawkUtils.loadImageIntoImageView(
         TomahawkApp.getContext(),
         (ImageView) v.findViewById(R.id.imageview2),
         artistImages.get(1),
         Image.getSmallImageSize(),
         false);
   } else {
     v = view.findViewById(gridTwoResId);
     if (v != null) {
       v.setVisibility(View.GONE);
     }
     v = view.findViewById(gridThreeResId);
     if (v != null) {
       v.setVisibility(View.GONE);
     }
     v = TomahawkUtils.ensureInflation(view, gridOneStubId, gridOneResId);
     v.setVisibility(View.VISIBLE);
     if (artistImages.size() > 0) {
       TomahawkUtils.loadImageIntoImageView(
           TomahawkApp.getContext(),
           (ImageView) v.findViewById(R.id.imageview1),
           artistImages.get(0),
           Image.getLargeImageSize(),
           false);
     } else {
       TomahawkUtils.loadDrawableIntoImageView(
           TomahawkApp.getContext(),
           (ImageView) v.findViewById(R.id.imageview1),
           R.drawable.album_placeholder_grid);
     }
   }
   if (height > 0) {
     v.getLayoutParams().height = height;
   }
 }