From de1b35209835f25e8ed354c521c88295e0d4fd0b Mon Sep 17 00:00:00 2001 From: Javier Santos Date: Wed, 17 Jun 2015 20:00:55 +0200 Subject: [PATCH] Progress Wheel change with the actual progress --- .../mlmanager/activities/MainActivity.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/javiersantos/mlmanager/activities/MainActivity.java b/app/src/main/java/com/javiersantos/mlmanager/activities/MainActivity.java index 391f38d..55b0829 100644 --- a/app/src/main/java/com/javiersantos/mlmanager/activities/MainActivity.java +++ b/app/src/main/java/com/javiersantos/mlmanager/activities/MainActivity.java @@ -125,13 +125,19 @@ private void setNavigationDrawer(AppAdapter appAdapter, AppAdapter appSystemAdap drawer = UtilsUI.setNavigationDrawer(this, getApplicationContext(), toolbar, appAdapter, appSystemAdapter, recyclerView); } - class getInstalledApps extends AsyncTask { - public getInstalledApps() {} + class getInstalledApps extends AsyncTask { + private Integer totalApps; + private Integer actualApps; + + public getInstalledApps() { + actualApps = 0; + } @Override protected Void doInBackground(Void... params) { final PackageManager packageManager = getPackageManager(); List packages = packageManager.getInstalledPackages(PackageManager.GET_META_DATA); + totalApps = packages.size(); // Get Sort Mode switch (appPreferences.getSortMode()) { default: @@ -207,13 +213,17 @@ public int compare(PackageInfo p1, PackageInfo p2) { } } } + + actualApps++; + publishProgress(Double.toString((actualApps * 100) / totalApps)); } return null; } @Override - protected void onProgressUpdate(PackageInfo... values) { - super.onProgressUpdate(values); + protected void onProgressUpdate(String... progress) { + super.onProgressUpdate(progress); + progressWheel.setProgress(Float.parseFloat(progress[0])); } @Override