Fix bug: in dialog, get all the views first inside onCreate

This commit is contained in:
Jimmy Shih
2014-01-14 12:57:01 -08:00
parent 2f64785a63
commit 5f436abbda
6 changed files with 16 additions and 16 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ limitations under the License.
--> -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto" android:installLocation="auto"
android:versionCode="71" android:versionCode="72"
android:versionName="2.0.6" android:versionName="2.0.6"
package="com.google.android.maps.mytracks" > package="com.google.android.maps.mytracks" >
<!-- Permission to initialize services --> <!-- Permission to initialize services -->
+2 -2
View File
@@ -932,7 +932,7 @@ limitations under the License.
translation_description="The accessibility description for a track icon, as opposed to a marker translation_description="The accessibility description for a track icon, as opposed to a marker
icon."> icon.">
Track Track
</string> </string>
<!-- Import --> <!-- Import -->
<string name="import_error" <string name="import_error"
@@ -1050,7 +1050,7 @@ limitations under the License.
translation_description="The title of the marker detail page. translation_description="The title of the marker detail page.
%1$d position. E.g., '1'. %1$d position. E.g., '1'.
%1$d totalt. E.g., '5'."> %1$d total. E.g., '5'.">
%1$d of %2$d %1$d of %2$d
</string> </string>
@@ -127,6 +127,9 @@ public class MarkerDetailFragment extends Fragment {
View view = inflater.inflate(R.layout.marker_detail_fragment, container, false); View view = inflater.inflate(R.layout.marker_detail_fragment, container, false);
photo = (ImageView) view.findViewById(R.id.marker_detail_waypoint_photo); photo = (ImageView) view.findViewById(R.id.marker_detail_waypoint_photo);
textGradient = (ImageView) view.findViewById(R.id.marker_detail_waypoint_text_gradient);
waypointInfo = (LinearLayout) view.findViewById(R.id.marker_detail_waypoint_info);
photo.setOnClickListener(new View.OnClickListener() { photo.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@@ -139,9 +142,6 @@ public class MarkerDetailFragment extends Fragment {
} }
} }
}); });
textGradient = (ImageView) view.findViewById(R.id.marker_detail_waypoint_text_gradient);
waypointInfo = (LinearLayout) view.findViewById(R.id.marker_detail_waypoint_info);
return view; return view;
}; };
@@ -111,16 +111,20 @@ public class ShareTrackDialogFragment extends AbstractMyTracksDialogFragment {
.setPositiveButton(R.string.generic_ok, null).create(); .setPositiveButton(R.string.generic_ok, null).create();
} }
// Get all the views
View view = fragmentActivity.getLayoutInflater().inflate(R.layout.share_track, null); View view = fragmentActivity.getLayoutInflater().inflate(R.layout.share_track, null);
// Setup publicCheckBox
publicCheckBox = (CheckBox) view.findViewById(R.id.share_track_public); publicCheckBox = (CheckBox) view.findViewById(R.id.share_track_public);
inviteCheckBox = (CheckBox) view.findViewById(R.id.share_track_invite);
multiAutoCompleteTextView = (MultiAutoCompleteTextView) view.findViewById(
R.id.share_track_emails);
accountSpinner = (Spinner) view.findViewById(R.id.share_track_account);
// Setup publicCheckBox
publicCheckBox.setChecked(PreferencesUtils.getBoolean( publicCheckBox.setChecked(PreferencesUtils.getBoolean(
fragmentActivity, R.string.share_track_public_key, fragmentActivity, R.string.share_track_public_key,
PreferencesUtils.SHARE_TRACK_PUBLIC_DEFAULT)); PreferencesUtils.SHARE_TRACK_PUBLIC_DEFAULT));
// Setup inviteCheckBox // Setup inviteCheckBox
inviteCheckBox = (CheckBox) view.findViewById(R.id.share_track_invite);
inviteCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { inviteCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@@ -132,10 +136,7 @@ public class ShareTrackDialogFragment extends AbstractMyTracksDialogFragment {
PreferencesUtils.SHARE_TRACK_INVITE_DEFAULT)); PreferencesUtils.SHARE_TRACK_INVITE_DEFAULT));
// Setup multiAutoCompleteTextView // Setup multiAutoCompleteTextView
multiAutoCompleteTextView = (MultiAutoCompleteTextView) view.findViewById(
R.id.share_track_emails);
multiAutoCompleteTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer()); multiAutoCompleteTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
SimpleCursorAdapter adapter = new SimpleCursorAdapter(fragmentActivity, SimpleCursorAdapter adapter = new SimpleCursorAdapter(fragmentActivity,
R.layout.add_emails_item, getAutoCompleteCursor(fragmentActivity, null), new String[] { R.layout.add_emails_item, getAutoCompleteCursor(fragmentActivity, null), new String[] {
ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.CommonDataKinds.Email.DATA }, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.CommonDataKinds.Email.DATA },
@@ -156,7 +157,6 @@ public class ShareTrackDialogFragment extends AbstractMyTracksDialogFragment {
multiAutoCompleteTextView.setAdapter(adapter); multiAutoCompleteTextView.setAdapter(adapter);
// Setup accountSpinner // Setup accountSpinner
accountSpinner = (Spinner) view.findViewById(R.id.share_track_account);
accountSpinner.setVisibility(accounts.length > 1 ? View.VISIBLE : View.GONE); accountSpinner.setVisibility(accounts.length > 1 ? View.VISIBLE : View.GONE);
AccountUtils.setupAccountSpinner(fragmentActivity, accountSpinner, accounts); AccountUtils.setupAccountSpinner(fragmentActivity, accountSpinner, accounts);
@@ -57,7 +57,7 @@ public class DescriptionGeneratorImplTest extends AndroidTestCase {
track.setTripStatistics(stats); track.setTripStatistics(stats);
track.setCategory("hiking"); track.setCategory("hiking");
String expected = "Created by" String expected = "Created by"
+ " <a href='http://www.google.com/mobile/mytracks'>Google My Tracks</a> on Android.<p>" + " <a href='http://www.google.com/mobile/mytracks'>Google My Tracks</a> on Android<p>"
+ "Name: -<br>" + "Name: -<br>"
+ "Activity type: hiking<br>" + "Activity type: hiking<br>"
+ "Description: -<br>" + "Description: -<br>"
@@ -62,7 +62,7 @@ public class DynamicSpeedTrackPathDescriptorTest extends AndroidTestCase {
dynamicSpeedTrackPathDescriptor.setAverageMovingSpeed(50); dynamicSpeedTrackPathDescriptor.setAverageMovingSpeed(50);
dynamicSpeedTrackPathDescriptor.setSpeedMargin(10); dynamicSpeedTrackPathDescriptor.setSpeedMargin(10);
assertEquals(50.0, dynamicSpeedTrackPathDescriptor.getAverageMovingSpeed()); assertEquals(50.0, dynamicSpeedTrackPathDescriptor.getAverageMovingSpeed());
assertEquals(45, dynamicSpeedTrackPathDescriptor.getSlowSpeed()); assertEquals(45.0, dynamicSpeedTrackPathDescriptor.getSlowSpeed());
} }
/** /**
@@ -74,7 +74,7 @@ public class DynamicSpeedTrackPathDescriptorTest extends AndroidTestCase {
dynamicSpeedTrackPathDescriptor.setAverageMovingSpeed(50); dynamicSpeedTrackPathDescriptor.setAverageMovingSpeed(50);
dynamicSpeedTrackPathDescriptor.setSpeedMargin(10); dynamicSpeedTrackPathDescriptor.setSpeedMargin(10);
assertEquals(50.0, dynamicSpeedTrackPathDescriptor.getAverageMovingSpeed()); assertEquals(50.0, dynamicSpeedTrackPathDescriptor.getAverageMovingSpeed());
assertEquals(55, dynamicSpeedTrackPathDescriptor.getNormalSpeed()); assertEquals(55.0, dynamicSpeedTrackPathDescriptor.getNormalSpeed());
} }
/** /**