use of android.os.Parcelable in project WordPress-Android by wordpress-mobile.
the class LegacyEditorFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_edit_post_content, container, false);
mFormatBar = (LinearLayout) rootView.findViewById(R.id.format_bar);
mTitleEditText = (EditText) rootView.findViewById(R.id.post_title);
mTitleEditText.setText(mTitle);
mTitleEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
// Go to full screen editor when 'next' button is tapped on soft keyboard
ActionBar actionBar = getActionBar();
if (actionId == EditorInfo.IME_ACTION_NEXT && actionBar != null && actionBar.isShowing()) {
setContentEditingModeVisible(true);
}
return false;
}
});
mContentEditText = (WPEditText) rootView.findViewById(R.id.post_content);
mContentEditText.setText(mContent);
mPostContentLinearLayout = (LinearLayout) rootView.findViewById(R.id.post_content_wrapper);
mPostSettingsLinearLayout = (LinearLayout) rootView.findViewById(R.id.post_settings_wrapper);
Button postSettingsButton = (Button) rootView.findViewById(R.id.post_settings_button);
postSettingsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mEditorFragmentListener.onSettingsClicked();
}
});
mBoldToggleButton = (ToggleButton) rootView.findViewById(R.id.bold);
mEmToggleButton = (ToggleButton) rootView.findViewById(R.id.em);
mBquoteToggleButton = (ToggleButton) rootView.findViewById(R.id.bquote);
mUnderlineToggleButton = (ToggleButton) rootView.findViewById(R.id.underline);
mStrikeToggleButton = (ToggleButton) rootView.findViewById(R.id.strike);
mAddPictureButton = (Button) rootView.findViewById(R.id.addPictureButton);
Button linkButton = (Button) rootView.findViewById(R.id.link);
Button moreButton = (Button) rootView.findViewById(R.id.more);
registerForContextMenu(mAddPictureButton);
mContentEditText = (WPEditText) rootView.findViewById(R.id.post_content);
mContentEditText.setOnSelectionChangedListener(this);
mContentEditText.setOnTouchListener(this);
mContentEditText.addTextChangedListener(this);
mContentEditText.setOnEditTextImeBackListener(new WPEditText.EditTextImeBackListener() {
@Override
public void onImeBack(WPEditText ctrl, String text) {
// Go back to regular editor if IME keyboard is dismissed
// Bottom comparison is there to ensure that the keyboard is actually showing
ActionBar actionBar = getActionBar();
if (mRootView.getBottom() < mFullViewBottom && actionBar != null && !actionBar.isShowing()) {
setContentEditingModeVisible(false);
}
}
});
mAddPictureButton.setOnClickListener(mFormatBarButtonClickListener);
mBoldToggleButton.setOnClickListener(mFormatBarButtonClickListener);
linkButton.setOnClickListener(mFormatBarButtonClickListener);
mEmToggleButton.setOnClickListener(mFormatBarButtonClickListener);
mUnderlineToggleButton.setOnClickListener(mFormatBarButtonClickListener);
mStrikeToggleButton.setOnClickListener(mFormatBarButtonClickListener);
mBquoteToggleButton.setOnClickListener(mFormatBarButtonClickListener);
moreButton.setOnClickListener(mFormatBarButtonClickListener);
mEditorFragmentListener.onEditorFragmentInitialized();
if (savedInstanceState != null) {
Parcelable[] spans = savedInstanceState.getParcelableArray(KEY_IMAGE_SPANS);
mContent = savedInstanceState.getString(KEY_CONTENT, "");
mContentEditText.setText(mContent);
mContentEditText.setSelection(savedInstanceState.getInt(KEY_START, 0), savedInstanceState.getInt(KEY_END, 0));
if (spans != null && spans.length > 0) {
for (Parcelable s : spans) {
WPImageSpan editSpan = (WPImageSpan) s;
addMediaFile(editSpan.getMediaFile(), editSpan.getMediaFile().getFilePath(), mImageLoader, editSpan.getStartPosition(), editSpan.getEndPosition());
}
}
}
return rootView;
}
use of android.os.Parcelable in project XobotOS by xamarin.
the class View method dispatchSaveInstanceState.
/**
* Called by {@link #saveHierarchyState(android.util.SparseArray)} to store the state for
* this view and its children. May be overridden to modify how freezing happens to a
* view's children; for example, some views may want to not store state for their children.
*
* @param container The SparseArray in which to save the view's state.
*
* @see #dispatchRestoreInstanceState(android.util.SparseArray)
* @see #saveHierarchyState(android.util.SparseArray)
* @see #onSaveInstanceState()
*/
protected void dispatchSaveInstanceState(SparseArray<Parcelable> container) {
if (mID != NO_ID && (mViewFlags & SAVE_DISABLED_MASK) == 0) {
mPrivateFlags &= ~SAVE_STATE_CALLED;
Parcelable state = onSaveInstanceState();
if ((mPrivateFlags & SAVE_STATE_CALLED) == 0) {
throw new IllegalStateException("Derived class did not call super.onSaveInstanceState()");
}
if (state != null) {
// Log.i("View", "Freezing #" + Integer.toHexString(mID)
// + ": " + state);
container.put(mID, state);
}
}
}
use of android.os.Parcelable in project XobotOS by xamarin.
the class View method dispatchRestoreInstanceState.
/**
* Called by {@link #restoreHierarchyState(android.util.SparseArray)} to retrieve the
* state for this view and its children. May be overridden to modify how restoring
* happens to a view's children; for example, some views may want to not store state
* for their children.
*
* @param container The SparseArray which holds previously saved state.
*
* @see #dispatchSaveInstanceState(android.util.SparseArray)
* @see #restoreHierarchyState(android.util.SparseArray)
* @see #onRestoreInstanceState(android.os.Parcelable)
*/
protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
if (mID != NO_ID) {
Parcelable state = container.get(mID);
if (state != null) {
// Log.i("View", "Restoreing #" + Integer.toHexString(mID)
// + ": " + state);
mPrivateFlags &= ~SAVE_STATE_CALLED;
onRestoreInstanceState(state);
if ((mPrivateFlags & SAVE_STATE_CALLED) == 0) {
throw new IllegalStateException("Derived class did not call super.onRestoreInstanceState()");
}
}
}
}
use of android.os.Parcelable in project Hummingbird-for-Android by xiprox.
the class RelativeTimeTextView method onSaveInstanceState.
@Override
public Parcelable onSaveInstanceState() {
Parcelable superState = super.onSaveInstanceState();
SavedState ss = new SavedState(superState);
ss.referenceTime = mReferenceTime;
return ss;
}
use of android.os.Parcelable in project XobotOS by xamarin.
the class MenuBuilder method restoreActionViewStates.
public void restoreActionViewStates(Bundle states) {
if (states == null) {
return;
}
SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(getActionViewStatesKey());
final int itemCount = size();
for (int i = 0; i < itemCount; i++) {
final MenuItem item = getItem(i);
final View v = item.getActionView();
if (v != null && v.getId() != View.NO_ID) {
v.restoreHierarchyState(viewStates);
}
if (item.hasSubMenu()) {
final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
subMenu.restoreActionViewStates(states);
}
}
final int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
if (expandedId > 0) {
MenuItem itemToExpand = findItem(expandedId);
if (itemToExpand != null) {
itemToExpand.expandActionView();
}
}
}
Aggregations