Android Open Source - FlibityBoop Critics






From Project

Back to project page FlibityBoop.

License

The source code is released under:

Apache License

If you think the Android project FlibityBoop 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

/**
 * IFT2905 : Interface personne machine//  w w  w  .j  a  va 2  s .c  o  m
 * Projet de session: FlibityBoop.
 * Team: Vincent CABELI, Henry LIM, Pamela MEHANNA, Emmanuel NOUTAHI, Olivier TASTET
 * @author Emmanuel Noutahi, Vincent Cabeli
 */
package com.maclandrol.flibityboop;

import java.io.Serializable;

import org.json.JSONObject;

import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.webkit.URLUtil;

/**
 * Classe Critics, contient les commentaires et les critiques sur un mdia ainsi que les mthodes
 * pour avoir accs aux informations relatives  ces critiques
 */
public class Critics implements Parcelable, Serializable {

  private static final long serialVersionUID = -4069392063214205777L;
  String author, comment, url, date;

  public Critics(String author, String comment, String url, String date) {

    this.author = author;
    this.comment = comment;
    this.url = url;
    this.date = date;
  }
  

  public Critics(JSONObject c) {
    // setting author
    String author = null, date = null, url = null, comment = null;
    if (c != null) {
      if (c.has("author"))
        author = c.optString("author");
      else if (c.has("critic"))
        author = c.optString("critic");

      // setting quote
      if (c.has("content"))
        comment = c.optString("content");
      else if (c.has("quote"))
        comment = c.optString("quote");

      // setting url
      if (c.has("url"))
        url = c.optString("url");
      else if (c.has("links"))
        url = c.optJSONObject("links").optString("review");

      // setting date
      if (c.has("date"))
        date = c.optString("date");
    }

    this.author = author;
    this.comment = comment;
    this.date = date;
    this.url = url;
  }

  public Critics(String author, String comment, String date) {
    this(author, comment, null , date);
  }

  public Critics(String author, String comment) {
    this(author, comment, null, null);
  }

  public Critics(Parcel source) {
    this.author= source.readString();
    this.comment = source.readString();
    this.url = source.readString();
    this.date = source.readString();
  }


  public boolean isPrintable() {
    return this.author != null && this.comment != null;
  }

  public boolean hasDate() {
    return this.date != null;
  }

  public boolean hasURL() {
    return  URLUtil.isValidUrl(url);
  }

  public Uri getURL(){
    return Uri.parse(this.url);
  }
  
  public String getDomain(){
    try {
      Uri uri = Uri.parse(url);
      String domain = uri.getHost();
      return domain.startsWith("www.") ? domain.substring(4) : domain;
    } catch (Exception e) {
      return null;
    }
  }

  public String getAuthor() {
    return author;
  }

  public String getComment() {
    return comment;
  }
  
  public String toString(){
    if(this.isPrintable())
      return "\nAuthor : "+this.author +"\nComment : "+this.comment;
    return "";
  }

  @Override
  public int describeContents() {
    return 0;
  }

  @Override
  public void writeToParcel(Parcel dest, int flags) {
    dest.writeString(author);
    dest.writeString(comment);
    dest.writeString(url);
    dest.writeString(date);
  }
  
  public static final Parcelable.Creator<Critics> CREATOR = new Creator<Critics>(){

    @Override
    public Critics createFromParcel(Parcel source) {
      return new Critics(source);
    }

    @Override
    public Critics[] newArray(int size) {
      return new Critics[size];
    }
    
    
  };
}




Java Source Code List

com.maclandrol.flibityboop.API.java
com.maclandrol.flibityboop.BaseActivity.java
com.maclandrol.flibityboop.Critics.java
com.maclandrol.flibityboop.DBHelperMedia.java
com.maclandrol.flibityboop.FavoriteActivity.java
com.maclandrol.flibityboop.FileCache.java
com.maclandrol.flibityboop.ImageLoader.java
com.maclandrol.flibityboop.MainActivity.java
com.maclandrol.flibityboop.MediaAdapter.java
com.maclandrol.flibityboop.MediaContentProvider.java
com.maclandrol.flibityboop.MediaDetails.java
com.maclandrol.flibityboop.MediaInfos.java
com.maclandrol.flibityboop.Media.java
com.maclandrol.flibityboop.MemoryCache.java
com.maclandrol.flibityboop.MovieFavoriteCursorAdapter.java
com.maclandrol.flibityboop.MovieListFragment.java
com.maclandrol.flibityboop.RottenTomatoes.java
com.maclandrol.flibityboop.SearchActivity.java
com.maclandrol.flibityboop.SearchSuggestionProvider.java
com.maclandrol.flibityboop.SectionListAdapter.java
com.maclandrol.flibityboop.SettingActivity.java
com.maclandrol.flibityboop.ShowFavoriteCursorAdapter.java
com.maclandrol.flibityboop.TVListFragment.java
com.maclandrol.flibityboop.Tastekid.java
com.maclandrol.flibityboop.TheMovieDB.java
com.maclandrol.flibityboop.TraktTV.java
com.maclandrol.flibityboop.Utils.java