Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add java sample and fix bug calling lib from java #125

Merged
merged 8 commits into from
May 9, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<activity
android:name="com.canhub.cropper.sample.extend_activity.app.SExtendActivity"
android:theme="@style/Theme.SampleNoActionBar" />
<activity
android:name="com.canhub.cropper.sample.extend_activity.app.SExtendActivityJava"
android:theme="@style/Theme.SampleNoActionBar" />

<provider
android:name="androidx.core.content.FileProvider"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.canhub.cropper.sample

import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.canhub.cropper.sample.camera.app.SCameraFragment
import com.canhub.cropper.sample.crop_image_view.app.SCropImageViewFragment
import com.canhub.cropper.sample.extend_activity.app.SExtendActivity
import com.canhub.cropper.sample.extend_activity.app.SExtendActivityJava
import com.example.croppersample.R
import com.example.croppersample.databinding.ActivityMainBinding

Expand Down Expand Up @@ -36,6 +38,11 @@ internal class SMainActivity : AppCompatActivity() {
.replace(R.id.container, SCameraFragment.newInstance())
.commit()
}

binding.sampleCustomActivityJava.setOnClickListener {
val intent = Intent(this, SExtendActivityJava::class.java)
startActivity(intent)
}
}

private fun hideButtons(binding: ActivityMainBinding) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.canhub.cropper.sample.extend_activity.app;
Canato marked this conversation as resolved.
Show resolved Hide resolved

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.canhub.cropper.CropImage;

public class SExtendActivityJava extends AppCompatActivity {
Canato marked this conversation as resolved.
Show resolved Hide resolved
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CropImage.activity()
.start(this);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
Uri photoUri = result.getUri();
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Exception error = result.getError();
Log.e("err", error.getMessage());
}
}
}
}
Canato marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 9 additions & 0 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/sample_calling_cropimage"/>

<Button
style="@style/Sample.Button"
android:id="@+id/sampleCustomActivityJava"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="@dimen/keyline_x4"
android:text="@string/sample_of_customactivity_java" />
</LinearLayout>

<FrameLayout
Expand Down
1 change: 1 addition & 0 deletions sample/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<string name="reset">Reset Crop Rect</string>
<string name="sample_using_cropimageview">Sample using CropImageView</string>
<string name="sample_of_customactivity">Sample of CustomActivity</string>
<string name="sample_of_customactivity_java">Sample of CustomActivity Java</string>
Canato marked this conversation as resolved.
Show resolved Hide resolved
<string name="sample_calling_cropimage">Sample calling CropImage</string>
<string name="take_picture">Take Picture</string>
<string name="crop_settings">Crop Settings</string>
Expand Down