@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_editor, container, false); Log.i("enter...", "new editor"); // Setup hiding the action bar when the soft keyboard is displayed for narrow viewports if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && !getResources().getBoolean(R.bool.is_large_tablet_landscape)) { mHideActionBarOnSoftKeyboardUp = true; } mWaitingMediaFiles = new ConcurrentHashMap<>(); // mUploadingMediaIds = new HashSet<>(); mFailedMediaIds = new HashSet<>(); // -- WebView configuration mWebView = (EditorWebViewAbstract) view.findViewById(R.id.webview); mWebView.setOnTouchListener(this); mWebView.setOnImeBackListener(this); LeaWebViewClient webViewClient = new LeaWebViewClient(); webViewClient.setImageLoadListener(this); // mWebView.setWebViewClient(webViewClient); // Ensure that the content field is always filling the remaining screen space mWebView.addOnLayoutChangeListener( new View.OnLayoutChangeListener() { @Override public void onLayoutChange( View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { mWebView.post( new Runnable() { @Override public void run() { // mWebView.execJavaScriptFromString("ZSSEditor.init()"); mWebView.execJavaScriptFromString("ZSSEditor.refreshVisibleViewportSize();"); } }); } }); mEditorFragmentListener.onEditorFragmentInitialized(); initJsEditor(); if (savedInstanceState != null) { setTitle(savedInstanceState.getCharSequence(KEY_TITLE)); setContent(savedInstanceState.getCharSequence(KEY_CONTENT)); } // -- HTML mode configuration mSourceView = view.findViewById(R.id.sourceview); mSourceViewTitle = (SourceViewEditText) view.findViewById(R.id.sourceview_title); mSourceViewContent = (SourceViewEditText) view.findViewById(R.id.sourceview_content); // Toggle format bar on/off as user changes focus between title and content in HTML mode mSourceViewTitle.setOnFocusChangeListener( new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { updateFormatBarEnabledState(!hasFocus); } }); mSourceViewTitle.setOnTouchListener(this); mSourceViewContent.setOnTouchListener(this); mSourceViewTitle.setOnImeBackListener(this); mSourceViewContent.setOnImeBackListener(this); mSourceViewContent.addTextChangedListener(new HtmlStyleTextWatcher()); mSourceViewTitle.setHint(mTitlePlaceholder); mSourceViewContent.setHint("<p>" + mContentPlaceholder + "</p>"); // -- Format bar configuration setupFormatBarButtonMap(view); return view; }