Refactoring
This commit is contained in:
parent
0c0ecc26bc
commit
bf205ebf8b
2 changed files with 13 additions and 32 deletions
|
@ -1,8 +1,7 @@
|
|||
package de.luhmer.owncloudnewsreader;
|
||||
|
||||
public class Constants {
|
||||
public static final Boolean DEBUG_MODE = true;
|
||||
public static final Boolean debugModeWidget = true;
|
||||
public static final Boolean debugModeWidget = false;
|
||||
|
||||
|
||||
public static final String _TAG_LABEL_UNREAD = "stream/contents/user/-/state/com.google/reading-list?n=1000&r=n&xt=user/-/state/com.google/read";
|
||||
|
|
|
@ -67,17 +67,16 @@ public class WidgetTodoViewsFactory implements RemoteViewsService.RemoteViewsFac
|
|||
Log.d(TAG, "onCreate");
|
||||
|
||||
dbConn = new DatabaseConnectionOrm(context);
|
||||
//onDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
//if(dbConn != null)
|
||||
//dbConn.closeDatabase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
Log.v(TAG, "getCount");
|
||||
|
||||
return rssItems.size();
|
||||
}
|
||||
|
||||
|
@ -85,19 +84,13 @@ public class WidgetTodoViewsFactory implements RemoteViewsService.RemoteViewsFac
|
|||
// combination with the app widget item XML file to construct a RemoteViews object.
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
public RemoteViews getViewAt(int position) {
|
||||
if(Constants.debugModeWidget)
|
||||
Log.d(TAG, "getViewAt: " + position);
|
||||
|
||||
RssItem rssItem = rssItems.get(position);
|
||||
|
||||
//RemoteViews rv = new RemoteViews(context.getPackageName(), android.R.layout.simple_list_item_2);
|
||||
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_item);
|
||||
|
||||
/*
|
||||
if(rssItem.getRead_temp())
|
||||
rv = new RemoteViews(context.getPackageName(), R.layout.widget_item);
|
||||
else
|
||||
rv = new RemoteViews(context.getPackageName(), R.layout.widget_item_unread);
|
||||
*/
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
String header = rssItem.getFeed().getFeedTitle();
|
||||
|
@ -121,22 +114,13 @@ public class WidgetTodoViewsFactory implements RemoteViewsService.RemoteViewsFac
|
|||
rv.setTextViewText(R.id.feed_title, title);
|
||||
|
||||
|
||||
|
||||
if(rssItem.getRead_temp()) {
|
||||
rv.setInt(R.id.cb_lv_item_read, "setBackgroundResource", R.drawable.btn_check_on_holo_dark);
|
||||
}
|
||||
else {
|
||||
rv.setInt(R.id.cb_lv_item_read, "setBackgroundResource", R.drawable.btn_check_off_holo_dark);
|
||||
}
|
||||
|
||||
|
||||
int resId = rssItem.getRead_temp() ? R.drawable.btn_check_on_holo_dark : R.drawable.btn_check_off_holo_dark;
|
||||
rv.setInt(R.id.cb_lv_item_read, "setBackgroundResource", resId);
|
||||
|
||||
//View viewColor = view.findViewById(R.id.color_line_feed);
|
||||
if(colorString != null)
|
||||
rv.setInt(R.id.color_line_feed, "setBackgroundColor", Integer.parseInt(colorString));
|
||||
|
||||
|
||||
|
||||
//Get a fresh new intent
|
||||
Intent ei = new Intent();
|
||||
//Load it with whatever extra you want
|
||||
|
@ -150,11 +134,8 @@ public class WidgetTodoViewsFactory implements RemoteViewsService.RemoteViewsFac
|
|||
iCheck.putExtra(WidgetProvider.RSS_ITEM_ID, id);
|
||||
iCheck.putExtra(WidgetProvider.ACTION_CHECKED_CLICK, true);
|
||||
rv.setOnClickFillInIntent(R.id.cb_lv_item_read, iCheck);
|
||||
|
||||
|
||||
|
||||
} catch(Exception ex) {
|
||||
Log.d(TAG, "Error: " + ex.getLocalizedMessage());
|
||||
Log.e(TAG, "Error: " + ex.getLocalizedMessage());
|
||||
}
|
||||
|
||||
// Return the RemoteViews object.
|
||||
|
@ -163,6 +144,7 @@ public class WidgetTodoViewsFactory implements RemoteViewsService.RemoteViewsFac
|
|||
|
||||
@Override
|
||||
public RemoteViews getLoadingView() {
|
||||
Log.v(TAG, "getLoadingView");
|
||||
return(null);
|
||||
}
|
||||
|
||||
|
@ -173,20 +155,20 @@ public class WidgetTodoViewsFactory implements RemoteViewsService.RemoteViewsFac
|
|||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
Log.v(TAG, "getItemId: " + position);
|
||||
return(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasStableIds() {
|
||||
Log.v(TAG, "hasStableIds: " + appWidgetId);
|
||||
return(true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onDataSetChanged() {
|
||||
if(Constants.debugModeWidget)
|
||||
Log.d(TAG, "DataSetChanged - WidgetID: " + appWidgetId);
|
||||
|
||||
Log.v(TAG, "DataSetChanged - WidgetID: " + appWidgetId);
|
||||
|
||||
rssItems = dbConn.getListOfAllItemsForFolder(SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_UNREAD_ITEMS.getValue(), false, SORT_DIRECTION.desc, 200);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue