diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ListView/SubscriptionExpandableListAdapter.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ListView/SubscriptionExpandableListAdapter.java index beeebda8..4180b6c9 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ListView/SubscriptionExpandableListAdapter.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ListView/SubscriptionExpandableListAdapter.java @@ -106,10 +106,10 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter } } - int mTextColorLightTheme; + private int mTextColorLightTheme; + private FavIconHandler favIconHandler; LayoutInflater inflater; - private final String favIconPath; boolean mIsTwoPane; public static boolean isTwoPane(Context context) { return context.getResources().getBoolean(R.bool.two_pane); @@ -120,7 +120,8 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter { mIsTwoPane = isTwoPane(mContext); - this.favIconPath = FileUtils.getPathFavIcons(mContext); + favIconHandler = new FavIconHandler(mContext); + this.inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); this.mContext = mContext; this.dbConn = dbConn; @@ -186,7 +187,7 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter else viewHolder.tV_UnreadCount.setText(""); - loadFavIconForFeed(item.favIcon, viewHolder.imgView_FavIcon); + favIconHandler.loadFavIconForFeed(item.favIcon, viewHolder.imgView_FavIcon); } else { @@ -316,7 +317,7 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter if(group.idFolder == ITEMS_WITHOUT_FOLDER.getValue()) { ConcreteFeedItem concreteFeedItem = ((ConcreteFeedItem) group); - loadFavIconForFeed(concreteFeedItem.favIcon, viewHolder.imgView); + favIconHandler.loadFavIconForFeed(concreteFeedItem.favIcon, viewHolder.imgView); } } else { if(group.id_database == ALL_STARRED_ITEMS.getValue()) { @@ -343,21 +344,7 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter 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); - } - } diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/adapter/NewsListArrayAdapter.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/adapter/NewsListArrayAdapter.java index 2c0dfbd8..0f50ec36 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/adapter/NewsListArrayAdapter.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/adapter/NewsListArrayAdapter.java @@ -50,6 +50,7 @@ import de.luhmer.owncloudnewsreader.cursor.IOnStayUnread; import de.luhmer.owncloudnewsreader.database.DatabaseConnectionOrm; import de.luhmer.owncloudnewsreader.database.model.RssItem; import de.luhmer.owncloudnewsreader.events.podcast.UpdatePodcastStatusEvent; +import de.luhmer.owncloudnewsreader.helper.FavIconHandler; import de.luhmer.owncloudnewsreader.helper.FillTextForTextViewHelper; import de.luhmer.owncloudnewsreader.helper.FontHelper; import de.luhmer.owncloudnewsreader.helper.PostDelayHandler; @@ -78,7 +79,7 @@ public class NewsListArrayAdapter extends GreenDaoListAdapter { private int selectedDesign = 0; private FragmentActivity mActivity; private IPlayPausePodcastClicked playPausePodcastClicked; - + private FavIconHandler favIconHandler; public NewsListArrayAdapter(FragmentActivity activity, LazyList lazyList, IOnStayUnread onStayUnread, IPlayPausePodcastClicked playPausePodcastClicked) { super(activity, lazyList); @@ -87,6 +88,7 @@ public class NewsListArrayAdapter extends GreenDaoListAdapter { this.onStayUnread = onStayUnread; this.playPausePodcastClicked = playPausePodcastClicked; + favIconHandler = new FavIconHandler(mActivity); pDelayHandler = new PostDelayHandler(context); //simpleDateFormat = new SimpleDateFormat("EEE, d. MMM HH:mm:ss"); @@ -250,6 +252,9 @@ public class NewsListArrayAdapter extends GreenDaoListAdapter { @Optional @InjectView(R.id.fl_playPausePodcastWrapper) FrameLayout flPlayPausePodcastWrapper; + @Optional + @InjectView(R.id.imgViewFavIcon) + ImageView imgViewFavIcon; SimpleLayout(View view) { ButterKnife.inject(this, view); @@ -289,6 +294,8 @@ public class NewsListArrayAdapter extends GreenDaoListAdapter { } + favIconHandler.loadFavIconForFeed(rssItem.getFeed().getFaviconUrl(), simpleLayout.imgViewFavIcon); + //Podcast stuff if (DatabaseConnectionOrm.ALLOWED_PODCASTS_TYPES.contains(rssItem.getEnclosureMime())) { final boolean isPlaying = idOfCurrentlyPlayedPodcast == rssItem.getId(); diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FavIconHandler.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FavIconHandler.java index 947f24fb..24a13b55 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FavIconHandler.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FavIconHandler.java @@ -33,6 +33,8 @@ import android.util.Log; import android.util.SparseArray; import android.widget.ImageView; +import com.squareup.picasso.Picasso; + import java.io.File; import java.lang.ref.WeakReference; @@ -44,10 +46,27 @@ import de.luhmer.owncloudnewsreader.database.model.Feed; public class FavIconHandler { private static final String TAG = "FavIconHandler"; - Context context; + private Context context; + private final String favIconPath; public FavIconHandler(Context context) { this.context = context; + favIconPath = FileUtils.getPathFavIcons(context); + } + + public void loadFavIconForFeed(String favIconUrl, ImageView imgView) { + File cacheFile = ImageHandler.getFullPathOfCacheFileSafe(favIconUrl, favIconPath); + if(cacheFile != null && cacheFile.exists()) { + Picasso.with(context) + .load(cacheFile) + .placeholder(FavIconHandler.getResourceIdForRightDefaultFeedIcon(context)) + .into(imgView, null); + } else { + Picasso.with(context) + .load(favIconUrl) + .placeholder(FavIconHandler.getResourceIdForRightDefaultFeedIcon(context)) + .into(imgView, null); + } } public static Drawable GetFavIconFromCache(String URL_TO_PAGE, Context context, Long feedID) @@ -94,7 +113,7 @@ public class FavIconHandler { return; } - GetImageThreaded giAsync = new GetImageThreaded(feed.getFaviconUrl(), favIconDownloadFinished, feed.getId(), FileUtils.getPathFavIcons(context), context); + GetImageThreaded giAsync = new GetImageThreaded(feed.getFaviconUrl(), favIconDownloadFinished, feed.getId(), favIconPath, context); giAsync.scaleImage = true; giAsync.dstHeight = 2*32; giAsync.dstWidth = 2*32; diff --git a/News-Android-App/src/main/res/layout/subscription_detail_list_item_extended.xml b/News-Android-App/src/main/res/layout/subscription_detail_list_item_extended.xml index 7ea0ff88..40e6fa18 100644 --- a/News-Android-App/src/main/res/layout/subscription_detail_list_item_extended.xml +++ b/News-Android-App/src/main/res/layout/subscription_detail_list_item_extended.xml @@ -31,15 +31,22 @@ android:layout_marginTop="@dimen/listview_row_margin_top" android:orientation="horizontal" > + + diff --git a/News-Android-App/src/main/res/layout/subscription_detail_list_item_simple.xml b/News-Android-App/src/main/res/layout/subscription_detail_list_item_simple.xml index 77f87cbc..fc734948 100644 --- a/News-Android-App/src/main/res/layout/subscription_detail_list_item_simple.xml +++ b/News-Android-App/src/main/res/layout/subscription_detail_list_item_simple.xml @@ -70,6 +70,13 @@ android:layout_height="match_parent" android:orientation="horizontal" > + +