Skip to content
This repository has been archived by the owner on May 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #14 from alhazmy13/develop
Browse files Browse the repository at this point in the history
fix crash when return back from Gallery, fix onError method with RxJava extension
  • Loading branch information
alhazmy13 authored Sep 15, 2016
2 parents cb73cbb + 4b887ea commit 80bee49
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 23 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Media Picker
![](https://img.shields.io/badge/Platform-Android-brightgreen.svg)
![](https://img.shields.io/packagist/l/doctrine/orm.svg)
![](https://img.shields.io/badge/version-2.2.3-blue.svg)
![](https://img.shields.io/badge/version-2.2.4-blue.svg)

**[Please let me know if your application go to production via this link](https://docs.google.com/forms/d/e/1FAIpQLSe4Y5Fwn1mlEoD4RxjXQzTvL4mofhESuBlTkAPQhI7J_WqMDQ/viewform?c=0&w=1)**
------
Expand All @@ -21,15 +21,15 @@ This build `2.x.x` will break backward compatibility and there are a lot of chan
<dependency>
<groupId>net.alhazmy13.MediaPicker</groupId>
<artifactId>libary</artifactId>
<version>2.2.3</version>
<version>2.2.4</version>
</dependency>
```


**Gradle**
```gradle
dependencies {
compile 'net.alhazmy13.MediaPicker:libary:2.2.3'
compile 'net.alhazmy13.MediaPicker:libary:2.2.4'
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,16 @@ public class MainActivity extends AppCompatActivity {
private ImageView imageView;
private String videoPath;
private List<String> mPath;

private Button pickButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

textView = (TextView) findViewById(R.id.tv_path);
Button pickButton = (Button) findViewById(R.id.bt_pick);
pickButton = (Button) findViewById(R.id.bt_pick);
imageView = (ImageView) findViewById(R.id.iv_image);

assert pickButton != null;
pickButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand Down Expand Up @@ -70,6 +69,7 @@ private void pickImage() {
.directory(ImagePicker.Directory.DEFAULT)
.extension(ImagePicker.Extension.PNG)
.scale(600, 600)
.allowMultipleImages(true)
.enableDebuggingMode(true))
.getObservable()
.subscribe(new Subscriber<List<String>>() {
Expand Down
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Sat Sep 10 13:03:48 EAT 2016
libVersion=2.2.3
systemProp.http.proxyHost=127.0.0.1
libVersion=2.2.4
isDubgMode=true
org.gradle.jvmargs=-Xmx2048m -XX\:MaxPermSize\=512m -XX\:+HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8
org.gradle.daemon=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,14 @@ protected void onRestoreInstanceState(Bundle savedInstanceState) {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

if (resultCode == RESULT_OK) {
switch (requestCode) {
case ImageTags.IntentCode.CAMERA_REQUEST:
if (resultCode == RESULT_OK) {
new CompressImageTask(destination.getAbsolutePath(), mImgConfig
, ImageActivity.this).execute();
} else {
finish();
}

break;
case ImageTags.IntentCode.REQUEST_CODE_SELECT_PHOTO:
if (resultCode == RESULT_OK) {
try {
Uri selectedImage = data.getData();
String selectedImagePath = FileProcessing.getPath(this, selectedImage);
Expand All @@ -196,16 +191,21 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
} catch (Exception e) {
e.printStackTrace();
}
} else {
finish();
}

break;
case ImageTags.IntentCode.REQUEST_CODE_SELECT_MULTI_PHOTO:
listOfImgs = ImageProcessing.processMultiImage(this, data);
new CompressImageTask(listOfImgs,
mImgConfig, ImageActivity.this).execute();
break;

break;
}
}else{
Intent intent = new Intent();
intent.setAction("net.alhazmy13.mediapicker.rxjava.image.service");
intent.putExtra(ImageTags.Tags.PICK_ERROR,"user did not select any image");
sendBroadcast(intent);
finish();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class ImageProcessing {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static List<String> processMultiImage(Context context, Intent data) {
List<String> listOfImgs = new ArrayList<>();
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2)
&& (null == data.getData()))
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) && (null == data.getData()))
{
ClipData clipdata = data.getClipData();
for (int i=0; i<clipdata.getItemCount();i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static final class Tags{
public static final String DEBUG = "DEBUG";
public static final String IMAGE_PICKER_DIR = "/mediapicker/images/";
public static final String IMG_CONFIG = "IMG_CONFIG";
public static final String PICK_ERROR = "PICK_ERROR";
}

public static final class Action{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Created by Alhazmy13 on 8/7/16.
* MediaPicker
*/
public class ImagePickerReceiver extends BroadcastReceiver{
public class ImagePickerReceiver extends BroadcastReceiver {

private static final String TAG = "ImagePickerReceiver";
private Observer<List<String>> observer;
Expand All @@ -25,8 +25,11 @@ public ImagePickerReceiver(Observer<List<String>> observer) {
}

public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Received message "+intent);
Log.d(TAG, "Received message " + intent);
List<String> imagePath = (List<String>) intent.getSerializableExtra(ImageTags.Tags.IMAGE_PATH);
observer.onNext(imagePath);
if (imagePath != null && imagePath.size() > 0)
observer.onNext(imagePath);
else
observer.onError(new Throwable(intent.getStringExtra(ImageTags.Tags.PICK_ERROR)));
}
}

0 comments on commit 80bee49

Please sign in to comment.