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

Added passing exception to onError of various callbacks #88

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
![](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/device-art/cover-art.png)
Fork of SimpleCropView https://github.com/IsseiAoki/SimpleCropView

[![](https://jitpack.io/v/ZacWolf/SimpleCropView.svg)](https://jitpack.io/#ZacWolf/SimpleCropView)

#SimpleCropView
[![build status](https://travis-ci.org/IsseiAoki/SimpleCropView.svg)](https://travis-ci.org/IsseiAoki/SimpleCropView)
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-SimpleCropView-green.svg?style=flat)](https://android-arsenal.com/details/1/2366)
[![Android Gems](http://www.android-gems.com/badge/IsseiAoki/SimpleCropView.svg?branch=master)](http://www.android-gems.com/lib/IsseiAoki/SimpleCropView)
![](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/device-art/cover-art.png)

The SimpleCropView is an image cropping library for Android.<br>
It simplifies your code for cropping image and provides an easily customizable UI.<br><br>
Supported on API Level 10 and above.


![demo](https://raw.github.com/wiki/IsseiAoki/SimpleCropView/images/1.1.0/demo_basic_usage.gif)


##Table of Contents
* [Download](#download)
* [Example](#example)
Expand Down
10 changes: 8 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
buildscript {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -17,5 +18,10 @@ buildscript {
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
8 changes: 4 additions & 4 deletions simplecropview-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ apply plugin: 'com.android.application'
apply plugin: 'android-apt'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion 25
buildToolsVersion "25.0.0"

defaultConfig {
applicationId "com.example.simplecropviewsample"
minSdkVersion 13
targetSdkVersion 23
targetSdkVersion 24
versionCode 1
versionName "1.0.0"
}
Expand Down Expand Up @@ -38,7 +38,7 @@ ext {
}

dependencies {
compile "com.android.support:appcompat-v7:23.3.0"
compile "com.android.support:appcompat-v7:25+"
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':simplecropview')
compile "com.github.hotchemi:permissionsdispatcher:${permissionsDispatcherVersion}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
package com.example.simplecropviewsample;

import com.isseiaoki.simplecropview.CropImageView;
import com.isseiaoki.simplecropview.callback.CropCallback;
import com.isseiaoki.simplecropview.callback.LoadCallback;
import com.isseiaoki.simplecropview.callback.SaveCallback;
import com.isseiaoki.simplecropview.util.Utils;

import android.Manifest;
import android.app.Activity;
import android.content.DialogInterface;
Expand All @@ -21,8 +14,15 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.isseiaoki.simplecropview.CropImageView;
import com.isseiaoki.simplecropview.callback.CropCallback;
import com.isseiaoki.simplecropview.callback.LoadCallback;
import com.isseiaoki.simplecropview.callback.SaveCallback;
import com.isseiaoki.simplecropview.util.Utils;

import java.io.File;

import permissions.dispatcher.NeedsPermission;
Expand All @@ -38,6 +38,7 @@ public class MainFragment extends Fragment {

// Views ///////////////////////////////////////////////////////////////////////////////////////
private CropImageView mCropView;
private ImageView mPreView;
private LinearLayout mRootLayout;

// Note: only the system can call this constructor by reflection.
Expand Down Expand Up @@ -71,20 +72,17 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
FontUtils.setFont(mRootLayout);
// mCropView.setDebug(true);
// set bitmap to CropImageView
if (mCropView.getImageBitmap() == null) {
mCropView.setImageResource(R.drawable.sample5);
}
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent result) {
super.onActivityResult(requestCode, resultCode, result);
if (requestCode == REQUEST_PICK_IMAGE && resultCode == Activity.RESULT_OK) {
showProgress();
mCropView.startLoad(result.getData(), mLoadCallback);
mCropView.startLoad(result.getData(), mLoadCallback,mPreView);
} else if (requestCode == REQUEST_SAF_PICK_IMAGE && resultCode == Activity.RESULT_OK) {
showProgress();
mCropView.startLoad(Utils.ensureUriPermission(getContext(), result), mLoadCallback);
mCropView.startLoad(Utils.ensureUriPermission(getContext(), result), mLoadCallback,mPreView);
}
}

Expand All @@ -98,6 +96,8 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis

private void bindViews(View view) {
mCropView = (CropImageView) view.findViewById(R.id.cropImageView);
mPreView = (ImageView) view.findViewById(R.id.previewImageView);

view.findViewById(R.id.buttonDone).setOnClickListener(btnListener);
view.findViewById(R.id.buttonFitImage).setOnClickListener(btnListener);
view.findViewById(R.id.button1_1).setOnClickListener(btnListener);
Expand Down Expand Up @@ -245,7 +245,7 @@ public void onSuccess() {
}

@Override
public void onError() {
public void onError(Throwable e) {
dismissProgress();
}
};
Expand All @@ -256,7 +256,7 @@ public void onSuccess(Bitmap cropped) {
}

@Override
public void onError() {
public void onError(Throwable e) {
}
};

Expand All @@ -268,8 +268,8 @@ public void onSuccess(Uri outputUri) {
}

@Override
public void onError() {
public void onError(Throwable e) {
dismissProgress();
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/transparent" />
<stroke
android:width="1sp"
android:color="@color/black" />
</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/white" />
<stroke
android:width="1sp"
android:color="@color/black" />
</shape>
31 changes: 30 additions & 1 deletion simplecropview-sample/src/main/res/layout/fragment_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,35 @@
custom:scv_guide_stroke_weight="1dp"
/>

<View android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:background="@color/divider"/>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Preview:"
android:layout_margin="16sp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
/>
<ImageView
android:id="@+id/previewImageView"
android:layout_width="wrap_content"
android:layout_height="50sp"
android:layout_margin="25sp"
android:layout_centerInParent="true"
/>
</RelativeLayout>


<View android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="8dp"
Expand Down Expand Up @@ -229,4 +258,4 @@
android:background="?attr/selectableItemBackgroundBorderless"
/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
5 changes: 4 additions & 1 deletion simplecropview-sample/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@
<color name="textColorPrimaryInverse">#1C1C1C</color>
<color name="overlay">#AA1C1C1C</color>
<color name="divider">#333333</color>
</resources>

<color name="black">#000000</color>
<color name="white">#FFFFFF</color>
</resources>
5 changes: 2 additions & 3 deletions simplecropview/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 23
Expand Down
Loading