Android Open Source - Rss-App-for-tumblr Feed Data






From Project

Back to project page Rss-App-for-tumblr.

License

The source code is released under:

GNU General Public License

If you think the Android project Rss-App-for-tumblr 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

/**
 * Ace Shooting/* w  w w . jav a 2  s .co  m*/
 *
 * Copyright (c) 2014 Ace Shooting
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 */

package com.aceshooting.rssapp.provider;

import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.BaseColumns;

import com.aceshooting.rssapp.handler.PictureFilenameFilter;

import java.io.File;

public class FeedData {
  public static final String CONTENT = "content://";
  
  public static final String AUTHORITY = "com.aceshooting.rssapp.provider.FeedData";
  
  private static final String TYPE_PRIMARY_KEY = "INTEGER PRIMARY KEY AUTOINCREMENT";
  
  protected static final String TYPE_TEXT = "TEXT";
  
  protected static final String TYPE_DATETIME = "DATETIME";
  
  protected static final String TYPE_INT = "INT";

  protected static final String TYPE_BOOLEAN = "INTEGER(1)";
  
  public static final String FEED_DEFAULTSORTORDER = FeedColumns.PRIORITY;
  
  public static class FeedColumns implements BaseColumns {
    public static final Uri CONTENT_URI = Uri.parse(new StringBuilder(CONTENT).append(AUTHORITY).append("/feeds").toString());
    
    public static final String URL = "url";
    
    public static final String NAME = "name";
    
    public static final String LASTUPDATE = "lastupdate";
    
    public static final String ICON = "icon";
    
    public static final String ERROR = "error";
    
    public static final String PRIORITY = "priority";
    
    public static final String FETCHMODE = "fetchmode";
    
    public static final String REALLASTUPDATE = "reallastupdate";
    
    public static final String WIFIONLY = "wifionly";
    
    public static final String IMPOSE_USERAGENT = "impose_useragent";
    
    public static final String HIDE_READ = "hide_read";
    
    public static final String[] COLUMNS = new String[] {_ID, URL, NAME, LASTUPDATE, ICON, ERROR, PRIORITY, FETCHMODE, REALLASTUPDATE, WIFIONLY, IMPOSE_USERAGENT, HIDE_READ};
    
    public static final String[] TYPES = new String[] {TYPE_PRIMARY_KEY, "TEXT UNIQUE", TYPE_TEXT, TYPE_DATETIME, "BLOB", TYPE_TEXT, TYPE_INT, TYPE_INT, TYPE_DATETIME, TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_BOOLEAN};
    
    public static final Uri CONTENT_URI(String feedId) {
      return Uri.parse(new StringBuilder(CONTENT).append(AUTHORITY).append("/feeds/").append(feedId).toString());
    }
    
    public static final Uri CONTENT_URI(long feedId) {
      return Uri.parse(new StringBuilder(CONTENT).append(AUTHORITY).append("/feeds/").append(feedId).toString());
    }
  }
  
  public static class EntryColumns implements BaseColumns {
    public static final String FEED_ID = "feedid";
    
    public static final String TITLE = "title";
    
    public static final String ABSTRACT = "abstract";
    
    public static final String DATE = "date";
    
    public static final String READDATE = "readdate";
    
    public static final String LINK = "link";
    
    public static final String FAVORITE = "favorite";
    
    public static final String ENCLOSURE = "enclosure";
    
    public static final String GUID = "guid";
    
    public static final String AUTHOR = "author";
    
    public static final String[] COLUMNS = new String[] {_ID, FEED_ID, TITLE, ABSTRACT, DATE, READDATE, LINK, FAVORITE, ENCLOSURE, GUID, AUTHOR};
    
    public static final String[] TYPES = new String[] {TYPE_PRIMARY_KEY, "INTEGER(7)", TYPE_TEXT, TYPE_TEXT, TYPE_DATETIME, TYPE_DATETIME, TYPE_TEXT, TYPE_BOOLEAN, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT};

    public static Uri CONTENT_URI = Uri.parse(new StringBuilder(CONTENT).append(AUTHORITY).append("/entries").toString());
    
    public static Uri FAVORITES_CONTENT_URI = Uri.parse(new StringBuilder(CONTENT).append(AUTHORITY).append("/favorites").toString());

