Android Open Source - HapiPodcastJ Episode Icons






From Project

Back to project page HapiPodcastJ.

License

The source code is released under:

GNU General Public License

If you think the Android project HapiPodcastJ listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package info.xuluan.podcast;
//from  w ww .  j a v  a  2  s  .c o m
import info.xuluan.podcast.provider.ItemColumns;
import info.xuluan.podcast.utils.IconCursorAdapter;
import info.xuluan.podcastj.R;

import java.util.HashMap;

import android.content.Context;
import android.database.Cursor;

public class EpisodeIcons {

  private static HashMap<Integer, Integer> mIconMap;
  public static HashMap<Integer, Integer> mKeepIconMap;
  
  static {
    mIconMap = new HashMap<Integer, Integer>();
    initFullIconMap(mIconMap);
    
    mKeepIconMap = new HashMap<Integer, Integer>();
    mKeepIconMap.put(1, R.drawable.keep);    
    mKeepIconMap.put(IconCursorAdapter.ICON_DEFAULT_ID, R.drawable.blank);   //anything other than KEEP  
  }
  
  public static void initFullIconMap(HashMap<Integer,Integer> iconMap) {
    //green
    iconMap.put(ItemColumns.ITEM_STATUS_UNREAD, R.drawable.feed_new);
    iconMap.put(ItemColumns.ITEM_STATUS_READ, R.drawable.feed_viewed);

    //blue
    iconMap.put(ItemColumns.ITEM_STATUS_DOWNLOAD_PAUSE, R.drawable.download_pause);
    iconMap.put(ItemColumns.ITEM_STATUS_DOWNLOAD_QUEUE, R.drawable.download_wait);
    iconMap.put(ItemColumns.ITEM_STATUS_DOWNLOADING_NOW, R.drawable.downloading);

    //orange
    iconMap.put(ItemColumns.ITEM_STATUS_NO_PLAY, R.drawable.playable);
    iconMap.put(ItemColumns.ITEM_STATUS_PLAY_READY, R.drawable.play_ready);
    iconMap.put(ItemColumns.ITEM_STATUS_PLAYING_NOW, R.drawable.playing);
    iconMap.put(ItemColumns.ITEM_STATUS_PLAY_PAUSE, R.drawable.play_pause);
    
    //red
    iconMap.put(ItemColumns.ITEM_STATUS_PLAYED, R.drawable.played);
    //iconMap.put(ItemColumns.ITEM_STATUS_KEEP, R.drawable.keep);
      //we now show KEEP status with a separate icon, based on separate DB flag

    //red
    iconMap.put(ItemColumns.ITEM_STATUS_DELETE, R.drawable.delete);
    iconMap.put(ItemColumns.ITEM_STATUS_DELETED, R.drawable.deleted);

    iconMap.put(IconCursorAdapter.ICON_DEFAULT_ID, R.drawable.status_unknown);    //default for unknowns
  }
  
  public static IconCursorAdapter listItemCursorAdapter(Context context, Cursor cursor) {
    IconCursorAdapter.FieldHandler[] fields = {
        IconCursorAdapter.defaultTextFieldHandler,
        IconCursorAdapter.defaultTextFieldHandler,
        IconCursorAdapter.defaultTextFieldHandler,
        new IconCursorAdapter.IconFieldHandler(mIconMap),
        new IconCursorAdapter.IconFieldHandler(mKeepIconMap)
    };
    return new IconCursorAdapter(context, R.layout.list_item, cursor,
        new String[] { ItemColumns.TITLE, ItemColumns.SUB_TITLE,
            ItemColumns.DURATION, ItemColumns.STATUS, ItemColumns.KEEP },
        new int[] { R.id.text1, R.id.text2, R.id.text3, R.id.icon, R.id.keep_icon },
        fields);
  }

  public static IconCursorAdapter channelListItemCursorAdapter(Context context, Cursor cursor) {
    IconCursorAdapter.FieldHandler[] fields = {
        IconCursorAdapter.defaultTextFieldHandler,
        new IconCursorAdapter.IconFieldHandler(mIconMap),
        new IconCursorAdapter.IconFieldHandler(mKeepIconMap)
    };
    return new IconCursorAdapter(context, R.layout.channel_list_item, cursor,
        new String[] { ItemColumns.TITLE, ItemColumns.STATUS, ItemColumns.KEEP },
        new int[] { R.id.text1, R.id.icon, R.id.keep_icon },
        fields);
  }

