mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Fix error in AppPickerActivity when it is quickly cancelled (hat tip to Asus)
git-svn-id: https://zxing.googlecode.com/svn/trunk@2252 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
c29cd1d2ef
commit
7a0f55da30
|
@ -18,7 +18,7 @@ package com.google.zxing.client.android.share;
|
||||||
|
|
||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.AsyncTask;
|
||||||
import android.provider.Browser;
|
import android.provider.Browser;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
@ -29,15 +29,23 @@ import java.util.List;
|
||||||
public final class AppPickerActivity extends ListActivity {
|
public final class AppPickerActivity extends ListActivity {
|
||||||
|
|
||||||
private final List<String[]> labelsPackages = new ArrayList<String[]>();
|
private final List<String[]> labelsPackages = new ArrayList<String[]>();
|
||||||
|
private LoadPackagesAsyncTask backgroundTask;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle icicle) {
|
protected void onResume() {
|
||||||
super.onCreate(icicle);
|
super.onResume();
|
||||||
if (labelsPackages.isEmpty()) {
|
labelsPackages.clear();
|
||||||
new LoadPackagesAsyncTask(this).execute(labelsPackages);
|
backgroundTask = new LoadPackagesAsyncTask(this);
|
||||||
|
backgroundTask.execute(labelsPackages);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
if (backgroundTask.getStatus() != AsyncTask.Status.FINISHED) {
|
||||||
|
backgroundTask.cancel(true);
|
||||||
}
|
}
|
||||||
// Otherwise use last copy we loaded -- apps don't change much, and it takes
|
backgroundTask = null;
|
||||||
// forever to load for some reason.
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue