mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Save fragment as instance variable
This commit is contained in:
parent
aae490a469
commit
38b04f4417
1 changed files with 11 additions and 5 deletions
|
|
@ -2,8 +2,11 @@ package fr.free.nrw.commons.nearby;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
|
@ -20,17 +23,17 @@ class DirectUpload {
|
||||||
private String title;
|
private String title;
|
||||||
private String desc;
|
private String desc;
|
||||||
private ContributionController controller;
|
private ContributionController controller;
|
||||||
|
private Fragment fragment;
|
||||||
|
|
||||||
DirectUpload(String title, String desc, Fragment fragment) {
|
DirectUpload(String title, String desc, Fragment fragment) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
|
this.fragment = fragment;
|
||||||
controller = new ContributionController(fragment);
|
controller = new ContributionController(fragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void storeSharedPrefs(Context context) {
|
void storeSharedPrefs() {
|
||||||
|
SharedPreferences sharedPref = fragment.getActivity().getPreferences(Context.MODE_PRIVATE);
|
||||||
Activity activity = (Activity) context;
|
|
||||||
SharedPreferences sharedPref = activity.getPreferences(Context.MODE_PRIVATE);
|
|
||||||
SharedPreferences.Editor editor = sharedPref.edit();
|
SharedPreferences.Editor editor = sharedPref.edit();
|
||||||
|
|
||||||
editor.putString("Title", title);
|
editor.putString("Title", title);
|
||||||
|
|
@ -38,7 +41,7 @@ class DirectUpload {
|
||||||
editor.apply();
|
editor.apply();
|
||||||
|
|
||||||
//TODO: Shift this into title/desc screen after upload initiated
|
//TODO: Shift this into title/desc screen after upload initiated
|
||||||
sharedPref = activity.getPreferences(Context.MODE_PRIVATE);
|
sharedPref = fragment.getActivity().getPreferences(Context.MODE_PRIVATE);
|
||||||
String imageTitle = sharedPref.getString("Title", "");
|
String imageTitle = sharedPref.getString("Title", "");
|
||||||
String imageDesc = sharedPref.getString("Desc", "");
|
String imageDesc = sharedPref.getString("Desc", "");
|
||||||
|
|
||||||
|
|
@ -72,4 +75,7 @@ class DirectUpload {
|
||||||
controller.startGalleryPick();
|
controller.startGalleryPick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//TODO: Handle onRequestPermissionsResult
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue