Android Open Source - HapiPodcastJ Item Columns






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.provider;
/*w w w .j a v  a 2 s .  c o m*/
import java.text.SimpleDateFormat;
import java.util.Date;

import android.content.ContentValues;
import android.database.SQLException;
import android.net.Uri;
import android.provider.BaseColumns;

public class ItemColumns implements BaseColumns {

  //green
  public static final int ITEM_STATUS_UNREAD = 0;
  public static final int ITEM_STATUS_READ = 1;
  public static final int ITEM_STATUS_MAX_READING_VIEW = 10;

  //blue
  public static final int ITEM_STATUS_DOWNLOAD_PAUSE = 15;
  public static final int ITEM_STATUS_DOWNLOAD_QUEUE = 20;
  public static final int ITEM_STATUS_DOWNLOADING_NOW = 21;
  public static final int ITEM_STATUS_MAX_DOWNLOADING_VIEW = 30;

  //orange
  public static final int ITEM_STATUS_NO_PLAY = 50;
  public static final int ITEM_STATUS_PLAY_READY = 51;
  public static final int ITEM_STATUS_PLAYING_NOW = 52;
  public static final int ITEM_STATUS_PLAY_PAUSE = 53;

  //KEEP status has been replaced by the KEEP database column starting in DB version 13,
  //so is no longer used except for upgrading from version 12, which strings are all in this file.
  private static final int ITEM_STATUS_KEEP = 63;
  
  //red
  public static final int ITEM_STATUS_PLAYED = 66;
  public static final int ITEM_STATUS_MAX_PLAYLIST_VIEW = 100;

  //red
  public static final int ITEM_STATUS_MIN_DELETE = 190;
  public static final int ITEM_STATUS_DELETE = 195;  
  public static final int ITEM_STATUS_DELETED = 200;

  public static final Uri URI = Uri.parse("content://"
      + PodcastProvider.AUTHORITY + "/items");

  public static final String TABLE_NAME = "item";

  // feed
  public static final String SUBS_ID = "subs_id";

  public static final String TITLE = "title";

  public static final String AUTHOR = "author";

  public static final String DATE = "date";

  public static final String LAST_UPDATE = "last_update";

  public static final String CONTENT = "content";

  // download
  public static final String STATUS = "status";

  public static final String URL = "url";

  public static final String RESOURCE = "res";

  public static final String DURATION = "duration";

  public static final String LENGTH = "length";

  public static final String OFFSET = "offset";

  public static final String PATHNAME = "path";

  public static final String FAIL_COUNT = "fail";

  // play
  public static final String MEDIA_URI = "uri";

  public static final String SUB_TITLE = "sub_title";
  public static final String CREATED = "created";
  public static final String TYPE = "audio_type";
  public static final String KEEP = "keep";

  public static final String[] ALL_COLUMNS = { _ID, SUBS_ID, TITLE, AUTHOR,
      DATE, LAST_UPDATE, CONTENT, STATUS, URL, RESOURCE, DURATION,
      LENGTH, OFFSET, PATHNAME, FAIL_COUNT, MEDIA_URI, SUB_TITLE,
      CREATED, TYPE, KEEP };

  public static final String DEFAULT_SORT_ORDER = CREATED + " DESC";

  public static final String sql_create_table = "CREATE TABLE " 
    + TABLE_NAME + " (" 
    + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " 
    + SUBS_ID + " INTEGER, " 
    + TITLE + " VARCHAR(128), " 
    + AUTHOR + " VARCHAR(128), " 
    + DATE + " VARCHAR(64), " 
    + LAST_UPDATE + " INTEGER, " 
    + CONTENT + " TEXT, " 
    + STATUS + " INTEGER, " 
    + URL + " VARCHAR(1024), " 
    + RESOURCE + " VARCHAR(1024), " 
    + DURATION + " VARCHAR(16), " 
    + LENGTH + " INTEGER, " 
    + OFFSET + " INTEGER, "
    + PATHNAME + " VARCHAR(128), " 
    + FAIL_COUNT + " INTEGER, "
    + MEDIA_URI + " VARCHAR(128), " 
    + SUB_TITLE + " VARCHAR(128), "
    + TYPE + " VARCHAR(64), " 
    + CREATED + " INTEGER, "
    + KEEP + " INTEGER NOT NULL DEFAULT 0"
    + ");";

