コード例 #1
0
  private void refreshAccountDetails() {
    // we only want to show user details for WordPress.com users
    if (AccountHelper.isSignedIn()) {
      Account defaultAccount = AccountHelper.getDefaultAccount();

      mDisplayNameTextView.setVisibility(View.VISIBLE);
      mUsernameTextView.setVisibility(View.VISIBLE);
      mAvatarFrame.setVisibility(View.VISIBLE);

      int avatarSz = getResources().getDimensionPixelSize(R.dimen.avatar_sz_large);
      String avatarUrl = GravatarUtils.fixGravatarUrl(defaultAccount.getmAvatar(), avatarSz);
      mAvatarImageView.setImageUrl(avatarUrl, LeaNetworkImageView.ImageType.AVATAR);

      mUsernameTextView.setText("@" + defaultAccount.getmUserName());
      mLoginLogoutTextView.setText(R.string.me_disconnect_from_leanote_com);

      String displayName = defaultAccount.getmUserName();
      if (!TextUtils.isEmpty(displayName)) {
        mDisplayNameTextView.setText(displayName);
      } else {
        mDisplayNameTextView.setText(defaultAccount.getmUserName());
      }
    } else {
      mDisplayNameTextView.setVisibility(View.GONE);
      mUsernameTextView.setVisibility(View.GONE);
      mAvatarFrame.setVisibility(View.GONE);
      mLoginLogoutTextView.setText(R.string.me_connect_to_leanote_com);
    }
  }
コード例 #2
0
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    setHasOptionsMenu(true);

    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

    mdatas = new ArrayList<>();
    Bundle extras = getActivity().getIntent().getExtras();
    if (extras != null) {
      type = extras.getInt("type");
      if (type == Constant.NOTEBOOK_SEARCH) {
        allDatas = Leanote.leaDB.getNotebookList(AccountHelper.getDefaultAccount().getmUserId());
      } else if (type == Constant.BLOG_SEARCH) {
        allDatas = Leanote.leaDB.getNoteisBlogList(AccountHelper.getDefaultAccount().getmUserId());
      } else {
        allDatas = Leanote.leaDB.getNotesList(AccountHelper.getDefaultAccount().getmUserId());
      }
    } else {
      allDatas = Leanote.leaDB.getNotesList(AccountHelper.getDefaultAccount().getmUserId());
    }

    mAdapter = new SearchAdapter(getActivity(), mdatas);
    mRecyclerView.setAdapter(mAdapter);
  }
コード例 #3
0
  private void signOutWordPressComWithConfirmation() {
    String message =
        String.format(
            getString(R.string.sign_out_leacom_confirm),
            AccountHelper.getDefaultAccount().getmUserName());

    new AlertDialog.Builder(getActivity())
        .setMessage(message)
        .setPositiveButton(
            R.string.signout,
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int whichButton) {
                signOutWordPressCom();
              }
            })
        .setNegativeButton(R.string.cancel, null)
        .setCancelable(true)
        .create()
        .show();
  }
コード例 #4
0
  private void initSettingsFields() {
    boolean isMarkdown = AccountHelper.getDefaultAccount().isUseMarkdown();

    switch_markdown.setChecked(isMarkdown);
    RelativeLayout.LayoutParams params =
        (RelativeLayout.LayoutParams) switch_markdown_button.getLayoutParams();

    if (isMarkdown) {
      params.addRule(RelativeLayout.ALIGN_RIGHT, -1);
      params.addRule(RelativeLayout.ALIGN_LEFT, R.id.toggleButton_public_blog);
      switch_markdown_button.setLayoutParams(params);
      switch_markdown_button.setImageResource(R.drawable.progress_thumb_selector);
      switch_markdown.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
    } else {
      params.addRule(RelativeLayout.ALIGN_RIGHT, R.id.switch_markdown);
      params.addRule(RelativeLayout.ALIGN_LEFT, -1);
      switch_markdown_button.setLayoutParams(params);
      switch_markdown_button.setImageResource(R.drawable.progress_thumb_off_selector);
      switch_markdown.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
    }
  }