Merge pull request #2623 from ByteHamster/webview-cache

Even use expired cache if there is no network
This commit is contained in:
Martin Fietz 2018-04-05 18:46:16 +02:00 committed by GitHub
commit 57b7b094bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -33,6 +33,7 @@ import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.util.Converter;
import de.danoeh.antennapod.core.util.IntentUtils;
import de.danoeh.antennapod.core.util.NetworkUtils;
import de.danoeh.antennapod.core.util.ShareUtils;
import de.danoeh.antennapod.core.util.ShownotesProvider;
import de.danoeh.antennapod.core.util.playback.Playable;
@ -118,6 +119,10 @@ public class ItemDescriptionFragment extends Fragment implements MediaplayerInfo
R.style.Theme_AntennaPod_Dark ? Color.BLACK : Color.WHITE);
ta.recycle();
webvDescription.setBackgroundColor(backgroundColor);
if (!NetworkUtils.networkAvailable()) {
webvDescription.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
// Use cached resources, even if they have expired
}
webvDescription.getSettings().setUseWideViewPort(false);
webvDescription.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
webvDescription.getSettings().setLoadWithOverviewMode(true);

View File

@ -34,6 +34,7 @@ import com.bumptech.glide.Glide;
import com.joanzapata.iconify.Iconify;
import com.joanzapata.iconify.widget.IconButton;
import de.danoeh.antennapod.core.util.NetworkUtils;
import org.apache.commons.lang3.ArrayUtils;
import java.util.List;
@ -189,6 +190,10 @@ public class ItemFragment extends Fragment implements OnSwipeGesture {
}
webvDescription.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.black));
}
if (!NetworkUtils.networkAvailable()) {
webvDescription.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
// Use cached resources, even if they have expired
}
webvDescription.getSettings().setUseWideViewPort(false);
webvDescription.getSettings().setLayoutAlgorithm(
WebSettings.LayoutAlgorithm.NARROW_COLUMNS);