mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	refactor: add final keywords, fix typo, and remove redundant spaces
For optimized code only
This commit is contained in:
		
							parent
							
								
									21b21846ac
								
							
						
					
					
						commit
						ee55b5933c
					
				
					 3 changed files with 62 additions and 59 deletions
				
			
		|  | @ -4,16 +4,12 @@ import android.app.NotificationManager; | ||||||
| import android.app.PendingIntent; | import android.app.PendingIntent; | ||||||
| import android.content.Context; | import android.content.Context; | ||||||
| import android.content.Intent; | import android.content.Intent; | ||||||
| 
 |  | ||||||
| import android.os.Build; | import android.os.Build; | ||||||
| import androidx.core.app.NotificationCompat; | import androidx.core.app.NotificationCompat; | ||||||
| 
 |  | ||||||
| import javax.inject.Inject; | import javax.inject.Inject; | ||||||
| import javax.inject.Singleton; | import javax.inject.Singleton; | ||||||
| 
 |  | ||||||
| import fr.free.nrw.commons.CommonsApplication; | import fr.free.nrw.commons.CommonsApplication; | ||||||
| import fr.free.nrw.commons.R; | import fr.free.nrw.commons.R; | ||||||
| 
 |  | ||||||
| import static androidx.core.app.NotificationCompat.DEFAULT_ALL; | import static androidx.core.app.NotificationCompat.DEFAULT_ALL; | ||||||
| import static androidx.core.app.NotificationCompat.PRIORITY_HIGH; | import static androidx.core.app.NotificationCompat.PRIORITY_HIGH; | ||||||
| 
 | 
 | ||||||
