mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 06:43:56 +01:00 
			
		
		
		
	Cleanup CommonsApplication Singelton
This commit is contained in:
		
							parent
							
								
									45a19620b9
								
							
						
					
					
						commit
						bdfbdc7579
					
				
					 29 changed files with 116 additions and 83 deletions
				
			
		|  | @ -109,7 +109,7 @@ public  class       ContributionsActivity | |||
|     @Override | ||||
|     protected void onAuthCookieAcquired(String authCookie) { | ||||
|         // Do a sync everytime we get here! | ||||
|         ContentResolver.requestSync(((CommonsApplication) getApplicationContext()).getCurrentAccount(), ContributionsContentProvider.AUTHORITY, new Bundle()); | ||||
|         ContentResolver.requestSync(CommonsApplication.getInstance().getCurrentAccount(), ContributionsContentProvider.AUTHORITY, new Bundle()); | ||||
|         Intent uploadServiceIntent = new Intent(this, UploadService.class); | ||||
|         uploadServiceIntent.setAction(UploadService.ACTION_START_SERVICE); | ||||
|         startService(uploadServiceIntent); | ||||
|  | @ -219,7 +219,7 @@ public  class       ContributionsActivity | |||
|     @Override | ||||
|     public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { | ||||
|         SharedPreferences sharedPref = | ||||
|                 PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); | ||||
|                 PreferenceManager.getDefaultSharedPreferences(this); | ||||
|         int uploads = sharedPref.getInt(Prefs.UPLOADS_SHOWING, 100); | ||||
|         return new CursorLoader(this, ContributionsContentProvider.BASE_URI, | ||||
|                 Contribution.Table.ALL_FIELDS, CONTRIBUTION_SELECTION, null, | ||||
|  |  | |||
|  | @ -49,7 +49,7 @@ class ContributionsListAdapter extends CursorAdapter { | |||
|         if(views.url == null || !views.url.equals(actualUrl)) { | ||||
|             if(actualUrl.startsWith("http")) { | ||||
|                 MediaWikiImageView mwImageView = views.imageView; | ||||
|                 mwImageView.setMedia(contribution, ((CommonsApplication) activity.getApplicationContext()).getImageLoader()); | ||||
|                 mwImageView.setMedia(contribution, CommonsApplication.getInstance().getImageLoader()); | ||||
|                 // FIXME: For transparent images | ||||
|             } else { | ||||
|                 ImageLoader.getInstance().displayImage(actualUrl, views.imageView, contributionDisplayOptions, new SimpleImageLoadingListener() { | ||||
|  | @ -66,7 +66,7 @@ class ContributionsListAdapter extends CursorAdapter { | |||
|                     public void onLoadingFailed(String imageUri, View view, FailReason failReason) { | ||||
|                         super.onLoadingFailed(imageUri, view, failReason); | ||||
|                         MediaWikiImageView mwImageView = views.imageView; | ||||
|                         mwImageView.setMedia(contribution, ((CommonsApplication) activity.getApplicationContext()).getImageLoader()); | ||||
|                         mwImageView.setMedia(contribution, CommonsApplication.getInstance().getImageLoader()); | ||||
|                     } | ||||
|                 }); | ||||
|             } | ||||
|  |  | |||
|  | @ -159,8 +159,7 @@ public class ContributionsListFragment extends Fragment { | |||
|         menu.clear(); // See http://stackoverflow.com/a/8495697/17865 | ||||
|         inflater.inflate(R.menu.fragment_contributions_list, menu); | ||||
| 
 | ||||
|         CommonsApplication app = (CommonsApplication)getActivity().getApplicationContext(); | ||||
|         if (!app.deviceHasCamera()) { | ||||
|         if (!CommonsApplication.getInstance().deviceHasCamera()) { | ||||
|             menu.findItem(R.id.menu_from_camera).setEnabled(false); | ||||
|         } | ||||
|     } | ||||
|  |  | |||
|  | @ -61,7 +61,7 @@ public class ContributionsSyncAdapter extends AbstractThreadedSyncAdapter { | |||
|     public void onPerformSync(Account account, Bundle bundle, String s, ContentProviderClient contentProviderClient, SyncResult syncResult) { | ||||
|         // This code is fraught with possibilities of race conditions, but lalalalala I can't hear you! | ||||
|         String user = account.name; | ||||
|         MWApi api = CommonsApplication.createMWApi(); | ||||
|         MWApi api = CommonsApplication.getInstance().getMWApi(); | ||||
|         SharedPreferences prefs = this.getContext().getSharedPreferences("prefs", Context.MODE_PRIVATE); | ||||
|         String lastModified = prefs.getString("lastSyncTimestamp", ""); | ||||
|         Date curTime = new Date(); | ||||
|  |  | |||
|  | @ -15,7 +15,7 @@ public class ContributionsSyncService extends Service { | |||
|         super.onCreate(); | ||||
|         synchronized (sSyncAdapterLock) { | ||||
|             if (sSyncAdapter == null) { | ||||
|                 sSyncAdapter = new ContributionsSyncAdapter(getApplicationContext(), true); | ||||
|                 sSyncAdapter = new ContributionsSyncAdapter(this, true); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 addshore
						addshore