mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 17:46:37 +03:00
Avoid toggling favourite for all selected files
This commit is contained in:
parent
b8a711f1c9
commit
9010476ccc
2 changed files with 25 additions and 13 deletions
|
@ -10,7 +10,7 @@ buildscript {
|
|||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.2.1'
|
||||
classpath 'com.android.tools.build:gradle:2.2.3'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ import java.io.BufferedReader;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -546,26 +547,37 @@ public class FileOperationsHelper {
|
|||
}
|
||||
|
||||
public void toggleFavorites(Collection<OCFile> files, boolean isFavorite){
|
||||
List<OCFile> found = new ArrayList<>();
|
||||
for(OCFile file : files){
|
||||
if(file.isFavorite() == isFavorite){
|
||||
found.add(file);
|
||||
}
|
||||
}
|
||||
|
||||
files.removeAll(found);
|
||||
|
||||
for (OCFile file: files) {
|
||||
toggleFavorite(file, isFavorite);
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleFavorite(OCFile file, boolean isFavorite) {
|
||||
file.setFavorite(isFavorite);
|
||||
mFileActivity.getStorageManager().saveFile(file);
|
||||
if (file.isFavorite() != isFavorite) {
|
||||
file.setFavorite(isFavorite);
|
||||
mFileActivity.getStorageManager().saveFile(file);
|
||||
|
||||
/// register the OCFile instance in the observer service to monitor local updates
|
||||
Intent observedFileIntent = FileObserverService.makeObservedFileIntent(
|
||||
mFileActivity,
|
||||
file,
|
||||
mFileActivity.getAccount(),
|
||||
isFavorite);
|
||||
mFileActivity.startService(observedFileIntent);
|
||||
/// register the OCFile instance in the observer service to monitor local updates
|
||||
Intent observedFileIntent = FileObserverService.makeObservedFileIntent(
|
||||
mFileActivity,
|
||||
file,
|
||||
mFileActivity.getAccount(),
|
||||
isFavorite);
|
||||
mFileActivity.startService(observedFileIntent);
|
||||
|
||||
/// immediate content synchronization
|
||||
if (file.isFavorite()) {
|
||||
syncFile(file);
|
||||
/// immediate content synchronization
|
||||
if (file.isFavorite()) {
|
||||
syncFile(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue