Fix #318
This commit is contained in:
parent
bd3c94fe91
commit
17afd9de0c
5 changed files with 51 additions and 24 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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<RssItem> {
|
|||
private int selectedDesign = 0;
|
||||
private FragmentActivity mActivity;
|
||||
private IPlayPausePodcastClicked playPausePodcastClicked;
|
||||
|
||||
private FavIconHandler favIconHandler;
|
||||
|
||||
public NewsListArrayAdapter(FragmentActivity activity, LazyList<RssItem> lazyList, IOnStayUnread onStayUnread, IPlayPausePodcastClicked playPausePodcastClicked) {
|
||||
super(activity, lazyList);
|
||||
|
@ -87,6 +88,7 @@ public class NewsListArrayAdapter extends GreenDaoListAdapter<RssItem> {
|
|||
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<RssItem> {
|
|||
@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<RssItem> {
|
|||
}
|
||||
|
||||
|
||||
favIconHandler.loadFavIconForFeed(rssItem.getFeed().getFaviconUrl(), simpleLayout.imgViewFavIcon);
|
||||
|
||||
//Podcast stuff
|
||||
if (DatabaseConnectionOrm.ALLOWED_PODCASTS_TYPES.contains(rssItem.getEnclosureMime())) {
|
||||
final boolean isPlaying = idOfCurrentlyPlayedPodcast == rssItem.getId();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -31,15 +31,22 @@
|
|||
android:layout_marginTop="@dimen/listview_row_margin_top"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ImageView
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:id="@+id/imgViewFavIcon"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_subscription"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_gravity="left"
|
||||
android:singleLine="true"
|
||||
android:text="Hdfsa"
|
||||
android:text="Hdfsffsggfddsa"
|
||||
android:layout_weight="1"
|
||||
android:textSize="15sp" />
|
||||
|
||||
|
|
|
@ -70,6 +70,13 @@
|
|||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ImageView
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:id="@+id/imgViewFavIcon"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_subscription"
|
||||
android:layout_width="0dp"
|
||||
|
|
Loading…
Reference in a new issue