Restore old invalidations after apk installs/uninstalls. Do not refresh the same app multiple times.
This commit is contained in:
		
							parent
							
								
									f5785c3de0
								
							
						
					
					
						commit
						3ce8cbf5bd
					
				| @ -706,15 +706,17 @@ public class AppDetails extends ListActivity { | ||||
|         Uri uri = Uri.fromParts("package", pkginfo.packageName, null); | ||||
|         Intent intent = new Intent(Intent.ACTION_DELETE, uri); | ||||
|         startActivityForResult(intent, REQUEST_UNINSTALL); | ||||
|         ((FDroidApp) getApplication()).invalidateApp(id); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     private void installApk(File file) { | ||||
|     private void installApk(File file, String id) { | ||||
|         Intent intent = new Intent(); | ||||
|         intent.setAction(android.content.Intent.ACTION_VIEW); | ||||
|         intent.setDataAndType(Uri.parse("file://" + file.getPath()), | ||||
|                 "application/vnd.android.package-archive"); | ||||
|         startActivityForResult(intent, REQUEST_INSTALL); | ||||
|         ((FDroidApp) getApplication()).invalidateApp(id); | ||||
|     } | ||||
| 
 | ||||
|     private void launchApk(String id) { | ||||
| @ -751,8 +753,10 @@ public class AppDetails extends ListActivity { | ||||
|         private Downloader download; | ||||
|         private ProgressDialog pd; | ||||
|         private boolean updating; | ||||
|         private String id; | ||||
| 
 | ||||
|         public DownloadHandler(DB.Apk apk, String repoaddress) { | ||||
|             id = apk.id; | ||||
|             download = new Downloader(apk, repoaddress); | ||||
|             download.start(); | ||||
|             startUpdates(); | ||||
| @ -790,7 +794,7 @@ public class AppDetails extends ListActivity { | ||||
|             case DONE: | ||||
|                 if (pd != null) | ||||
|                     pd.dismiss(); | ||||
|                 installApk(download.localFile()); | ||||
|                 installApk(download.localFile(), id); | ||||
|                 finished = true; | ||||
|                 break; | ||||
|             case CANCELLED: | ||||
|  | ||||
| @ -800,7 +800,9 @@ public class DB { | ||||
|         List<PackageInfo> installedPackages = mContext.getPackageManager() | ||||
|                 .getInstalledPackages(0); | ||||
|         long startTime = System.currentTimeMillis(); | ||||
|         List<String> refreshedApps = new ArrayList<String>(); | ||||
|         for (String appid : invalidApps) { | ||||
|             if (refreshedApps.contains(appid)) continue; | ||||
|             App app = null; | ||||
|             int index = -1; | ||||
|             for (App oldapp : apps) { | ||||
| @ -839,8 +841,9 @@ public class DB { | ||||
|             } | ||||
| 
 | ||||
|             apps.set(index, app); | ||||
|             refreshedApps.add(appid); | ||||
|         } | ||||
|         Log.d("FDroid", "Refreshing " + invalidApps.size() + " apps took " | ||||
|         Log.d("FDroid", "Refreshing " + refreshedApps.size() + " apps took " | ||||
|                 + (System.currentTimeMillis() - startTime) + " ms"); | ||||
| 
 | ||||
|         return apps; | ||||
|  | ||||
| @ -28,7 +28,7 @@ public class PackageReceiver extends BroadcastReceiver { | ||||
|     @Override | ||||
|     public void onReceive(Context ctx, Intent intent) { | ||||
|         String appid = intent.getData().getSchemeSpecificPart(); | ||||
|         Log.d("FDroid", "PackageReceiver invalidating "+appid); | ||||
|         Log.d("FDroid", "PackageReceiver received "+appid); | ||||
|         ((FDroidApp) ctx.getApplicationContext()).invalidateApp(appid); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Daniel Martí
						Daniel Martí