I have many fields which should be saved/restored in Activity.
private int mPrevRdbDayId;
private ScrollView mScrView;
private TextView mTxtTitleFirst;
private TextView mTxtTitleSecond;
private TextView mTxtTitleCoin;
private ImageView mImgBackground;
private View mLoutColor;
private TextView mTxtTime;
private RadioGroup mRdgDay;
private RadioButton mRdbOtherDay;
private RadioGroup mRdgPrivacy;
private View mLoutFriends;
private EditText mEdtAddTxt;
private TextView mTxtAddMedia;
private TextView mTxtAddMap;
private SeekBar mSkbTime;
private View mLoutMap;
private GoogleMap mMap;
private FeedItem mFeedItem;
private RecyclerView mRvMedia;
private TextView mTxtMapPlace;
private TextView mTxtMapAddress;
private RecyclerView mRvRecipients;
private RecipientRecyclerAdapter mRvRecipientsAdapter;
private RecyclerLoader mRvFriends;
private List<ImageItem> mListMedia;
private List<ImageItem> mListPrepareVideo;
So I am supposed to save everything like this:
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("mPrevRdbDayId", mPrevRdbDayId);
....... and same for each field
Log.d(LOG_TAG, "onSaveInstanceState");
}
And then the same for onRestoreInstanceState, which seems like too boilplate code in approach. Is there any appropriate pattern to handle this case? Thx in advance.
Aucun commentaire:
Enregistrer un commentaire