mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 06:43:56 +01:00 
			
		
		
		
	Move storeSharedPrefs to fragment that is already injected
This commit is contained in:
		
							parent
							
								
									40495d91ab
								
							
						
					
					
						commit
						083564c906
					
				
					 3 changed files with 13 additions and 10 deletions
				
			
		|  | @ -31,7 +31,7 @@ public interface CommonsApplicationComponent extends AndroidInjector<CommonsAppl | |||
| 
 | ||||
|     void inject(MediaWikiImageView mediaWikiImageView); | ||||
| 
 | ||||
|     void inject(DirectUpload directUpload); | ||||
|     //void inject(DirectUpload directUpload); | ||||
| 
 | ||||
|     @Component.Builder | ||||
|     @SuppressWarnings({"WeakerAccess", "unused"}) | ||||
|  |  | |||
|  | @ -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() { | ||||
|     } | ||||
|  | @ -407,7 +408,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(); | ||||
|         }); | ||||
| 
 | ||||
|  | @ -415,11 +416,19 @@ 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(); | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     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
	
	 misaochan
						misaochan