|  | @ -30,11 +26,11 @@ public class NotificationHelper { | ||||||
|     public static final int NOTIFICATION_EDIT_DESCRIPTION = 4; |     public static final int NOTIFICATION_EDIT_DESCRIPTION = 4; | ||||||
|     public static final int NOTIFICATION_EDIT_DEPICTIONS = 5; |     public static final int NOTIFICATION_EDIT_DEPICTIONS = 5; | ||||||
| 
 | 
 | ||||||
|     private NotificationManager notificationManager; |     private final NotificationManager notificationManager; | ||||||
|     private NotificationCompat.Builder notificationBuilder; |     private final NotificationCompat.Builder notificationBuilder; | ||||||
| 
 | 
 | ||||||
|     @Inject |     @Inject | ||||||
|     public NotificationHelper(Context context) { |     public NotificationHelper(final Context context) { | ||||||
|         notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); |         notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); | ||||||
|         notificationBuilder = new NotificationCompat |         notificationBuilder = new NotificationCompat | ||||||
|                 .Builder(context, CommonsApplication.NOTIFICATION_CHANNEL_ID_ALL) |                 .Builder(context, CommonsApplication.NOTIFICATION_CHANNEL_ID_ALL) | ||||||
|  | @ -49,12 +45,13 @@ public class NotificationHelper { | ||||||
|      * @param notificationId the notificationID |      * @param notificationId the notificationID | ||||||
|      * @param intent the intent to be fired when the notification is clicked |      * @param intent the intent to be fired when the notification is clicked | ||||||
|      */ |      */ | ||||||
|     public void showNotification(Context context, |     public void showNotification( | ||||||
|         String notificationTitle, |         final Context context, | ||||||
|         String notificationMessage, |         final String notificationTitle, | ||||||
|         int notificationId, |         final String notificationMessage, | ||||||
|         Intent intent) { |         final int notificationId, | ||||||
| 
 |         final Intent intent | ||||||
|  |     ) { | ||||||
|         notificationBuilder.setDefaults(DEFAULT_ALL) |         notificationBuilder.setDefaults(DEFAULT_ALL) | ||||||
|             .setContentTitle(notificationTitle) |             .setContentTitle(notificationTitle) | ||||||
|             .setStyle(new NotificationCompat.BigTextStyle() |             .setStyle(new NotificationCompat.BigTextStyle() | ||||||
|  |  | ||||||
|  | @ -48,13 +48,12 @@ import java.util.* | ||||||
| import java.util.regex.Pattern | import java.util.regex.Pattern | ||||||
| import javax.inject.Inject | import javax.inject.Inject | ||||||
| 
 | 
 | ||||||
| 
 | class UploadWorker( | ||||||
| class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : |     private var appContext: Context, workerParams: WorkerParameters | ||||||
|     CoroutineWorker(appContext, workerParams) { | ): CoroutineWorker(appContext, workerParams) { | ||||||
| 
 | 
 | ||||||
|     private var notificationManager: NotificationManagerCompat? = null |     private var notificationManager: NotificationManagerCompat? = null | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     @Inject |     @Inject | ||||||
|     lateinit var wikidataEditService: WikidataEditService |     lateinit var wikidataEditService: WikidataEditService | ||||||
| 
 | 
 | ||||||
|  | @ -83,14 +82,13 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     //Attributes of the current-upload notification |     //Attributes of the current-upload notification | ||||||
|     private var currentNotificationID: Int = -1// lateinit is not allowed with primitives |     private var currentNotificationID: Int = -1// late init is not allowed with primitives | ||||||
|     private lateinit var currentNotificationTag: String |     private lateinit var currentNotificationTag: String | ||||||
|     private var curentNotification: NotificationCompat.Builder |     private var currentNotification: NotificationCompat.Builder | ||||||
| 
 | 
 | ||||||
|     private val statesToProcess= ArrayList<Int>() |     private val statesToProcess= ArrayList<Int>() | ||||||
| 
 | 
 | ||||||
|     private val STASH_ERROR_CODES = Arrays |     private val STASH_ERROR_CODES = listOf( | ||||||
|         .asList( |  | ||||||
|             "uploadstash-file-not-found", |             "uploadstash-file-not-found", | ||||||
|             "stashfailed", |             "stashfailed", | ||||||
|             "verification-error", |             "verification-error", | ||||||
|  | @ -102,7 +100,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|             .getInstance(appContext) |             .getInstance(appContext) | ||||||
|             .commonsApplicationComponent |             .commonsApplicationComponent | ||||||
|             .inject(this) |             .inject(this) | ||||||
|         curentNotification = |         currentNotification = | ||||||
|             getNotificationBuilder(CommonsApplication.NOTIFICATION_CHANNEL_ID_ALL)!! |             getNotificationBuilder(CommonsApplication.NOTIFICATION_CHANNEL_ID_ALL)!! | ||||||
| 
 | 
 | ||||||
|         statesToProcess.add(Contribution.STATE_QUEUED) |         statesToProcess.add(Contribution.STATE_QUEUED) | ||||||
|  | @ -123,21 +121,23 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|         fun onProgress(transferred: Long, total: Long) { |         fun onProgress(transferred: Long, total: Long) { | ||||||
|             if (transferred == total) { |             if (transferred == total) { | ||||||
|                 // Completed! |                 // Completed! | ||||||
|                 curentNotification.setContentTitle(notificationFinishingTitle) |                 currentNotification.setContentTitle(notificationFinishingTitle) | ||||||
|                     .setProgress(0, 100, true) |                     .setProgress(0, 100, true) | ||||||
|             } else { |             } else { | ||||||
|                 curentNotification |                 currentNotification | ||||||
|                     .setProgress( |                     .setProgress( | ||||||
|                         100, |                         100, | ||||||
|                         (transferred.toDouble() / total.toDouble() * 100).toInt(), |                         (transferred.toDouble() / total.toDouble() * 100).toInt(), | ||||||
|                         false |                         false | ||||||
|                     ) |                     ) | ||||||
|             } |             } | ||||||
|             notificationManager?.cancel(PROCESSING_UPLOADS_NOTIFICATION_TAG, PROCESSING_UPLOADS_NOTIFICATION_ID) |             notificationManager?.cancel( | ||||||
|  |                 PROCESSING_UPLOADS_NOTIFICATION_TAG, PROCESSING_UPLOADS_NOTIFICATION_ID | ||||||
|  |             ) | ||||||
|             notificationManager?.notify( |             notificationManager?.notify( | ||||||
|                 currentNotificationTag, |                 currentNotificationTag, | ||||||
|                 currentNotificationID, |                 currentNotificationID, | ||||||
|                 curentNotification.build()!! |                 currentNotification.build() | ||||||
|             ) |             ) | ||||||
|             contribution!!.transferred = transferred |             contribution!!.transferred = transferred | ||||||
|             contributionDao.update(contribution).blockingAwait() |             contributionDao.update(contribution).blockingAwait() | ||||||
|  | @ -188,7 +188,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|                 .blockingGet() |                 .blockingGet() | ||||||
|             //Showing initial notification for the number of uploads being processed |             //Showing initial notification for the number of uploads being processed | ||||||
| 
 | 
 | ||||||
|             Timber.e("Queued Contributions: " + queuedContributions.size) |             Timber.e("Queued Contributions: %s", queuedContributions.size) | ||||||
| 
 | 
 | ||||||
|             processingUploads.setContentTitle(appContext.getString(R.string.starting_uploads)) |             processingUploads.setContentTitle(appContext.getString(R.string.starting_uploads)) | ||||||
|             processingUploads.setContentText( |             processingUploads.setContentText( | ||||||
|  | @ -249,7 +249,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|                 PROCESSING_UPLOADS_NOTIFICATION_ID |                 PROCESSING_UPLOADS_NOTIFICATION_ID | ||||||
|             ) |             ) | ||||||
|         } |         } | ||||||
|         // Trigger WorkManager to process any new contributions that may have been added to the queue |         //Trigger WorkManager to process any new contributions that may have been added to the queue | ||||||
|         val updatedContributionQueue = withContext(Dispatchers.IO) { |         val updatedContributionQueue = withContext(Dispatchers.IO) { | ||||||
|             contributionDao.getContribution(statesToProcess).blockingGet() |             contributionDao.getContribution(statesToProcess).blockingGet() | ||||||
|         } |         } | ||||||
|  | @ -311,9 +311,9 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|         currentNotificationID = |         currentNotificationID = | ||||||
|             (contribution.localUri.toString() + contribution.media.filename).hashCode() |             (contribution.localUri.toString() + contribution.media.filename).hashCode() | ||||||
| 
 | 
 | ||||||
|         curentNotification |         currentNotification | ||||||
|         getNotificationBuilder(CommonsApplication.NOTIFICATION_CHANNEL_ID_ALL)!! |         getNotificationBuilder(CommonsApplication.NOTIFICATION_CHANNEL_ID_ALL)!! | ||||||
|         curentNotification.setContentTitle( |         currentNotification.setContentTitle( | ||||||
|             appContext.getString( |             appContext.getString( | ||||||
|                 R.string.upload_progress_notification_title_start, |                 R.string.upload_progress_notification_title_start, | ||||||
|                 displayTitle |                 displayTitle | ||||||
|  | @ -323,7 +323,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|         notificationManager?.notify( |         notificationManager?.notify( | ||||||
|             currentNotificationTag, |             currentNotificationTag, | ||||||
|             currentNotificationID, |             currentNotificationID, | ||||||
|             curentNotification.build()!! |             currentNotification.build() | ||||||
|         ) |         ) | ||||||
| 
 | 
 | ||||||
|         val filename = media.filename |         val filename = media.filename | ||||||
|  | @ -341,15 +341,17 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|             val stashUploadResult = uploadClient.uploadFileToStash( |             val stashUploadResult = uploadClient.uploadFileToStash( | ||||||
|                 filename!!, contribution, notificationProgressUpdater |                 filename!!, contribution, notificationProgressUpdater | ||||||
|             ).onErrorReturn{ |             ).onErrorReturn{ | ||||||
|                 return@onErrorReturn StashUploadResult(StashUploadState.FAILED,fileKey = null,errorMessage = it.message) |                 return@onErrorReturn StashUploadResult( | ||||||
|  |                     StashUploadState.FAILED,fileKey = null,errorMessage = it.message | ||||||
|  |                 ) | ||||||
|             }.blockingSingle() |             }.blockingSingle() | ||||||
| 
 | 
 | ||||||
|             when (stashUploadResult.state) { |             when (stashUploadResult.state) { | ||||||
|                 StashUploadState.SUCCESS -> { |                 StashUploadState.SUCCESS -> { | ||||||
|                     //If the stash upload succeeds |                     //If the stash upload succeeds | ||||||
|                     Timber.d("Upload to stash success for fileName: $filename") |                     Timber.d("Upload to stash success for fileName: $filename") | ||||||
|                     Timber.d("Ensure uniqueness of filename"); |                     Timber.d("Ensure uniqueness of filename") | ||||||
|                     val uniqueFileName = findUniqueFileName(filename!!) |                     val uniqueFileName = findUniqueFileName(filename) | ||||||
| 
 | 
 | ||||||
|                     try { |                     try { | ||||||
|                         //Upload the file from stash |                         //Upload the file from stash | ||||||
|  | @ -365,7 +367,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|                             ) |                             ) | ||||||
| 
 | 
 | ||||||
|                             wikidataEditService.addDepictionsAndCaptions(uploadResult, contribution) |                             wikidataEditService.addDepictionsAndCaptions(uploadResult, contribution) | ||||||
|                                 .blockingSubscribe(); |                                 .blockingSubscribe() | ||||||
|                             if(contribution.wikidataPlace==null){ |                             if(contribution.wikidataPlace==null){ | ||||||
|                                 Timber.d( |                                 Timber.d( | ||||||
|                                     "WikiDataEdit not required, upload success" |                                     "WikiDataEdit not required, upload success" | ||||||
|  | @ -404,12 +406,14 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|                     contributionDao.saveSynchronous(contribution) |                     contributionDao.saveSynchronous(contribution) | ||||||
|                 } |                 } | ||||||
|                 else -> { |                 else -> { | ||||||
|                     Timber.e("""upload file to stash failed with status: ${stashUploadResult.state}""") |                     Timber.e("Upload file to stash failed with status: ${stashUploadResult.state}") | ||||||
|                     showInvalidLoginNotification(contribution) |                     showInvalidLoginNotification(contribution) | ||||||
|                     contribution.state = Contribution.STATE_FAILED |                     contribution.state = Contribution.STATE_FAILED | ||||||
|                     contribution.chunkInfo = null |                     contribution.chunkInfo = null | ||||||
|                     contributionDao.saveSynchronous(contribution) |                     contributionDao.saveSynchronous(contribution) | ||||||
|                     if (stashUploadResult.errorMessage.equals(CsrfTokenClient.INVALID_TOKEN_ERROR_MESSAGE)) { |                     if (stashUploadResult.errorMessage.equals( | ||||||
|  |                             CsrfTokenClient.INVALID_TOKEN_ERROR_MESSAGE) | ||||||
|  |                         ) { | ||||||
|                         Timber.e("Invalid Login, logging out") |                         Timber.e("Invalid Login, logging out") | ||||||
|                         val username = sessionManager.userName |                         val username = sessionManager.userName | ||||||
|                         var logoutListener = CommonsApplication.BaseLogoutListener( |                         var logoutListener = CommonsApplication.BaseLogoutListener( | ||||||
|  | @ -499,7 +503,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|                         imageSha1 == modifiedSha1, |                         imageSha1 == modifiedSha1, | ||||||
|                         true |                         true | ||||||
|                     ) |                     ) | ||||||
|                 ); |                 ) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | @ -543,7 +547,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|     private fun showSuccessNotification(contribution: Contribution) { |     private fun showSuccessNotification(contribution: Contribution) { | ||||||
|         val displayTitle = contribution.media.displayTitle |         val displayTitle = contribution.media.displayTitle | ||||||
|         contribution.state=Contribution.STATE_COMPLETED |         contribution.state=Contribution.STATE_COMPLETED | ||||||
|         curentNotification.setContentTitle( |         currentNotification.setContentTitle( | ||||||
|             appContext.getString( |             appContext.getString( | ||||||
|                 R.string.upload_completed_notification_title, |                 R.string.upload_completed_notification_title, | ||||||
|                 displayTitle |                 displayTitle | ||||||
|  | @ -554,7 +558,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|             .setOngoing(false) |             .setOngoing(false) | ||||||
|         notificationManager?.notify( |         notificationManager?.notify( | ||||||
|             currentNotificationTag, currentNotificationID, |             currentNotificationTag, currentNotificationID, | ||||||
|             curentNotification.build() |             currentNotification.build() | ||||||
|         ) |         ) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -565,8 +569,8 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|     @SuppressLint("StringFormatInvalid") |     @SuppressLint("StringFormatInvalid") | ||||||
|     private fun showFailedNotification(contribution: Contribution) { |     private fun showFailedNotification(contribution: Contribution) { | ||||||
|         val displayTitle = contribution.media.displayTitle |         val displayTitle = contribution.media.displayTitle | ||||||
|         curentNotification.setContentIntent(getPendingIntent(MainActivity::class.java)) |         currentNotification.setContentIntent(getPendingIntent(MainActivity::class.java)) | ||||||
|         curentNotification.setContentTitle( |         currentNotification.setContentTitle( | ||||||
|             appContext.getString( |             appContext.getString( | ||||||
|                 R.string.upload_failed_notification_title, |                 R.string.upload_failed_notification_title, | ||||||
|                 displayTitle |                 displayTitle | ||||||
|  | @ -577,13 +581,13 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|             .setOngoing(false) |             .setOngoing(false) | ||||||
|         notificationManager?.notify( |         notificationManager?.notify( | ||||||
|             currentNotificationTag, currentNotificationID, |             currentNotificationTag, currentNotificationID, | ||||||
|             curentNotification.build() |             currentNotification.build() | ||||||
|         ) |         ) | ||||||
|     } |     } | ||||||
|     @SuppressLint("StringFormatInvalid") |     @SuppressLint("StringFormatInvalid") | ||||||
|     private fun showInvalidLoginNotification(contribution: Contribution) { |     private fun showInvalidLoginNotification(contribution: Contribution) { | ||||||
|         val displayTitle = contribution.media.displayTitle |         val displayTitle = contribution.media.displayTitle | ||||||
|         curentNotification.setContentTitle( |         currentNotification.setContentTitle( | ||||||
|             appContext.getString( |             appContext.getString( | ||||||
|                 R.string.upload_failed_notification_title, |                 R.string.upload_failed_notification_title, | ||||||
|                 displayTitle |                 displayTitle | ||||||
|  | @ -594,7 +598,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|             .setOngoing(false) |             .setOngoing(false) | ||||||
|         notificationManager?.notify( |         notificationManager?.notify( | ||||||
|             currentNotificationTag, currentNotificationID, |             currentNotificationTag, currentNotificationID, | ||||||
|             curentNotification.build() |             currentNotification.build() | ||||||
|         ) |         ) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -604,7 +608,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|      */ |      */ | ||||||
|     private fun showPausedNotification(contribution: Contribution) { |     private fun showPausedNotification(contribution: Contribution) { | ||||||
|         val displayTitle = contribution.media.displayTitle |         val displayTitle = contribution.media.displayTitle | ||||||
|         curentNotification.setContentTitle( |         currentNotification.setContentTitle( | ||||||
|             appContext.getString( |             appContext.getString( | ||||||
|                 R.string.upload_paused_notification_title, |                 R.string.upload_paused_notification_title, | ||||||
|                 displayTitle |                 displayTitle | ||||||
|  | @ -615,7 +619,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|             .setOngoing(false) |             .setOngoing(false) | ||||||
|         notificationManager!!.notify( |         notificationManager!!.notify( | ||||||
|             currentNotificationTag, currentNotificationID, |             currentNotificationTag, currentNotificationID, | ||||||
|             curentNotification.build() |             currentNotification.build() | ||||||
|         ) |         ) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -634,6 +638,6 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | ||||||
|              } else { |              } else { | ||||||
|                  getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT) |                  getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT) | ||||||
|              } |              } | ||||||
|          }; |          } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -9,10 +9,9 @@ import android.graphics.Bitmap; | ||||||
| import android.graphics.Canvas; | import android.graphics.Canvas; | ||||||
| import android.graphics.Paint; | import android.graphics.Paint; | ||||||
| import android.net.Uri; | import android.net.Uri; | ||||||
|  | import android.os.Build; | ||||||
| import android.widget.RemoteViews; | import android.widget.RemoteViews; | ||||||
| 
 |  | ||||||
| import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||||
| 
 |  | ||||||
| import com.facebook.common.executors.CallerThreadExecutor; | import com.facebook.common.executors.CallerThreadExecutor; | ||||||
| import com.facebook.common.references.CloseableReference; | import com.facebook.common.references.CloseableReference; | ||||||
| import com.facebook.datasource.DataSource; | import com.facebook.datasource.DataSource; | ||||||
|  | @ -22,10 +21,8 @@ import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber; | ||||||
| import com.facebook.imagepipeline.image.CloseableImage; | import com.facebook.imagepipeline.image.CloseableImage; | ||||||
| import com.facebook.imagepipeline.request.ImageRequest; | import com.facebook.imagepipeline.request.ImageRequest; | ||||||
| import com.facebook.imagepipeline.request.ImageRequestBuilder; | import com.facebook.imagepipeline.request.ImageRequestBuilder; | ||||||
| 
 |  | ||||||
| import fr.free.nrw.commons.media.MediaClient; | import fr.free.nrw.commons.media.MediaClient; | ||||||
| import javax.inject.Inject; | import javax.inject.Inject; | ||||||
| 
 |  | ||||||
| import fr.free.nrw.commons.R; | import fr.free.nrw.commons.R; | ||||||
| import fr.free.nrw.commons.contributions.MainActivity; | import fr.free.nrw.commons.contributions.MainActivity; | ||||||
| import fr.free.nrw.commons.di.ApplicationlessInjection; | import fr.free.nrw.commons.di.ApplicationlessInjection; | ||||||
|  | @ -148,32 +145,37 @@ public class PicOfDayAppWidget extends AppWidgetProvider { | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             @Override |             @Override | ||||||
|             protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) { |             protected void onFailureImpl( | ||||||
|  |                 final DataSource<CloseableReference<CloseableImage>> dataSource | ||||||
|  |             ) { | ||||||
|                 // Ignore failure for now. |                 // Ignore failure for now. | ||||||
|             } |             } | ||||||
|         }, CallerThreadExecutor.getInstance()); |         }, CallerThreadExecutor.getInstance()); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { |     public void onUpdate( | ||||||
|  |         final Context context, | ||||||
|  |         final AppWidgetManager appWidgetManager, | ||||||
|  |         final int[] appWidgetIds | ||||||
|  |     ) { | ||||||
|         ApplicationlessInjection |         ApplicationlessInjection | ||||||
|                 .getInstance(context |                 .getInstance(context.getApplicationContext()) | ||||||
|                         .getApplicationContext()) |  | ||||||
|                 .getCommonsApplicationComponent() |                 .getCommonsApplicationComponent() | ||||||
|                 .inject(this); |                 .inject(this); | ||||||
|         // There may be multiple widgets active, so update all of them |         // There may be multiple widgets active, so update all of them | ||||||
|         for (int appWidgetId : appWidgetIds) { |         for (final int appWidgetId : appWidgetIds) { | ||||||
|             updateAppWidget(context, appWidgetManager, appWidgetId); |             updateAppWidget(context, appWidgetManager, appWidgetId); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public void onEnabled(Context context) { |     public void onEnabled(final Context context) { | ||||||
|         // Enter relevant functionality for when the first widget is created |         // Enter relevant functionality for when the first widget is created | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public void onDisabled(Context context) { |     public void onDisabled(final Context context) { | ||||||
|         // Enter relevant functionality for when the last widget is disabled |         // Enter relevant functionality for when the last widget is disabled | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Rohit Verma
						Rohit Verma