Show cached images even if option "Show images" disabled

This commit is contained in:
Alex Sytnyk 2018-04-13 19:00:34 +03:00
parent 65ba05cc11
commit 3ad7d20096
2 changed files with 12 additions and 6 deletions

View file

@ -17,6 +17,7 @@ import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.TextView;
@ -117,9 +118,10 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
saveBtn = (TextView) mainView.findViewById(R.id.save_button);
boolean showImages = getSettings().WIKIVOYAGE_SHOW_IMAGES.get();
contentWebView = (WebView) mainView.findViewById(R.id.content_web_view);
contentWebView.getSettings().setJavaScriptEnabled(true);
contentWebView.getSettings().setLoadsImagesAutomatically(getSettings().WIKIVOYAGE_SHOW_IMAGES.get());
contentWebView.getSettings().setCacheMode(showImages ? WebSettings.LOAD_DEFAULT : WebSettings.LOAD_CACHE_ONLY);
return mainView;
}
@ -231,7 +233,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
StringBuilder sb = new StringBuilder(HEADER_INNER);
String imageTitle = article.getImageTitle();
if (!TextUtils.isEmpty(imageTitle) && getSettings().WIKIVOYAGE_SHOW_IMAGES.get()) {
if (!TextUtils.isEmpty(imageTitle)) {
String url = WikivoyageArticle.getImageUrl(imageTitle, false);
sb.append("<div class=\"title-image\" style=\"background-image: url(").append(url).append(")\"></div>");
}

View file

@ -12,7 +12,9 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.NetworkPolicy;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.RequestCreator;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
@ -73,10 +75,12 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView
Object item = getItem(pos);
if (item instanceof WikivoyageSearchResult) {
WikivoyageSearchResult searchRes = (WikivoyageSearchResult) item;
Picasso.get()
.load(app.getSettings().WIKIVOYAGE_SHOW_IMAGES.get()
? WikivoyageArticle.getImageUrl(searchRes.getImageTitle(), true) : null)
.transform(new CropCircleTransformation())
RequestCreator rc = Picasso.get()
.load(WikivoyageArticle.getImageUrl(searchRes.getImageTitle(), true));
if (!app.getSettings().WIKIVOYAGE_SHOW_IMAGES.get()) {
rc.networkPolicy(NetworkPolicy.OFFLINE);
}
rc.transform(new CropCircleTransformation())
.placeholder(placeholder)
.into(holder.icon);
holder.title.setText(searchRes.getArticleTitles().get(0));