mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
Merge pull request #524 from mario/improvement-toggle-favourite-only-relevant-files
Avoid toggling favourite for all selected files
This commit is contained in:
commit
668229a2ed
1 changed files with 24 additions and 12 deletions
|
@ -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> alreadyRightStateList = new ArrayList<>();
|
||||
for(OCFile file : files) {
|
||||
if(file.isFavorite() == isFavorite) {
|
||||
alreadyRightStateList.add(file);
|
||||
}
|
||||
}
|
||||
|
||||
files.removeAll(alreadyRightStateList);
|
||||
|
||||
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