@Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (requestCode == RESULT_LOAD_IMAGE && resultCode == Activity.RESULT_OK && null != data) {
     mImagesPanel.addImage(data.getData(), data.getType());
   }
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_new_post, container, false);
    mPostText = (MultiAutoCompleteTextView) rootView.findViewById(R.id.postText);
    mUsersListAdapter = new UserCompletionAdapter(getActivity());
    mPostText.setAdapter(mUsersListAdapter);
    mPostText.setTokenizer(new SymbolTokenizer('@'));
    mIsPrivate = (Switch) rootView.findViewById(R.id.isPrivate);
    mTagsListAdapter =
        new ArrayAdapter<>(getActivity(), android.R.layout.simple_dropdown_item_1line);
    mPostTags = (MultiAutoCompleteTextView) rootView.findViewById(R.id.postTags);
    mPostTags.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
    mPostTags.setAdapter(mTagsListAdapter);
    mImagesPanel = (ImageUploadingPanel) rootView.findViewById(R.id.imagesPanel);
    setHasOptionsMenu(true);
    if (savedInstanceState == null) {
      Bundle args = getArguments();
      if (args != null) {
        mPostId = args.getString(ARG_ID);
        mPostText.setText(args.getString(ARG_TEXT, ""));
        String[] tags = args.getStringArray(ARG_TAGS);
        mIsPrivate.setChecked(args.getBoolean(ARG_PRIVATE));
        if (tags != null) {
          mPostTags.setText(TextUtils.join(", ", tags));
        }
        ArrayList<Uri> images = args.getParcelableArrayList(ARG_IMAGES);
        if (images != null)
          for (Uri image : images) {
            mImagesPanel.addImage(image, mMime);
          }
        mMime = args.getString(ARG_MIME);
      }
    }
    if (mPostId == null) {
      mIsPrivate.setVisibility(View.VISIBLE);
    } else {
      mIsPrivate.setVisibility(View.GONE);
    }
    mProgressDialog =
        new MaterialDialog.Builder(getActivity())
            .cancelable(false)
            .customView(R.layout.dialog_progress, false)
            .build();

    TagsRequest request = new TagsRequest(PointConnectionManager.getInstance().loginResult.login);
    getSpiceManager()
        .getFromCacheAndLoadFromNetworkIfExpired(
            request, request.getCacheName(), DurationInMillis.ONE_DAY, mTagsRequestListener);
    UserSubscriptionsRequest request2 =
        new UserSubscriptionsRequest(PointConnectionManager.getInstance().loginResult.login);
    getSpiceManager()
        .getFromCacheAndLoadFromNetworkIfExpired(
            request2, request2.getCacheName(), DurationInMillis.ONE_DAY, mUsersRequestListener);
    return rootView;
  }