-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
heaven7
committed
Nov 25, 2019
1 parent
9b9d079
commit 2ea7bd6
Showing
2 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
...pp-components/src/main/java/com/heaven7/android/component/gallery/ImagePickComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.heaven7.android.component.gallery; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
|
||
import com.heaven7.android.component.AppComponentContext; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* the image pick delegate | ||
* @author heaven7 | ||
* @since 1.1.4 | ||
*/ | ||
public interface ImagePickComponent extends AppComponentContext { | ||
|
||
/** | ||
* start pick image from camera. you should start with startActivityForResult and setResult for callback | ||
* @param activity the activity | ||
* @param op the pick option | ||
* @param callback the callback of pick | ||
*/ | ||
void startPickFromCamera(Activity activity, PickOption op, Callback callback); | ||
|
||
/** | ||
* start pick from gallery. | ||
* @param activity the activity | ||
* @param op the pick option | ||
* @param callback the callback of pick | ||
*/ | ||
void startPickFromGallery(Activity activity, PickOption op, Callback callback); | ||
|
||
/** | ||
* often we handle data from activity onActivityResult. | ||
* @param requestCode the request code | ||
* @param resultCode the result code | ||
* @param data the intent data. | ||
*/ | ||
void onActivityResult(int requestCode, int resultCode, Intent data); | ||
|
||
/** | ||
* the callback of pick | ||
*/ | ||
interface Callback{ | ||
/** | ||
* called on pick result | ||
* @param activity the activity | ||
* @param files the files. | ||
*/ | ||
void onPickResult(Activity activity, List<String> files); | ||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
...ndroid-app-components/src/main/java/com/heaven7/android/component/gallery/PickOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package com.heaven7.android.component.gallery; | ||
|
||
/** | ||
* the pick option | ||
* @author heaven7 | ||
* @since 1.1.4 | ||
*/ | ||
public class PickOption { | ||
|
||
private int minCount; | ||
private int maxCount; | ||
private boolean crop; | ||
private int aspectX; | ||
private int aspectY; | ||
private int outputX; | ||
private int outputY; | ||
private String outputFormat; //png ,jpeg and etc. | ||
|
||
protected PickOption(PickOption.Builder builder) { | ||
this.minCount = builder.minCount; | ||
this.maxCount = builder.maxCount; | ||
this.crop = builder.crop; | ||
this.aspectX = builder.aspectX; | ||
this.aspectY = builder.aspectY; | ||
this.outputX = builder.outputX; | ||
this.outputY = builder.outputY; | ||
this.outputFormat = builder.outputFormat; | ||
} | ||
|
||
public int getMinCount() { | ||
return this.minCount; | ||
} | ||
|
||
public int getMaxCount() { | ||
return this.maxCount; | ||
} | ||
|
||
public boolean isCrop() { | ||
return this.crop; | ||
} | ||
|
||
public int getAspectX() { | ||
return this.aspectX; | ||
} | ||
|
||
public int getAspectY() { | ||
return this.aspectY; | ||
} | ||
|
||
public int getOutputX() { | ||
return this.outputX; | ||
} | ||
|
||
public int getOutputY() { | ||
return this.outputY; | ||
} | ||
|
||
public String getOutputFormat() { | ||
return this.outputFormat; | ||
} | ||
|
||
public static class Builder { | ||
private int minCount; | ||
private int maxCount; | ||
private boolean crop; | ||
private int aspectX; | ||
private int aspectY; | ||
private int outputX; | ||
private int outputY; | ||
private String outputFormat; //png ,jpeg and etc. | ||
|
||
public Builder setMinCount(int minCount) { | ||
this.minCount = minCount; | ||
return this; | ||
} | ||
|
||
public Builder setMaxCount(int maxCount) { | ||
this.maxCount = maxCount; | ||
return this; | ||
} | ||
|
||
public Builder setCrop(boolean crop) { | ||
this.crop = crop; | ||
return this; | ||
} | ||
|
||
public Builder setAspectX(int aspectX) { | ||
this.aspectX = aspectX; | ||
return this; | ||
} | ||
|
||
public Builder setAspectY(int aspectY) { | ||
this.aspectY = aspectY; | ||
return this; | ||
} | ||
|
||
public Builder setOutputX(int outputX) { | ||
this.outputX = outputX; | ||
return this; | ||
} | ||
|
||
public Builder setOutputY(int outputY) { | ||
this.outputY = outputY; | ||
return this; | ||
} | ||
|
||
public Builder setOutputFormat(String outputFormat) { | ||
this.outputFormat = outputFormat; | ||
return this; | ||
} | ||
|
||
public PickOption build() { | ||
return new PickOption(this); | ||
} | ||
} | ||
} |