Skip to content

Commit 0e72162

Browse files
Merge pull request #83 from Omega-R/develop
Updated readme
2 parents 3f6bedd + f4f2b61 commit 0e72162

5 files changed

Lines changed: 63 additions & 41 deletions

File tree

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ allprojects {
1717
}
1818
```
1919
**Step 2.** Add the dependency
20+
#### If you use only Java.
2021
```
2122
dependencies {
2223
implementation 'com.github.Omega-R.OmegaIntentBuilder:core:1.1.1'
@@ -26,6 +27,30 @@ dependencies {
2627
}
2728
```
2829

30+
#### If you use Kotlin or Java with Kotlin, please use kapt instead java annotationProcessor. Main build.gradle file should look like this
31+
```
32+
apply plugin: 'com.android.application'
33+
apply plugin: 'kotlin-android'
34+
apply plugin: 'kotlin-kapt'
35+
36+
kapt {
37+
generateStubs = true
38+
}
39+
40+
android {
41+
......
42+
}
43+
44+
dependencies {
45+
implementation 'com.github.Omega-R.OmegaIntentBuilder:core:1.1.1'
46+
// For extras
47+
implementation 'com.github.Omega-R.OmegaIntentBuilder:annotations:1.1.1'
48+
kapt 'com.github.Omega-R.OmegaIntentBuilder:processor:1.1.1'
49+
}
50+
```
51+
52+
53+
2954
## [Wiki](https://github.com/Omega-R/OmegaIntentBuilder/wiki)
3055

3156
Supported features.

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.2.30'
5-
ext.supportVersion = '27.0.2'
4+
ext.kotlin_version = '1.2.41'
5+
ext.supportVersion = '27.1.1'
66
ext.compileSdkVersion = 27
77
ext.targetSdkVersion = 27
88
ext.javapoet = '1.9.0'
@@ -12,7 +12,7 @@ buildscript {
1212
jcenter()
1313
}
1414
dependencies {
15-
classpath 'com.android.tools.build:gradle:3.1.0'
15+
classpath 'com.android.tools.build:gradle:3.1.2'
1616
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1717
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
1818

examples/build.gradle

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-kapt'
4+
5+
kapt {
6+
generateStubs = true
7+
}
38

49
android {
510
compileSdkVersion rootProject.ext.compileSdkVersion
@@ -31,17 +36,17 @@ dependencies {
3136
implementation "com.android.support:appcompat-v7:$supportVersion"
3237
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
3338

34-
api project(':core')
39+
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
40+
implementation "com.android.support:support-v4:$supportVersion"
41+
implementation "com.android.support:design:$supportVersion"
3542

43+
api project(':core')
3644
api project(':annotations')
37-
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
38-
implementation 'com.android.support:support-v4:27.1.0'
39-
implementation 'com.android.support:design:27.1.0'
40-
annotationProcessor project(':processor')
45+
kapt project(':processor')
4146

4247
testImplementation 'junit:junit:4.12'
43-
androidTestImplementation 'com.android.support.test:runner:1.0.1'
44-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
48+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
49+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
4550
}
4651

4752
repositories {

examples/src/main/java/com/omega_r/omegaintentbuilder/CropImageActivity.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
import android.widget.Toast;
1010
import com.omega_r.libs.omegaintentbuilder.OmegaIntentBuilder;
1111
import com.omega_r.libs.omegaintentbuilder.downloader.DownloadCallback;
12-
import com.omega_r.libs.omegaintentbuilder.handlers.ActivityResultCallback;
1312
import com.omega_r.libs.omegaintentbuilder.handlers.ContextIntentHandler;
1413
import com.omega_r.libs.omegaintentbuilder.types.MimeTypes;
1514

1615
import org.jetbrains.annotations.NotNull;
1716

1817
public class CropImageActivity extends BaseActivity implements View.OnClickListener {
1918

19+
private static final int REQUEST_CODE = 111;
2020
private static final int DEFAULT_OUTPUT_X = 200;
2121
private static final int DEFAULT_OUTPUT_Y = 200;
2222

@@ -49,14 +49,9 @@ private void crop() {
4949
.cropImage()
5050
.property(DEFAULT_OUTPUT_X, DEFAULT_OUTPUT_Y)
5151
.bitmap(BitmapFactory.decodeResource(getResources(), R.drawable.crop_image))
52-
.createIntentHandler()
52+
.createIntentHandler(this)
5353
.failToast("You don't have app for cropping image")
54-
.startActivityForResult(new ActivityResultCallback() {
55-
@Override
56-
public void onActivityResult(int resultCode, @NotNull Intent data) {
57-
onResult(resultCode, data);
58-
}
59-
});
54+
.startActivityForResult(REQUEST_CODE);
6055
}
6156

6257
private void cropFromInternet() {
@@ -69,18 +64,14 @@ private void cropFromInternet() {
6964
@Override
7065
public void onDownloaded(boolean success, @NotNull ContextIntentHandler contextIntentHandler) {
7166
hideProgress();
72-
contextIntentHandler.startActivityForResult(new ActivityResultCallback() {
73-
@Override
74-
public void onActivityResult(int resultCode, @NotNull Intent data) {
75-
onResult(resultCode, data);
76-
}
77-
});
67+
startActivityForResult(contextIntentHandler.getIntent(), REQUEST_CODE);
7868
}
7969
});
8070
}
8171

82-
private void onResult(int resultCode, Intent data) {
83-
if (resultCode == RESULT_OK) {
72+
@Override
73+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
74+
if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
8475
Bundle extras = data.getExtras();
8576
if (extras != null) {
8677
Bitmap cropped = extras.getParcelable("data");

examples/src/main/java/com/omega_r/omegaintentbuilder/PickImageActivity.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
public class PickImageActivity extends BaseActivity implements View.OnClickListener {
1919

20+
private static final int REQUEST_CODE = 141;
2021
private ImageView imageView;
2122

2223
@Override
@@ -34,20 +35,20 @@ public void onClick(View v) {
3435
.image()
3536
.multiply(false)
3637
.createIntentHandler(this)
37-
.startActivityForResult(new ActivityResultCallback() {
38-
@Override
39-
public void onActivityResult(int resultCode, @Nullable Intent data) {
40-
if (resultCode == RESULT_OK && data != null) {
41-
try {
42-
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), data.getData());
43-
imageView.setImageBitmap(bitmap);
44-
} catch (IOException exc) {
45-
exc.printStackTrace();
46-
}
47-
} else if (resultCode == RESULT_CANCELED) {
48-
Toast.makeText(getApplicationContext(), "Pick cancelled", Toast.LENGTH_SHORT).show();
49-
}
50-
}
51-
});
38+
.startActivityForResult(REQUEST_CODE);
39+
}
40+
41+
@Override
42+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
43+
if (requestCode == REQUEST_CODE && resultCode == RESULT_OK && data != null) {
44+
try {
45+
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), data.getData());
46+
imageView.setImageBitmap(bitmap);
47+
} catch (IOException exc) {
48+
exc.printStackTrace();
49+
}
50+
} else if (resultCode == RESULT_CANCELED) {
51+
Toast.makeText(getApplicationContext(), "Pick cancelled", Toast.LENGTH_SHORT).show();
52+
}
5253
}
5354
}

0 commit comments

Comments
 (0)