  //To upgrade from database version 12 to version 13
  public static final String sql_upgrade_table_add_keep_column = "ALTER TABLE "
      + TABLE_NAME + " ADD COLUMN " + KEEP + " INTEGER NOT NULL DEFAULT 0;";
  public static final String sql_populate_keep_from_status =
      "UPDATE " + TABLE_NAME + " SET " + KEEP + " = 1 "
      + " WHERE " + STATUS + "=" + ITEM_STATUS_KEEP;
  public static final String sql_change_keep_status_to_played =
      "UPDATE " + TABLE_NAME + " SET " + STATUS + "=" + ITEM_STATUS_PLAYED
      + " WHERE " + STATUS + "=" + ITEM_STATUS_KEEP;
  
  public static final String sql_index_item_res = "CREATE INDEX IDX_"
      + TABLE_NAME + "_" + RESOURCE + " ON " + TABLE_NAME + " ("
      + RESOURCE + ");";

  public static final String sql_index_item_created = "CREATE INDEX IDX_"
      + TABLE_NAME + "_" + LAST_UPDATE + " ON " + TABLE_NAME + " ("
      + LAST_UPDATE + ");";

  public static ContentValues checkValues(ContentValues values, Uri uri) {
    if (values.containsKey(SUBS_ID) == false) {
      throw new SQLException(
          "Fail to insert row because SUBS_ID is needed " + uri);
    }

    if (values.containsKey(URL) == false) {
      values.put(URL, "");
    }

    if (values.containsKey(TITLE) == false) {
      values.put(TITLE, "unknow");
    }

    if (values.containsKey(AUTHOR) == false) {
      values.put(AUTHOR, "");
    }

    Long now = Long.valueOf(System.currentTimeMillis());

    if (values.containsKey(LAST_UPDATE) == false) {
      values.put(LAST_UPDATE, now);
    }

    if (values.containsKey(DATE) == false) {
      SimpleDateFormat formatter = new SimpleDateFormat(
          "EEE, dd MMM yyyy HH:mm:ss Z");
      Date currentTime = new Date();
      values.put(DATE, formatter.format(currentTime));
    }

    if (values.containsKey(CONTENT) == false) {
      values.put(CONTENT, "");
    }

    if (values.containsKey(STATUS) == false) {
      values.put(STATUS, ITEM_STATUS_UNREAD);
    }

    if (values.containsKey(RESOURCE) == false) {
      throw new SQLException(
          "Fail to insert row because RESOURCE is needed " + uri);
    }

    if (values.containsKey(DURATION) == false) {
      values.put(DURATION, "");
    }

    if (values.containsKey(LENGTH) == false) {
      values.put(LENGTH, 0);
    }

    if (values.containsKey(OFFSET) == false) {
      values.put(OFFSET, 0);
    }

    if (values.containsKey(PATHNAME) == false) {
      values.put(PATHNAME, "");
    }

    if (values.containsKey(FAIL_COUNT) == false) {
      values.put(FAIL_COUNT, 0);
    }

    if (values.containsKey(MEDIA_URI) == false) {
      values.put(MEDIA_URI, "");
    }

    if (values.containsKey(SUB_TITLE) == false) {
      values.put(SUB_TITLE, "");
    }

    if (values.containsKey(CREATED) == false) {
      values.put(CREATED, now);
    }
    if (values.containsKey(TYPE) == false) {
      values.put(TYPE, "");
    }
    if (values.containsKey(KEEP) == false) {
      values.put(KEEP, 0);
    }
    return values;
  }

}




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