mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Move storeSharedPrefs to fragment that is already injected
This commit is contained in:
parent
9fb82da313
commit
9b63a8f87d
2 changed files with 12 additions and 9 deletions
|
|
@ -25,7 +25,7 @@ public class DirectUpload {
|
|||
private Fragment fragment;
|
||||
private SharedPreferences prefs;
|
||||
|
||||
@Inject @Named("direct_nearby_upload_prefs") SharedPreferences directPrefs;
|
||||
|
||||
|
||||
DirectUpload(String title, String desc, Fragment fragment, ContributionController controller, SharedPreferences prefs) {
|
||||
this.title = title;
|
||||
|
|
@ -35,13 +35,7 @@ public class DirectUpload {
|
|||
this.prefs = prefs;
|
||||
}
|
||||
|
||||
void storeSharedPrefs() {
|
||||
SharedPreferences.Editor editor = directPrefs.edit();
|
||||
|
||||
editor.putString("Title", title);
|
||||
editor.putString("Desc", desc);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
void initiateCameraUpload() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ public class NearbyMapFragment extends DaggerFragment {
|
|||
private Marker selected;
|
||||
|
||||
@Inject @Named("prefs") SharedPreferences prefs;
|
||||
@Inject @Named("direct_nearby_upload_prefs") SharedPreferences directPrefs;
|
||||
|
||||
public NearbyMapFragment() {
|
||||
}
|
||||
|
|
@ -410,7 +411,7 @@ public class NearbyMapFragment extends DaggerFragment {
|
|||
Timber.d("Camera button tapped. Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
|
||||
controller = new ContributionController(this);
|
||||
DirectUpload directUpload = new DirectUpload(place.getName(), place.getLongDescription(), this, controller, prefs);
|
||||
directUpload.storeSharedPrefs();
|
||||
storeSharedPrefs();
|
||||
directUpload.initiateCameraUpload();
|
||||
});
|
||||
|
||||
|
|
@ -418,7 +419,7 @@ public class NearbyMapFragment extends DaggerFragment {
|
|||
Timber.d("Gallery button tapped. Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
|
||||
controller = new ContributionController(this);
|
||||
DirectUpload directUpload = new DirectUpload(place.getName(), place.getLongDescription(), this, controller, prefs);
|
||||
directUpload.storeSharedPrefs();
|
||||
storeSharedPrefs();
|
||||
directUpload.initiateGalleryUpload();
|
||||
|
||||
//TODO: App crashes after image upload completes
|
||||
|
|
@ -426,6 +427,14 @@ public class NearbyMapFragment extends DaggerFragment {
|
|||
});
|
||||
}
|
||||
|
||||
void storeSharedPrefs() {
|
||||
SharedPreferences.Editor editor = directPrefs.edit();
|
||||
|
||||
editor.putString("Title", title);
|
||||
editor.putString("Desc", desc);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
Timber.d("onRequestPermissionsResult: req code = " + " perm = " + permissions + " grant =" + grantResults);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue