Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
f7aafb87a8
12 changed files with 173 additions and 89 deletions
10
app/proguard-rules.pro
vendored
10
app/proguard-rules.pro
vendored
|
@ -25,3 +25,13 @@
|
||||||
-dontwarn org.mozilla.javascript.tools.**
|
-dontwarn org.mozilla.javascript.tools.**
|
||||||
-dontwarn android.arch.util.paging.CountedDataSource
|
-dontwarn android.arch.util.paging.CountedDataSource
|
||||||
-dontwarn android.arch.persistence.room.paging.LimitOffsetDataSource
|
-dontwarn android.arch.persistence.room.paging.LimitOffsetDataSource
|
||||||
|
|
||||||
|
|
||||||
|
# Rules for icepick. Copy paste from https://github.com/frankiesardo/icepick
|
||||||
|
-dontwarn icepick.**
|
||||||
|
-keep class icepick.** { *; }
|
||||||
|
-keep class **$$Icepick { *; }
|
||||||
|
-keepclasseswithmembernames class * {
|
||||||
|
@icepick.* <fields>;
|
||||||
|
}
|
||||||
|
-keepnames class * { @icepick.State *;}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.arch.persistence.room.Index;
|
||||||
import android.arch.persistence.room.PrimaryKey;
|
import android.arch.persistence.room.PrimaryKey;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||||
|
import org.schabi.newpipe.util.Constants;
|
||||||
|
|
||||||
import static org.schabi.newpipe.database.subscription.SubscriptionEntity.SUBSCRIPTION_SERVICE_ID;
|
import static org.schabi.newpipe.database.subscription.SubscriptionEntity.SUBSCRIPTION_SERVICE_ID;
|
||||||
import static org.schabi.newpipe.database.subscription.SubscriptionEntity.SUBSCRIPTION_TABLE;
|
import static org.schabi.newpipe.database.subscription.SubscriptionEntity.SUBSCRIPTION_TABLE;
|
||||||
|
@ -28,7 +29,7 @@ public class SubscriptionEntity {
|
||||||
private long uid = 0;
|
private long uid = 0;
|
||||||
|
|
||||||
@ColumnInfo(name = SUBSCRIPTION_SERVICE_ID)
|
@ColumnInfo(name = SUBSCRIPTION_SERVICE_ID)
|
||||||
private int serviceId = -1;
|
private int serviceId = Constants.NO_SERVICE_ID;
|
||||||
|
|
||||||
@ColumnInfo(name = SUBSCRIPTION_URL)
|
@ColumnInfo(name = SUBSCRIPTION_URL)
|
||||||
private String url;
|
private String url;
|
||||||
|
|
|
@ -65,6 +65,7 @@ import org.schabi.newpipe.player.PopupVideoPlayer;
|
||||||
import org.schabi.newpipe.player.old.PlayVideoActivity;
|
import org.schabi.newpipe.player.old.PlayVideoActivity;
|
||||||
import org.schabi.newpipe.report.ErrorActivity;
|
import org.schabi.newpipe.report.ErrorActivity;
|
||||||
import org.schabi.newpipe.report.UserAction;
|
import org.schabi.newpipe.report.UserAction;
|
||||||
|
import org.schabi.newpipe.util.Constants;
|
||||||
import org.schabi.newpipe.util.ExtractorHelper;
|
import org.schabi.newpipe.util.ExtractorHelper;
|
||||||
import org.schabi.newpipe.util.InfoCache;
|
import org.schabi.newpipe.util.InfoCache;
|
||||||
import org.schabi.newpipe.util.ListHelper;
|
import org.schabi.newpipe.util.ListHelper;
|
||||||
|
@ -110,7 +111,7 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
|
||||||
private boolean wasRelatedStreamsExpanded = false;
|
private boolean wasRelatedStreamsExpanded = false;
|
||||||
|
|
||||||
@State
|
@State
|
||||||
protected int serviceId = -1;
|
protected int serviceId = Constants.NO_SERVICE_ID;
|
||||||
@State
|
@State
|
||||||
protected String name;
|
protected String name;
|
||||||
@State
|
@State
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.view.View;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.ListExtractor;
|
import org.schabi.newpipe.extractor.ListExtractor;
|
||||||
import org.schabi.newpipe.extractor.ListInfo;
|
import org.schabi.newpipe.extractor.ListInfo;
|
||||||
|
import org.schabi.newpipe.util.Constants;
|
||||||
|
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
public abstract class BaseListInfoFragment<I extends ListInfo> extends BaseListFragment<I, ListExtractor.NextItemsResult> {
|
public abstract class BaseListInfoFragment<I extends ListInfo> extends BaseListFragment<I, ListExtractor.NextItemsResult> {
|
||||||
|
|
||||||
@State
|
@State
|
||||||
protected int serviceId = -1;
|
protected int serviceId = Constants.NO_SERVICE_ID;
|
||||||
@State
|
@State
|
||||||
protected String name;
|
protected String name;
|
||||||
@State
|
@State
|
||||||
|
|
|
@ -46,6 +46,7 @@ import org.schabi.newpipe.fragments.BackPressable;
|
||||||
import org.schabi.newpipe.fragments.list.BaseListFragment;
|
import org.schabi.newpipe.fragments.list.BaseListFragment;
|
||||||
import org.schabi.newpipe.history.HistoryListener;
|
import org.schabi.newpipe.history.HistoryListener;
|
||||||
import org.schabi.newpipe.report.UserAction;
|
import org.schabi.newpipe.report.UserAction;
|
||||||
|
import org.schabi.newpipe.util.Constants;
|
||||||
import org.schabi.newpipe.util.AnimationUtils;
|
import org.schabi.newpipe.util.AnimationUtils;
|
||||||
import org.schabi.newpipe.util.ExtractorHelper;
|
import org.schabi.newpipe.util.ExtractorHelper;
|
||||||
import org.schabi.newpipe.util.LayoutManagerSmoothScroller;
|
import org.schabi.newpipe.util.LayoutManagerSmoothScroller;
|
||||||
|
@ -100,7 +101,7 @@ public class SearchFragment extends BaseListFragment<SearchResult, ListExtractor
|
||||||
private SearchEngine.Filter filter = SearchEngine.Filter.ANY;
|
private SearchEngine.Filter filter = SearchEngine.Filter.ANY;
|
||||||
|
|
||||||
@State
|
@State
|
||||||
protected int serviceId = -1;
|
protected int serviceId = Constants.NO_SERVICE_ID;
|
||||||
@State
|
@State
|
||||||
protected String searchQuery;
|
protected String searchQuery;
|
||||||
@State
|
@State
|
||||||
|
|
|
@ -9,4 +9,6 @@ public class Constants {
|
||||||
public static final String KEY_QUERY = "key_query";
|
public static final String KEY_QUERY = "key_query";
|
||||||
|
|
||||||
public static final String KEY_THEME_CHANGE = "key_theme_change";
|
public static final String KEY_THEME_CHANGE = "key_theme_change";
|
||||||
|
|
||||||
|
public static final int NO_SERVICE_ID = -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,14 @@ public final class ExtractorHelper {
|
||||||
//no instance
|
//no instance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void checkServiceId(int serviceId) {
|
||||||
|
if(serviceId == Constants.NO_SERVICE_ID) {
|
||||||
|
throw new IllegalArgumentException("serviceId is NO_SERVICE_ID");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Single<SearchResult> searchFor(final int serviceId, final String query, final int pageNumber, final String searchLanguage, final SearchEngine.Filter filter) {
|
public static Single<SearchResult> searchFor(final int serviceId, final String query, final int pageNumber, final String searchLanguage, final SearchEngine.Filter filter) {
|
||||||
|
checkServiceId(serviceId);
|
||||||
return Single.fromCallable(new Callable<SearchResult>() {
|
return Single.fromCallable(new Callable<SearchResult>() {
|
||||||
@Override
|
@Override
|
||||||
public SearchResult call() throws Exception {
|
public SearchResult call() throws Exception {
|
||||||
|
@ -61,6 +68,7 @@ public final class ExtractorHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Single<NextItemsResult> getMoreSearchItems(final int serviceId, final String query, final int nextPageNumber, final String searchLanguage, final SearchEngine.Filter filter) {
|
public static Single<NextItemsResult> getMoreSearchItems(final int serviceId, final String query, final int nextPageNumber, final String searchLanguage, final SearchEngine.Filter filter) {
|
||||||
|
checkServiceId(serviceId);
|
||||||
return searchFor(serviceId, query, nextPageNumber, searchLanguage, filter)
|
return searchFor(serviceId, query, nextPageNumber, searchLanguage, filter)
|
||||||
.map(new Function<SearchResult, NextItemsResult>() {
|
.map(new Function<SearchResult, NextItemsResult>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -71,6 +79,7 @@ public final class ExtractorHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Single<List<String>> suggestionsFor(final int serviceId, final String query, final String searchLanguage) {
|
public static Single<List<String>> suggestionsFor(final int serviceId, final String query, final String searchLanguage) {
|
||||||
|
checkServiceId(serviceId);
|
||||||
return Single.fromCallable(new Callable<List<String>>() {
|
return Single.fromCallable(new Callable<List<String>>() {
|
||||||
@Override
|
@Override
|
||||||
public List<String> call() throws Exception {
|
public List<String> call() throws Exception {
|
||||||
|
@ -80,6 +89,7 @@ public final class ExtractorHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Single<StreamInfo> getStreamInfo(final int serviceId, final String url, boolean forceLoad) {
|
public static Single<StreamInfo> getStreamInfo(final int serviceId, final String url, boolean forceLoad) {
|
||||||
|
checkServiceId(serviceId);
|
||||||
return checkCache(forceLoad, serviceId, url, Single.fromCallable(new Callable<StreamInfo>() {
|
return checkCache(forceLoad, serviceId, url, Single.fromCallable(new Callable<StreamInfo>() {
|
||||||
@Override
|
@Override
|
||||||
public StreamInfo call() throws Exception {
|
public StreamInfo call() throws Exception {
|
||||||
|
@ -89,6 +99,7 @@ public final class ExtractorHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Single<ChannelInfo> getChannelInfo(final int serviceId, final String url, boolean forceLoad) {
|
public static Single<ChannelInfo> getChannelInfo(final int serviceId, final String url, boolean forceLoad) {
|
||||||
|
checkServiceId(serviceId);
|
||||||
return checkCache(forceLoad, serviceId, url, Single.fromCallable(new Callable<ChannelInfo>() {
|
return checkCache(forceLoad, serviceId, url, Single.fromCallable(new Callable<ChannelInfo>() {
|
||||||
@Override
|
@Override
|
||||||
public ChannelInfo call() throws Exception {
|
public ChannelInfo call() throws Exception {
|
||||||
|
@ -98,6 +109,7 @@ public final class ExtractorHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Single<NextItemsResult> getMoreChannelItems(final int serviceId, final String url, final String nextStreamsUrl) {
|
public static Single<NextItemsResult> getMoreChannelItems(final int serviceId, final String url, final String nextStreamsUrl) {
|
||||||
|
checkServiceId(serviceId);
|
||||||
return Single.fromCallable(new Callable<NextItemsResult>() {
|
return Single.fromCallable(new Callable<NextItemsResult>() {
|
||||||
@Override
|
@Override
|
||||||
public NextItemsResult call() throws Exception {
|
public NextItemsResult call() throws Exception {
|
||||||
|
@ -107,6 +119,7 @@ public final class ExtractorHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Single<PlaylistInfo> getPlaylistInfo(final int serviceId, final String url, boolean forceLoad) {
|
public static Single<PlaylistInfo> getPlaylistInfo(final int serviceId, final String url, boolean forceLoad) {
|
||||||
|
checkServiceId(serviceId);
|
||||||
return checkCache(forceLoad, serviceId, url, Single.fromCallable(new Callable<PlaylistInfo>() {
|
return checkCache(forceLoad, serviceId, url, Single.fromCallable(new Callable<PlaylistInfo>() {
|
||||||
@Override
|
@Override
|
||||||
public PlaylistInfo call() throws Exception {
|
public PlaylistInfo call() throws Exception {
|
||||||
|
@ -116,6 +129,7 @@ public final class ExtractorHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Single<NextItemsResult> getMorePlaylistItems(final int serviceId, final String url, final String nextStreamsUrl) {
|
public static Single<NextItemsResult> getMorePlaylistItems(final int serviceId, final String url, final String nextStreamsUrl) {
|
||||||
|
checkServiceId(serviceId);
|
||||||
return Single.fromCallable(new Callable<NextItemsResult>() {
|
return Single.fromCallable(new Callable<NextItemsResult>() {
|
||||||
@Override
|
@Override
|
||||||
public NextItemsResult call() throws Exception {
|
public NextItemsResult call() throws Exception {
|
||||||
|
@ -133,6 +147,7 @@ public final class ExtractorHelper {
|
||||||
* and put the results in the cache.
|
* and put the results in the cache.
|
||||||
*/
|
*/
|
||||||
private static <I extends Info> Single<I> checkCache(boolean forceLoad, int serviceId, String url, Single<I> loadFromNetwork) {
|
private static <I extends Info> Single<I> checkCache(boolean forceLoad, int serviceId, String url, Single<I> loadFromNetwork) {
|
||||||
|
checkServiceId(serviceId);
|
||||||
loadFromNetwork = loadFromNetwork.doOnSuccess(new Consumer<I>() {
|
loadFromNetwork = loadFromNetwork.doOnSuccess(new Consumer<I>() {
|
||||||
@Override
|
@Override
|
||||||
public void accept(@NonNull I i) throws Exception {
|
public void accept(@NonNull I i) throws Exception {
|
||||||
|
@ -157,6 +172,7 @@ public final class ExtractorHelper {
|
||||||
* Default implementation uses the {@link InfoCache} to get cached results
|
* Default implementation uses the {@link InfoCache} to get cached results
|
||||||
*/
|
*/
|
||||||
public static <I extends Info> Maybe<I> loadFromCache(final int serviceId, final String url) {
|
public static <I extends Info> Maybe<I> loadFromCache(final int serviceId, final String url) {
|
||||||
|
checkServiceId(serviceId);
|
||||||
return Maybe.defer(new Callable<MaybeSource<? extends I>>() {
|
return Maybe.defer(new Callable<MaybeSource<? extends I>>() {
|
||||||
@Override
|
@Override
|
||||||
public MaybeSource<? extends I> call() throws Exception {
|
public MaybeSource<? extends I> call() throws Exception {
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.schabi.newpipe.util;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
@ -29,6 +30,7 @@ import android.support.annotation.Nullable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.schabi.newpipe.BuildConfig;
|
||||||
import org.schabi.newpipe.MainActivity;
|
import org.schabi.newpipe.MainActivity;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -110,6 +112,7 @@ public class StateSaver {
|
||||||
/**
|
/**
|
||||||
* Try to restore the state from memory and disk, using the {@link StateSaver.WriteRead#readFrom(Queue)} from the writeRead.
|
* Try to restore the state from memory and disk, using the {@link StateSaver.WriteRead#readFrom(Queue)} from the writeRead.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
private static SavedState tryToRestore(@NonNull SavedState savedState, @NonNull WriteRead writeRead) {
|
private static SavedState tryToRestore(@NonNull SavedState savedState, @NonNull WriteRead writeRead) {
|
||||||
if (MainActivity.DEBUG) {
|
if (MainActivity.DEBUG) {
|
||||||
Log.d(TAG, "tryToRestore() called with: savedState = [" + savedState + "], writeRead = [" + writeRead + "]");
|
Log.d(TAG, "tryToRestore() called with: savedState = [" + savedState + "], writeRead = [" + writeRead + "]");
|
||||||
|
@ -117,7 +120,7 @@ public class StateSaver {
|
||||||
|
|
||||||
FileInputStream fileInputStream = null;
|
FileInputStream fileInputStream = null;
|
||||||
try {
|
try {
|
||||||
Queue<Object> savedObjects = stateObjectsHolder.remove(savedState.prefixFileSaved);
|
Queue<Object> savedObjects = stateObjectsHolder.remove(savedState.getPrefixFileSaved());
|
||||||
if (savedObjects != null) {
|
if (savedObjects != null) {
|
||||||
writeRead.readFrom(savedObjects);
|
writeRead.readFrom(savedObjects);
|
||||||
if (MainActivity.DEBUG) {
|
if (MainActivity.DEBUG) {
|
||||||
|
@ -126,8 +129,13 @@ public class StateSaver {
|
||||||
return savedState;
|
return savedState;
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = new File(savedState.pathFileSaved);
|
File file = new File(savedState.getPathFileSaved());
|
||||||
if (!file.exists()) return null;
|
if (!file.exists()) {
|
||||||
|
if(MainActivity.DEBUG) {
|
||||||
|
Log.d(TAG, "Cache file doesn't exist: " + file.getAbsolutePath());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
fileInputStream = new FileInputStream(file);
|
fileInputStream = new FileInputStream(file);
|
||||||
ObjectInputStream inputStream = new ObjectInputStream(fileInputStream);
|
ObjectInputStream inputStream = new ObjectInputStream(fileInputStream);
|
||||||
|
@ -139,7 +147,7 @@ public class StateSaver {
|
||||||
|
|
||||||
return savedState;
|
return savedState;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
Log.e(TAG, "Failed to restore state", e);
|
||||||
} finally {
|
} finally {
|
||||||
if (fileInputStream != null) {
|
if (fileInputStream != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -154,10 +162,17 @@ public class StateSaver {
|
||||||
/**
|
/**
|
||||||
* @see #tryToSave(boolean, String, String, WriteRead)
|
* @see #tryToSave(boolean, String, String, WriteRead)
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public static SavedState tryToSave(boolean isChangingConfig, @Nullable SavedState savedState, Bundle outState, WriteRead writeRead) {
|
public static SavedState tryToSave(boolean isChangingConfig, @Nullable SavedState savedState, Bundle outState, WriteRead writeRead) {
|
||||||
String currentSavedPrefix = savedState == null || TextUtils.isEmpty(savedState.prefixFileSaved)
|
@NonNull
|
||||||
? System.nanoTime() - writeRead.hashCode() + ""
|
String currentSavedPrefix;
|
||||||
: savedState.prefixFileSaved;
|
if (savedState == null || TextUtils.isEmpty(savedState.getPrefixFileSaved())) {
|
||||||
|
// Generate unique prefix
|
||||||
|
currentSavedPrefix = System.nanoTime() - writeRead.hashCode() + "";
|
||||||
|
} else {
|
||||||
|
// Reuse prefix
|
||||||
|
currentSavedPrefix = savedState.getPrefixFileSaved();
|
||||||
|
}
|
||||||
|
|
||||||
savedState = tryToSave(isChangingConfig, currentSavedPrefix, writeRead.generateSuffix(), writeRead);
|
savedState = tryToSave(isChangingConfig, currentSavedPrefix, writeRead.generateSuffix(), writeRead);
|
||||||
if (savedState != null) {
|
if (savedState != null) {
|
||||||
|
@ -173,22 +188,33 @@ public class StateSaver {
|
||||||
* to the file with the name of prefixFileName + suffixFileName, in a cache folder got from the {@link #init(Context)}.
|
* to the file with the name of prefixFileName + suffixFileName, in a cache folder got from the {@link #init(Context)}.
|
||||||
* <p>
|
* <p>
|
||||||
* It checks if the file already exists and if it does, just return the path, so a good way to save is:
|
* It checks if the file already exists and if it does, just return the path, so a good way to save is:
|
||||||
* <li> A fixed prefix for the file
|
* <ul>
|
||||||
* <li> A changing suffix
|
* <li> A fixed prefix for the file</li>
|
||||||
|
* <li> A changing suffix</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @param isChangingConfig
|
||||||
|
* @param prefixFileName
|
||||||
|
* @param suffixFileName
|
||||||
|
* @param writeRead
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
private static SavedState tryToSave(boolean isChangingConfig, final String prefixFileName, String suffixFileName, WriteRead writeRead) {
|
private static SavedState tryToSave(boolean isChangingConfig, final String prefixFileName, String suffixFileName, WriteRead writeRead) {
|
||||||
if (MainActivity.DEBUG) {
|
if (MainActivity.DEBUG) {
|
||||||
Log.d(TAG, "tryToSave() called with: isChangingConfig = [" + isChangingConfig + "], prefixFileName = [" + prefixFileName + "], suffixFileName = [" + suffixFileName + "], writeRead = [" + writeRead + "]");
|
Log.d(TAG, "tryToSave() called with: isChangingConfig = [" + isChangingConfig + "], prefixFileName = [" + prefixFileName + "], suffixFileName = [" + suffixFileName + "], writeRead = [" + writeRead + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
Queue<Object> savedObjects = new LinkedList<>();
|
LinkedList<Object> savedObjects = new LinkedList<>();
|
||||||
writeRead.writeTo(savedObjects);
|
writeRead.writeTo(savedObjects);
|
||||||
|
|
||||||
if (isChangingConfig) {
|
if (isChangingConfig) {
|
||||||
if (savedObjects.size() > 0) {
|
if (savedObjects.size() > 0) {
|
||||||
stateObjectsHolder.put(prefixFileName, savedObjects);
|
stateObjectsHolder.put(prefixFileName, savedObjects);
|
||||||
return new SavedState(prefixFileName, "");
|
return new SavedState(prefixFileName, "");
|
||||||
} else return null;
|
} else {
|
||||||
|
if(MainActivity.DEBUG) Log.d(TAG, "Nothing to save");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileOutputStream fileOutputStream = null;
|
FileOutputStream fileOutputStream = null;
|
||||||
|
@ -197,8 +223,12 @@ public class StateSaver {
|
||||||
if (!cacheDir.exists()) throw new RuntimeException("Cache dir does not exist > " + cacheDirPath);
|
if (!cacheDir.exists()) throw new RuntimeException("Cache dir does not exist > " + cacheDirPath);
|
||||||
cacheDir = new File(cacheDir, CACHE_DIR_NAME);
|
cacheDir = new File(cacheDir, CACHE_DIR_NAME);
|
||||||
if (!cacheDir.exists()) {
|
if (!cacheDir.exists()) {
|
||||||
boolean mkdirResult = cacheDir.mkdir();
|
if(!cacheDir.mkdir()) {
|
||||||
if (!mkdirResult) return null;
|
if(BuildConfig.DEBUG) {
|
||||||
|
Log.e(TAG, "Failed to create cache directory " + cacheDir.getAbsolutePath());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TextUtils.isEmpty(suffixFileName)) suffixFileName = ".cache";
|
if (TextUtils.isEmpty(suffixFileName)) suffixFileName = ".cache";
|
||||||
|
@ -214,7 +244,9 @@ public class StateSaver {
|
||||||
return name.contains(prefixFileName);
|
return name.contains(prefixFileName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
for (File file1 : files) file1.delete();
|
for (File fileToDelete : files) {
|
||||||
|
fileToDelete.delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileOutputStream = new FileOutputStream(file);
|
fileOutputStream = new FileOutputStream(file);
|
||||||
|
@ -223,7 +255,7 @@ public class StateSaver {
|
||||||
|
|
||||||
return new SavedState(prefixFileName, file.getAbsolutePath());
|
return new SavedState(prefixFileName, file.getAbsolutePath());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
Log.e(TAG, "Failed to save state", e);
|
||||||
} finally {
|
} finally {
|
||||||
if (fileOutputStream != null) {
|
if (fileOutputStream != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -241,11 +273,11 @@ public class StateSaver {
|
||||||
public static void onDestroy(SavedState savedState) {
|
public static void onDestroy(SavedState savedState) {
|
||||||
if (MainActivity.DEBUG) Log.d(TAG, "onDestroy() called with: savedState = [" + savedState + "]");
|
if (MainActivity.DEBUG) Log.d(TAG, "onDestroy() called with: savedState = [" + savedState + "]");
|
||||||
|
|
||||||
if (savedState != null && !TextUtils.isEmpty(savedState.pathFileSaved)) {
|
if (savedState != null && !TextUtils.isEmpty(savedState.getPathFileSaved())) {
|
||||||
stateObjectsHolder.remove(savedState.prefixFileSaved);
|
stateObjectsHolder.remove(savedState.getPrefixFileSaved());
|
||||||
try {
|
try {
|
||||||
//noinspection ResultOfMethodCallIgnored
|
//noinspection ResultOfMethodCallIgnored
|
||||||
new File(savedState.pathFileSaved).delete();
|
new File(savedState.getPathFileSaved()).delete();
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -271,9 +303,12 @@ public class StateSaver {
|
||||||
// Inner
|
// Inner
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information about the saved state on the disk
|
||||||
|
*/
|
||||||
public static class SavedState implements Parcelable {
|
public static class SavedState implements Parcelable {
|
||||||
public String prefixFileSaved;
|
private final String prefixFileSaved;
|
||||||
public String pathFileSaved;
|
private final String pathFileSaved;
|
||||||
|
|
||||||
public SavedState(String prefixFileSaved, String pathFileSaved) {
|
public SavedState(String prefixFileSaved, String pathFileSaved) {
|
||||||
this.prefixFileSaved = prefixFileSaved;
|
this.prefixFileSaved = prefixFileSaved;
|
||||||
|
@ -287,7 +322,7 @@ public class StateSaver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return prefixFileSaved + " > " + pathFileSaved;
|
return getPrefixFileSaved() + " > " + getPathFileSaved();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -313,6 +348,22 @@ public class StateSaver {
|
||||||
return new SavedState[size];
|
return new SavedState[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the prefix of the saved file
|
||||||
|
* @return the file prefix
|
||||||
|
*/
|
||||||
|
public String getPrefixFileSaved() {
|
||||||
|
return prefixFileSaved;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the path to the saved file
|
||||||
|
* @return the path to the saved file
|
||||||
|
*/
|
||||||
|
public String getPathFileSaved() {
|
||||||
|
return pathFileSaved;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,5 @@
|
||||||
#Tue Mar 07 14:05:42 CET 2017
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-bin.zip
|
||||||
|
|
110
gradlew
vendored
110
gradlew
vendored
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
##
|
||||||
|
@ -6,47 +6,6 @@
|
||||||
##
|
##
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
DEFAULT_JVM_OPTS=""
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=`basename "$0"`
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
||||||
MAX_FD="maximum"
|
|
||||||
|
|
||||||
warn ( ) {
|
|
||||||
echo "$*"
|
|
||||||
}
|
|
||||||
|
|
||||||
die ( ) {
|
|
||||||
echo
|
|
||||||
echo "$*"
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
|
||||||
cygwin=false
|
|
||||||
msys=false
|
|
||||||
darwin=false
|
|
||||||
case "`uname`" in
|
|
||||||
CYGWIN* )
|
|
||||||
cygwin=true
|
|
||||||
;;
|
|
||||||
Darwin* )
|
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
|
||||||
if $cygwin ; then
|
|
||||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
PRG="$0"
|
PRG="$0"
|
||||||
|
@ -61,9 +20,49 @@ while [ -h "$PRG" ] ; do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
SAVED="`pwd`"
|
SAVED="`pwd`"
|
||||||
cd "`dirname \"$PRG\"`/" >&-
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
APP_HOME="`pwd -P`"
|
APP_HOME="`pwd -P`"
|
||||||
cd "$SAVED" >&-
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
@ -90,7 +89,7 @@ location of your Java installation."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
if [ $? -eq 0 ] ; then
|
if [ $? -eq 0 ] ; then
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
@ -114,6 +113,7 @@ fi
|
||||||
if $cygwin ; then
|
if $cygwin ; then
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
@ -154,11 +154,19 @@ if $cygwin ; then
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
# Escape application args
|
||||||
function splitJvmOpts() {
|
save () {
|
||||||
JVM_OPTS=("$@")
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
}
|
}
|
||||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
APP_ARGS=$(save "$@")
|
||||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
|
||||||
|
|
||||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
|
|
14
gradlew.bat
vendored
14
gradlew.bat
vendored
|
@ -8,14 +8,14 @@
|
||||||
@rem Set local scope for the variables with windows NT shell
|
@rem Set local scope for the variables with windows NT shell
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
set DEFAULT_JVM_OPTS=
|
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
@ -46,10 +46,9 @@ echo location of your Java installation.
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:init
|
:init
|
||||||
@rem Get command-line arguments, handling Windowz variants
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
|
||||||
|
|
||||||
:win9xME_args
|
:win9xME_args
|
||||||
@rem Slurp the command line arguments.
|
@rem Slurp the command line arguments.
|
||||||
|
@ -60,11 +59,6 @@ set _SKIP=2
|
||||||
if "x%~1" == "x" goto execute
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
set CMD_LINE_ARGS=%*
|
||||||
goto execute
|
|
||||||
|
|
||||||
:4NT_args
|
|
||||||
@rem Get arguments from the 4NT Shell from JP Software
|
|
||||||
set CMD_LINE_ARGS=%$
|
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
Loading…
Reference in a new issue