use of com.theartofdev.edmodo.cropper.CropImageView in project Alphago by Onedelay.
the class SendImageActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_send_image);
imageFile = (File) getIntent().getSerializableExtra("sendImage");
cropImageView = findViewById(R.id.cropImageView);
cropImageView.setImageUriAsync(Uri.fromFile(imageFile));
cropImageView.setAspectRatio(1, 1);
cropImageView.setFixedAspectRatio(true);
cropImageView.setCropShape(CropImageView.CropShape.RECTANGLE);
cropImageView.setAutoZoomEnabled(false);
cropImageView.setCropRect(new Rect(1000, 1000, 1000, 1000));
cropImageView.setOnCropImageCompleteListener(new CropImageView.OnCropImageCompleteListener() {
@Override
public void onCropImageComplete(CropImageView view, CropImageView.CropResult result) {
Bitmap bitmap = result.getBitmap();
if (bitmap != null) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 80, bos);
byte[] bitmapData = bos.toByteArray();
FileOutputStream fos = new FileOutputStream(imageFile);
fos.write(bitmapData);
fos.flush();
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
// onComplete(imageFile);
// new BitmapToFileTask(imageFile, SendImageActivity.this)
// .execute(bitmap);
AlphagoServer.getInstance().sendImage(getBaseContext(), imageFile, new Callback<ResponeImageLabel>() {
@Override
public void onResponse(Call<ResponeImageLabel> call, Response<ResponeImageLabel> response) {
if (response.body() != null) {
category = response.body().getCategory();
max_label = response.body().getResponseLabel();
ID = response.body().getID();
cate_ID = response.body().getCate_ID();
Intent intent = new Intent(getBaseContext(), ImageRecognitionActivity.class);
intent.putExtra("imageFile", imageFile);
intent.putExtra("category", category);
intent.putExtra("max_label", max_label);
intent.putExtra("ID", ID);
intent.putExtra("cate_ID", cate_ID);
frameLoading.setVisibility(View.GONE);
startActivity(intent);
finish();
}
}
@Override
public void onFailure(Call<ResponeImageLabel> call, Throwable t) {
frameLoading.setVisibility(View.GONE);
Toast.makeText(SendImageActivity.this, "서버 연결 안됨", Toast.LENGTH_SHORT).show();
t.printStackTrace();
}
});
}
});
findViewById(R.id.crop_image_menu_rotate_right).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
cropImageView.rotateImage(90);
}
});
findViewById(R.id.btn_retry).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new ImageSelectionMethodDialog().show(getSupportFragmentManager(), "dialog");
}
});
findViewById(R.id.btn_send).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
frameLoading.setVisibility(View.VISIBLE);
cropImageView.getCroppedImageAsync();
}
});
frameLoading = (FrameLayout) findViewById(R.id.frame_loading);
}
use of com.theartofdev.edmodo.cropper.CropImageView in project Zom-Android by zom.
the class AccountFragment method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK && requestCode == 200) {
Uri imageUri = getPickImageResultUri(data);
if (imageUri == null)
return;
// (CropImageView)view.findViewById(R.id.CropImageView);
mCropImageView = new CropImageView(getActivity());
mCropImageView.setAspectRatio(1, 1);
mCropImageView.setFixedAspectRatio(true);
mCropImageView.setCropShape(CropImageView.CropShape.OVAL);
try {
Bitmap bmpThumbnail = SecureMediaStore.getThumbnailFile(getActivity(), imageUri, 512);
mCropImageView.setImageBitmap(bmpThumbnail);
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(mCropImageView).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
setAvatar(mCropImageView.getCroppedImage());
}
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog
}
});
// Create the AlertDialog object and return it
AlertDialog dialog = builder.create();
dialog.show();
;
} catch (IOException ioe) {
Log.e(ImApp.LOG_TAG, "couldn't load avatar", ioe);
}
}
}
use of com.theartofdev.edmodo.cropper.CropImageView in project Zom-Android by zom.
the class OnboardingActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
ImApp mApp = (ImApp) getApplication();
mApp.initAccountInfo();
if (resultCode == RESULT_OK) {
if (requestCode == OnboardingManager.REQUEST_SCAN) {
showInviteScreen();
ArrayList<String> resultScans = data.getStringArrayListExtra("result");
for (String resultScan : resultScans) {
try {
// parse each string and if they are for a new user then add the user
OnboardingManager.DecodedInviteLink diLink = OnboardingManager.decodeInviteLink(resultScan);
new AddContactAsyncTask(mNewAccount.providerId, mNewAccount.accountId, mApp).execute(diLink.username, diLink.fingerprint, diLink.nickname);
// if they are for a group chat, then add the group
} catch (Exception e) {
Log.w(ImApp.LOG_TAG, "error parsing QR invite link", e);
}
}
if (resultScans.size() > 0) {
showMainScreen();
}
} else if (requestCode == OnboardingManager.REQUEST_CHOOSE_AVATAR) {
Uri imageUri = getPickImageResultUri(data);
if (imageUri == null)
return;
// (CropImageView)view.findViewById(R.id.CropImageView);
mCropImageView = new CropImageView(OnboardingActivity.this);
mCropImageView.setAspectRatio(1, 1);
mCropImageView.setFixedAspectRatio(true);
mCropImageView.setCropShape(CropImageView.CropShape.OVAL);
try {
Bitmap bmpThumbnail = SecureMediaStore.getThumbnailFile(OnboardingActivity.this, imageUri, 512);
mCropImageView.setImageBitmap(bmpThumbnail);
// Use the Builder class for convenient dialog construction
android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(OnboardingActivity.this);
builder.setView(mCropImageView).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
setAvatar(mCropImageView.getCroppedImage(), mNewAccount);
showInviteScreen();
delete(mOutputFileUri);
}
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog
delete(mOutputFileUri);
}
});
// Create the AlertDialog object and return it
android.support.v7.app.AlertDialog dialog = builder.create();
dialog.show();
;
} catch (IOException ioe) {
Log.e(ImApp.LOG_TAG, "couldn't load avatar", ioe);
}
}
}
}
use of com.theartofdev.edmodo.cropper.CropImageView in project android by testpress.
the class CropImageActivity method onCreate.
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.crop_image_layout);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
cropImageView = (CropImageView) findViewById(R.id.CropImageView);
cropImageView.setImageBitmap(ImageUtils.decodeImage(getIntent().getStringExtra("picturePath"), 500, 500));
((TextView) findViewById(R.id.done)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// get the cropped coordinates
Rect rect = cropImageView.getCropRect();
// details to crop in server
int[] croppedImageDetails = new int[] { rect.left, rect.top, rect.width(), rect.height() };
Intent intent = new Intent();
intent.putExtra("croppedImageDetails", croppedImageDetails);
intent.putExtra("rotatedDegree", rotatedDegree);
setResult(RESULT_OK, intent);
finish();
}
});
((TextView) findViewById(R.id.cancel)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
Aggregations