}
return true;
}
+ case R.id.action_favorite_file:{
+ mContainerActivity.getFileOperationsHelper().toggleKeepInSync(getFile(), true);
+ return true;
+ }
+ case R.id.action_unfavorite_file:{
+ mContainerActivity.getFileOperationsHelper().toggleKeepInSync(getFile(), false);
+ return true;
+ }
default:
return false;
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.fdKeepInSync: {
- toggleKeepInSync();
+ CheckBox cb = (CheckBox) getView().findViewById(R.id.fdKeepInSync);
+ mContainerActivity.getFileOperationsHelper().toggleKeepInSync(getFile(),cb.isChecked());
break;
}
case R.id.fdCancelBtn: {
Log_OC.e(TAG, "Incorrect view clicked!");
}
}
-
-
- private void toggleKeepInSync() {
- CheckBox cb = (CheckBox) getView().findViewById(R.id.fdKeepInSync);
- OCFile file = getFile();
- file.setKeepInSync(cb.isChecked());
- mContainerActivity.getStorageManager().saveFile(file);
-
- /// register the OCFile instance in the observer service to monitor local updates
- Intent observedFileIntent = FileObserverService.makeObservedFileIntent(
- getActivity(),
- file,
- mAccount,
- cb.isChecked());
- getActivity().startService(observedFileIntent);
-
- /// immediate content synchronization
- if (file.keepInSync()) {
- mContainerActivity.getFileOperationsHelper().syncFile(getFile());
- }
- }
+
/**
* Check if the fragment was created with an empty layout. An empty fragment can't show file details, must be replaced.