Performance Update
This commit is contained in:
parent
a34806c6d7
commit
cc5a5695da
19 changed files with 566 additions and 390 deletions
|
@ -72,6 +72,7 @@
|
||||||
<orderEntry type="library" exported="" name="extra-abs-0.9.3" level="project" />
|
<orderEntry type="library" exported="" name="extra-abs-0.9.3" level="project" />
|
||||||
<orderEntry type="library" exported="" name="library-0.2.0" level="project" />
|
<orderEntry type="library" exported="" name="library-0.2.0" level="project" />
|
||||||
<orderEntry type="library" exported="" name="library-0.9.3" level="project" />
|
<orderEntry type="library" exported="" name="library-0.9.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="picasso-2.2.0" level="project" />
|
||||||
<orderEntry type="library" exported="" name="gson-2.2.4" level="project" />
|
<orderEntry type="library" exported="" name="gson-2.2.4" level="project" />
|
||||||
<orderEntry type="library" exported="" name="butterknife-4.0.1" level="project" />
|
<orderEntry type="library" exported="" name="butterknife-4.0.1" level="project" />
|
||||||
<orderEntry type="library" exported="" name="support-v4-19.1.0" level="project" />
|
<orderEntry type="library" exported="" name="support-v4-19.1.0" level="project" />
|
||||||
|
|
|
@ -35,9 +35,9 @@ android {
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.android.support:support-v4:19.0.+'
|
compile 'com.android.support:support-v4:19.0.+'
|
||||||
compile 'com.jakewharton:butterknife:4.0.+'
|
compile 'com.jakewharton:butterknife:4.0.+'
|
||||||
|
compile 'com.squareup.picasso:picasso:2.2.0@jar'
|
||||||
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
|
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
|
||||||
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abs:+'
|
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abs:+'
|
||||||
|
|
||||||
// You must install or update the Google Repository through the SDK manager to use this dependency.
|
// You must install or update the Google Repository through the SDK manager to use this dependency.
|
||||||
// The Google Repository (separate from the corresponding library) can be found in the Extras category.
|
// The Google Repository (separate from the corresponding library) can be found in the Extras category.
|
||||||
// compile 'com.google.android.gms:play-services:4.2.42'
|
// compile 'com.google.android.gms:play-services:4.2.42'
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="de.luhmer.owncloudnewsreader"
|
package="de.luhmer.owncloudnewsreader"
|
||||||
android:versionCode="43"
|
android:versionCode="44"
|
||||||
android:versionName="0.5.8" >
|
android:versionName="0.5.9" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="7"
|
android:minSdkVersion="7"
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class DownloadImagesActivity extends Activity {
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(getString(android.R.string.yes) ,new DialogInterface.OnClickListener() {
|
.setPositiveButton(getString(android.R.string.yes) ,new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog,int id) {
|
public void onClick(DialogInterface dialog,int id) {
|
||||||
AsyncTask_GetItems.StartDownloadingImages(DownloadImagesActivity.this, highestItemIdBeforeSync);
|
AsyncTask_GetItems.StartDownloadingImages(DownloadImagesActivity.this, highestItemIdBeforeSync, false);
|
||||||
DownloadImagesActivity.this.finish();
|
DownloadImagesActivity.this.finish();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -40,9 +40,13 @@ import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.squareup.picasso.Picasso;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.InjectView;
|
||||||
import de.luhmer.owncloudnewsreader.R;
|
import de.luhmer.owncloudnewsreader.R;
|
||||||
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||||
import de.luhmer.owncloudnewsreader.async_tasks.FillTextForTextViewAsyncTask;
|
import de.luhmer.owncloudnewsreader.async_tasks.FillTextForTextViewAsyncTask;
|
||||||
|
@ -51,14 +55,14 @@ import de.luhmer.owncloudnewsreader.data.AbstractItem;
|
||||||
import de.luhmer.owncloudnewsreader.data.ConcreteFeedItem;
|
import de.luhmer.owncloudnewsreader.data.ConcreteFeedItem;
|
||||||
import de.luhmer.owncloudnewsreader.data.FolderSubscribtionItem;
|
import de.luhmer.owncloudnewsreader.data.FolderSubscribtionItem;
|
||||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||||
import de.luhmer.owncloudnewsreader.helper.BitmapDrawableLruCache;
|
|
||||||
import de.luhmer.owncloudnewsreader.helper.FavIconHandler;
|
import de.luhmer.owncloudnewsreader.helper.FavIconHandler;
|
||||||
import de.luhmer.owncloudnewsreader.helper.FontHelper;
|
import de.luhmer.owncloudnewsreader.helper.FontHelper;
|
||||||
|
import de.luhmer.owncloudnewsreader.helper.ImageHandler;
|
||||||
import de.luhmer.owncloudnewsreader.interfaces.ExpListTextClicked;
|
import de.luhmer.owncloudnewsreader.interfaces.ExpListTextClicked;
|
||||||
|
|
||||||
public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter {
|
public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter {
|
||||||
|
|
||||||
BitmapDrawableLruCache favIconCache = null;
|
//BitmapDrawableLruCache favIconCache = null;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private DatabaseConnection dbConn;
|
private DatabaseConnection dbConn;
|
||||||
|
@ -76,18 +80,22 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter
|
||||||
public static final String ITEMS_WITHOUT_FOLDER = "-22";
|
public static final String ITEMS_WITHOUT_FOLDER = "-22";
|
||||||
//private static final String TAG = "SubscriptionExpandableListAdapter";
|
//private static final String TAG = "SubscriptionExpandableListAdapter";
|
||||||
|
|
||||||
|
LayoutInflater inflater;
|
||||||
|
private final String favIconPath;
|
||||||
|
|
||||||
public SubscriptionExpandableListAdapter(Context mContext, DatabaseConnection dbConn)
|
public SubscriptionExpandableListAdapter(Context mContext, DatabaseConnection dbConn)
|
||||||
{
|
{
|
||||||
|
//Picasso.with(mContext).setDebugging(true);
|
||||||
|
|
||||||
|
this.favIconPath = ImageHandler.getPathFavIcons(mContext);
|
||||||
|
this.inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
this.mContext = mContext;
|
this.mContext = mContext;
|
||||||
this.dbConn = dbConn;
|
this.dbConn = dbConn;
|
||||||
|
|
||||||
int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
|
//int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
|
||||||
//Use 1/8 of the available memory for this memory cache
|
//Use 1/8 of the available memory for this memory cache
|
||||||
int cachSize = maxMemory / 8;
|
//int cachSize = maxMemory / 8;
|
||||||
favIconCache = new BitmapDrawableLruCache(cachSize);
|
//favIconCache = new BitmapDrawableLruCache(cachSize);
|
||||||
|
|
||||||
fHelper = new FontHelper(mContext);
|
fHelper = new FontHelper(mContext);
|
||||||
|
|
||||||
|
@ -151,41 +159,38 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter
|
||||||
@Override
|
@Override
|
||||||
public View getChildView(int groupPosition, int childPosition,
|
public View getChildView(int groupPosition, int childPosition,
|
||||||
boolean isLastChild, View convertView, ViewGroup parent) {
|
boolean isLastChild, View convertView, ViewGroup parent) {
|
||||||
LinearLayout view;
|
final ConcreteFeedItem item = (ConcreteFeedItem)getChild(groupPosition, childPosition);
|
||||||
ChildHolder viewHolder;
|
final ChildHolder viewHolder;
|
||||||
ConcreteFeedItem item = (ConcreteFeedItem)getChild(groupPosition, childPosition);
|
|
||||||
|
|
||||||
|
if (convertView != null) {
|
||||||
if (convertView == null) {
|
|
||||||
view = new LinearLayout(mContext);
|
|
||||||
String inflater = Context.LAYOUT_INFLATER_SERVICE;
|
|
||||||
LayoutInflater vi = (LayoutInflater) mContext.getSystemService(inflater);
|
|
||||||
vi.inflate(R.layout.subscription_list_sub_item, view, true);
|
|
||||||
if(item != null)
|
|
||||||
view.setTag(item.id_database);
|
|
||||||
|
|
||||||
FontHelper fHelper = new FontHelper(mContext);
|
|
||||||
fHelper.setFontForAllChildren(view, fHelper.getFont());
|
|
||||||
|
|
||||||
viewHolder = new ChildHolder();
|
|
||||||
viewHolder.tV_HeaderText = (TextView) view.findViewById(R.id.summary);
|
|
||||||
viewHolder.tV_UnreadCount = (TextView) view.findViewById(R.id.tv_unreadCount);
|
|
||||||
viewHolder.imgView_FavIcon = (ImageView) view.findViewById(R.id.iVFavicon);
|
|
||||||
|
|
||||||
view.setTag(viewHolder);
|
|
||||||
} else {
|
|
||||||
view = (LinearLayout) convertView;
|
|
||||||
viewHolder = (ChildHolder) convertView.getTag();
|
viewHolder = (ChildHolder) convertView.getTag();
|
||||||
|
} else {
|
||||||
|
LinearLayout view = new LinearLayout(mContext);
|
||||||
|
convertView = inflater.inflate(R.layout.subscription_list_sub_item, view, true);
|
||||||
|
viewHolder = new ChildHolder(convertView, mContext);
|
||||||
|
convertView.setTag(viewHolder);
|
||||||
|
|
||||||
|
/*
|
||||||
|
if(item != null)
|
||||||
|
convertView.setTag(item.id_database);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(item != null)
|
if(item != null)
|
||||||
{
|
{
|
||||||
String headerText = (item.header != null) ? item.header : "";
|
String headerText = (item.header != null) ? item.header : "";
|
||||||
viewHolder.tV_HeaderText.setText(headerText);
|
viewHolder.tV_HeaderText.setText(headerText);
|
||||||
|
|
||||||
|
String unreadCount = unreadCountFeeds.get((int) item.id_database);
|
||||||
|
if(unreadCount != null)
|
||||||
|
viewHolder.tV_UnreadCount.setText(unreadCount);
|
||||||
|
else {
|
||||||
boolean execludeStarredItems = (item.folder_id.equals(ALL_STARRED_ITEMS)) ? false : true;
|
boolean execludeStarredItems = (item.folder_id.equals(ALL_STARRED_ITEMS)) ? false : true;
|
||||||
SetUnreadCountForFeed(viewHolder.tV_UnreadCount, String.valueOf(item.id_database), execludeStarredItems);
|
SetUnreadCountForFeed(viewHolder.tV_UnreadCount, String.valueOf(item.id_database), execludeStarredItems);
|
||||||
GetFavIconForFeed(item.favIcon, viewHolder.imgView_FavIcon, String.valueOf(item.id_database));
|
}
|
||||||
|
|
||||||
|
loadFavIconForFeed(item.favIcon, viewHolder.imgView_FavIcon);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -194,13 +199,20 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter
|
||||||
viewHolder.imgView_FavIcon.setImageDrawable(null);
|
viewHolder.imgView_FavIcon.setImageDrawable(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return view;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ChildHolder {
|
static class ChildHolder {
|
||||||
public TextView tV_HeaderText;
|
@InjectView(R.id.summary) TextView tV_HeaderText;
|
||||||
public TextView tV_UnreadCount;
|
@InjectView(R.id.tv_unreadCount) TextView tV_UnreadCount;
|
||||||
public ImageView imgView_FavIcon;
|
@InjectView(R.id.iVFavicon) ImageView imgView_FavIcon;
|
||||||
|
|
||||||
|
public ChildHolder(View view, Context mContext) {
|
||||||
|
ButterKnife.inject(this, view);
|
||||||
|
|
||||||
|
FontHelper fHelper = new FontHelper(mContext);
|
||||||
|
fHelper.setFontForAllChildren(view, fHelper.getFont());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -236,30 +248,17 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter
|
||||||
@Override
|
@Override
|
||||||
public View getGroupView(int groupPosition, boolean isExpanded,
|
public View getGroupView(int groupPosition, boolean isExpanded,
|
||||||
View convertView, ViewGroup parent) {
|
View convertView, ViewGroup parent) {
|
||||||
LinearLayout view;
|
|
||||||
GroupHolder viewHolder;
|
|
||||||
|
|
||||||
|
GroupHolder viewHolder;
|
||||||
final FolderSubscribtionItem group = (FolderSubscribtionItem)getGroup(groupPosition);
|
final FolderSubscribtionItem group = (FolderSubscribtionItem)getGroup(groupPosition);
|
||||||
|
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
view = new LinearLayout(mContext);
|
LinearLayout view = new LinearLayout(mContext);
|
||||||
String inflater = Context.LAYOUT_INFLATER_SERVICE;
|
convertView = inflater.inflate(R.layout.subscription_list_item, view, true);
|
||||||
LayoutInflater vi = (LayoutInflater) mContext.getSystemService(inflater);
|
viewHolder = new GroupHolder(convertView, mContext);
|
||||||
vi.inflate(R.layout.subscription_list_item, view, true);
|
|
||||||
|
|
||||||
fHelper.setFontForAllChildren(view, fHelper.getFont());
|
|
||||||
|
|
||||||
viewHolder = new GroupHolder();
|
|
||||||
viewHolder.imgView = (ImageView) view.findViewById(R.id.img_View_expandable_indicator);
|
|
||||||
viewHolder.txt_Summary = (TextView) view.findViewById(R.id.summary);
|
|
||||||
viewHolder.txt_UnreadCount = (TextView) view.findViewById(R.id.tV_feedsCount);
|
|
||||||
|
|
||||||
viewHolder.txt_Summary.setClickable(true);
|
|
||||||
|
|
||||||
view.setTag(viewHolder);
|
view.setTag(viewHolder);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
view = (LinearLayout) convertView;
|
|
||||||
viewHolder = (GroupHolder) convertView.getTag();
|
viewHolder = (GroupHolder) convertView.getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,8 +296,8 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter
|
||||||
|
|
||||||
if(unreadCount != null)
|
if(unreadCount != null)
|
||||||
viewHolder.txt_UnreadCount.setText(unreadCount);
|
viewHolder.txt_UnreadCount.setText(unreadCount);
|
||||||
//else
|
else
|
||||||
//SetUnreadCountForFeed(viewHolder.txt_UnreadCount, String.valueOf(group.id_database), true);
|
SetUnreadCountForFeed(viewHolder.txt_UnreadCount, String.valueOf(group.id_database), true);
|
||||||
|
|
||||||
skipGetUnread = true;
|
skipGetUnread = true;
|
||||||
}
|
}
|
||||||
|
@ -326,17 +325,7 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter
|
||||||
{
|
{
|
||||||
String favIconURL = urlsToFavIcons.get((int) group.id_database);
|
String favIconURL = urlsToFavIcons.get((int) group.id_database);
|
||||||
|
|
||||||
viewHolder.imgView.setImageDrawable(null);
|
loadFavIconForFeed(favIconURL, viewHolder.imgView);
|
||||||
|
|
||||||
String feedID = String.valueOf(group.id_database);
|
|
||||||
|
|
||||||
if(favIconURL != null) {
|
|
||||||
if(favIconCache != null && favIconCache.get(feedID) != null) {
|
|
||||||
viewHolder.imgView.setImageDrawable(favIconCache.get(feedID));
|
|
||||||
} else {
|
|
||||||
GetFavIconForFeed(favIconURL, viewHolder.imgView, String.valueOf(group.id_database));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(String.valueOf(group.id_database).equals(ALL_STARRED_ITEMS)) {
|
if(String.valueOf(group.id_database).equals(ALL_STARRED_ITEMS)) {
|
||||||
|
@ -360,9 +349,26 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return view;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadFavIconForFeed(String favIconUrl, ImageView imgView) {
|
||||||
|
File cacheFile = ImageHandler.getFullPathOfCacheFileSafe(favIconUrl, favIconPath);
|
||||||
|
if(cacheFile != null && cacheFile.exists()) {
|
||||||
|
Picasso.with(mContext)
|
||||||
|
.load(cacheFile)
|
||||||
|
.placeholder(FavIconHandler.getResourceIdForRightDefaultFeedIcon(mContext))
|
||||||
|
.into(imgView, null);
|
||||||
|
} else {
|
||||||
|
Picasso.with(mContext)
|
||||||
|
.load(favIconUrl)
|
||||||
|
.placeholder(FavIconHandler.getResourceIdForRightDefaultFeedIcon(mContext))
|
||||||
|
.into(imgView, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Drawable ic_find_next_holo_dark;
|
Drawable ic_find_next_holo_dark;
|
||||||
Drawable ic_find_previous_holo_dark;
|
Drawable ic_find_previous_holo_dark;
|
||||||
Drawable btn_rating_star_off_normal_holo_light;
|
Drawable btn_rating_star_off_normal_holo_light;
|
||||||
|
@ -386,6 +392,7 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||||
private void SetUnreadCountForFeed(TextView textView, String idDatabase, boolean execludeStarredItems)
|
private void SetUnreadCountForFeed(TextView textView, String idDatabase, boolean execludeStarredItems)
|
||||||
{
|
{
|
||||||
|
@ -410,31 +417,23 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GetFavIconForFeed(String favIconURL, ImageView imgView, String feedID)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if(favIconURL != null)
|
|
||||||
{
|
|
||||||
if(favIconURL.trim().length() > 0)
|
|
||||||
new FavIconHandler().GetImageAsync(imgView, favIconURL, mContext, feedID, favIconCache);
|
|
||||||
else
|
|
||||||
imgView.setImageResource(FavIconHandler.getResourceIdForRightDefaultFeedIcon(mContext));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
imgView.setImageResource(FavIconHandler.getResourceIdForRightDefaultFeedIcon(mContext));
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static class GroupHolder
|
static class GroupHolder
|
||||||
{
|
{
|
||||||
TextView txt_Summary;
|
@InjectView(R.id.summary) TextView txt_Summary;
|
||||||
TextView txt_UnreadCount;
|
@InjectView(R.id.tV_feedsCount) TextView txt_UnreadCount;
|
||||||
ImageView imgView;
|
@InjectView(R.id.img_View_expandable_indicator) ImageView imgView;
|
||||||
|
|
||||||
|
public GroupHolder(View view, Context mContext) {
|
||||||
|
ButterKnife.inject(this, view);
|
||||||
|
|
||||||
|
txt_Summary.setClickable(true);
|
||||||
|
|
||||||
|
FontHelper fHelper = new FontHelper(mContext);
|
||||||
|
fHelper.setFontForAllChildren(view, fHelper.getFont());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,47 +3,30 @@ package de.luhmer.owncloudnewsreader;
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.LoaderManager.LoaderCallbacks;
|
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.CursorLoader;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.Loader;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build.VERSION;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.ContactsContract;
|
|
||||||
import android.support.v4.app.NavUtils;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.inputmethod.EditorInfo;
|
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.AutoCompleteTextView;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.actionbarsherlock.app.SherlockActivity;
|
import com.actionbarsherlock.app.SherlockActivity;
|
||||||
import com.actionbarsherlock.view.MenuItem;
|
import com.actionbarsherlock.view.MenuItem;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.InjectView;
|
import butterknife.InjectView;
|
||||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||||
import de.luhmer.owncloudnewsreader.reader.GoogleReaderApi.HttpHelper;
|
|
||||||
import de.luhmer.owncloudnewsreader.reader.HttpJsonRequest;
|
import de.luhmer.owncloudnewsreader.reader.HttpJsonRequest;
|
||||||
import de.luhmer.owncloudnewsreader.reader.owncloud.API;
|
import de.luhmer.owncloudnewsreader.reader.owncloud.API;
|
||||||
import de.luhmer.owncloudnewsreader.reader.owncloud.apiv2.APIv2;
|
import de.luhmer.owncloudnewsreader.reader.owncloud.apiv2.APIv2;
|
||||||
|
|
|
@ -45,7 +45,6 @@ import com.devspark.robototextview.widget.RobotoCheckBox;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import de.luhmer.owncloudnewsreader.ListView.BlockingExpandableListView;
|
|
||||||
import de.luhmer.owncloudnewsreader.ListView.BlockingListView;
|
import de.luhmer.owncloudnewsreader.ListView.BlockingListView;
|
||||||
import de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter;
|
import de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter;
|
||||||
import de.luhmer.owncloudnewsreader.cursor.IOnStayUnread;
|
import de.luhmer.owncloudnewsreader.cursor.IOnStayUnread;
|
||||||
|
@ -270,7 +269,6 @@ public class NewsReaderDetailFragment extends SherlockListFragment implements IO
|
||||||
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
|
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
|
||||||
NewsListCursorAdapter nca = (NewsListCursorAdapter) getListAdapter();
|
NewsListCursorAdapter nca = (NewsListCursorAdapter) getListAdapter();
|
||||||
|
|
||||||
|
|
||||||
// Block children layout for now
|
// Block children layout for now
|
||||||
BlockingListView bView = ((BlockingListView) getListView());
|
BlockingListView bView = ((BlockingListView) getListView());
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,6 @@ import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Looper;
|
|
||||||
import android.os.Message;
|
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
@ -508,6 +505,7 @@ public class NewsReaderListActivity extends MenuUtilsSherlockFragmentActivity im
|
||||||
long highestItemId = dbConn.getLowestItemIdUnread();
|
long highestItemId = dbConn.getLowestItemIdUnread();
|
||||||
Intent service = new Intent(this, DownloadImagesService.class);
|
Intent service = new Intent(this, DownloadImagesService.class);
|
||||||
service.putExtra(DownloadImagesService.LAST_ITEM_ID, highestItemId);
|
service.putExtra(DownloadImagesService.LAST_ITEM_ID, highestItemId);
|
||||||
|
//service.putExtra(DownloadImagesService.DOWNLOAD_FAVICONS_EXCLUSIVE, true);
|
||||||
startService(service);
|
startService(service);
|
||||||
} finally {
|
} finally {
|
||||||
dbConn.closeDatabase();
|
dbConn.closeDatabase();
|
||||||
|
|
|
@ -14,7 +14,6 @@ import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
|
|
||||||
import com.actionbarsherlock.app.SherlockFragment;
|
import com.actionbarsherlock.app.SherlockFragment;
|
||||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||||
import com.actionbarsherlock.view.Menu;
|
import com.actionbarsherlock.view.Menu;
|
||||||
|
|
|
@ -26,6 +26,7 @@ import android.annotation.TargetApi;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.widget.CursorAdapter;
|
import android.support.v4.widget.CursorAdapter;
|
||||||
|
@ -37,6 +38,9 @@ import android.text.style.ForegroundColorSpan;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.animation.AccelerateInterpolator;
|
||||||
|
import android.view.animation.AlphaAnimation;
|
||||||
|
import android.view.animation.Animation;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
|
@ -47,6 +51,10 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||||
import com.devspark.robototextview.widget.RobotoCheckBox;
|
import com.devspark.robototextview.widget.RobotoCheckBox;
|
||||||
import com.devspark.robototextview.widget.RobotoTextView;
|
import com.devspark.robototextview.widget.RobotoTextView;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.InjectView;
|
||||||
import de.luhmer.owncloudnewsreader.NewsDetailFragment;
|
import de.luhmer.owncloudnewsreader.NewsDetailFragment;
|
||||||
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
|
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
|
||||||
import de.luhmer.owncloudnewsreader.R;
|
import de.luhmer.owncloudnewsreader.R;
|
||||||
|
@ -207,38 +215,60 @@ public class NewsListCursorAdapter extends CursorAdapter {
|
||||||
|
|
||||||
public void setSimpleLayout(View view, Cursor cursor)
|
public void setSimpleLayout(View view, Cursor cursor)
|
||||||
{
|
{
|
||||||
TextView textViewSummary = (TextView) view.findViewById(R.id.summary);
|
SimpleLayout simpleLayout = new SimpleLayout(view);
|
||||||
textViewSummary.setText(Html.fromHtml(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_TITLE))).toString());
|
|
||||||
|
simpleLayout.textViewSummary.setText(Html.fromHtml(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_TITLE))).toString());
|
||||||
|
|
||||||
TextView textViewItemDate = (TextView) view.findViewById(R.id.tv_item_date);
|
|
||||||
long pubDate = cursor.getLong(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_PUBDATE));
|
long pubDate = cursor.getLong(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_PUBDATE));
|
||||||
//textViewItemDate.setText(simpleDateFormat.format(new Date(pubDate)));
|
|
||||||
String dateString = (String) DateUtils.getRelativeTimeSpanString(pubDate);
|
String dateString = (String) DateUtils.getRelativeTimeSpanString(pubDate);
|
||||||
textViewItemDate.setText(dateString);
|
simpleLayout.textViewItemDate.setText(dateString);
|
||||||
|
|
||||||
TextView textViewTitle = (TextView) view.findViewById(R.id.tv_subscription);
|
simpleLayout.textViewTitle.setText(dbConn.getTitleOfSubscriptionByRowID(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_SUBSCRIPTION_ID))));
|
||||||
textViewTitle.setText(dbConn.getTitleOfSubscriptionByRowID(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_SUBSCRIPTION_ID))));
|
simpleLayout.textViewSummary.setTag(cursor.getString(0));
|
||||||
textViewSummary.setTag(cursor.getString(0));
|
}
|
||||||
|
|
||||||
|
static class SimpleLayout {
|
||||||
|
@InjectView(R.id.summary) TextView textViewSummary;
|
||||||
|
@InjectView(R.id.tv_item_date) TextView textViewItemDate;
|
||||||
|
@InjectView(R.id.tv_subscription) TextView textViewTitle;
|
||||||
|
|
||||||
|
SimpleLayout(View view) {
|
||||||
|
ButterKnife.inject(this, view);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExtendedLayout(View view, Cursor cursor)
|
public void setExtendedLayout(View view, Cursor cursor)
|
||||||
{
|
{
|
||||||
TextView textViewSummary = (TextView) view.findViewById(R.id.summary);
|
ExtendedLayout extendedLayout = new ExtendedLayout(view);
|
||||||
textViewSummary.setText(Html.fromHtml(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_TITLE))).toString());
|
|
||||||
|
extendedLayout.textViewSummary.setText(Html.fromHtml(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_TITLE))).toString());
|
||||||
|
|
||||||
TextView textViewItemDate = (TextView) view.findViewById(R.id.tv_item_date);
|
|
||||||
long pubDate = cursor.getLong(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_PUBDATE));
|
long pubDate = cursor.getLong(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_PUBDATE));
|
||||||
//textViewItemDate.setText(simpleDateFormat.format(new Date(pubDate)));
|
//textViewItemDate.setText(simpleDateFormat.format(new Date(pubDate)));
|
||||||
String dateString = (String) DateUtils.getRelativeTimeSpanString(pubDate);
|
String dateString = (String) DateUtils.getRelativeTimeSpanString(pubDate);
|
||||||
textViewItemDate.setText(dateString);
|
extendedLayout.textViewItemDate.setText(dateString);
|
||||||
|
|
||||||
TextView textViewItemBody = (TextView) view.findViewById(R.id.body);
|
extendedLayout.textViewItemBody.setVisibility(View.INVISIBLE);
|
||||||
String body = cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_BODY));
|
String idItemDb = cursor.getString(0);
|
||||||
textViewItemBody.setText(getBodyText(body));
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||||
|
// Execute in parallel
|
||||||
|
new DescriptionTextLoaderTask(extendedLayout.textViewItemBody, idItemDb).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ((Void) null));
|
||||||
|
else
|
||||||
|
new DescriptionTextLoaderTask(extendedLayout.textViewItemBody, idItemDb).execute((Void) null);
|
||||||
|
|
||||||
TextView textViewTitle = (TextView) view.findViewById(R.id.tv_subscription);
|
extendedLayout.textViewTitle.setText(dbConn.getTitleOfSubscriptionByRowID(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_SUBSCRIPTION_ID))));
|
||||||
textViewTitle.setText(dbConn.getTitleOfSubscriptionByRowID(cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_SUBSCRIPTION_ID))));
|
extendedLayout.textViewSummary.setTag(cursor.getString(0));
|
||||||
textViewSummary.setTag(cursor.getString(0));
|
}
|
||||||
|
|
||||||
|
static class ExtendedLayout {
|
||||||
|
@InjectView(R.id.summary) TextView textViewSummary;
|
||||||
|
@InjectView(R.id.tv_item_date) TextView textViewItemDate;
|
||||||
|
@InjectView(R.id.body) TextView textViewItemBody;
|
||||||
|
@InjectView(R.id.tv_subscription) TextView textViewTitle;
|
||||||
|
|
||||||
|
ExtendedLayout(View view) {
|
||||||
|
ButterKnife.inject(this, view);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||||
|
@ -330,4 +360,76 @@ public class NewsListCursorAdapter extends CursorAdapter {
|
||||||
|
|
||||||
return retView;
|
return retView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class DescriptionTextLoaderTask extends AsyncTask<Void, Void, String> {
|
||||||
|
private String idItemDb;
|
||||||
|
private final WeakReference<TextView> textViewWeakReference;
|
||||||
|
|
||||||
|
public DescriptionTextLoaderTask(TextView textView, String idItemDb) {
|
||||||
|
textViewWeakReference = new WeakReference<TextView>(textView);
|
||||||
|
this.idItemDb = idItemDb;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
// Actual download method, run in the task thread
|
||||||
|
protected String doInBackground(Void... params) {
|
||||||
|
|
||||||
|
DatabaseConnection dbConn = new DatabaseConnection(mContext);
|
||||||
|
|
||||||
|
Cursor cursor = dbConn.getItemByDbID(idItemDb);
|
||||||
|
cursor.moveToFirst();
|
||||||
|
String body = cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_BODY));
|
||||||
|
String result = getBodyText(body);
|
||||||
|
cursor.close();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
// Once the image is downloaded, associates it to the imageView
|
||||||
|
protected void onPostExecute(String text) {
|
||||||
|
if (isCancelled()) {
|
||||||
|
text = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (textViewWeakReference != null) {
|
||||||
|
TextView textView = textViewWeakReference.get();
|
||||||
|
if (textView != null) {
|
||||||
|
textView.setText(text);
|
||||||
|
|
||||||
|
fadeInTextView(textView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void fadeInTextView(final TextView textView)
|
||||||
|
{
|
||||||
|
Animation fadeOut = new AlphaAnimation(0, 1);
|
||||||
|
fadeOut.setInterpolator(new AccelerateInterpolator());
|
||||||
|
fadeOut.setDuration(300);
|
||||||
|
|
||||||
|
fadeOut.setAnimationListener(new Animation.AnimationListener()
|
||||||
|
{
|
||||||
|
public void onAnimationEnd(Animation animation)
|
||||||
|
{
|
||||||
|
textView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
public void onAnimationRepeat(Animation animation) {}
|
||||||
|
public void onAnimationStart(Animation animation) {}
|
||||||
|
});
|
||||||
|
|
||||||
|
textView.startAnimation(fadeOut);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class DatabaseConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SparseArray<String> getUnreadItemCountForFeed() {
|
public SparseArray<String> getUnreadItemCountForFeed() {
|
||||||
String buildSQL = "SELECT " + RSS_ITEM_SUBSCRIPTION_ID + ", COUNT(" + RSS_ITEM_RSSITEM_ID + ")" +
|
String buildSQL = "SELECT " + RSS_ITEM_SUBSCRIPTION_ID + ", COUNT(" + RSS_ITEM_RSSITEM_ID + ")" + // rowid as _id,
|
||||||
" FROM " + RSS_ITEM_TABLE +
|
" FROM " + RSS_ITEM_TABLE +
|
||||||
" GROUP BY " + RSS_ITEM_SUBSCRIPTION_ID;
|
" GROUP BY " + RSS_ITEM_SUBSCRIPTION_ID;
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ public class DatabaseConnection {
|
||||||
|
|
||||||
public long getLowestItemIdStarred()
|
public long getLowestItemIdStarred()
|
||||||
{
|
{
|
||||||
String buildSQL = "SELECT MIN(" + RSS_ITEM_RSSITEM_ID + ") FROM " + RSS_ITEM_TABLE + " WHERE " + RSS_ITEM_STARRED_TEMP + " == 1";
|
String buildSQL = "SELECT MIN(" + RSS_ITEM_RSSITEM_ID + ") FROM " + RSS_ITEM_TABLE + " WHERE " + RSS_ITEM_STARRED_TEMP + " = 1";
|
||||||
return getLongValueBySQL(buildSQL);
|
return getLongValueBySQL(buildSQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,6 +351,24 @@ public class DatabaseConnection {
|
||||||
return database.delete(RSS_ITEM_TABLE, "rowid < ?", new String[] { id_db });
|
return database.delete(RSS_ITEM_TABLE, "rowid < ?", new String[] { id_db });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeXLatestItems(int limit, String execludeFeed) {
|
||||||
|
String sql = "DELETE FROM " + RSS_ITEM_TABLE + " WHERE rowid IN (SELECT rowid FROM " + RSS_ITEM_TABLE + " WHERE " + RSS_ITEM_READ + " != 0 " +
|
||||||
|
" AND " + RSS_ITEM_READ_TEMP + " != 0 XX ORDER BY " + RSS_ITEM_PUBDATE + " desc LIMIT " + limit + ")";
|
||||||
|
|
||||||
|
if(execludeFeed != null)
|
||||||
|
sql = sql.replace("XX", "AND " + RSS_ITEM_SUBSCRIPTION_ID +" != " + execludeFeed);
|
||||||
|
else
|
||||||
|
sql = sql.replace("XX", "");
|
||||||
|
|
||||||
|
database.execSQL(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeReadItems(int limit) {
|
||||||
|
String sql = "DELETE FROM " + RSS_ITEM_TABLE + " WHERE rowid IN (SELECT rowid FROM " + RSS_ITEM_TABLE + " WHERE " + RSS_ITEM_READ_TEMP + " = 1 " +
|
||||||
|
" AND " + RSS_ITEM_READ + " = 1 ORDER BY " + RSS_ITEM_PUBDATE + " desc LIMIT " + limit + ")";
|
||||||
|
database.execSQL(sql);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public Cursor getAllData(String TABLE_NAME) {
|
public Cursor getAllData(String TABLE_NAME) {
|
||||||
String buildSQL = "SELECT rowid as _id, * FROM " + TABLE_NAME;
|
String buildSQL = "SELECT rowid as _id, * FROM " + TABLE_NAME;
|
||||||
|
@ -429,6 +447,14 @@ public class DatabaseConnection {
|
||||||
return database.rawQuery(buildSQL, null);
|
return database.rawQuery(buildSQL, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Cursor getItemByDbID(String ID_ITEM_DB) {//Feeds
|
||||||
|
String buildSQL = "SELECT rowid as _id, * FROM " + RSS_ITEM_TABLE + " WHERE rowid = '" + ID_ITEM_DB + "'";
|
||||||
|
|
||||||
|
if(DATABASE_DEBUG_MODE)
|
||||||
|
Log.d("DB_HELPER", "getSubSubscriptionsByID SQL: " + buildSQL);
|
||||||
|
return database.rawQuery(buildSQL, null);
|
||||||
|
}
|
||||||
|
|
||||||
public Cursor getFeedByDbID(String ID_FEED_DB) {//Feeds
|
public Cursor getFeedByDbID(String ID_FEED_DB) {//Feeds
|
||||||
String buildSQL = "SELECT rowid as _id, * FROM " + SUBSCRIPTION_TABLE + " WHERE rowid = '" + ID_FEED_DB + "'";
|
String buildSQL = "SELECT rowid as _id, * FROM " + SUBSCRIPTION_TABLE + " WHERE rowid = '" + ID_FEED_DB + "'";
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,40 @@ public class FavIconHandler {
|
||||||
static SparseArray<FavIconCache> imageViewReferences = new SparseArray<FavIconCache>();
|
static SparseArray<FavIconCache> imageViewReferences = new SparseArray<FavIconCache>();
|
||||||
String feedID;
|
String feedID;
|
||||||
|
|
||||||
|
|
||||||
|
static SparseArray<FavIconCache> favIconToFeedId = new SparseArray<FavIconCache>();
|
||||||
|
public static void PreCacheFavIcon(String WEB_URL_TO_FILE, Context context, String feedID) {
|
||||||
|
|
||||||
|
FavIconCache favIconCache = new FavIconCache();
|
||||||
|
favIconCache.context = context;
|
||||||
|
favIconCache.WEB_URL_TO_FILE = WEB_URL_TO_FILE;
|
||||||
|
|
||||||
|
int key = Integer.parseInt(feedID);
|
||||||
|
favIconToFeedId.put(key, favIconCache);
|
||||||
|
GetImageAsyncTask giAsync = new GetImageAsyncTask(WEB_URL_TO_FILE, favIconDownloadFinished, key, ImageHandler.getPathFavIcons(context), context, null);
|
||||||
|
giAsync.scaleImage = true;
|
||||||
|
giAsync.dstHeight = 2*32;
|
||||||
|
giAsync.dstWidth = 2*32;
|
||||||
|
giAsync.feedID = feedID;
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||||
|
// Execute in parallel
|
||||||
|
giAsync.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ((Void)null));
|
||||||
|
else
|
||||||
|
giAsync.execute((Void)null);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImageDownloadFinished favIconDownloadFinished = new ImageDownloadFinished() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void DownloadFinished(int AsynkTaskId, String fileCachePath, BitmapDrawableLruCache lruCache) {
|
||||||
|
FavIconCache favIconCache = favIconToFeedId.get(AsynkTaskId);
|
||||||
|
FavIconHandler.GetFavIconFromCache(favIconCache.WEB_URL_TO_FILE, favIconCache.context, String.valueOf(AsynkTaskId));
|
||||||
|
imageViewReferences.remove(AsynkTaskId);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||||
public void GetImageAsync(ImageView imageView, String WEB_URL_TO_FILE, Context context, String feedID, BitmapDrawableLruCache lruCache)
|
public void GetImageAsync(ImageView imageView, String WEB_URL_TO_FILE, Context context, String feedID, BitmapDrawableLruCache lruCache)
|
||||||
{
|
{
|
||||||
|
|
|
@ -80,6 +80,14 @@ public class ImageHandler {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static File getFullPathOfCacheFileSafe(String WEB_URL_TO_FILE, String rootPath) {
|
||||||
|
try {
|
||||||
|
return getFullPathOfCacheFile(WEB_URL_TO_FILE, rootPath);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static File getFullPathOfCacheFile(String WEB_URL_TO_FILE, String rootPath) throws Exception
|
public static File getFullPathOfCacheFile(String WEB_URL_TO_FILE, String rootPath) throws Exception
|
||||||
{
|
{
|
||||||
URL url = new URL(WEB_URL_TO_FILE.trim());
|
URL url = new URL(WEB_URL_TO_FILE.trim());
|
||||||
|
|
|
@ -26,7 +26,6 @@ import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
|
||||||
import de.luhmer.owncloudnewsreader.async_tasks.FillTextForTextViewAsyncTask;
|
|
||||||
import de.luhmer.owncloudnewsreader.async_tasks.GetImageAsyncTask;
|
import de.luhmer.owncloudnewsreader.async_tasks.GetImageAsyncTask;
|
||||||
import de.luhmer.owncloudnewsreader.helper.BitmapDrawableLruCache;
|
import de.luhmer.owncloudnewsreader.helper.BitmapDrawableLruCache;
|
||||||
import de.luhmer.owncloudnewsreader.helper.ImageDownloadFinished;
|
import de.luhmer.owncloudnewsreader.helper.ImageDownloadFinished;
|
||||||
|
|
|
@ -31,6 +31,7 @@ import android.content.SharedPreferences;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
|
import android.util.SparseArray;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -47,12 +48,14 @@ import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||||
import de.luhmer.owncloudnewsreader.async_tasks.GetImageAsyncTask;
|
import de.luhmer.owncloudnewsreader.async_tasks.GetImageAsyncTask;
|
||||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
|
||||||
import de.luhmer.owncloudnewsreader.helper.BitmapDrawableLruCache;
|
import de.luhmer.owncloudnewsreader.helper.BitmapDrawableLruCache;
|
||||||
|
import de.luhmer.owncloudnewsreader.helper.FavIconHandler;
|
||||||
import de.luhmer.owncloudnewsreader.helper.ImageDownloadFinished;
|
import de.luhmer.owncloudnewsreader.helper.ImageDownloadFinished;
|
||||||
import de.luhmer.owncloudnewsreader.helper.ImageHandler;
|
import de.luhmer.owncloudnewsreader.helper.ImageHandler;
|
||||||
|
|
||||||
public class DownloadImagesService extends IntentService {
|
public class DownloadImagesService extends IntentService {
|
||||||
|
|
||||||
public static final String LAST_ITEM_ID = "LAST_ITEM_ID";
|
public static final String LAST_ITEM_ID = "LAST_ITEM_ID";
|
||||||
|
public static final String DOWNLOAD_FAVICONS_EXCLUSIVE = "DOWNLOAD_FAVICONS_EXCLUSIVE";
|
||||||
private static Random random;
|
private static Random random;
|
||||||
|
|
||||||
private int NOTIFICATION_ID = 1;
|
private int NOTIFICATION_ID = 1;
|
||||||
|
@ -100,16 +103,31 @@ public class DownloadImagesService extends IntentService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onHandleIntent(Intent intent) {
|
protected void onHandleIntent(Intent intent) {
|
||||||
String lastId = String.valueOf(intent.getLongExtra(LAST_ITEM_ID, 0));
|
boolean downloadFavIconsExclusive = intent.getBooleanExtra(DOWNLOAD_FAVICONS_EXCLUSIVE, false);
|
||||||
|
|
||||||
DatabaseConnection dbConn = new DatabaseConnection(this);
|
DatabaseConnection dbConn = new DatabaseConnection(this);
|
||||||
|
Notification notify = BuildNotification();
|
||||||
|
SparseArray<String> linksFavIcons = dbConn.getUrlsToFavIcons();
|
||||||
|
|
||||||
|
if(linksFavIcons.size() > 0)
|
||||||
|
notificationManager.notify(NOTIFICATION_ID, notify);
|
||||||
|
|
||||||
|
for(int i = 0; i < linksFavIcons.size(); i++) {
|
||||||
|
int key = linksFavIcons.keyAt(i);
|
||||||
|
String link = linksFavIcons.get(i);
|
||||||
|
FavIconHandler.PreCacheFavIcon(link, this, String.valueOf(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(!downloadFavIconsExclusive) {
|
||||||
|
String lastId = String.valueOf(intent.getLongExtra(LAST_ITEM_ID, 0));
|
||||||
Cursor cursor = dbConn.getAllItemsWithIdHigher(lastId);
|
Cursor cursor = dbConn.getAllItemsWithIdHigher(lastId);
|
||||||
List<String> links = new ArrayList<String>();
|
List<String> links = new ArrayList<String>();
|
||||||
try
|
try {
|
||||||
{
|
if (cursor != null) {
|
||||||
if(cursor != null)
|
while (cursor.moveToNext()) {
|
||||||
{
|
|
||||||
while(cursor.moveToNext())
|
|
||||||
{
|
|
||||||
String body = cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_BODY));
|
String body = cursor.getString(cursor.getColumnIndex(DatabaseConnection.RSS_ITEM_BODY));
|
||||||
links.addAll(ImageHandler.getImageLinksFromText(body));
|
links.addAll(ImageHandler.getImageLinksFromText(body));
|
||||||
}
|
}
|
||||||
|
@ -122,6 +140,15 @@ public class DownloadImagesService extends IntentService {
|
||||||
}
|
}
|
||||||
maxCount = links.size();
|
maxCount = links.size();
|
||||||
|
|
||||||
|
if (maxCount > 0)
|
||||||
|
notificationManager.notify(NOTIFICATION_ID, notify);
|
||||||
|
|
||||||
|
for (String link : links)
|
||||||
|
new GetImageAsyncTask(link, imgDownloadFinished, 999, ImageHandler.getPathImageCache(this), this, null).execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Notification BuildNotification() {
|
||||||
Intent intentNewsReader = new Intent(this, NewsReaderListActivity.class);
|
Intent intentNewsReader = new Intent(this, NewsReaderListActivity.class);
|
||||||
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intentNewsReader, 0);
|
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intentNewsReader, 0);
|
||||||
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
@ -137,11 +164,7 @@ public class DownloadImagesService extends IntentService {
|
||||||
notify.flags |= Notification.FLAG_AUTO_CANCEL;
|
notify.flags |= Notification.FLAG_AUTO_CANCEL;
|
||||||
//notify.flags |= Notification.FLAG_NO_CLEAR;
|
//notify.flags |= Notification.FLAG_NO_CLEAR;
|
||||||
|
|
||||||
if(maxCount > 0)
|
return notify;
|
||||||
notificationManager.notify(NOTIFICATION_ID, notify);
|
|
||||||
|
|
||||||
for(String link : links)
|
|
||||||
new GetImageAsyncTask(link, imgDownloadFinished, 999, ImageHandler.getPathImageCache(this), this, null).execute();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveOldImages(Context context) {
|
private void RemoveOldImages(Context context) {
|
||||||
|
|
|
@ -85,8 +85,8 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:lines="4"
|
android:lines="4"
|
||||||
android:text="Hi\nfsddfs\nfdsfs\nfsfdsds"
|
android:text="Test"
|
||||||
android:textColor="#858585"
|
android:textColor="@color/extended_listview_body_text_color"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:autoLink="none" />
|
android:autoLink="none" />
|
||||||
<!-- android:gravity="center_vertical" -->
|
<!-- android:gravity="center_vertical" -->
|
||||||
|
@ -120,5 +120,12 @@
|
||||||
android:layout_gravity="center_horizontal" />
|
android:layout_gravity="center_horizontal" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1.5dp"
|
||||||
|
android:layout_marginTop="-2.0dp"
|
||||||
|
android:background="@color/divider_row_color" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -3,9 +3,8 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="65dp"
|
android:layout_height="72dp"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal" >
|
||||||
android:background="@drawable/row_divider_line" >
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/color_line_feed"
|
android:id="@+id/color_line_feed"
|
||||||
|
@ -21,7 +20,7 @@
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="65dp"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,7 +60,7 @@
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:lines="2"
|
android:lines="2"
|
||||||
android:textSize="17sp"
|
android:textSize="17sp"
|
||||||
android:text="hidsaf afdaljkök"
|
android:text="Test"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
@ -78,7 +77,7 @@
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:layout_gravity="left"
|
android:layout_gravity="left"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="Hif dsajfdjasklfds"
|
android:text="Test"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:textSize="13sp" />
|
android:textSize="13sp" />
|
||||||
|
|
||||||
|
@ -93,7 +92,6 @@
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textSize="13sp" />
|
android:textSize="13sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<com.devspark.robototextview.widget.RobotoCheckBox
|
<com.devspark.robototextview.widget.RobotoCheckBox
|
||||||
|
@ -108,9 +106,8 @@
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0.5dp"
|
android:layout_height="1.5dp"
|
||||||
|
android:layout_marginTop="5.5dp"
|
||||||
android:background="@color/divider_row_color" />
|
android:background="@color/divider_row_color" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -4,4 +4,6 @@
|
||||||
<color name="slider_listview_background_color">#383d43</color>
|
<color name="slider_listview_background_color">#383d43</color>
|
||||||
<color name="slider_listview_text_color">#F0F0F0</color>
|
<color name="slider_listview_text_color">#F0F0F0</color>
|
||||||
<color name="divider_row_color">#292929</color>
|
<color name="divider_row_color">#292929</color>
|
||||||
|
|
||||||
|
<color name="extended_listview_body_text_color">#ff9e9e9e</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue