Skip to content

Commit

Permalink
Progress Wheel change with the actual progress
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersantos committed Jun 17, 2015
1 parent d234fdb commit de1b352
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,19 @@ private void setNavigationDrawer(AppAdapter appAdapter, AppAdapter appSystemAdap
drawer = UtilsUI.setNavigationDrawer(this, getApplicationContext(), toolbar, appAdapter, appSystemAdapter, recyclerView);
}

class getInstalledApps extends AsyncTask<Void, PackageInfo, Void> {
public getInstalledApps() {}
class getInstalledApps extends AsyncTask<Void, String, Void> {
private Integer totalApps;
private Integer actualApps;

public getInstalledApps() {
actualApps = 0;
}

@Override
protected Void doInBackground(Void... params) {
final PackageManager packageManager = getPackageManager();
List<PackageInfo> packages = packageManager.getInstalledPackages(PackageManager.GET_META_DATA);
totalApps = packages.size();
// Get Sort Mode
switch (appPreferences.getSortMode()) {
default:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit de1b352

Please # to comment.