    public static Uri CONTENT_URI(String feedId) {
      return Uri.parse(new StringBuilder(CONTENT).append(AUTHORITY).append("/feeds/").append(feedId).append("/entries").toString());
    }

    public static Uri ENTRY_CONTENT_URI(String entryId) {
      return Uri.parse(new StringBuilder(CONTENT).append(AUTHORITY).append("/entries/").append(entryId).toString());
    }
    
    public static Uri PARENT_URI(String path) {
      return Uri.parse(new StringBuilder(CONTENT).append(AUTHORITY).append(path.substring(0, path.lastIndexOf('/'))).toString());
    }
    
  }
    
  private static String[] IDPROJECTION = new String[] {FeedData.EntryColumns._ID};
  
  public static void deletePicturesOfFeedAsync(final Context context, final Uri entriesUri, final String selection) {
    if (FeedDataContentProvider.IMAGEFOLDER_FILE.exists()) {
      new Thread() {
        public void run() {
          deletePicturesOfFeed(context, entriesUri, selection);
        }
      }.start();
    }
  }
  
  public static synchronized void deletePicturesOfFeed(Context context, Uri entriesUri, String selection) {
    if (FeedDataContentProvider.IMAGEFOLDER_FILE.exists()) {
      PictureFilenameFilter filenameFilter = new PictureFilenameFilter();
      
      Cursor cursor = context.getContentResolver().query(entriesUri, IDPROJECTION, selection, null, null);
      
      while (cursor.moveToNext()) {
        filenameFilter.setEntryId(cursor.getString(0));
        
        File[] files = FeedDataContentProvider.IMAGEFOLDER_FILE.listFiles(filenameFilter);
        
        for (int n = 0, i = files != null ? files.length : 0; n < i; n++) {
          files[n].delete();
        }
      }
      cursor.close();
    }
  }
  
  public static synchronized void deletePicturesOfEntry(String entryId) {
    if (FeedDataContentProvider.IMAGEFOLDER_FILE.exists()) {
      PictureFilenameFilter filenameFilter = new PictureFilenameFilter(entryId);
      
      File[] files = FeedDataContentProvider.IMAGEFOLDER_FILE.listFiles(filenameFilter);
      
      for (int n = 0, i = files != null ? files.length : 0; n < i; n++) {
        files[n].delete();
      }
    }
  }
  

}




Java Source Code List

com.aceshooting.rssapp.Animations.java
com.aceshooting.rssapp.ApplicationPreferencesActivity.java
com.aceshooting.rssapp.BASE64.java
com.aceshooting.rssapp.BootCompletedBroadcastReceiver.java
com.aceshooting.rssapp.CompatibilityHelper.java
com.aceshooting.rssapp.EmptyActivity.java
com.aceshooting.rssapp.EntriesListActivity.java
com.aceshooting.rssapp.EntriesListAdapter.java
com.aceshooting.rssapp.EntryActivity.java
com.aceshooting.rssapp.FeedConfigActivity.java
com.aceshooting.rssapp.MainTabActivity.java
com.aceshooting.rssapp.MyApplication.java
com.aceshooting.rssapp.RSSOverviewListAdapter.java
com.aceshooting.rssapp.RSSOverview.java
com.aceshooting.rssapp.RefreshBroadcastReceiver.java
com.aceshooting.rssapp.Requeryable.java
com.aceshooting.rssapp.SimpleTask.java
com.aceshooting.rssapp.Strings.java
com.aceshooting.rssapp.handler.PictureFilenameFilter.java
com.aceshooting.rssapp.handler.RSSHandler.java
com.aceshooting.rssapp.provider.FeedDataContentProvider.java
com.aceshooting.rssapp.provider.FeedData.java
com.aceshooting.rssapp.provider.OPML.java
com.aceshooting.rssapp.service.FetcherService.java
com.aceshooting.rssapp.service.RefreshService.java
com.aceshooting.rssapp.widget.ColorPickerDialogPreference.java
com.aceshooting.rssapp.widget.SparseRSSAppWidgetProvider.java
com.aceshooting.rssapp.widget.WidgetConfigActivity.java