android.support.v7.app.AppCompatActivity.getCurrentFocus()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中android.support.v7.app.AppCompatActivity.getCurrentFocus()方法的一些代码示例,展示了AppCompatActivity.getCurrentFocus()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AppCompatActivity.getCurrentFocus()方法的具体详情如下:
包路径:android.support.v7.app.AppCompatActivity
类名称:AppCompatActivity
方法名:getCurrentFocus

AppCompatActivity.getCurrentFocus介绍

暂无

代码示例

代码示例来源:origin: zeleven/mua

/**
   * Toggle keyboard according flag. If flag equals 0, hide or close keyboard. Otherwise, open.
   * @param flag A flag which indicate it should open keyboard or not.
   */
  public void toggleKeyboard(int flag) {
    InputMethodManager inputMethodManager = (InputMethodManager)
        (context.getSystemService(Context.INPUT_METHOD_SERVICE));
    if (inputMethodManager != null) {
      if (flag == 0) {
        View currentFocus = ((AppCompatActivity) context).getCurrentFocus();
        if (currentFocus != null) {
          inputMethodManager.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
        }
      } else {
        inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
      }
    }
  }
}

代码示例来源:origin: rsiebert/TVHClient

private void save() {
  if (TextUtils.isEmpty(recording.getTitle())) {
    if (activity.getCurrentFocus() != null) {
      Snackbar.make(activity.getCurrentFocus(), getString(R.string.error_empty_title), Snackbar.LENGTH_SHORT).show();
    }
    return;
  }
  if (!TextUtils.isEmpty(id)) {
    updateTimerRecording();
  } else {
    addTimerRecording();
  }
}

代码示例来源:origin: rsiebert/TVHClient

/**
 * Checks certain given values for plausibility and if everything is fine
 * creates the intent that will be passed to the service to save the newly
 * created recording.
 */
private void save() {
  if (TextUtils.isEmpty(recording.getTitle()) && serverStatus.getHtspVersion() >= 21) {
    if (activity.getCurrentFocus() != null) {
      Snackbar.make(activity.getCurrentFocus(), getString(R.string.error_empty_title), Snackbar.LENGTH_SHORT).show();
    }
    return;
  }
  if (recording.getChannelId() == 0 && serverStatus.getHtspVersion() < 21) {
    if (activity.getCurrentFocus() != null) {
      Snackbar.make(activity.getCurrentFocus(), getString(R.string.error_no_channel_selected), Snackbar.LENGTH_SHORT).show();
    }
    return;
  }
  if (recording.getStart() >= recording.getStop()) {
    if (activity.getCurrentFocus() != null) {
      Snackbar.make(activity.getCurrentFocus(), getString(R.string.error_start_time_past_stop_time), Snackbar.LENGTH_SHORT).show();
    }
    return;
  }
  if (id > 0) {
    updateRecording();
  } else {
    addRecording();
  }
}

代码示例来源:origin: rsiebert/TVHClient

/**
 * Checks certain given values for plausibility and if everything is fine
 * creates the intent that will be passed to the service to save the newly
 * created recording.
 */
private void save() {
  if (TextUtils.isEmpty(recording.getTitle())) {
    if (activity.getCurrentFocus() != null) {
      Snackbar.make(activity.getCurrentFocus(), getString(R.string.error_empty_title), Snackbar.LENGTH_SHORT).show();
    }
    return;
  }
  // The maximum durationTextView must be at least the minimum durationTextView
  if (recording.getMinDuration() > 0
      && recording.getMaxDuration() > 0
      && recording.getMaxDuration() < recording.getMinDuration()) {
    recording.setMaxDuration(recording.getMinDuration());
  }
  if (!TextUtils.isEmpty(id)) {
    updateSeriesRecording();
  } else {
    addSeriesRecording();
  }
}

相关文章

微信公众号

最新文章

更多

AppCompatActivity类方法