2017-09-03 06:04:18 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Mauricio Colli <mauriciocolli@outlook.com>
|
|
|
|
* StateSaver.java is part of NewPipe
|
|
|
|
*
|
|
|
|
* License: GPL-3.0+
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.schabi.newpipe.util;
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Parcel;
|
|
|
|
import android.os.Parcelable;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.util.Log;
|
|
|
|
|
2020-03-31 17:20:15 +00:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
2017-10-08 15:37:02 +00:00
|
|
|
import org.schabi.newpipe.BuildConfig;
|
2017-09-03 06:04:18 +00:00
|
|
|
import org.schabi.newpipe.MainActivity;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
import java.io.FilenameFilter;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.ObjectInputStream;
|
|
|
|
import java.io.ObjectOutputStream;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.Queue;
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
|
|
/**
|
2020-03-31 17:20:15 +00:00
|
|
|
* A way to save state to disk or in a in-memory map
|
|
|
|
* if it's just changing configurations (i.e. rotating the phone).
|
2017-09-03 06:04:18 +00:00
|
|
|
*/
|
2020-03-31 17:20:15 +00:00
|
|
|
public final class StateSaver {
|
|
|
|
public static final String KEY_SAVED_STATE = "key_saved_state";
|
|
|
|
private static final ConcurrentHashMap<String, Queue<Object>> STATE_OBJECTS_HOLDER
|
|
|
|
= new ConcurrentHashMap<>();
|
2017-09-03 06:04:18 +00:00
|
|
|
private static final String TAG = "StateSaver";
|
|
|
|
private static final String CACHE_DIR_NAME = "state_cache";
|
|
|
|
private static String cacheDirPath;
|
|
|
|
|
|
|
|
private StateSaver() {
|
|
|
|
//no instance
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-03-31 17:20:15 +00:00
|
|
|
* Initialize the StateSaver, usually you want to call this in the Application class.
|
2017-09-03 06:04:18 +00:00
|
|
|
*
|
|
|
|
* @param context used to get the available cache dir
|
|
|
|
*/
|
2020-03-31 17:20:15 +00:00
|
|
|
public static void init(final Context context) {
|
2020-08-16 08:24:58 +00:00
|
|
|
final File externalCacheDir = context.getExternalCacheDir();
|
2020-03-31 17:20:15 +00:00
|
|
|
if (externalCacheDir != null) {
|
|
|
|
cacheDirPath = externalCacheDir.getAbsolutePath();
|
|
|
|
}
|
|
|
|
if (TextUtils.isEmpty(cacheDirPath)) {
|
|
|
|
cacheDirPath = context.getCacheDir().getAbsolutePath();
|
|
|
|
}
|
2017-09-03 06:04:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see #tryToRestore(SavedState, WriteRead)
|
2020-03-31 17:20:15 +00:00
|
|
|
* @param outState
|
|
|
|
* @param writeRead
|
|
|
|
* @return the saved state
|
2017-09-03 06:04:18 +00:00
|
|
|
*/
|
2020-03-31 17:20:15 +00:00
|
|
|
public static SavedState tryToRestore(final Bundle outState, final WriteRead writeRead) {
|
|
|
|
if (outState == null || writeRead == null) {
|
|
|
|
return null;
|
|
|
|
}
|
2017-09-03 06:04:18 +00:00
|
|
|
|
2020-08-16 08:24:58 +00:00
|
|
|
final SavedState savedState = outState.getParcelable(KEY_SAVED_STATE);
|
2020-03-31 17:20:15 +00:00
|
|
|
if (savedState == null) {
|
|
|
|
return null;
|
|
|
|
}
|
2017-09-03 06:04:18 +00:00
|
|
|
|
|
|
|
return tryToRestore(savedState, writeRead);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-03-31 17:20:15 +00:00
|
|
|
* Try to restore the state from memory and disk,
|
|
|
|
* using the {@link StateSaver.WriteRead#readFrom(Queue)} from the writeRead.
|
|
|
|
* @param savedState
|
|
|
|
* @param writeRead
|
|
|
|
* @return the saved state
|
2017-09-03 06:04:18 +00:00
|
|
|
*/
|
2017-10-08 15:37:02 +00:00
|
|
|
@Nullable
|
2020-03-31 17:20:15 +00:00
|
|
|
private static SavedState tryToRestore(@NonNull final SavedState savedState,
|
|
|
|
@NonNull final WriteRead writeRead) {
|
2017-09-03 06:04:18 +00:00
|
|
|
if (MainActivity.DEBUG) {
|
2020-03-31 17:20:15 +00:00
|
|
|
Log.d(TAG, "tryToRestore() called with: savedState = [" + savedState + "], "
|
|
|
|
+ "writeRead = [" + writeRead + "]");
|
2017-09-03 06:04:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FileInputStream fileInputStream = null;
|
|
|
|
try {
|
2020-03-31 17:20:15 +00:00
|
|
|
Queue<Object> savedObjects
|
|
|
|
= STATE_OBJECTS_HOLDER.remove(savedState.getPrefixFileSaved());
|
2017-09-03 06:04:18 +00:00
|
|
|
if (savedObjects != null) {
|
|
|
|
writeRead.readFrom(savedObjects);
|
|
|
|
if (MainActivity.DEBUG) {
|
2020-03-31 17:20:15 +00:00
|
|
|
Log.d(TAG, "tryToSave: reading objects from holder > " + savedObjects
|
|
|
|
+ ", stateObjectsHolder > " + STATE_OBJECTS_HOLDER);
|
2017-09-03 06:04:18 +00:00
|
|
|
}
|
|
|
|
return savedState;
|
|
|
|
}
|
|
|
|
|
2020-08-16 08:24:58 +00:00
|
|
|
final File file = new File(savedState.getPathFileSaved());
|
2017-10-08 15:37:02 +00:00
|
|
|
if (!file.exists()) {
|
2020-03-31 17:20:15 +00:00
|
|
|
if (MainActivity.DEBUG) {
|
2017-10-08 15:37:02 +00:00
|
|
|
Log.d(TAG, "Cache file doesn't exist: " + file.getAbsolutePath());
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2017-09-03 06:04:18 +00:00
|
|
|
|
|
|
|
fileInputStream = new FileInputStream(file);
|
2020-08-16 08:24:58 +00:00
|
|
|
final ObjectInputStream inputStream = new ObjectInputStream(fileInputStream);
|
2017-09-03 06:04:18 +00:00
|
|
|
//noinspection unchecked
|
|
|
|
savedObjects = (Queue<Object>) inputStream.readObject();
|
|
|
|
if (savedObjects != null) {
|
|
|
|
writeRead.readFrom(savedObjects);
|
|
|
|
}
|
|
|
|
|
|
|
|
return savedState;
|
2020-08-16 08:24:58 +00:00
|
|
|
} catch (final Exception e) {
|
2017-10-08 15:37:02 +00:00
|
|
|
Log.e(TAG, "Failed to restore state", e);
|
2017-09-03 06:04:18 +00:00
|
|
|
} finally {
|
|
|
|
if (fileInputStream != null) {
|
|
|
|
try {
|
|
|
|
fileInputStream.close();
|
2020-08-16 08:24:58 +00:00
|
|
|
} catch (final IOException ignored) {
|
2017-09-03 06:04:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see #tryToSave(boolean, String, String, WriteRead)
|
2020-03-31 17:20:15 +00:00
|
|
|
* @param isChangingConfig
|
|
|
|
* @param savedState
|
|
|
|
* @param outState
|
|
|
|
* @param writeRead
|
|
|
|
* @return the saved state or {@code null}
|
2017-09-03 06:04:18 +00:00
|
|
|
*/
|
2017-10-08 15:37:02 +00:00
|
|
|
@Nullable
|
2020-03-31 17:20:15 +00:00
|
|
|
public static SavedState tryToSave(final boolean isChangingConfig,
|
|
|
|
@Nullable final SavedState savedState, final Bundle outState,
|
|
|
|
final WriteRead writeRead) {
|
2017-10-08 15:37:02 +00:00
|
|
|
@NonNull
|
2020-08-16 08:24:58 +00:00
|
|
|
final String currentSavedPrefix;
|
2017-10-08 15:37:02 +00:00
|
|
|
if (savedState == null || TextUtils.isEmpty(savedState.getPrefixFileSaved())) {
|
|
|
|
// Generate unique prefix
|
|
|
|
currentSavedPrefix = System.nanoTime() - writeRead.hashCode() + "";
|
|
|
|
} else {
|
|
|
|
// Reuse prefix
|
|
|
|
currentSavedPrefix = savedState.getPrefixFileSaved();
|
|
|
|
}
|
2017-09-03 06:04:18 +00:00
|
|
|
|
2020-03-31 17:20:15 +00:00
|
|
|
final SavedState newSavedState = tryToSave(isChangingConfig, currentSavedPrefix,
|
|
|
|
writeRead.generateSuffix(), writeRead);
|
|
|
|
if (newSavedState != null) {
|
|
|
|
outState.putParcelable(StateSaver.KEY_SAVED_STATE, newSavedState);
|
|
|
|
return newSavedState;
|
2017-09-03 06:04:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-03-31 17:20:15 +00:00
|
|
|
* If it's not changing configuration (i.e. rotating screen),
|
|
|
|
* try to write the state from {@link StateSaver.WriteRead#writeTo(Queue)}
|
|
|
|
* to the file with the name of prefixFileName + suffixFileName,
|
|
|
|
* in a cache folder got from the {@link #init(Context)}.
|
2017-09-03 06:04:18 +00:00
|
|
|
* <p>
|
2020-03-31 17:20:15 +00:00
|
|
|
* It checks if the file already exists and if it does, just return the path,
|
|
|
|
* so a good way to save is:
|
|
|
|
* </p>
|
2017-10-08 15:37:02 +00:00
|
|
|
* <ul>
|
2020-03-31 17:20:15 +00:00
|
|
|
* <li>A fixed prefix for the file</li>
|
|
|
|
* <li>A changing suffix</li>
|
2017-10-08 15:37:02 +00:00
|
|
|
* </ul>
|
|
|
|
*
|
|
|
|
* @param isChangingConfig
|
|
|
|
* @param prefixFileName
|
|
|
|
* @param suffixFileName
|
|
|
|
* @param writeRead
|
2020-03-31 17:20:15 +00:00
|
|
|
* @return the saved state or {@code null}
|
2017-09-03 06:04:18 +00:00
|
|
|
*/
|
2017-10-08 15:37:02 +00:00
|
|
|
@Nullable
|
2020-03-31 17:20:15 +00:00
|
|
|
private static SavedState tryToSave(final boolean isChangingConfig, final String prefixFileName,
|
|
|
|
final String suffixFileName, final WriteRead writeRead) {
|
2017-09-03 06:04:18 +00:00
|
|
|
if (MainActivity.DEBUG) {
|
2020-03-31 17:20:15 +00:00
|
|
|
Log.d(TAG, "tryToSave() called with: "
|
|
|
|
+ "isChangingConfig = [" + isChangingConfig + "], "
|
|
|
|
+ "prefixFileName = [" + prefixFileName + "], "
|
|
|
|
+ "suffixFileName = [" + suffixFileName + "], "
|
|
|
|
+ "writeRead = [" + writeRead + "]");
|
2017-09-03 06:04:18 +00:00
|
|
|
}
|
|
|
|
|
2020-08-16 08:24:58 +00:00
|
|
|
final LinkedList<Object> savedObjects = new LinkedList<>();
|
2017-09-03 06:04:18 +00:00
|
|
|
writeRead.writeTo(savedObjects);
|
|
|
|
|
|
|
|
if (isChangingConfig) {
|
|
|
|
if (savedObjects.size() > 0) {
|
2020-03-31 17:20:15 +00:00
|
|
|
STATE_OBJECTS_HOLDER.put(prefixFileName, savedObjects);
|
2017-09-03 06:04:18 +00:00
|
|
|
return new SavedState(prefixFileName, "");
|
2017-10-08 15:37:02 +00:00
|
|
|
} else {
|
2020-03-31 17:20:15 +00:00
|
|
|
if (MainActivity.DEBUG) {
|
|
|
|
Log.d(TAG, "Nothing to save");
|
|
|
|
}
|
2017-10-08 15:37:02 +00:00
|
|
|
return null;
|
|
|
|
}
|
2017-09-03 06:04:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FileOutputStream fileOutputStream = null;
|
|
|
|
try {
|
|
|
|
File cacheDir = new File(cacheDirPath);
|
2020-03-31 17:20:15 +00:00
|
|
|
if (!cacheDir.exists()) {
|
|
|
|
throw new RuntimeException("Cache dir does not exist > " + cacheDirPath);
|
|
|
|
}
|
2017-09-03 06:04:18 +00:00
|
|
|
cacheDir = new File(cacheDir, CACHE_DIR_NAME);
|
|
|
|
if (!cacheDir.exists()) {
|
2020-03-31 17:20:15 +00:00
|
|
|
if (!cacheDir.mkdir()) {
|
|
|
|
if (BuildConfig.DEBUG) {
|
|
|
|
Log.e(TAG,
|
|
|
|
"Failed to create cache directory " + cacheDir.getAbsolutePath());
|
2017-10-08 15:37:02 +00:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2017-09-03 06:04:18 +00:00
|
|
|
}
|
|
|
|
|
2020-08-16 08:24:58 +00:00
|
|
|
final File file = new File(cacheDir, prefixFileName
|
2020-03-31 17:20:15 +00:00
|
|
|
+ (TextUtils.isEmpty(suffixFileName) ? ".cache" : suffixFileName));
|
2017-09-03 06:04:18 +00:00
|
|
|
if (file.exists() && file.length() > 0) {
|
|
|
|
// If the file already exists, just return it
|
|
|
|
return new SavedState(prefixFileName, file.getAbsolutePath());
|
|
|
|
} else {
|
|
|
|
// Delete any file that contains the prefix
|
2020-08-16 08:24:58 +00:00
|
|
|
final File[] files = cacheDir.listFiles(new FilenameFilter() {
|
2017-09-03 06:04:18 +00:00
|
|
|
@Override
|
2020-03-31 17:20:15 +00:00
|
|
|
public boolean accept(final File dir, final String name) {
|
2017-09-03 06:04:18 +00:00
|
|
|
return name.contains(prefixFileName);
|
|
|
|
}
|
|
|
|
});
|
2020-08-16 08:24:58 +00:00
|
|
|
for (final File fileToDelete : files) {
|
2017-10-08 15:37:02 +00:00
|
|
|
fileToDelete.delete();
|
|
|
|
}
|
2017-09-03 06:04:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fileOutputStream = new FileOutputStream(file);
|
2020-08-16 08:24:58 +00:00
|
|
|
final ObjectOutputStream outputStream = new ObjectOutputStream(fileOutputStream);
|
2017-09-03 06:04:18 +00:00
|
|
|
outputStream.writeObject(savedObjects);
|
|
|
|
|
|
|
|
return new SavedState(prefixFileName, file.getAbsolutePath());
|
2020-08-16 08:24:58 +00:00
|
|
|
} catch (final Exception e) {
|
2017-10-08 15:37:02 +00:00
|
|
|
Log.e(TAG, "Failed to save state", e);
|
2017-09-03 06:04:18 +00:00
|
|
|
} finally {
|
|
|
|
if (fileOutputStream != null) {
|
|
|
|
try {
|
|
|
|
fileOutputStream.close();
|
2020-08-16 08:24:58 +00:00
|
|
|
} catch (final IOException ignored) { }
|
2017-09-03 06:04:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-03-31 17:20:15 +00:00
|
|
|
* Delete the cache file contained in the savedState.
|
|
|
|
* Also remove any possible-existing value in the memory-cache.
|
|
|
|
*
|
|
|
|
* @param savedState the saved state to delete
|
2017-09-03 06:04:18 +00:00
|
|
|
*/
|
2020-03-31 17:20:15 +00:00
|
|
|
public static void onDestroy(final SavedState savedState) {
|
|
|
|
if (MainActivity.DEBUG) {
|
|
|
|
Log.d(TAG, "onDestroy() called with: savedState = [" + savedState + "]");
|
|
|
|
}
|
2017-09-03 06:04:18 +00:00
|
|
|
|
2017-10-08 15:37:02 +00:00
|
|
|
if (savedState != null && !TextUtils.isEmpty(savedState.getPathFileSaved())) {
|
2020-03-31 17:20:15 +00:00
|
|
|
STATE_OBJECTS_HOLDER.remove(savedState.getPrefixFileSaved());
|
2017-09-03 06:04:18 +00:00
|
|
|
try {
|
|
|
|
//noinspection ResultOfMethodCallIgnored
|
2017-10-08 15:37:02 +00:00
|
|
|
new File(savedState.getPathFileSaved()).delete();
|
2020-08-16 08:24:58 +00:00
|
|
|
} catch (final Exception ignored) {
|
2017-09-03 06:04:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear all the files in cache (in memory and disk).
|
|
|
|
*/
|
|
|
|
public static void clearStateFiles() {
|
2020-03-31 17:20:15 +00:00
|
|
|
if (MainActivity.DEBUG) {
|
|
|
|
Log.d(TAG, "clearStateFiles() called");
|
|
|
|
}
|
2017-09-03 06:04:18 +00:00
|
|
|
|
2020-03-31 17:20:15 +00:00
|
|
|
STATE_OBJECTS_HOLDER.clear();
|
2017-09-03 06:04:18 +00:00
|
|
|
File cacheDir = new File(cacheDirPath);
|
2020-03-31 17:20:15 +00:00
|
|
|
if (!cacheDir.exists()) {
|
|
|
|
return;
|
|
|
|
}
|
2017-09-03 06:04:18 +00:00
|
|
|
|
|
|
|
cacheDir = new File(cacheDir, CACHE_DIR_NAME);
|
|
|
|
if (cacheDir.exists()) {
|
2020-08-16 08:24:58 +00:00
|
|
|
for (final File file : cacheDir.listFiles()) {
|
2020-03-31 17:20:15 +00:00
|
|
|
file.delete();
|
|
|
|
}
|
2017-09-03 06:04:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-31 17:20:15 +00:00
|
|
|
/**
|
|
|
|
* Used for describe how to save/read the objects.
|
|
|
|
* <p>
|
|
|
|
* Queue was chosen by its FIFO property.
|
|
|
|
*/
|
|
|
|
public interface WriteRead {
|
|
|
|
/**
|
|
|
|
* Generate a changing suffix that will name the cache file,
|
|
|
|
* and be used to identify if it changed (thus reducing useless reading/saving).
|
|
|
|
*
|
|
|
|
* @return a unique value
|
|
|
|
*/
|
|
|
|
String generateSuffix();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add to this queue objects that you want to save.
|
|
|
|
*
|
|
|
|
* @param objectsToSave the objects to save
|
|
|
|
*/
|
|
|
|
void writeTo(Queue<Object> objectsToSave);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Poll saved objects from the queue in the order they were written.
|
|
|
|
*
|
|
|
|
* @param savedObjects queue of objects returned by {@link #writeTo(Queue)}
|
|
|
|
*/
|
|
|
|
void readFrom(@NonNull Queue<Object> savedObjects) throws Exception;
|
|
|
|
}
|
|
|
|
|
2017-09-03 06:04:18 +00:00
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Inner
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
2017-10-08 15:37:02 +00:00
|
|
|
/**
|
2020-03-31 17:20:15 +00:00
|
|
|
* Information about the saved state on the disk.
|
2017-10-08 15:37:02 +00:00
|
|
|
*/
|
2017-09-03 06:04:18 +00:00
|
|
|
public static class SavedState implements Parcelable {
|
2020-03-31 17:20:15 +00:00
|
|
|
@SuppressWarnings("unused")
|
|
|
|
public static final Parcelable.Creator<SavedState> CREATOR
|
|
|
|
= new Parcelable.Creator<SavedState>() {
|
|
|
|
@Override
|
|
|
|
public SavedState createFromParcel(final Parcel in) {
|
|
|
|
return new SavedState(in);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public SavedState[] newArray(final int size) {
|
|
|
|
return new SavedState[size];
|
|
|
|
}
|
|
|
|
};
|
2017-10-08 15:37:02 +00:00
|
|
|
private final String prefixFileSaved;
|
|
|
|
private final String pathFileSaved;
|
2017-09-03 06:04:18 +00:00
|
|
|
|
2020-03-31 17:20:15 +00:00
|
|
|
public SavedState(final String prefixFileSaved, final String pathFileSaved) {
|
2017-09-03 06:04:18 +00:00
|
|
|
this.prefixFileSaved = prefixFileSaved;
|
|
|
|
this.pathFileSaved = pathFileSaved;
|
|
|
|
}
|
|
|
|
|
2020-03-31 17:20:15 +00:00
|
|
|
protected SavedState(final Parcel in) {
|
2017-09-03 06:04:18 +00:00
|
|
|
prefixFileSaved = in.readString();
|
|
|
|
pathFileSaved = in.readString();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
2017-10-08 15:37:02 +00:00
|
|
|
return getPrefixFileSaved() + " > " + getPathFileSaved();
|
2017-09-03 06:04:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int describeContents() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-03-31 17:20:15 +00:00
|
|
|
public void writeToParcel(final Parcel dest, final int flags) {
|
2017-09-03 06:04:18 +00:00
|
|
|
dest.writeString(prefixFileSaved);
|
|
|
|
dest.writeString(pathFileSaved);
|
|
|
|
}
|
|
|
|
|
2017-10-08 15:37:02 +00:00
|
|
|
/**
|
2020-03-31 17:20:15 +00:00
|
|
|
* Get the prefix of the saved file.
|
|
|
|
*
|
2017-10-08 15:37:02 +00:00
|
|
|
* @return the file prefix
|
|
|
|
*/
|
|
|
|
public String getPrefixFileSaved() {
|
|
|
|
return prefixFileSaved;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-03-31 17:20:15 +00:00
|
|
|
* Get the path to the saved file.
|
|
|
|
*
|
2017-10-08 15:37:02 +00:00
|
|
|
* @return the path to the saved file
|
|
|
|
*/
|
|
|
|
public String getPathFileSaved() {
|
|
|
|
return pathFileSaved;
|
|
|
|
}
|
2017-09-03 06:04:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|