UIL: use time-limited disk cache instead of flushing it on startup
flavor images: show X more label if more than one image fix crash on loadmore row
This commit is contained in:
parent
903e4250f9
commit
1bfc708bc0
@ -54,6 +54,7 @@ import org.fox.ttrss.util.TypefaceCache;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -669,6 +670,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
public ImageView menuButtonView;
|
||||
public ViewGroup flavorImageHolder;
|
||||
public ProgressBar flavorImageLoadingBar;
|
||||
public TextView flavorImageMore;
|
||||
}
|
||||
|
||||
private class ArticleListAdapter extends ArrayAdapter<Article> {
|
||||
@ -762,6 +764,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
holder.menuButtonView = (ImageView) v.findViewById(R.id.article_menu_button);
|
||||
holder.flavorImageHolder = (ViewGroup) v.findViewById(R.id.flavorImageHolder);
|
||||
holder.flavorImageLoadingBar = (ProgressBar) v.findViewById(R.id.flavorImageLoadingBar);
|
||||
holder.flavorImageMore = (TextView) v.findViewById(R.id.flavorImageMore);
|
||||
|
||||
v.setTag(holder);
|
||||
|
||||
@ -857,13 +860,20 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
if (holder.flavorImageMore != null) {
|
||||
holder.flavorImageMore.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (holder.flavorImageView != null && m_prefs.getBoolean("headlines_show_flavor_image", true)) {
|
||||
Document doc = Jsoup.parse(articleContent);
|
||||
|
||||
boolean loadableImageFound = false;
|
||||
|
||||
if (doc != null) {
|
||||
Element img = doc.select("img").first();
|
||||
//Element img = doc.select("img").first();
|
||||
|
||||
Elements imgs = doc.select("img");
|
||||
Element img = imgs.first();
|
||||
|
||||
if (img != null) {
|
||||
String imgSrc = img.attr("src");
|
||||
@ -886,6 +896,11 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
|
||||
flavorImageHolder.setVisibility(View.VISIBLE);
|
||||
|
||||
if (imgs.size() > 1 && holder.flavorImageMore != null) {
|
||||
holder.flavorImageMore.setVisibility(View.VISIBLE);
|
||||
holder.flavorImageMore.setText(getString(R.string.flavor_image_more, imgs.size()-1));
|
||||
}
|
||||
|
||||
final boolean weNeedAnimation = MemoryCacheUtils.findCachedBitmapsForImageUri(imgSrc, ImageLoader.getInstance().getMemoryCache()).size() == 0;
|
||||
|
||||
loadableImageFound = true;
|
||||
@ -939,10 +954,10 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
if (!loadableImageFound) {
|
||||
if (!loadableImageFound && holder.flavorImageHolder != null) {
|
||||
holder.flavorImageHolder.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
} else if (holder.flavorImageHolder != null) {
|
||||
holder.flavorImageHolder.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
@ -1,22 +1,5 @@
|
||||
package org.fox.ttrss;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.fox.ttrss.offline.OfflineActivity;
|
||||
import org.fox.ttrss.offline.OfflineDownloadService;
|
||||
import org.fox.ttrss.offline.OfflineUploadService;
|
||||
import org.fox.ttrss.share.SubscribeActivity;
|
||||
import org.fox.ttrss.types.Article;
|
||||
import org.fox.ttrss.types.ArticleList;
|
||||
import org.fox.ttrss.types.Feed;
|
||||
import org.fox.ttrss.types.Label;
|
||||
import org.fox.ttrss.widget.SmallWidgetProvider;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
@ -51,8 +34,28 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nostra13.universalimageloader.cache.disc.impl.LimitedAgeDiscCache;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
||||
import com.nostra13.universalimageloader.utils.StorageUtils;
|
||||
|
||||
import org.fox.ttrss.offline.OfflineActivity;
|
||||
import org.fox.ttrss.offline.OfflineDownloadService;
|
||||
import org.fox.ttrss.offline.OfflineUploadService;
|
||||
import org.fox.ttrss.share.SubscribeActivity;
|
||||
import org.fox.ttrss.types.Article;
|
||||
import org.fox.ttrss.types.ArticleList;
|
||||
import org.fox.ttrss.types.Feed;
|
||||
import org.fox.ttrss.types.Label;
|
||||
import org.fox.ttrss.widget.SmallWidgetProvider;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class OnlineActivity extends CommonActivity {
|
||||
private final String TAG = this.getClass().getSimpleName();
|
||||
@ -175,10 +178,16 @@ public class OnlineActivity extends CommonActivity {
|
||||
|
||||
setStatusBarTint();
|
||||
|
||||
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).build();
|
||||
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
|
||||
.diskCache(
|
||||
new LimitedAgeDiscCache(new File(StorageUtils.getCacheDirectory(getApplicationContext()), "article-images"),
|
||||
2*24*60*60)) // 2 days
|
||||
.build();
|
||||
ImageLoader.getInstance().init(config);
|
||||
ImageLoader.getInstance().clearDiskCache();
|
||||
|
||||
//ImageLoader.getInstance().clearDiskCache();
|
||||
|
||||
|
||||
|
||||
//m_pullToRefreshAttacher = PullToRefreshAttacher.get(this);
|
||||
|
||||
if (isOffline) {
|
||||
|
@ -93,6 +93,14 @@
|
||||
android:scaleType="fitCenter"
|
||||
android:cropToPadding="true"
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="(5 more)"
|
||||
android:alpha="0.5"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:id="@+id/flavorImageMore" />
|
||||
</FrameLayout>
|
||||
</TableRow>
|
||||
|
||||
|
@ -93,6 +93,14 @@
|
||||
android:scaleType="fitCenter"
|
||||
android:cropToPadding="true"
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="(5 more)"
|
||||
android:alpha="0.5"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:id="@+id/flavorImageMore" />
|
||||
</FrameLayout>
|
||||
</TableRow>
|
||||
|
||||
|
@ -94,6 +94,14 @@
|
||||
android:scaleType="fitCenter"
|
||||
android:cropToPadding="true"
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="(5 more)"
|
||||
android:alpha="0.5"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:id="@+id/flavorImageMore" />
|
||||
</FrameLayout>
|
||||
</TableRow>
|
||||
|
||||
|
@ -94,6 +94,14 @@
|
||||
android:scaleType="fitCenter"
|
||||
android:cropToPadding="true"
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="(5 more)"
|
||||
android:alpha="0.5"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:id="@+id/flavorImageMore" />
|
||||
</FrameLayout>
|
||||
</TableRow>
|
||||
|
||||
|
@ -232,5 +232,5 @@
|
||||
<string name="pref_headlines_full_content_long">Show full article content in headlines. Resource intensive, can cause UI lag on some devices.</string>
|
||||
<string name="pref_headlines_full_content">Show full content</string>
|
||||
<string name="prefs_headlines_show_flavor_image">Show article image</string>
|
||||
|
||||
<string name="flavor_image_more">(%1$d more)</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user