Rename ExportAllActivity to ExportActivity

Rename ExportAllAsyncTask to ExportAsyncTask
This commit is contained in:
Jimmy Shih
2012-03-20 12:21:57 -07:00
parent 887c4e3dd1
commit cd741ab93c
4 changed files with 35 additions and 36 deletions
+1 -1
View File
@@ -159,7 +159,7 @@ limitations under the License.
android:name="android.app.default_searchable" android:name="android.app.default_searchable"
android:value="com.google.android.apps.mytracks.SearchActivity" /> android:value="com.google.android.apps.mytracks.SearchActivity" />
</activity> </activity>
<activity android:name="com.google.android.apps.mytracks.ExportAllActivity"/> <activity android:name="com.google.android.apps.mytracks.ExportActivity"/>
<activity <activity
android:label="@string/my_tracks_importer" android:label="@string/my_tracks_importer"
android:name="com.google.android.apps.mytracks.ImportActivity" android:name="com.google.android.apps.mytracks.ImportActivity"
@@ -31,13 +31,13 @@ import android.widget.Toast;
* *
* @author Sandor Dornbush * @author Sandor Dornbush
*/ */
public class ExportAllActivity extends Activity { public class ExportActivity extends Activity {
public static final String EXTRA_TRACK_FILE_FORMAT = "track_file_format"; public static final String EXTRA_TRACK_FILE_FORMAT = "track_file_format";
private static final int DIALOG_PROGRESS_ID = 0; private static final int DIALOG_PROGRESS_ID = 0;
private ExportAllAsyncTask exportAllAsyncTask; private ExportAsyncTask exportAsyncTask;
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
@Override @Override
@@ -45,22 +45,22 @@ public class ExportAllActivity extends Activity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Object retained = getLastNonConfigurationInstance(); Object retained = getLastNonConfigurationInstance();
if (retained instanceof ExportAllAsyncTask) { if (retained instanceof ExportAsyncTask) {
exportAllAsyncTask = (ExportAllAsyncTask) retained; exportAsyncTask = (ExportAsyncTask) retained;
exportAllAsyncTask.setActivity(this); exportAsyncTask.setActivity(this);
} else { } else {
Intent intent = getIntent(); Intent intent = getIntent();
TrackFileFormat trackFileFormat = intent.getParcelableExtra(EXTRA_TRACK_FILE_FORMAT); TrackFileFormat trackFileFormat = intent.getParcelableExtra(EXTRA_TRACK_FILE_FORMAT);
exportAllAsyncTask = new ExportAllAsyncTask(this, trackFileFormat); exportAsyncTask = new ExportAsyncTask(this, trackFileFormat);
exportAllAsyncTask.execute(); exportAsyncTask.execute();
} }
} }
@Override @Override
public Object onRetainNonConfigurationInstance() { public Object onRetainNonConfigurationInstance() {
exportAllAsyncTask.setActivity(null); exportAsyncTask.setActivity(null);
return exportAllAsyncTask; return exportAsyncTask;
} }
@Override @Override
@@ -74,7 +74,7 @@ public class ExportAllActivity extends Activity {
progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
exportAllAsyncTask.cancel(true); exportAsyncTask.cancel(true);
finish(); finish();
} }
}); });
@@ -35,9 +35,9 @@ import android.os.PowerManager.WakeLock;
* *
* @author Jimmy Shih * @author Jimmy Shih
*/ */
public class ExportAllAsyncTask extends AsyncTask<Void, Integer, Boolean> { public class ExportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
private ExportAllActivity exportAllActivity; private ExportActivity exportActivity;
private final TrackFileFormat trackFileFormat; private final TrackFileFormat trackFileFormat;
private final Context context; private final Context context;
private final MyTracksProviderUtils myTracksProviderUtils; private final MyTracksProviderUtils myTracksProviderUtils;
@@ -56,24 +56,23 @@ public class ExportAllAsyncTask extends AsyncTask<Void, Integer, Boolean> {
/** /**
* Creates an AsyncTask. * Creates an AsyncTask.
* *
* @param exportAllActivity the activity currently associated with this * @param exportActivity the activity currently associated with this AsyncTask
* AsyncTask
* @param trackFileFormat the track file format * @param trackFileFormat the track file format
*/ */
public ExportAllAsyncTask(ExportAllActivity exportAllActivity, TrackFileFormat trackFileFormat) { public ExportAsyncTask(ExportActivity exportActivity, TrackFileFormat trackFileFormat) {
this.exportAllActivity = exportAllActivity; this.exportActivity = exportActivity;
this.trackFileFormat = trackFileFormat; this.trackFileFormat = trackFileFormat;
context = exportAllActivity.getApplicationContext(); context = exportActivity.getApplicationContext();
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(exportAllActivity); myTracksProviderUtils = MyTracksProviderUtils.Factory.get(exportActivity);
SharedPreferences sharedPreferences = exportAllActivity.getSharedPreferences( SharedPreferences sharedPreferences = exportActivity.getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE); Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
long recordingTrackId = sharedPreferences.getLong( long recordingTrackId = sharedPreferences.getLong(
exportAllActivity.getString(R.string.recording_track_key), -1L); exportActivity.getString(R.string.recording_track_key), -1L);
// Get the wake lock if not recording // Get the wake lock if not recording
if (recordingTrackId == -1L) { if (recordingTrackId == -1L) {
wakeLock = SystemUtils.acquireWakeLock(exportAllActivity, wakeLock); wakeLock = SystemUtils.acquireWakeLock(exportActivity, wakeLock);
} }
success = false; success = false;
completed = false; completed = false;
@@ -81,21 +80,21 @@ public class ExportAllAsyncTask extends AsyncTask<Void, Integer, Boolean> {
} }
/** /**
* Sets the current {@link ExportAllActivity} associated with this AyncTask. * Sets the current {@link ExportActivity} associated with this AyncTask.
* *
* @param exportAllActivity the current {@link ExportAllActivity}, can be null * @param exportActivity the current {@link ExportActivity}, can be null
*/ */
public void setActivity(ExportAllActivity exportAllActivity) { public void setActivity(ExportActivity exportActivity) {
this.exportAllActivity = exportAllActivity; this.exportActivity = exportActivity;
if (completed && exportAllActivity != null) { if (completed && exportActivity != null) {
exportAllActivity.onAsyncTaskCompleted(success, messageId); exportActivity.onAsyncTaskCompleted(success, messageId);
} }
} }
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
if (exportAllActivity != null) { if (exportActivity != null) {
exportAllActivity.showProgressDialog(); exportActivity.showProgressDialog();
} }
} }
@@ -144,8 +143,8 @@ public class ExportAllAsyncTask extends AsyncTask<Void, Integer, Boolean> {
@Override @Override
protected void onProgressUpdate(Integer... values) { protected void onProgressUpdate(Integer... values) {
if (exportAllActivity != null) { if (exportActivity != null) {
exportAllActivity.setProgressDialogValue(values[0], values[1]); exportActivity.setProgressDialogValue(values[0], values[1]);
} }
} }
@@ -153,8 +152,8 @@ public class ExportAllAsyncTask extends AsyncTask<Void, Integer, Boolean> {
protected void onPostExecute(Boolean result) { protected void onPostExecute(Boolean result) {
success = result; success = result;
completed = true; completed = true;
if (exportAllActivity != null) { if (exportActivity != null) {
exportAllActivity.onAsyncTaskCompleted(success, messageId); exportActivity.onAsyncTaskCompleted(success, messageId);
} }
} }
@@ -343,8 +343,8 @@ public class TrackList extends ListActivity
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
int index = ((AlertDialog) dialog).getListView().getCheckedItemPosition(); int index = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
Intent intent = new Intent(TrackList.this, ExportAllActivity.class); Intent intent = new Intent(TrackList.this, ExportActivity.class).putExtra(
intent.putExtra(ExportAllActivity.EXTRA_TRACK_FILE_FORMAT, ExportActivity.EXTRA_TRACK_FILE_FORMAT,
(Parcelable) TrackFileFormat.values()[index]); (Parcelable) TrackFileFormat.values()[index]);
TrackList.this.startActivity(intent); TrackList.this.startActivity(intent);
} }