コード例 #1
0
 public static void setPicture(Context context, Media m, Bitmap p) {
   Log.d(TAG, "Setting new picture for " + m.getTitle());
   try {
     MediaDatabase.getInstance(context)
         .updateMedia(m.getLocation(), MediaDatabase.mediaColumn.MEDIA_PICTURE, p);
   } catch (SQLiteFullException e) {
     Log.d(TAG, "SQLiteFullException while setting picture");
   }
   m.setPictureParsed(true);
 }
コード例 #2
0
 public static Bitmap getPictureFromCache(Media media) {
   // mPicture is not null only if passed through
   // the ctor which is deprecated by now.
   Bitmap b = media.getPicture();
   if (b == null) {
     BitmapCache cache = BitmapCache.getInstance();
     Bitmap picture = cache.getBitmapFromMemCache(media.getLocation());
     if (picture == null) {
       /* Not in memcache:
        * serving the file from the database and
        * adding it to the memcache for later use.
        */
       Context c = VLCApplication.getAppContext();
       picture = MediaDatabase.getInstance(c).getPicture(c, media.getLocation());
       cache.addBitmapToMemCache(media.getLocation(), picture);
     }
     return picture;
   } else {
     return b;
   }
 }
コード例 #3
0
  /**
   * Returns a single list containing all media, along with the position of the first media in
   * 'position' in the _new_ single list.
   *
   * @param outputList The list to be written to.
   * @param position Position to retrieve in to _this_ adapter.
   * @return The position of 'position' in the new single list, or 0 if not found.
   */
  public int getListWithPosition(List<String> outputList, int position) {
    int outputPosition = 0;
    outputList.clear();
    for (int i = 0; i < mItems.size(); i++) {
      if (!mItems.get(i).mIsSeparator) {
        if (position == i && !mItems.get(i).mMediaList.isEmpty())
          outputPosition = outputList.size();

        for (Media k : mItems.get(i).mMediaList) {
          outputList.add(k.getLocation());
        }
      }
    }
    return outputPosition;
  }
コード例 #4
0
 /**
  * Remove all the reference to a media in the list items. Remove also all the list items that
  * contain only this media.
  *
  * @param media the media to remove
  */
 public void removeMedia(Media media) {
   for (int i = 0; i < mItems.size(); ++i) {
     ListItem item = mItems.get(i);
     if (item.mMediaList == null) continue;
     for (int j = 0; j < item.mMediaList.size(); ++j)
       if (item.mMediaList.get(j).getLocation().equals(media.getLocation())) {
         item.mMediaList.remove(j);
         j--;
       }
     if (item.mMediaList.isEmpty() && !item.mIsSeparator) {
       mItems.remove(i);
       i--;
     }
   }
   notifyDataSetChanged();
 }