mirror of
https://github.com/nextcloud/android.git
synced 2024-12-21 08:24:08 +03:00
Use favourite
This commit is contained in:
parent
bb3dfac2d4
commit
add50e3149
2 changed files with 20 additions and 6 deletions
|
@ -92,6 +92,8 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
|
||||||
|
|
||||||
private boolean mShareWithSharee;
|
private boolean mShareWithSharee;
|
||||||
|
|
||||||
|
private boolean mIsFavorite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URI to the local path of the file contents, if stored in the device; cached after first call
|
* URI to the local path of the file contents, if stored in the device; cached after first call
|
||||||
* to {@link #getStorageUri()}
|
* to {@link #getStorageUri()}
|
||||||
|
@ -151,7 +153,7 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
|
||||||
mIsDownloading = source.readInt() == 1;
|
mIsDownloading = source.readInt() == 1;
|
||||||
mEtagInConflict = source.readString();
|
mEtagInConflict = source.readString();
|
||||||
mShareWithSharee = source.readInt() == 1;
|
mShareWithSharee = source.readInt() == 1;
|
||||||
|
mIsFavorite = source.readInt() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -178,6 +180,15 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
|
||||||
dest.writeInt(mIsDownloading ? 1 : 0);
|
dest.writeInt(mIsDownloading ? 1 : 0);
|
||||||
dest.writeString(mEtagInConflict);
|
dest.writeString(mEtagInConflict);
|
||||||
dest.writeInt(mShareWithSharee ? 1 : 0);
|
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;
|
mIsDownloading = false;
|
||||||
mEtagInConflict = null;
|
mEtagInConflict = null;
|
||||||
mShareWithSharee = false;
|
mShareWithSharee = false;
|
||||||
|
mIsFavorite = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -570,10 +582,10 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String asString = "[id=%s, name=%s, mime=%s, downloaded=%s, local=%s, remote=%s, " +
|
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(),
|
asString = String.format(asString, mId, getFileName(), mMimeType, isDown(),
|
||||||
mLocalPath, mRemotePath, mParentId, mAvailableOffline,
|
mLocalPath, mRemotePath, mParentId, mAvailableOffline,
|
||||||
mEtag);
|
mEtag, mIsFavorite);
|
||||||
return asString;
|
return asString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -228,6 +228,7 @@ public class FileStorageUtils {
|
||||||
file.setEtag(remote.getEtag());
|
file.setEtag(remote.getEtag());
|
||||||
file.setPermissions(remote.getPermissions());
|
file.setPermissions(remote.getPermissions());
|
||||||
file.setRemoteId(remote.getRemoteId());
|
file.setRemoteId(remote.getRemoteId());
|
||||||
|
file.setFavorite(remote.getIsFavorite());
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,6 +247,7 @@ public class FileStorageUtils {
|
||||||
file.setEtag(ocFile.getEtag());
|
file.setEtag(ocFile.getEtag());
|
||||||
file.setPermissions(ocFile.getPermissions());
|
file.setPermissions(ocFile.getPermissions());
|
||||||
file.setRemoteId(ocFile.getRemoteId());
|
file.setRemoteId(ocFile.getRemoteId());
|
||||||
|
file.setFavorite(ocFile.getIsFavorite());
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,11 +456,11 @@ public class FileStorageUtils {
|
||||||
public static Vector<OCFile> sortOCFilesByFavourite(Vector<OCFile> files){
|
public static Vector<OCFile> sortOCFilesByFavourite(Vector<OCFile> files){
|
||||||
Collections.sort(files, new Comparator<OCFile>() {
|
Collections.sort(files, new Comparator<OCFile>() {
|
||||||
public int compare(OCFile o1, OCFile o2) {
|
public int compare(OCFile o1, OCFile o2) {
|
||||||
if (o1.isAvailableOffline() && o2.isAvailableOffline()) {
|
if (o1.getIsFavorite() && o2.getIsFavorite()) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (o1.isAvailableOffline()) {
|
} else if (o1.getIsFavorite()) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (o2.isAvailableOffline()) {
|
} else if (o2.getIsFavorite()) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue