Show cached images even if option "Show images" disabled
This commit is contained in:
parent
65ba05cc11
commit
3ad7d20096
2 changed files with 12 additions and 6 deletions
|
@ -17,6 +17,7 @@ import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -117,9 +118,10 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
|
|
||||||
saveBtn = (TextView) mainView.findViewById(R.id.save_button);
|
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 = (WebView) mainView.findViewById(R.id.content_web_view);
|
||||||
contentWebView.getSettings().setJavaScriptEnabled(true);
|
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;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +233,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
StringBuilder sb = new StringBuilder(HEADER_INNER);
|
StringBuilder sb = new StringBuilder(HEADER_INNER);
|
||||||
|
|
||||||
String imageTitle = article.getImageTitle();
|
String imageTitle = article.getImageTitle();
|
||||||
if (!TextUtils.isEmpty(imageTitle) && getSettings().WIKIVOYAGE_SHOW_IMAGES.get()) {
|
if (!TextUtils.isEmpty(imageTitle)) {
|
||||||
String url = WikivoyageArticle.getImageUrl(imageTitle, false);
|
String url = WikivoyageArticle.getImageUrl(imageTitle, false);
|
||||||
sb.append("<div class=\"title-image\" style=\"background-image: url(").append(url).append(")\"></div>");
|
sb.append("<div class=\"title-image\" style=\"background-image: url(").append(url).append(")\"></div>");
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,9 @@ import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.squareup.picasso.NetworkPolicy;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
|
import com.squareup.picasso.RequestCreator;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -73,10 +75,12 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView
|
||||||
Object item = getItem(pos);
|
Object item = getItem(pos);
|
||||||
if (item instanceof WikivoyageSearchResult) {
|
if (item instanceof WikivoyageSearchResult) {
|
||||||
WikivoyageSearchResult searchRes = (WikivoyageSearchResult) item;
|
WikivoyageSearchResult searchRes = (WikivoyageSearchResult) item;
|
||||||
Picasso.get()
|
RequestCreator rc = Picasso.get()
|
||||||
.load(app.getSettings().WIKIVOYAGE_SHOW_IMAGES.get()
|
.load(WikivoyageArticle.getImageUrl(searchRes.getImageTitle(), true));
|
||||||
? WikivoyageArticle.getImageUrl(searchRes.getImageTitle(), true) : null)
|
if (!app.getSettings().WIKIVOYAGE_SHOW_IMAGES.get()) {
|
||||||
.transform(new CropCircleTransformation())
|
rc.networkPolicy(NetworkPolicy.OFFLINE);
|
||||||
|
}
|
||||||
|
rc.transform(new CropCircleTransformation())
|
||||||
.placeholder(placeholder)
|
.placeholder(placeholder)
|
||||||
.into(holder.icon);
|
.into(holder.icon);
|
||||||
holder.title.setText(searchRes.getArticleTitles().get(0));
|
holder.title.setText(searchRes.getArticleTitles().get(0));
|
||||||
|
|
Loading…
Reference in a new issue