Use favourite

This commit is contained in:
Mario Danic 2017-03-10 18:52:48 +01:00 committed by AndyScherzinger
parent bb3dfac2d4
commit add50e3149
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 20 additions and 6 deletions

View file

@ -92,6 +92,8 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
private boolean mShareWithSharee;
private boolean mIsFavorite;
/**
* URI to the local path of the file contents, if stored in the device; cached after first call
* to {@link #getStorageUri()}
@ -151,7 +153,7 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
mIsDownloading = source.readInt() == 1;
mEtagInConflict = source.readString();
mShareWithSharee = source.readInt() == 1;
mIsFavorite = source.readInt() == 1;
}
@Override
@ -178,6 +180,15 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
dest.writeInt(mIsDownloading ? 1 : 0);
dest.writeString(mEtagInConflict);
dest.writeInt(mShareWithSharee ? 1 : 0);
dest.writeInt(mIsFavorite ? 1 : 0);
}
public boolean getIsFavorite() {
return mIsFavorite;
}
public void setFavorite(boolean mIsFavorite) {
this.mIsFavorite = mIsFavorite;
}
/**
@ -423,6 +434,7 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
mIsDownloading = false;
mEtagInConflict = null;
mShareWithSharee = false;
mIsFavorite = false;
}
/**
@ -570,10 +582,10 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
@Override
public String toString() {
String asString = "[id=%s, name=%s, mime=%s, downloaded=%s, local=%s, remote=%s, " +
"parentId=%s, favorite=%s etag=%s]";
"parentId=%s, availableOffline=%s etag=%s favourite=%s]";
asString = String.format(asString, mId, getFileName(), mMimeType, isDown(),
mLocalPath, mRemotePath, mParentId, mAvailableOffline,
mEtag);
mEtag, mIsFavorite);
return asString;
}

View file

@ -228,6 +228,7 @@ public class FileStorageUtils {
file.setEtag(remote.getEtag());
file.setPermissions(remote.getPermissions());
file.setRemoteId(remote.getRemoteId());
file.setFavorite(remote.getIsFavorite());
return file;
}
@ -246,6 +247,7 @@ public class FileStorageUtils {
file.setEtag(ocFile.getEtag());
file.setPermissions(ocFile.getPermissions());
file.setRemoteId(ocFile.getRemoteId());
file.setFavorite(ocFile.getIsFavorite());
return file;
}
@ -454,11 +456,11 @@ public class FileStorageUtils {
public static Vector<OCFile> sortOCFilesByFavourite(Vector<OCFile> files){
Collections.sort(files, new Comparator<OCFile>() {
public int compare(OCFile o1, OCFile o2) {
if (o1.isAvailableOffline() && o2.isAvailableOffline()) {
if (o1.getIsFavorite() && o2.getIsFavorite()) {
return 0;
} else if (o1.isAvailableOffline()) {
} else if (o1.getIsFavorite()) {
return -1;
} else if (o2.isAvailableOffline()) {
} else if (o2.getIsFavorite()) {
return 1;
}
return 0;