コード例 #1
0
 @Override
 public void onClick(View view) {
   if (view.equals(btLoad)) {
     Intent intent = new Intent();
     intent.setType("image/*");
     intent.setAction(Intent.ACTION_PICK);
     String title = getResources().getString(R.string.choose_image);
     Intent chooser = Intent.createChooser(intent, title);
     startActivityForResult(chooser, REQ_PICK_IMAGE);
   } else if (view.equals(btClear)) {
     mvImage.clear();
     mvImage.setErase(false);
   } else if (view.equals(btSave)) {
     boolean succced = mvImage.save();
     String text = "save image " + (succced ? " succeed" : " failed");
     Toast.makeText(view.getContext(), text, Toast.LENGTH_SHORT).show();
   } else if (view.equals(btEffect)) {
     initEffectList();
     effectList.show(btEffect);
   } else if (view.equals(btMode)) {
     initModeList();
     modeList.show(btMode);
   } else if (view.equals(btErase)) {
     mvImage.setErase(true);
   }
 }
コード例 #2
0
 @Override
 public void onItemClick(int index) {
   if (index == 0) {
     mvImage.setMode(MosaicView.Mode.PATH);
   } else if (index == 1) {
     mvImage.setMode(MosaicView.Mode.GRID);
   }
 }
コード例 #3
0
 @Override
 public void onItemClick(int index) {
   if (index == 0) {
     mvImage.setEffect(MosaicView.Effect.GRID);
   } else if (index == 1) {
     mvImage.setEffect(MosaicView.Effect.BLUR);
   } else if (index == 2) {
     mvImage.setMosaicColor(0xFF4D4D4D);
     mvImage.setEffect(MosaicView.Effect.COLOR);
   }
 }
コード例 #4
0
  public void onActivityResult(int reqCode, int resultCode, Intent data) {
    super.onActivityResult(reqCode, resultCode, data);

    // user cancelled
    if (resultCode != Activity.RESULT_OK) {
      Log.d(TAG, "user cancelled");
      return;
    }

    if (reqCode == REQ_PICK_IMAGE) {
      Uri selectedImage = data.getData();
      String[] filePathColumn = {MediaStore.Images.Media.DATA};

      Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
      cursor.moveToFirst();

      int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
      String filePath = cursor.getString(columnIndex);
      cursor.close();
      mvImage.setSrcPath(filePath);
    }
  }