SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
19.
@Override
public Parcelable onSaveInstanceState() {
Parcelable superState = super.onSaveInstanceState();
SavedState ss = new SavedState(superState);
ss.imageUrl = imageUrl;
if (localImageUri != null) {
ss.uriString = localImageUri.toString();
}
return ss;
}
@Override
public void onRestoreInstanceState(Parcelable state) {
SavedState ss = (SavedState) state;
super.onRestoreInstanceState(ss.getSuperState());
if (!TextUtils.isEmpty(ss.uriString)) {
setImageFromUriString(ss.uriString);
} else if (!TextUtils.isEmpty(ss.imageUrl)) {
setImageUrl(ss.imageUrl);
}
requestLayout();
}
20.
final int id = eventGroup.getCheckedRadioButtonId();
switch (id) {
case R.id.attend:
profileData.eventStatus = ProfileData.EVENT_STATUS_ATTEN
break;
case R.id.not_attend:
profileData.eventStatus = ProfileData.EVENT_STATUS_NOT_A
break;
case R.id.unknown:
profileData.eventStatus = ProfileData.EVENT_STATUS_UNKNO
break;
default:
return;
}
21.
@Retention(RetentionPolicy.SOURCE)
@IntDef({EVENT_STATUS_UNDEFINED, EVENT_STATUS_ATTEND,
EVENT_STATUS_NOT_ATTEND, EVENT_STATUS_UNKNOWN})
public @interface EventStatus {
}
@EventStatus
public int getEventStatus() {
final int id = getCheckedRadioButtonId();
switch (id) {
case R.id.attend:
return EVENT_STATUS_ATTEND;
case R.id.not_attend:
return EVENT_STATUS_NOT_ATTEND;
case R.id.unknown:
return EVENT_STATUS_UNKNOWN;
default:
return EVENT_STATUS_UNDEFINED;
}
}
22.
private boolean validate() {
// バリデーション失敗: エラーメッセージ表示
final String name = nameEditText.getText().toString();
if (TextUtils.isEmpty(name)) {
Toast.makeText(MainActivity.this,
"名前が入力されていません", Toast.LENGTH_SHORT).show(
return false;
}
if (eventStatusPicker.getEventStatus() ==
EventStatusPicker.EVENT_STATUS_UNDEFINED) {
Toast.makeText(MainActivity.this,
"DroidKaigiが選択されていません", Toast.LENGTH_SHORT
return false;
}
return true;
}