Commit fe180b0f authored by Kirk Rader's avatar Kirk Rader

reuse AsyncTask instances

parent 64f1c63e
......@@ -198,18 +198,18 @@ public final class MainActivity extends FragmentActivity implements
* {@link Activity#startActivityForResult(Intent, int)} request code when
* launching {@link SavedRowsActivity}
*/
public static final int REQUEST_SHOWS_SAVED_DATA = 2;
public static final int REQUEST_SHOWS_SAVED_DATA = 2;
/**
* {@link Activity#startActivityForResult(Intent, int)} request code when
* launching {@link WriteTagActivity}
*/
public static final int REQUEST_WRITE_TAG = 1;
public static final int REQUEST_WRITE_TAG = 1;
/**
* Cached singleton instance of {@link WifiSettings}
*/
private static WifiSettings wifiSettings;
private static WifiSettings wifiSettings;
static {
......@@ -217,6 +217,16 @@ public final class MainActivity extends FragmentActivity implements
}
/**
* {@link ConnectTask}
*/
private ConnectTask connectTask;
/**
* {@link GetActiveConnectionTask}
*/
private GetActiveConnectionTask getActiveConnectionTask;
/**
* {@link QrCodeFragment} to notify when the wi fi wifiSettings model state
* changes
......@@ -224,18 +234,28 @@ public final class MainActivity extends FragmentActivity implements
* Note that this will be <code>null</code> on devices that display only a
* single pane
*/
private QrCodeFragment qrCodeFragment;
private QrCodeFragment qrCodeFragment;
/**
* Cached singleton instance of {@link WifiManager}
*/
private WifiManager wifiManager;
private WifiManager wifiManager;
/**
* {@link WifiSettingsFragment} to notify when {@link WifiSettings} state
* changes
*/
private WifiSettingsFragment wifiSettingsFragment;
private WifiSettingsFragment wifiSettingsFragment;
/**
* Initialize {@link #getActiveConnectionTask} and {@link #connectTask}
*/
public MainActivity() {
getActiveConnectionTask = new GetActiveConnectionTask();
connectTask = new ConnectTask();
}
/**
* Inflate the options {@link Menu}
......@@ -376,7 +396,7 @@ public final class MainActivity extends FragmentActivity implements
if (!parseIntentData()) {
new GetActiveConnectionTask().execute();
getActiveConnectionTask.execute();
}
}
......@@ -699,7 +719,7 @@ public final class MainActivity extends FragmentActivity implements
if (wifiSettings.parse(uri)) {
new ConnectTask().execute();
connectTask.execute();
return true;
}
......
......@@ -260,11 +260,11 @@ public final class QrCodeFragment extends Fragment {
private int getQrCodeSize() {
View view = getView();
if (view == null) {
return 0;
}
View qrView = view.findViewById(R.id.qr_code_layout);
......
......@@ -397,6 +397,11 @@ public final class WifiSettingsFragment extends Fragment {
*/
private OnWifiSettingsChangedListener listener;
/**
* {@link LookupPasswordTask}
*/
private LookupPasswordTask lookupPasswordTask;
/**
* {@link EditText} for a wifi access point password string or WEP key
*/
......@@ -412,6 +417,15 @@ public final class WifiSettingsFragment extends Fragment {
*/
private EditText ssidText;
/**
* Initialize {@link #lookupPasswordTask}
*/
public WifiSettingsFragment() {
lookupPasswordTask = new LookupPasswordTask();
}
/**
* Set the {@link #listener}
*
......@@ -514,7 +528,7 @@ public final class WifiSettingsFragment extends Fragment {
*/
public void onInitializedFromActiveConnection() {
new LookupPasswordTask().execute();
lookupPasswordTask.execute();
}
......
......@@ -236,6 +236,11 @@ public abstract class ForegroundDispatchActivity<ResultType extends Parcelable>
*/
private PendingIntent pendingIntent;
/**
* {@link ProcessTagTask}
*/
private ProcessTagTask processTagTask;
/**
* Request code to use with {@link #pendingIntent} when enabling foreground
* dispatch
......@@ -255,6 +260,7 @@ public abstract class ForegroundDispatchActivity<ResultType extends Parcelable>
protected ForegroundDispatchActivity(int requestCode) {
this.requestCode = requestCode;
processTagTask = new ProcessTagTask();
}
......@@ -304,7 +310,7 @@ public abstract class ForegroundDispatchActivity<ResultType extends Parcelable>
if (tag != null) {
new ProcessTagTask().execute(tag);
processTagTask.execute(tag);
}
}
......
......@@ -39,14 +39,14 @@ import android.os.ParcelFileDescriptor;
public final class FileProvider extends ContentProvider {
/**
* {@link String}
* Scheme for content a {@link Uri}
*/
private static final String DEFAULT_MIME_TYPE = "application/octet-stream"; //$NON-NLS-1$
private static final String CONTENT_SCHEME = "content://"; //$NON-NLS-1$
/**
* Scheme for content a {@link Uri}
* {@link String}
*/
private static final String CONTENT_SCHEME = "content://"; //$NON-NLS-1$
private static final String DEFAULT_MIME_TYPE = "application/octet-stream"; //$NON-NLS-1$
/**
* Mapping from file name extensions to MIME types for use by
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment