Refactoring: a single method to request ShareActivity

This commit is contained in:
David A. Velasco 2015-10-29 16:16:36 +01:00
parent f4ae62cc48
commit d89488ea01
9 changed files with 9 additions and 57 deletions

View file

@ -278,6 +278,11 @@ public class FileOperationsHelper {
}
}
/**
* Show an instance of {@link ShareType} for sharing or unsharing the {@OCFile} received as parameter.
*
* @param file File to share or unshare.
*/
public void showShareFile(OCFile file){
Intent intent = new Intent(mFileActivity, ShareActivity.class);
intent.putExtra(mFileActivity.EXTRA_FILE, file);

View file

@ -1236,20 +1236,6 @@ public class FileDisplayActivity extends HookActivity
setFile(file);
}
/**
* Shows the share view for sharing {@link OCFile} received as a
* parameter in the second fragment.
*
* @param file {@link OCFile} File to share with
*/
@Override
public void showShareFile(OCFile file) {
Intent intent = new Intent(this, ShareActivity.class);
intent.putExtra(EXTRA_FILE, file);
intent.putExtra(EXTRA_ACCOUNT, getAccount());
startActivity(intent);
}
@Override
protected void updateActionBarTitleAndHomeButton(OCFile chosenFile) {
if (mDualPane) {

View file

@ -38,7 +38,6 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.Toast;
@ -558,17 +557,6 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
}
/**
* Shows the share view for sharing {@link OCFile} received as a
* parameter in the second fragment.
*
* @param file {@link OCFile} File to share with
*/
@Override
public void showShareFile(OCFile file) {
}
@Override
public void onRefresh() {
refreshList(true);

View file

@ -143,12 +143,6 @@ public class FileFragment extends Fragment {
*/
public void onTransferStateChanged(OCFile file, boolean downloading, boolean uploading);
/**
* Request the parent activity to show the view for sharing an {@link OCFile}.
*
* @param file File to share
*/
public void showShareFile(OCFile file);
}
}

View file

@ -348,7 +348,7 @@ public class OCFileListFragment extends ExtendedListFragment
return true;
}
case R.id.action_share_with_users: {
mContainerActivity.showShareFile(mTargetFile);
mContainerActivity.getFileOperationsHelper().showShareFile(mTargetFile);
return true;
}
case R.id.action_open_file_with: {

View file

@ -400,19 +400,6 @@ public class PreviewImageActivity extends FileActivity implements
}
/**
* Shows the share view for sharing {@link OCFile} received as a
* parameter in the second fragment.
*
* @param file {@link OCFile} File to share with
*/
@Override
public void showShareFile(OCFile file) {
Intent intent = new Intent(this, ShareActivity.class);
intent.putExtra(EXTRA_FILE, file);
intent.putExtra(EXTRA_ACCOUNT, getAccount());
startActivity(intent);
}
private void requestForDownload(OCFile file) {
if (mDownloaderBinder == null) {
Log_OC.d(TAG, "requestForDownload called without binder to download service");

View file

@ -290,7 +290,7 @@ public class PreviewImageFragment extends FileFragment {
return true;
}
case R.id.action_share_with_users: {
seeShareFile();
mContainerActivity.getFileOperationsHelper().showShareFile(getFile());
return true;
}
case R.id.action_unshare_file: {
@ -336,10 +336,6 @@ public class PreviewImageFragment extends FileFragment {
mContainerActivity.showDetails(getFile());
}
private void seeShareFile(){
mContainerActivity.showShareFile(getFile());
}
@Override
public void onResume() {
super.onResume();

View file

@ -421,7 +421,7 @@ public class PreviewMediaFragment extends FileFragment implements
private void seeShareFile() {
stopPreview(false);
mContainerActivity.showShareFile(getFile());
mContainerActivity.getFileOperationsHelper().showShareFile(getFile());
}
private void prepareVideo() {

View file

@ -303,7 +303,7 @@ public class PreviewTextFragment extends FileFragment {
return true;
}
case R.id.action_share_with_users: {
seeShareFile();
mContainerActivity.getFileOperationsHelper().showShareFile(getFile());
return true;
}
case R.id.action_unshare_file: {
@ -354,10 +354,6 @@ public class PreviewTextFragment extends FileFragment {
mContainerActivity.showDetails(getFile());
}
private void seeShareFile(){
mContainerActivity.showShareFile(getFile());
}
@Override
public void onPause() {
Log_OC.e(TAG, "onPause");