OsmAnd/OsmAnd-api/src/net/osmand/aidlapi/copyfile/CopyFileParams.java

97 lines
2.4 KiB
Java
Raw Normal View History

2019-10-10 16:09:20 +02:00
package net.osmand.aidlapi.copyfile;
2019-10-08 16:42:00 +02:00
import android.os.Bundle;
import android.os.Parcel;
2020-03-04 15:12:06 +01:00
import androidx.annotation.NonNull;
2019-10-08 16:42:00 +02:00
2019-10-10 16:09:20 +02:00
import net.osmand.aidlapi.AidlParams;
2019-10-08 16:42:00 +02:00
public class CopyFileParams extends AidlParams {
2020-10-02 17:15:22 +02:00
public static final String DESTINATION_DIR_KEY = "destinationDir";
public static final String FILE_NAME_KEY = "fileName";
public static final String FILE_PART_DATA_KEY = "filePartData";
public static final String START_TIME_KEY = "startTime";
public static final String DONE_KEY = "done";
private String destinationDir;
2019-10-08 16:42:00 +02:00
private String fileName;
private byte[] filePartData;
private long startTime;
private boolean done;
2020-10-02 17:15:22 +02:00
public CopyFileParams(@NonNull String destinationDir, @NonNull String fileName, @NonNull byte[] filePartData,
long startTime, boolean done) {
this.destinationDir = destinationDir;
2019-10-08 16:42:00 +02:00
this.fileName = fileName;
this.filePartData = filePartData;
this.startTime = startTime;
this.done = done;
}
protected CopyFileParams(Parcel in) {
2019-10-10 13:49:47 +02:00
readFromParcel(in);
2019-10-08 16:42:00 +02:00
}
public static final Creator<CopyFileParams> CREATOR = new Creator<CopyFileParams>() {
@Override
public CopyFileParams createFromParcel(Parcel in) {
return new CopyFileParams(in);
}
@Override
public CopyFileParams[] newArray(int size) {
return new CopyFileParams[size];
}
};
2020-10-02 17:15:22 +02:00
public String getDestinationDir() {
return destinationDir;
}
2019-10-08 16:42:00 +02:00
public String getFileName() {
return fileName;
}
public byte[] getFilePartData() {
return filePartData;
}
public boolean isDone() {
return done;
}
public long getStartTime() {
return startTime;
}
@Override
public void writeToBundle(Bundle bundle) {
2020-10-02 17:15:22 +02:00
bundle.putString(DESTINATION_DIR_KEY, destinationDir);
bundle.putString(FILE_NAME_KEY, fileName);
bundle.putByteArray(FILE_PART_DATA_KEY, filePartData);
bundle.putLong(START_TIME_KEY, startTime);
bundle.putBoolean(DONE_KEY, done);
2019-10-08 16:42:00 +02:00
}
@Override
protected void readFromBundle(Bundle bundle) {
2020-10-02 17:15:22 +02:00
destinationDir = bundle.getString(DESTINATION_DIR_KEY);
fileName = bundle.getString(FILE_NAME_KEY);
filePartData = bundle.getByteArray(FILE_PART_DATA_KEY);
startTime = bundle.getLong(START_TIME_KEY);
done = bundle.getBoolean(DONE_KEY);
2019-10-08 16:42:00 +02:00
}
@Override
public String toString() {
return "CopyFileParams {" +
2020-10-02 17:15:22 +02:00
" destinationDir=" + destinationDir +
2019-10-08 16:42:00 +02:00
" fileName=" + fileName +
", filePartData size=" + filePartData.length +
", startTime=" + startTime +
", done=" + done +
" }";
}
}