Even use expired cache if there is no network

Closes #2260
This commit is contained in:
ByteHamster 2018-04-05 16:57:48 +02:00
parent 43f450433e
commit 8016a35193
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);