Ask for active downloading url in on resume.
Fixes #624. The `AppDetails` activity was not correctly asking for the active download url string when being resumed. This change recalculates the value when being resumed now.
This commit is contained in:
		
							parent
							
								
									3a1fcfd226
								
							
						
					
					
						commit
						2c7033e367
					
				| @ -426,7 +426,12 @@ public class AppDetails extends AppCompatActivity { | ||||
| 
 | ||||
|     @Override | ||||
|     protected void onResumeFragments() { | ||||
|         // Must be called before super.onResumeFragments(), as the fragments depend on the active | ||||
|         // url being correctly set in order to know whether or not to show the download progress bar. | ||||
|         calcActiveDownloadUrlString(app.packageName); | ||||
| 
 | ||||
|         super.onResumeFragments(); | ||||
| 
 | ||||
|         headerFragment = (AppDetailsHeaderFragment) getSupportFragmentManager().findFragmentById(R.id.header); | ||||
|         refreshApkList(); | ||||
|         supportInvalidateOptionsMenu(); | ||||
| @ -582,13 +587,7 @@ public class AppDetails extends AppCompatActivity { | ||||
|         Utils.debugLog(TAG, "Getting application details for " + packageName); | ||||
|         App newApp = null; | ||||
| 
 | ||||
|         String urlString = getPreferences(MODE_PRIVATE).getString(packageName, null); | ||||
|         if (DownloaderService.isQueuedOrActive(urlString)) { | ||||
|             activeDownloadUrlString = urlString; | ||||
|         } else { | ||||
|             // this URL is no longer active, remove it | ||||
|             PreferencesCompat.apply(getPreferences(MODE_PRIVATE).edit().remove(packageName)); | ||||
|         } | ||||
|         calcActiveDownloadUrlString(packageName); | ||||
| 
 | ||||
|         if (!TextUtils.isEmpty(packageName)) { | ||||
|             newApp = AppProvider.Helper.findByPackageName(getContentResolver(), packageName); | ||||
| @ -599,6 +598,16 @@ public class AppDetails extends AppCompatActivity { | ||||
|         return this.app != null; | ||||
|     } | ||||
| 
 | ||||
|     private void calcActiveDownloadUrlString(String packageName) { | ||||
|         String urlString = getPreferences(MODE_PRIVATE).getString(packageName, null); | ||||
|         if (DownloaderService.isQueuedOrActive(urlString)) { | ||||
|             activeDownloadUrlString = urlString; | ||||
|         } else { | ||||
|             // this URL is no longer active, remove it | ||||
|             PreferencesCompat.apply(getPreferences(MODE_PRIVATE).edit().remove(packageName)); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * If passed null, this will show a message to the user ("Could not find app ..." or something | ||||
|      * like that) and then finish the activity. | ||||
|  | ||||
| @ -389,6 +389,9 @@ public class DownloaderService extends Service { | ||||
|         if (TextUtils.isEmpty(urlString)) { //NOPMD - suggests unreadable format | ||||
|             return false; | ||||
|         } | ||||
|         if (serviceHandler == null) { | ||||
|             return false; // this service is not even running | ||||
|         } | ||||
|         return serviceHandler.hasMessages(urlString.hashCode()) || isActive(urlString); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Peter Serwylo
						Peter Serwylo