Android Open Source - Flippy-Radio Pls Entry






From Project

Back to project page Flippy-Radio.

License

The source code is released under:

Apache License

If you think the Android project Flippy-Radio 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 com.bitflippersanonymous.flippy.domain;
//  ww  w .j  ava2s .c  o m
import com.bitflippersanonymous.flippy.util.Util;

import java.sql.Time;
import java.util.HashMap;

import android.content.ContentValues;
import android.database.Cursor;
import android.text.format.DateFormat;

public class PlsEntry /*implements Parcelable*/ {
  
  public static final String PLSENTRY = Util.PACKAGE + ".PLSENTRY";
  public enum Tags { title, verses, description, enclosure, author, pubDate, enqueue, keywords }
    
  private int mId;
  private final HashMap<Tags, String> mData;
  public PlsEntry(HashMap<Tags, String> data) {
    mData = data;
    if ( mData.containsKey(Tags.title) ) {
      String bybar[] = get(Tags.title).split("[|]");
      String byphen[] = bybar[0].split(" - ", -1);
      mData.put(Tags.title, byphen[0]);
      mData.put(Tags.verses, byphen[1]);
    }
  }
  
  public PlsEntry(HashMap<Tags, String> data, int id) {
    mId = id;
    mData = data;
  }

  public int getId() {
    return mId;
  }
  
  public String get(Tags tag) {
    return mData.get(tag);
  }
  
  // Into DB
  public ContentValues createEntryContentValues() {
    ContentValues values = new ContentValues();
    for ( Tags tag : Tags.values() ) {
      switch ( tag ) {
      case keywords:
        continue;
      case enqueue:
        values.put(tag.name(), false);
        break;
      case pubDate:
        values.put(tag.name(), Time.parse(get(tag)));
        break;
      default:
        values.put(tag.name(), get(tag));
        break;
      }
    }
    return values;
  }
  
  // Outof DB
  public static PlsEntry cursorToEntry(Cursor cursor) {
    if ( cursor.getCount() == 0 )
      return null;
    
    int id = cursor.getInt(0);
    HashMap<Tags, String> data = new HashMap<Tags, String>();
    String[] colNames = cursor.getColumnNames();
    for ( int i = 0; i< cursor.getColumnCount(); i++ ) {
      Tags tag = null;
      try { 
        tag = Tags.valueOf(colNames[i]);
        data.put(tag, cursor.getString(i));
      } catch(IllegalArgumentException ex) { }
    }
    return new PlsEntry(data, id);
  }

  public boolean getEnqueue() {
    return get(Tags.enqueue).equals("1");
  }
  
  /*
  @Override
  public int describeContents() {
    return 0;
  }
  
  @Override
  public void writeToParcel(Parcel dest, int flags) {
    dest.writeString(mFile);
    dest.writeString(mTitle);
  }
  
  public PlsEntry(Parcel in) {
        mFile = in.readString();
        mTitle = in.readString();
  }
  
  public static final Parcelable.Creator<PlsEntry> CREATOR = new Parcelable.Creator<PlsEntry>() {
    public PlsEntry createFromParcel(Parcel in) {
      return new PlsEntry(in);
    }
    public PlsEntry[] newArray(int size) {
      return new PlsEntry[size];
    }
  };
  */
}




Java Source Code List

.PlsAdapter.java
com.bitflippersanonymous.flippy.activity.FlippyAboutActivity.java
com.bitflippersanonymous.flippy.activity.FlippyBaseActivity.java
com.bitflippersanonymous.flippy.activity.FlippyBrowseActivity.java
com.bitflippersanonymous.flippy.activity.FlippyInfoActivity.java
com.bitflippersanonymous.flippy.activity.FlippyMainActivity.java
com.bitflippersanonymous.flippy.activity.FlippyQueueActivity.java
com.bitflippersanonymous.flippy.activity.FlippySearchActivity.java
com.bitflippersanonymous.flippy.activity.FlippySettingsActivity.java
com.bitflippersanonymous.flippy.db.FlippyDatabaseAdapter.java
com.bitflippersanonymous.flippy.db.FlippyDatabaseHelper.java
com.bitflippersanonymous.flippy.domain.EntryView.java
com.bitflippersanonymous.flippy.domain.PlsDbAdapter.java
com.bitflippersanonymous.flippy.domain.PlsEntry.java
com.bitflippersanonymous.flippy.domain.PodcastParser.java
com.bitflippersanonymous.flippy.domain.SimpleCursorLoader.java
com.bitflippersanonymous.flippy.service.FlippyPlayerService.java
com.bitflippersanonymous.flippy.util.ActivitySwipeDetector.java
com.bitflippersanonymous.flippy.util.Util.java