// Path: app/src/main/java/com/mitechlt/tvportal/play/databases/RecentTable.java
// public class RecentTable extends SQLiteOpenHelper {
// 
//     public static final String TABLE_RECENTS = "recents";
//     public static final String COLUMN_ID = "_id";
//     public static final String COLUMN_TYPE = "type";
//     public static final String COLUMN_TITLE = "title";
//     public static final String COLUMN_LINK = "link";
//     public static final String COLUMN_SEASON = "season";
//     public static final String COLUMN_EPISODE = "episode";
//     public static final String COLUMN_IMAGE = "image";
//     public static final String COLUMN_NUM_SEASONS = "num_seasons";
//     public static final String COLUMN_NUM_EPISODES = "num_episodes";
//     public static final String COLUMN_RATING = "rating";
// 
//     private static final String DATABASE_NAME = "recents.db";
//     private static final int DATABASE_VERSION = 2;
// 
//     private static final String DATABASE_CREATE = "create table "
//             + TABLE_RECENTS + "("
//             + COLUMN_ID + " integer primary key autoincrement, "
//             + COLUMN_TITLE + " text not null, "
//             + COLUMN_LINK + " text not null, "
//             + COLUMN_TYPE + " text not null, "
//             + COLUMN_NUM_EPISODES + " text not null, "
//             + COLUMN_NUM_SEASONS + " text not null, "
//             + COLUMN_EPISODE + " text, "
//             + COLUMN_SEASON + " text, "
//             + COLUMN_IMAGE + " text not null, "
//             + COLUMN_RATING + " integer);";
// 
//     public RecentTable(Context context) {
//         super(context, DATABASE_NAME, null, DATABASE_VERSION);
//     }
// 
//     @Override
//     public void onCreate(SQLiteDatabase database) {
//         database.execSQL(DATABASE_CREATE);
//     }
// 
//     @Override
//     public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
//         Log.w(RecentTable.class.getName(),
//                 "Upgrading database from version " + oldVersion + " to "
//                         + newVersion + ", which will destroy all old data"
//         );
//         db.execSQL("DROP TABLE IF EXISTS " + TABLE_RECENTS);
//         onCreate(db);
//     }
// 
// }


import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.database.Cursor;
import android.preference.PreferenceManager;
import android.support.v4.widget.SimpleCursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.mitechlt.tvportal.play.R;
import com.mitechlt.tvportal.play.databases.RecentTable;
import com.squareup.picasso.Picasso;

            String type = mRecentCursor.getString(mTypeIdx);
            if (type != null && type.equals("movie")) {
                mData[i].typeBackgroundColor = res.getColor(R.color.holo_blue);
                type = "Movie";
            } else if (type != null && type.equals("tvshow")) {
                mData[i].typeBackgroundColor = res.getColor(R.color.holo_green);
                StringBuilder seasonString = new StringBuilder();
                seasonString.append("S");
                if (seasonNum < 10) {
                    seasonString.append("0");
                }
                seasonString.append(seasonNum);
                mData[i].season = seasonString.toString();
                StringBuilder episodeString = new StringBuilder();
                episodeString.append("E");
                if (episodeNum < 10) {
                    episodeString.append("0");
                }
                episodeString.append(episodeNum);
                mData[i].episode = episodeString.toString();
                type = "TV Show";

            }
            mData[i].type = type;
        }
    }

    private void getColumnIndices(Cursor cursor) {
        if (cursor != null && !cursor.isClosed()) {
// Path: app/src/main/java/com/mitechlt/tvportal/play/databases/RecentTable.java
// public class RecentTable extends SQLiteOpenHelper {
// 
//     public static final String TABLE_RECENTS = "recents";
//     public static final String COLUMN_ID = "_id";
//     public static final String COLUMN_TYPE = "type";
//     public static final String COLUMN_TITLE = "title";
//     public static final String COLUMN_LINK = "link";
//     public static final String COLUMN_SEASON = "season";
//     public static final String COLUMN_EPISODE = "episode";
//     public static final String COLUMN_IMAGE = "image";
//     public static final String COLUMN_NUM_SEASONS = "num_seasons";
//     public static final String COLUMN_NUM_EPISODES = "num_episodes";
//     public static final String COLUMN_RATING = "rating";
// 
//     private static final String DATABASE_NAME = "recents.db";
//     private static final int DATABASE_VERSION = 2;
// 
//     private static final String DATABASE_CREATE = "create table "
//             + TABLE_RECENTS + "("
//             + COLUMN_ID + " integer primary key autoincrement, "
//             + COLUMN_TITLE + " text not null, "
//             + COLUMN_LINK + " text not null, "
//             + COLUMN_TYPE + " text not null, "
//             + COLUMN_NUM_EPISODES + " text not null, "
//             + COLUMN_NUM_SEASONS + " text not null, "
//             + COLUMN_EPISODE + " text, "
//             + COLUMN_SEASON + " text, "
//             + COLUMN_IMAGE + " text not null, "
//             + COLUMN_RATING + " integer);";
// 
//     public RecentTable(Context context) {
//         super(context, DATABASE_NAME, null, DATABASE_VERSION);
//     }
// 
//     @Override
//     public void onCreate(SQLiteDatabase database) {
//         database.execSQL(DATABASE_CREATE);
//     }
// 
//     @Override
//     public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
//         Log.w(RecentTable.class.getName(),
//                 "Upgrading database from version " + oldVersion + " to "
//                         + newVersion + ", which will destroy all old data"
//         );
//         db.execSQL("DROP TABLE IF EXISTS " + TABLE_RECENTS);
//         onCreate(db);
//     }
// 
// }


// Path: app/src/main/java/com/mitechlt/tvportal/play/adapters/RecentAdapter.java
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.database.Cursor;
import android.preference.PreferenceManager;
import android.support.v4.widget.SimpleCursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.mitechlt.tvportal.play.R;
import com.mitechlt.tvportal.play.databases.RecentTable;
import com.squareup.picasso.Picasso;


            String type = mRecentCursor.getString(mTypeIdx);
            if (type != null && type.equals("movie")) {
                mData[i].typeBackgroundColor = res.getColor(R.color.holo_blue);
                type = "Movie";
            } else if (type != null && type.equals("tvshow")) {
                mData[i].typeBackgroundColor = res.getColor(R.color.holo_green);
                StringBuilder seasonString = new StringBuilder();
                seasonString.append("S");
                if (seasonNum < 10) {
                    seasonString.append("0");
                }
                seasonString.append(seasonNum);
                mData[i].season = seasonString.toString();
                StringBuilder episodeString = new StringBuilder();
                episodeString.append("E");
                if (episodeNum < 10) {
                    episodeString.append("0");
                }
                episodeString.append(episodeNum);
                mData[i].episode = episodeString.toString();
                type = "TV Show";

            }
            mData[i].type = type;
        }
    }

    private void getColumnIndices(Cursor cursor) {
        if (cursor != null && !cursor.isClosed()) {
            mTitleIdx = cursor.getColumnIndexOrThrow(RecentTable.COLUMN_TITLE);