Exemplo n.º 1
0
  public void showAlbumDialog() {
    albumDialog = new AlertDialog.Builder(mContext).create();
    albumDialog.setCanceledOnTouchOutside(true);
    View v = LayoutInflater.from(mContext).inflate(R.layout.dialog_usericon, null);
    albumDialog.show();
    albumDialog.setContentView(v);
    albumDialog.getWindow().setGravity(Gravity.CENTER);

    TextView albumPic = (TextView) v.findViewById(R.id.album_pic);
    TextView cameraPic = (TextView) v.findViewById(R.id.camera_pic);
    albumPic.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            // TODO Auto-generated method stub
            albumDialog.dismiss();
            Date date1 = new Date(System.currentTimeMillis());
            dateTime = date1.getTime() + "";
            getAvataFromAlbum();
          }
        });
    cameraPic.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            albumDialog.dismiss();
            Date date = new Date(System.currentTimeMillis());
            dateTime = date.getTime() + "";
            getAvataFromCamera();
          }
        });
  }
  /** @Description: 弹框选择图片来源 */
  @SuppressLint("InflateParams")
  private void showAlbumDialog() {
    albumDialog = new AlertDialog.Builder(this).create();
    albumDialog.setCanceledOnTouchOutside(true);
    View v = LayoutInflater.from(this).inflate(R.layout.dialog_select_picture, null);
    albumDialog.show();
    albumDialog.setContentView(v);
    albumDialog.getWindow().setGravity(Gravity.CENTER);

    TextView albumPic = (TextView) v.findViewById(R.id.album_pic);
    TextView cameraPic = (TextView) v.findViewById(R.id.camera_pic);
    // 动态特效
    MaterialRippleLayout.on(albumPic)
        .rippleColor(Color.parseColor(CommonConstant.RIPPLE_COLOR_DARK))
        .rippleAlpha(CommonConstant.RIPPLE_ALPHA)
        .rippleHover(true)
        .create();
    MaterialRippleLayout.on(cameraPic)
        .rippleColor(Color.parseColor(CommonConstant.RIPPLE_COLOR_DARK))
        .rippleAlpha(CommonConstant.RIPPLE_ALPHA)
        .rippleHover(true)
        .create();
    albumPic.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            albumDialog.dismiss();
            getPicFromAlbum();
          }
        });
    cameraPic.setOnClickListener(
        new OnClickListener() {

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