Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mysite.models;
- public class Section
- {
- public static final String TABLE = "sections";
- public static final String COLUMN_ID = "_id";
- public static final String COLUMN_TITLE = "title";
- public static final String COLUMN_LINK = "link";
- public static final String COLUMN_SLUG = "slug";
- public static final String COLUMN_LASTUPDATED = "last_updated";
- public long id;
- public String title;
- public String link;
- public String slug;
- public String last_updated;
- public static final int INDEX_TITLE = 0;
- public static final int INDEX_URL = 1;
- public static final int INDEX_SLUG = 2;
- //Database creation sql statement
- public static final String TABLE_CREATE = "CREATE TABLE "
- + Section.TABLE + "( "
- + Section.COLUMN_ID + " INTEGER primary key autoincrement, "
- + Section.COLUMN_SLUG + " TEXT, "
- + Section.COLUMN_LASTUPDATED + " TEXT"
- + ");";
- /*+ ") VALUES "
- + "('Top News', " + "'http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpichomepagenewsandroid.csp', " + "'top'), "
- + "('Utah News', " + "'http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicnewspageandroid.csp', " + "'utah'), "
- + "('Sports', " + "'http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicsportspageandroid.csp', " + "'sports'), "
- + "('Opinion', " + "'http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicopinionpageandroid.csp', " + "'opinion'), "
- + "('Money', " + "'http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicmoneypageandroid.csp', " + "'money'), "
- + "('Mix', " + "'http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicmixpageandroid.csp', " + "'mix'), "
- + "('Obituaries', " + "'http://img.mysite.com/getObits_android.php', " + "'obits'), "
- + "('Weather', " + "'http://www.mysite.com/mysite/weather.php', " + "'weather')"
- + "";*/
- //name, url, feed
- public static final String[] TOP = {
- "Top News",
- "http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpichomepagenewsandroid.csp",
- "top"
- };
- public static final String[] UTAH = {
- "Local News",
- "http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicnewspageandroid.csp",
- "utah"
- };
- public static final String[] SPORTS = {
- "Sports",
- "http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicsportspageandroid.csp",
- "sports"
- };
- public static final String[] OPINION = {
- "Opinion",
- "http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicopinionpageandroid.csp",
- "opinion"
- };
- public static final String[] MONEY = {
- "Money",
- "http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicmoneypageandroid.csp",
- "money"
- };
- public static final String[] MIX = {
- "The Mix",
- "http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicmixpageandroid.csp",
- "mix"
- };
- public static final String[] OBITS = {
- "Obituaries",
- "http://img.mysite.com/getObits_android.php",
- "obits"
- };
- public static final String[] WEATHER = {
- "Weather",
- "http://www.mysite.com/mysite/weather.php",
- "weather"
- };
- public static final String[] COMICS= {
- "Comics",
- "http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpiccomicspageandroid.csp",
- "comics"
- };
- public static final String[] POPULAR = {
- "Popular Stories",
- "http://www.mysite.com/csp/cms/sites/mysite/RSS/rssfullpicpopularandroid.csp",
- "popular"
- };
- public static final String[][] SECTIONS = { TOP, UTAH, SPORTS, OPINION, MONEY, MIX, OBITS, WEATHER, COMICS, POPULAR };
- public static String[] currentSection = TOP;
- public static final String POPULATE_TABLE = "INSERT INTO "
- + Section.TABLE + " "
- + "SELECT '1' AS '" + Section.COLUMN_ID + "', '" + Section.TOP[Section.INDEX_SLUG] + "' AS '" + Section.COLUMN_SLUG + "', '' AS '" + Section.COLUMN_LASTUPDATED + "' "
- + "UNION SELECT '2', '" + Section.UTAH[Section.INDEX_SLUG] + "', '' "
- + "UNION SELECT '3', '" + Section.SPORTS[Section.INDEX_SLUG] + "', '' "
- + "UNION SELECT '4', '" + Section.OPINION[Section.INDEX_SLUG] + "', '' "
- + "UNION SELECT '5', '" + Section.MONEY[Section.INDEX_SLUG] + "', '' "
- + "UNION SELECT '6', '" + Section.MIX[Section.INDEX_SLUG] + "', '' "
- + "UNION SELECT '7', '" + Section.OBITS[Section.INDEX_SLUG] + "', '' "
- + "UNION SELECT '8', '" + Section.WEATHER[Section.INDEX_SLUG] + "', '' "
- + "UNION SELECT '9', '" + Section.COMICS[Section.INDEX_SLUG] + "', '' "
- + "UNION SELECT '10', '" + Section.POPULAR[Section.INDEX_SLUG] + "', ''";
- //Uses a string to return the corresponding
- public static String[] stringToSection(String string)
- {
- String[] section = TOP; //defaults if it can't find a match
- for(final String[] tmpSection : SECTIONS)
- {
- if(tmpSection[INDEX_TITLE].equals(string))
- {
- section = tmpSection;
- }
- }
- return section;
- }
- public static Boolean isEqual(String[] section, String string)
- {
- if(string.equals(section[INDEX_TITLE]) || string.equals(section[INDEX_URL]) || string.equals(section[INDEX_SLUG]))
- {
- return true;
- }
- return false;
- }
- public static String currentSectionTitle() {
- return currentSection[INDEX_TITLE];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement