Skip to content

Commit

Permalink
Rename INIT_SCALE_TYPE_AUTO to INIT_SCALE_TYPE_CUSTOM; update dep…
Browse files Browse the repository at this point in the history
…endencies; publish v1.4.4;
  • Loading branch information
Piasy committed Nov 26, 2017
1 parent ffa5290 commit cf53d73
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 54 deletions.
2 changes: 1 addition & 1 deletion BigImageViewer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

apply plugin: 'com.android.library'
apply plugin: 'com.github.ben-manes.versions'
apply from: "https://raw.githubusercontent.com/Piasy/BintrayUploadScript/master/bintray.gradle"
apply from: "https://raw.githubusercontent.com/Piasy/GradleScripts/master/PRJ_NAME/gradle/bintray.gradle"

android {
compileSdkVersion rootProject.ext.androidCompileSdkVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@
public class BigImageView extends FrameLayout implements ImageLoader.Callback {
public static final int INIT_SCALE_TYPE_CENTER_INSIDE = 1;
public static final int INIT_SCALE_TYPE_CENTER_CROP = 2;
public static final int INIT_SCALE_TYPE_AUTO = 3;
public static final int INIT_SCALE_TYPE_CUSTOM = 3;
public static final int INIT_SCALE_TYPE_START = 4;

public static final int IMAGE_SCALE_TYPE_FIT_CENTER = 2;
public static final int IMAGE_SCALE_TYPE_FIT_CENTER_INDEX = 3;
public static final ImageView.ScaleType[] IMAGE_SCALE_TYPES = {
ImageView.ScaleType.FIT_XY,
ImageView.ScaleType.FIT_START,
ImageView.ScaleType.FIT_CENTER,
ImageView.ScaleType.FIT_END,
ImageView.ScaleType.CENTER,
ImageView.ScaleType.CENTER_CROP,
ImageView.ScaleType.CENTER_INSIDE,
ImageView.ScaleType.CENTER_CROP
ImageView.ScaleType.FIT_CENTER,
ImageView.ScaleType.FIT_END,
ImageView.ScaleType.FIT_START,
ImageView.ScaleType.FIT_XY,
};

private final ImageLoader mImageLoader;
Expand Down Expand Up @@ -118,7 +118,11 @@ public BigImageView(Context context, AttributeSet attrs, int defStyleAttr) {
if (array.hasValue(R.styleable.BigImageView_failureImage)) {
int scaleTypeIndex = array.getInteger(
R.styleable.BigImageView_failureImageInitScaleType,
IMAGE_SCALE_TYPE_FIT_CENTER);
IMAGE_SCALE_TYPE_FIT_CENTER_INDEX);
if (scaleTypeIndex < 0 || IMAGE_SCALE_TYPES.length <= scaleTypeIndex) {
throw new IllegalArgumentException("Bad failureImageInitScaleType value: "
+ scaleTypeIndex);
}
mFailureImageScaleType = IMAGE_SCALE_TYPES[scaleTypeIndex];
Drawable mFailureImageDrawable = array.getDrawable(
R.styleable.BigImageView_failureImage);
Expand Down Expand Up @@ -146,22 +150,6 @@ public BigImageView(Context context, AttributeSet attrs, int defStyleAttr) {
mTempImages = new ArrayList<>();
}

@Override
protected void onFinishInflate() {
super.onFinishInflate();

if (mImageView == null) {
mImageView = findViewById(mCustomSsivId);
}
LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
mImageView.setLayoutParams(params);
mImageView.setMinimumTileDpi(160);

setOptimizeDisplay(mOptimizeDisplay);
setInitScaleType(mInitScaleType);
}

@Override
public void setOnClickListener(final OnClickListener listener) {
mImageView.setOnClickListener(listener);
Expand All @@ -184,6 +172,22 @@ public void setOnLongClickListener(OnLongClickListener listener) {
mImageView.setOnLongClickListener(listener);
}

@Override
protected void onFinishInflate() {
super.onFinishInflate();

if (mImageView == null) {
mImageView = findViewById(mCustomSsivId);
}
LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
mImageView.setLayoutParams(params);
mImageView.setMinimumTileDpi(160);

setOptimizeDisplay(mOptimizeDisplay);
setInitScaleType(mInitScaleType);
}

public void setFailureImageInitScaleType(ImageView.ScaleType scaleType) {
mFailureImageScaleType = scaleType;
}
Expand Down Expand Up @@ -215,7 +219,7 @@ public void setInitScaleType(int initScaleType) {
case INIT_SCALE_TYPE_CENTER_CROP:
mImageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_CROP);
break;
case INIT_SCALE_TYPE_AUTO:
case INIT_SCALE_TYPE_CUSTOM:
mImageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CUSTOM);
break;
case INIT_SCALE_TYPE_START:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void onReady() {
result += 0.2f;
}

if (mInitScaleType == BigImageView.INIT_SCALE_TYPE_AUTO) {
if (mInitScaleType == BigImageView.INIT_SCALE_TYPE_CUSTOM) {
float maxScale = Math.max((float) viewWidth / imageWidth,
(float) viewHeight / imageHeight);
if (maxScale > 1) {
Expand Down
17 changes: 9 additions & 8 deletions BigImageViewer/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,21 @@
<attr format="enum" name="initScaleType">
<enum name="centerInside" value="1"/>
<enum name="centerCrop" value="2"/>
<enum name="auto" value="3"/>
<enum name="custom" value="3"/>
<enum name="start" value="4"/>
</attr>
<attr format="boolean" name="tapToRetry"/>
<attr format="boolean" name="optimizeDisplay"/>
<!-- A drawable to be be used as a failure image. -->
<attr name="failureImage" format="reference"/>
<attr name="failureImageInitScaleType" format="enum">
<enum name="fitXY" value="0" />
<enum name="fitStart" value="1" />
<enum name="fitCenter" value="2" />
<enum name="fitEnd" value="3" />
<enum name="center" value="4" />
<enum name="centerInside" value="5" />
<enum name="centerCrop" value="6" />
<enum name="center" value="0" />
<enum name="centerCrop" value="1" />
<enum name="centerInside" value="2" />
<enum name="fitCenter" value="3" />
<enum name="fitEnd" value="4" />
<enum name="fitStart" value="5" />
<enum name="fitXY" value="6" />
</attr>
<attr name="customSsivId" format="reference"/>
</declare-styleable>
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change log

+ v1.4.4
- Add `INIT_SCALE_TYPE_START` scale type;
- Rename `INIT_SCALE_TYPE_AUTO` to `INIT_SCALE_TYPE_CUSTOM`;
+ v1.4.3
- Fix #72: allow disable tap to retry fail image;
+ v1.4.2
Expand Down
2 changes: 1 addition & 1 deletion FrescoImageLoader/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

apply plugin: 'com.android.library'
apply plugin: 'com.github.ben-manes.versions'
apply from: "https://raw.githubusercontent.com/Piasy/BintrayUploadScript/master/bintray.gradle"
apply from: "https://raw.githubusercontent.com/Piasy/GradleScripts/master/PRJ_NAME/gradle/bintray.gradle"

android {
compileSdkVersion rootProject.ext.androidCompileSdkVersion
Expand Down
4 changes: 2 additions & 2 deletions GlideImageLoader/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

apply plugin: 'com.android.library'
apply plugin: 'com.github.ben-manes.versions'
apply from: "https://raw.githubusercontent.com/Piasy/BintrayUploadScript/master/bintray.gradle"
apply from: "https://raw.githubusercontent.com/Piasy/GradleScripts/master/PRJ_NAME/gradle/bintray.gradle"

android {
compileSdkVersion rootProject.ext.androidCompileSdkVersion
Expand Down Expand Up @@ -53,5 +53,5 @@ dependencies {

api "com.github.bumptech.glide:glide:$rootProject.ext.glideVersion"
api "com.github.bumptech.glide:okhttp3-integration:$rootProject.ext.glideVersion"
api 'com.squareup.okhttp3:okhttp:3.9.0'
api 'com.squareup.okhttp3:okhttp:3.9.1'
}
2 changes: 1 addition & 1 deletion ProgressPieIndicator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

apply plugin: 'com.android.library'
apply plugin: 'com.github.ben-manes.versions'
apply from: "https://raw.githubusercontent.com/Piasy/BintrayUploadScript/master/bintray.gradle"
apply from: "https://raw.githubusercontent.com/Piasy/GradleScripts/master/PRJ_NAME/gradle/bintray.gradle"

android {
compileSdkVersion rootProject.ext.androidCompileSdkVersion
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ allprojects {
}
}
compile 'com.github.piasy:BigImageViewer:1.4.3'
compile 'com.github.piasy:BigImageViewer:1.4.4'
// load with fresco
compile 'com.github.piasy:FrescoImageLoader:1.4.3'
compile 'com.github.piasy:FrescoImageLoader:1.4.4'
// load with glide
compile 'com.github.piasy:GlideImageLoader:1.4.3'
compile 'com.github.piasy:GlideImageLoader:1.4.4'
// progress pie indicator
compile 'com.github.piasy:ProgressPieIndicator:1.4.3'
compile 'com.github.piasy:ProgressPieIndicator:1.4.4'
```

### Initialize
Expand Down Expand Up @@ -144,9 +144,10 @@ mBigImageView.setInitScaleType(BigImageView.INIT_SCALE_TYPE_CENTER_CROP);

| value | effect |
| ------| ------ |
| centerInside | default, Scale the image so that both dimensions of the image will be equal to or less than the corresponding dimension of the view. The image is then centered in the view. This is the default behaviour and best for galleries. |
| centerInside | Scale the image so that both dimensions of the image will be equal to or less than the corresponding dimension of the view. The image is then centered in the view. This is the default behaviour and best for galleries. |
| centerCrop | Scale the image uniformly so that both dimensions of the image will be equal to or larger than the corresponding dimension of the view. The image is then centered in the view. |
| auto | determine the max scale and min scale by image size and view size, fit the image to screen and centered when loaded. |
| custom | Scale the image so that both dimensions of the image will be equal to or less than the maxScale and equal to or larger than minScale. The image is then centered in the view. |
| start | Scale the image so that both dimensions of the image will be equal to or larger than the corresponding dimension of the view. The top left is shown. |

### Failure image

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ dependencies {
api "com.android.support:appcompat-v7:$rootProject.ext.androidSupportSdkVersion"
api "com.android.support:recyclerview-v7:$rootProject.ext.androidSupportSdkVersion"

implementation('com.afollestad.material-dialogs:core:0.9.5.0') {
implementation('com.afollestad.material-dialogs:core:0.9.6.0') {
exclude module: 'support-v4'
exclude module: 'appcompat-v7'
exclude module: 'recyclerview-v7'
Expand All @@ -90,7 +90,7 @@ dependencies {
}
implementation 'io.reactivex.rxjava2:rxjava:2.1.6'
implementation "io.reactivex.rxjava2:rxandroid:2.0.1"
implementation "com.github.akarnokd:rxjava2-interop:0.11.0"
implementation "com.github.akarnokd:rxjava2-interop:0.11.1"
implementation('com.github.piasy:RxQrCode:1.3.0') {
exclude module: 'support-v4'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ private void setScaleType() {
mBigImageView.setInitScaleType(BigImageView.INIT_SCALE_TYPE_CENTER_CROP);
} else if (TextUtils.equals(scaleType, getString(R.string.scale_center_inside))) {
mBigImageView.setInitScaleType(BigImageView.INIT_SCALE_TYPE_CENTER_INSIDE);
} else if (TextUtils.equals(scaleType, getString(R.string.scale_auto))) {
mBigImageView.setInitScaleType(BigImageView.INIT_SCALE_TYPE_AUTO);
} else if (TextUtils.equals(scaleType, getString(R.string.scale_custom))) {
mBigImageView.setInitScaleType(BigImageView.INIT_SCALE_TYPE_CUSTOM);
} else if (TextUtils.equals(scaleType, getString(R.string.scale_start))) {
mBigImageView.setInitScaleType(BigImageView.INIT_SCALE_TYPE_START);
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

<string name="scale_center_crop">centerCrop</string>
<string name="scale_center_inside">centerInside</string>
<string name="scale_auto">auto</string>
<string name="scale_custom">custom</string>
<string name="scale_start">start</string>
<string-array name="init_scale_type">
<item>@string/scale_center_crop</item>
<item>@string/scale_center_inside</item>
<item>@string/scale_auto</item>
<item>@string/scale_custom</item>
<item>@string/scale_start</item>
</string-array>

Expand Down
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.android.tools.build:gradle:3.0.1'

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'

// ./gradlew dependencyUpdates
classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
}
}
Expand Down Expand Up @@ -74,8 +75,8 @@ ext {
'usage and full featured image loading choices. Powered by Subsampling Scale ' +
'Image View, Fresco, Glide, and Picasso.'
artifactLabels = ['big', 'image', 'viewer', 'Fresco', 'Glide', 'Picasso']
releaseVersionCode = 22
releaseVersionName = '1.4.3'
releaseVersionCode = 23
releaseVersionName = '1.4.4'

androidCompileSdkVersion = 27
androidBuildToolsVersion = '27.0.1'
Expand Down

0 comments on commit cf53d73

Please sign in to comment.