示例#1
0
  /** Force show keyboard */
  public void showKeyboard() {
    this.requestFocus();

    Context context = getContext();
    if (Activity.class.isInstance(context)) {
      ((Activity) context)
          .getWindow()
          .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    }

    // mImm.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT | InputMethodManager.SHOW_FORCED);
    // mImm.toggleSoftInput(0, 0);

    // Trick used to create a fake touch event on the editText
    MotionEvent event =
        MotionEvent.obtain(
            0,
            SystemClock.uptimeMillis(),
            MotionEvent.ACTION_DOWN | MotionEvent.ACTION_UP,
            this.getMeasuredWidth(),
            0,
            0);
    this.onTouchEvent(event);
    event.recycle();
  }
示例#2
0
  /** Force hide keyboard */
  public void hideKeyboard() {
    this.clearFocus();

    Context context = getContext();
    if (Activity.class.isInstance(context)) {
      ((Activity) context)
          .getWindow()
          .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    }
    // mImm.hideSoftInputFromWindow(this.getWindowToken(), 0);
    // mImm.toggleSoftInput(0, 0);
  }
  @SuppressWarnings("deprecation")
  public void showImagePopupWindow(final Image image, String templateName) {
    DisplayMetrics metrics = new DisplayMetrics();
    ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int parentWidth = metrics.widthPixels;
    int parentHeight = metrics.heightPixels;

    popUpView = ((Activity) context).getLayoutInflater().inflate(R.layout.display_image, null);
    popupWindow =
        new PopupWindow(popUpView, (int) (parentWidth * 1.0), (int) (parentHeight * 1.0), true);

    final ImageView imageViewImage = (ImageView) popUpView.findViewById(R.id.imageViewImage);

    imageViewImage.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            popupWindow.dismiss();
          }
        });

    // Long press to save picture or set as wall paper
    imageViewImage.setOnLongClickListener(
        new ImageView.OnLongClickListener() {

          @Override
          public boolean onLongClick(View v) {
            MenuManager.displayImageProcessOptionsMenu(
                context,
                image,
                ((BitmapDrawable) imageViewImage.getDrawable()).getBitmap(),
                ReviewImageManager.this);
            return false;
          }
        });

    AQuery aq = new AQuery(context);
    boolean memCache = false;
    boolean fileCache = true;
    ProgressBar progressBar = (ProgressBar) popUpView.findViewById(R.id.progressBar);
    String imageWithTemplateFileUrl = image.getImageWithTemplateFileUrl(templateName);
    aq.id(imageViewImage)
        .progress(progressBar)
        .image(imageWithTemplateFileUrl, memCache, fileCache, 0, 0, null, AQuery.FADE_IN);

    popupWindow.setBackgroundDrawable(new BitmapDrawable());

    popupWindow.setAnimationStyle(R.style.AnimationPopup);
    try {
      popupWindow.showAtLocation(popUpView, Gravity.CENTER, 0, 0);
    } catch (Exception e) {

    }

    // Do not show the soft keyboard
    ((Activity) context)
        .getWindow()
        .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    Toast.makeText(context, context.getString(R.string.longPressImage), Toast.LENGTH_LONG).show();
    ;
  }