drop databasehelper, misc cleanup, suppress some warnings
This commit is contained in:
parent
de1db3b5ff
commit
0dbf6d75ca
@ -56,6 +56,7 @@ public class Article implements Parcelable {
|
|||||||
content = in.readString();
|
content = in.readString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Parcelable.Creator CREATOR =
|
public static final Parcelable.Creator CREATOR =
|
||||||
new Parcelable.Creator() {
|
new Parcelable.Creator() {
|
||||||
public Article createFromParcel(Parcel in) {
|
public Article createFromParcel(Parcel in) {
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package org.fox.ttrss;
|
package org.fox.ttrss;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@ -19,6 +17,7 @@ import android.webkit.WebView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class ArticleFragment extends Fragment {
|
public class ArticleFragment extends Fragment {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private final String TAG = this.getClass().getSimpleName();
|
private final String TAG = this.getClass().getSimpleName();
|
||||||
|
|
||||||
private SharedPreferences m_prefs;
|
private SharedPreferences m_prefs;
|
||||||
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public class ArticleList extends ArrayList<Article> implements Parcelable {
|
public class ArticleList extends ArrayList<Article> implements Parcelable {
|
||||||
@Override
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
@ -34,6 +35,7 @@ public class ArticleList extends ArrayList<Article> implements Parcelable {
|
|||||||
readFromParcel(in);
|
readFromParcel(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Parcelable.Creator CREATOR =
|
public static final Parcelable.Creator CREATOR =
|
||||||
new Parcelable.Creator() {
|
new Parcelable.Creator() {
|
||||||
public ArticleList createFromParcel(Parcel in) {
|
public ArticleList createFromParcel(Parcel in) {
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
package org.fox.ttrss;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
|
||||||
import android.provider.BaseColumns;
|
|
||||||
|
|
||||||
|
|
||||||
public class DatabaseHelper extends SQLiteOpenHelper {
|
|
||||||
|
|
||||||
private final String TAG = this.getClass().getSimpleName();
|
|
||||||
public static final String DATABASE_NAME = "LocalStorage";
|
|
||||||
public static final int DATABASE_VERSION = 7;
|
|
||||||
|
|
||||||
public DatabaseHelper(Context context) {
|
|
||||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(SQLiteDatabase db) {
|
|
||||||
db.execSQL("DROP TABLE IF EXISTS feeds;");
|
|
||||||
db.execSQL("DROP TABLE IF EXISTS articles;");
|
|
||||||
db.execSQL("DROP VIEW IF EXISTS feeds_unread;");
|
|
||||||
|
|
||||||
db.execSQL("CREATE TABLE IF NOT EXISTS feeds (" +
|
|
||||||
BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
|
|
||||||
"feed_url TEXT, " +
|
|
||||||
"title TEXT, " +
|
|
||||||
"unread INTEGER, " +
|
|
||||||
"has_icon BOOLEAN, " +
|
|
||||||
"cat_id INTEGER, " +
|
|
||||||
"last_updated INTEGER, " +
|
|
||||||
"count INTEGER" +
|
|
||||||
");");
|
|
||||||
|
|
||||||
db.execSQL("CREATE TABLE IF NOT EXISTS articles (" +
|
|
||||||
BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
|
|
||||||
"unread BOOLEAN, " +
|
|
||||||
"marked BOOLEAN, " +
|
|
||||||
"published BOOLEAN, " +
|
|
||||||
"updated INTEGER, " +
|
|
||||||
"is_updated BOOLEAN, " +
|
|
||||||
"title TEXT, " +
|
|
||||||
"link TEXT, " +
|
|
||||||
"feed_id INTEGER, " +
|
|
||||||
"tags TEXT, " +
|
|
||||||
"content TEXT, " +
|
|
||||||
"excerpt TEXT" +
|
|
||||||
");");
|
|
||||||
|
|
||||||
db.execSQL("CREATE VIEW feeds_unread AS SELECT feeds."+BaseColumns._ID+" AS "+BaseColumns._ID+", " +
|
|
||||||
"feeds.title AS title, " +
|
|
||||||
"SUM(articles.unread) AS unread FROM feeds " +
|
|
||||||
"LEFT JOIN articles ON (articles.feed_id = feeds."+BaseColumns._ID+") " +
|
|
||||||
"GROUP BY feeds."+BaseColumns._ID+", feeds.title;");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
|
||||||
onCreate(db);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -50,6 +50,7 @@ public class Feed implements Comparable<Feed>, Parcelable {
|
|||||||
last_updated = in.readInt();
|
last_updated = in.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Parcelable.Creator CREATOR =
|
public static final Parcelable.Creator CREATOR =
|
||||||
new Parcelable.Creator() {
|
new Parcelable.Creator() {
|
||||||
public Feed createFromParcel(Parcel in) {
|
public Feed createFromParcel(Parcel in) {
|
||||||
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public class FeedList extends ArrayList<Feed> implements Parcelable {
|
public class FeedList extends ArrayList<Feed> implements Parcelable {
|
||||||
|
|
||||||
public FeedList() { }
|
public FeedList() { }
|
||||||
@ -36,6 +37,7 @@ public class FeedList extends ArrayList<Feed> implements Parcelable {
|
|||||||
readFromParcel(in);
|
readFromParcel(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Parcelable.Creator CREATOR =
|
public static final Parcelable.Creator CREATOR =
|
||||||
new Parcelable.Creator() {
|
new Parcelable.Creator() {
|
||||||
public FeedList createFromParcel(Parcel in) {
|
public FeedList createFromParcel(Parcel in) {
|
||||||
|
@ -29,6 +29,7 @@ import com.google.gson.JsonObject;
|
|||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
public class FeedsFragment extends Fragment implements OnItemClickListener {
|
public class FeedsFragment extends Fragment implements OnItemClickListener {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private final String TAG = this.getClass().getSimpleName();
|
private final String TAG = this.getClass().getSimpleName();
|
||||||
private SharedPreferences m_prefs;
|
private SharedPreferences m_prefs;
|
||||||
private FeedListAdapter m_adapter;
|
private FeedListAdapter m_adapter;
|
||||||
@ -62,17 +63,6 @@ public class FeedsFragment extends Fragment implements OnItemClickListener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public void showLoading(boolean show) {
|
|
||||||
View v = getView();
|
|
||||||
|
|
||||||
if (v != null) {
|
|
||||||
v = v.findViewById(R.id.loading_container);
|
|
||||||
|
|
||||||
if (v != null)
|
|
||||||
v.setVisibility(show ? View.VISIBLE : View.GONE);
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
||||||
@ -129,6 +119,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "unchecked", "serial" })
|
||||||
public void refresh(boolean background) {
|
public void refresh(boolean background) {
|
||||||
FeedsRequest req = new FeedsRequest(getActivity().getApplicationContext());
|
FeedsRequest req = new FeedsRequest(getActivity().getApplicationContext());
|
||||||
|
|
||||||
|
@ -13,11 +13,7 @@ import org.jsoup.Jsoup;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -43,7 +39,6 @@ import com.google.gson.reflect.TypeToken;
|
|||||||
|
|
||||||
public class HeadlinesFragment extends Fragment implements OnItemClickListener {
|
public class HeadlinesFragment extends Fragment implements OnItemClickListener {
|
||||||
private final String TAG = this.getClass().getSimpleName();
|
private final String TAG = this.getClass().getSimpleName();
|
||||||
private SharedPreferences m_prefs;
|
|
||||||
|
|
||||||
private Feed m_feed;
|
private Feed m_feed;
|
||||||
private int m_activeArticleId;
|
private int m_activeArticleId;
|
||||||
@ -85,21 +80,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public void showLoading(boolean show) {
|
|
||||||
View v = getView();
|
|
||||||
|
|
||||||
if (v != null) {
|
|
||||||
v = v.findViewById(R.id.loading_container);
|
|
||||||
|
|
||||||
if (v != null)
|
|
||||||
v.setVisibility(show ? View.VISIBLE : View.GONE);
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
m_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
|
||||||
m_feed = ((MainActivity)activity).getActiveFeed();
|
m_feed = ((MainActivity)activity).getActiveFeed();
|
||||||
m_articleOps = (ArticleOps) activity;
|
m_articleOps = (ArticleOps) activity;
|
||||||
}
|
}
|
||||||
@ -122,12 +105,10 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "unchecked", "serial" })
|
||||||
public void refresh(boolean append) {
|
public void refresh(boolean append) {
|
||||||
HeadlinesRequest req = new HeadlinesRequest(getActivity().getApplicationContext());
|
HeadlinesRequest req = new HeadlinesRequest(getActivity().getApplicationContext());
|
||||||
|
|
||||||
//req.setApi(m_prefs.getString("ttrss_url", null));
|
|
||||||
//req.setTrustAny(m_prefs.getBoolean("ssl_trust_any", false));
|
|
||||||
|
|
||||||
final String sessionId = ((MainActivity)getActivity()).getSessionId();
|
final String sessionId = ((MainActivity)getActivity()).getSessionId();
|
||||||
final boolean showUnread = ((MainActivity)getActivity()).getUnreadArticlesOnly();
|
final boolean showUnread = ((MainActivity)getActivity()).getUnreadArticlesOnly();
|
||||||
int skip = 0;
|
int skip = 0;
|
||||||
|
@ -50,6 +50,7 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "unchecked", "serial" })
|
||||||
public void saveArticleUnread(final Article article) {
|
public void saveArticleUnread(final Article article) {
|
||||||
ApiRequest req = new ApiRequest(getApplicationContext());
|
ApiRequest req = new ApiRequest(getApplicationContext());
|
||||||
|
|
||||||
@ -66,6 +67,7 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
|
|||||||
req.execute(map);
|
req.execute(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "unchecked", "serial" })
|
||||||
public void saveArticleMarked(final Article article) {
|
public void saveArticleMarked(final Article article) {
|
||||||
ApiRequest req = new ApiRequest(getApplicationContext());
|
ApiRequest req = new ApiRequest(getApplicationContext());
|
||||||
|
|
||||||
@ -82,6 +84,7 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
|
|||||||
req.execute(map);
|
req.execute(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "unchecked", "serial" })
|
||||||
public void saveArticlePublished(final Article article) {
|
public void saveArticlePublished(final Article article) {
|
||||||
ApiRequest req = new ApiRequest(getApplicationContext());
|
ApiRequest req = new ApiRequest(getApplicationContext());
|
||||||
|
|
||||||
@ -684,6 +687,7 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
|
|||||||
initMainMenu();
|
initMainMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "unchecked", "serial" })
|
||||||
public void login() {
|
public void login() {
|
||||||
|
|
||||||
logout();
|
logout();
|
||||||
@ -697,8 +701,6 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
LoginRequest ar = new LoginRequest(getApplicationContext());
|
LoginRequest ar = new LoginRequest(getApplicationContext());
|
||||||
//ar.setApi(m_prefs.getString("ttrss_url", null));
|
|
||||||
//ar.setTrustAny(m_prefs.getBoolean("ssl_trust_any", false));
|
|
||||||
|
|
||||||
HashMap<String,String> map = new HashMap<String,String>() {
|
HashMap<String,String> map = new HashMap<String,String>() {
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user