  public static int mapToIcon(int status) {
    return mapToIcon(status,mIconMap);
  }
  
  public static int mapToIcon(int key, HashMap<Integer,Integer> iconMap) {
    Integer iconI = iconMap.get(key);
    if (iconI==null)
      iconI = iconMap.get(IconCursorAdapter.ICON_DEFAULT_ID);  //look for default value in map
    int icon = (iconI!=null)?
      iconI.intValue():
      R.drawable.status_unknown;  //Use this icon when not in map and no map default.
        //This allows going back to a previous version after data has been
        //added in a new version with additional status codes.
    return icon;
  }
  
}




Java Source Code List

info.xuluan.podcast.AddChannelActivity.java
info.xuluan.podcast.BackupChannelsActivity.java
info.xuluan.podcast.ChannelActivity.java
info.xuluan.podcast.ChannelDetailsActivity.java
info.xuluan.podcast.ChannelsActivity.java
info.xuluan.podcast.DownloadActivity.java
info.xuluan.podcast.EpisodeDetailsActivity.java
info.xuluan.podcast.EpisodeIcons.java
info.xuluan.podcast.EpisodesActivity.java
info.xuluan.podcast.FlingGestureDetector.java
info.xuluan.podcast.Flingable.java
info.xuluan.podcast.HapiActivity.java
info.xuluan.podcast.HapiListActivity.java
info.xuluan.podcast.HapiPreferenceActivity.java
info.xuluan.podcast.HomeActivity.java
info.xuluan.podcast.MainActivity.java
info.xuluan.podcast.PlayerActivity.java
info.xuluan.podcast.PodcastBaseActivity.java
info.xuluan.podcast.PodcastTab.java
info.xuluan.podcast.Pref.java
info.xuluan.podcast.SearchActivity.java
info.xuluan.podcast.StartupActivity.java
info.xuluan.podcast.TabsHelper.java
info.xuluan.podcast.actionbar.ActionBarHelperBase.java
info.xuluan.podcast.actionbar.ActionBarHelperHoneycomb.java
info.xuluan.podcast.actionbar.ActionBarHelperICS.java
info.xuluan.podcast.actionbar.ActionBarHelper.java
info.xuluan.podcast.actionbar.SimpleMenuItem.java
info.xuluan.podcast.actionbar.SimpleMenu.java
info.xuluan.podcast.fetcher.FeedFetcher.java
info.xuluan.podcast.fetcher.Response.java
info.xuluan.podcast.parser.FeedHandler.java
info.xuluan.podcast.parser.FeedParserHandler.java
info.xuluan.podcast.parser.FeedParserListenerInterface.java
info.xuluan.podcast.parser.FeedParserListener.java
info.xuluan.podcast.parser.FeedParser.java
info.xuluan.podcast.parser.OPMLParserHandler.java
info.xuluan.podcast.parser.SearchItem.java
info.xuluan.podcast.provider.FeedItem.java
info.xuluan.podcast.provider.ItemColumns.java
info.xuluan.podcast.provider.PodcastOpenHelper.java
info.xuluan.podcast.provider.PodcastProvider.java
info.xuluan.podcast.provider.SubscriptionColumns.java
info.xuluan.podcast.provider.Subscription.java
info.xuluan.podcast.service.PlayerService.java
info.xuluan.podcast.service.PodcastService.java
info.xuluan.podcast.utils.DialogMenu.java
info.xuluan.podcast.utils.FileUtils.java
info.xuluan.podcast.utils.IconCursorAdapter.java
info.xuluan.podcast.utils.LabeledFrame.java
info.xuluan.podcast.utils.LockHandler.java
info.xuluan.podcast.utils.Log.java
info.xuluan.podcast.utils.SDCardMgr.java
info.xuluan.podcast.utils.StrUtils.java
info.xuluan.podcast.utils.ZipExporter.java
info.xuluan.podcast.utils.ZipImporter.java