-
Notifications
You must be signed in to change notification settings - Fork 77
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
1 parent
5e848e8
commit 06f7776
Showing
15 changed files
with
507 additions
and
71 deletions.
There are no files selected for viewing
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
Binary file not shown.
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
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
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
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
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
26 changes: 26 additions & 0 deletions
26
gallery/src/main/java/io/valuesfeng/picker/engine/LoadEngine.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,26 @@ | ||
package io.valuesfeng.picker.engine; | ||
|
||
import android.os.Parcelable; | ||
import android.widget.GridView; | ||
import android.widget.ImageView; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* Author: valuesfeng | ||
* Version V1.0 | ||
* Date: 16/1/1 | ||
* Description: | ||
* Modification History: | ||
* Date Author Version Description | ||
* ----------------------------------------------------------------------------------- | ||
* 16/1/1 valuesfeng 1.0 1.0 | ||
* Why & What is modified: | ||
*/ | ||
public interface LoadEngine extends Parcelable{ | ||
String INITIALIZE_ENGINE_ERROR = "initialize error,image load engine can not be null"; | ||
|
||
void displayImage(int res, ImageView imageView); | ||
void displayImage(String path, ImageView imageView); | ||
void pauseOnScroll(GridView view); | ||
} |
103 changes: 103 additions & 0 deletions
103
gallery/src/main/java/io/valuesfeng/picker/engine/glide/GlideEngine.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,103 @@ | ||
package io.valuesfeng.picker.engine.glide; | ||
|
||
import android.content.Context; | ||
import android.os.Parcel; | ||
import android.widget.GridView; | ||
import android.widget.ImageView; | ||
|
||
import com.bumptech.glide.Glide; | ||
|
||
import io.valuesfeng.picker.R; | ||
import io.valuesfeng.picker.engine.LoadEngine; | ||
|
||
/** | ||
* Author: valuesfeng | ||
* Version V1.0 | ||
* Date: 16/1/1 | ||
* Description: | ||
* Modification History: | ||
* Date Author Version Description | ||
* ----------------------------------------------------------------------------------- | ||
* 16/1/1 valuesfeng 1.0 1.0 | ||
* Why & What is modified: | ||
*/ | ||
public class GlideEngine implements LoadEngine { | ||
|
||
private int img_loading; | ||
private int camera_loading; | ||
|
||
public GlideEngine() { | ||
this(0, 0); | ||
} | ||
|
||
public GlideEngine(int camera_loading, int img_loading) { | ||
if (img_loading == 0) | ||
this.img_loading = R.drawable.image_not_exist; | ||
else | ||
this.img_loading = img_loading; | ||
if (camera_loading == 0) | ||
this.camera_loading = R.drawable.ic_camera; | ||
else | ||
this.camera_loading = camera_loading; | ||
} | ||
|
||
@Override | ||
public void displayImage(String path, ImageView imageView) { | ||
chargeInit(imageView.getContext()); | ||
Glide.with(imageView.getContext()) | ||
.load(path) | ||
.centerCrop() | ||
.error(img_loading) | ||
.placeholder(img_loading) | ||
.crossFade() | ||
.into(imageView); | ||
} | ||
|
||
@Override | ||
public void displayImage(int res, ImageView imageView) { | ||
chargeInit(imageView.getContext()); | ||
Glide.with(imageView.getContext()) | ||
.load(res) | ||
.centerCrop() | ||
.error(camera_loading) | ||
.placeholder(camera_loading) | ||
.crossFade() | ||
.into(imageView); | ||
} | ||
|
||
private void chargeInit(Context context){ | ||
if (Glide.get(context) == null) { | ||
throw new ExceptionInInitializerError(INITIALIZE_ENGINE_ERROR); | ||
} | ||
} | ||
@Override | ||
public void pauseOnScroll(GridView view) { | ||
|
||
} | ||
|
||
@Override | ||
public int describeContents() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void writeToParcel(Parcel dest, int flags) { | ||
dest.writeInt(this.img_loading); | ||
dest.writeInt(this.camera_loading); | ||
} | ||
|
||
protected GlideEngine(Parcel in) { | ||
this.img_loading = in.readInt(); | ||
this.camera_loading = in.readInt(); | ||
} | ||
|
||
public static final Creator<GlideEngine> CREATOR = new Creator<GlideEngine>() { | ||
public GlideEngine createFromParcel(Parcel source) { | ||
return new GlideEngine(source); | ||
} | ||
|
||
public GlideEngine[] newArray(int size) { | ||
return new GlideEngine[size]; | ||
} | ||
}; | ||
} |
Oops, something went wrong.