merge heads

This commit is contained in:
Jimmy Shih
2012-03-20 13:31:47 -07:00
parent 21ba44d422
commit 6e413f41b3
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:value="com.google.android.apps.mytracks.SearchActivity" />
</activity>
<activity android:name="com.google.android.apps.mytracks.ExportAllActivity"/>
<activity android:name="com.google.android.apps.mytracks.ExportActivity"/>
<activity
android:label="@string/my_tracks_importer"
android:name="com.google.android.apps.mytracks.ImportActivity"
@@ -31,13 +31,13 @@ import android.widget.Toast;
*
* @author Sandor Dornbush
*/
public class ExportAllActivity extends Activity {
public class ExportActivity extends Activity {
public static final String EXTRA_TRACK_FILE_FORMAT = "track_file_format";
private static final int DIALOG_PROGRESS_ID = 0;
private ExportAllAsyncTask exportAllAsyncTask;
private ExportAsyncTask exportAsyncTask;
private ProgressDialog progressDialog;
@Override
@@ -45,22 +45,22 @@ public class ExportAllActivity extends Activity {
super.onCreate(savedInstanceState);
Object retained = getLastNonConfigurationInstance();
if (retained instanceof ExportAllAsyncTask) {
exportAllAsyncTask = (ExportAllAsyncTask) retained;
exportAllAsyncTask.setActivity(this);
if (retained instanceof ExportAsyncTask) {
exportAsyncTask = (ExportAsyncTask) retained;
exportAsyncTask.setActivity(this);
} else {
Intent intent = getIntent();
TrackFileFormat trackFileFormat = intent.getParcelableExtra(EXTRA_TRACK_FILE_FORMAT);
exportAllAsyncTask = new ExportAllAsyncTask(this, trackFileFormat);
exportAllAsyncTask.execute();
exportAsyncTask = new ExportAsyncTask(this, trackFileFormat);
exportAsyncTask.execute();
}
}
@Override
public Object onRetainNonConfigurationInstance() {
exportAllAsyncTask.setActivity(null);
return exportAllAsyncTask;
exportAsyncTask.setActivity(null);
return exportAsyncTask;
}
@Override
@@ -74,7 +74,7 @@ public class ExportAllActivity extends Activity {
progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
exportAllAsyncTask.cancel(true);
exportAsyncTask.cancel(true);
finish();
}
});
@@ -35,9 +35,9 @@ import android.os.PowerManager.WakeLock;
*
* @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 Context context;
private final MyTracksProviderUtils myTracksProviderUtils;
@@ -56,24 +56,23 @@ public class ExportAllAsyncTask extends AsyncTask<Void, Integer, Boolean> {
/**
* Creates an AsyncTask.
*
* @param exportAllActivity the activity currently associated with this
* AsyncTask
* @param exportActivity the activity currently associated with this AsyncTask
* @param trackFileFormat the track file format
*/
public ExportAllAsyncTask(ExportAllActivity exportAllActivity, TrackFileFormat trackFileFormat) {
this.exportAllActivity = exportAllActivity;
public ExportAsyncTask(ExportActivity exportActivity, TrackFileFormat trackFileFormat) {
this.exportActivity = exportActivity;
this.trackFileFormat = trackFileFormat;
context = exportAllActivity.getApplicationContext();
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(exportAllActivity);
context = exportActivity.getApplicationContext();
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(exportActivity);
SharedPreferences sharedPreferences = exportAllActivity.getSharedPreferences(
SharedPreferences sharedPreferences = exportActivity.getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
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
if (recordingTrackId == -1L) {
wakeLock = SystemUtils.acquireWakeLock(exportAllActivity, wakeLock);
wakeLock = SystemUtils.acquireWakeLock(exportActivity, wakeLock);
}
success = 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) {
this.exportAllActivity = exportAllActivity;
if (completed && exportAllActivity != null) {
exportAllActivity.onAsyncTaskCompleted(success, messageId);
public void setActivity(ExportActivity exportActivity) {
this.exportActivity = exportActivity;
if (completed && exportActivity != null) {
exportActivity.onAsyncTaskCompleted(success, messageId);
}
}
@Override
protected void onPreExecute() {
if (exportAllActivity != null) {
exportAllActivity.showProgressDialog();
if (exportActivity != null) {
exportActivity.showProgressDialog();
}
}
@@ -144,8 +143,8 @@ public class ExportAllAsyncTask extends AsyncTask<Void, Integer, Boolean> {
@Override
protected void onProgressUpdate(Integer... values) {
if (exportAllActivity != null) {
exportAllActivity.setProgressDialogValue(values[0], values[1]);
if (exportActivity != null) {
exportActivity.setProgressDialogValue(values[0], values[1]);
}
}
@@ -153,8 +152,8 @@ public class ExportAllAsyncTask extends AsyncTask<Void, Integer, Boolean> {
protected void onPostExecute(Boolean result) {
success = result;
completed = true;
if (exportAllActivity != null) {
exportAllActivity.onAsyncTaskCompleted(success, messageId);
if (exportActivity != null) {
exportActivity.onAsyncTaskCompleted(success, messageId);
}
}
@@ -343,8 +343,8 @@ public class TrackList extends ListActivity
@Override
public void onClick(DialogInterface dialog, int which) {
int index = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
Intent intent = new Intent(TrackList.this, ExportAllActivity.class);
intent.putExtra(ExportAllActivity.EXTRA_TRACK_FILE_FORMAT,
Intent intent = new Intent(TrackList.this, ExportActivity.class).putExtra(
ExportActivity.EXTRA_TRACK_FILE_FORMAT,
(Parcelable) TrackFileFormat.values()[index]);
TrackList.this.startActivity(intent);
}