Skip to content

Commit

Permalink
升级SDK、Glide、Gradle版本
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfusheng committed May 8, 2018
1 parent 1787bc6 commit 9d820fb
Show file tree
Hide file tree
Showing 26 changed files with 324 additions and 97 deletions.
29 changes: 29 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 10 additions & 13 deletions GlideImageView/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'

android {
compileSdkVersion 26
buildToolsVersion "26.0.2"

compileSdkVersion rootProject.compileSdkVersion
defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 4
versionName "1.3.0"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode rootProject.versionCode
versionName rootProject.versionName
}

lintOptions {
Expand All @@ -25,18 +23,17 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:26.1.0'
compile 'com.github.bumptech.glide:glide:4.3.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
compile "com.github.bumptech.glide:okhttp3-integration:4.3.1"
api 'com.android.support:support-v4:' + rootProject.supportLibraryVersion
api 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
api "com.github.bumptech.glide:okhttp3-integration:4.7.1"
}

publish {
userOrg = 'sfsheng0322'
groupId = 'com.sunfusheng'
artifactId = 'glideimageview'
publishVersion = '1.3.0'
publishVersion = rootProject.versionName
desc = 'GlideImageView is an image loading library which you can listen to the progress of loading.'
website = 'https://github.com/sfsheng0322/GlideImageView'
}
6 changes: 1 addition & 5 deletions GlideImageView/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"/>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.load.resource.gif.GifDrawable;
import com.sunfusheng.glideimageview.util.DisplayUtil;

/**
Expand Down Expand Up @@ -107,7 +106,9 @@ public ShapeImageView(Context context, AttributeSet attrs, int defStyleAttr) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width = getMeasuredWidth(), height = getMeasuredHeight();
int width = getMeasuredWidth();
int height = getMeasuredHeight();

if (mIsCircle) {
int size = Math.min(width, height);
setMeasuredDimension(size, size);
Expand All @@ -117,8 +118,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mBitmap == null) {
return;
}
if (widthMode == View.MeasureSpec.AT_MOST || widthMode == View.MeasureSpec.UNSPECIFIED ||
heightMode == View.MeasureSpec.AT_MOST || heightMode == View.MeasureSpec.UNSPECIFIED) {
if (widthMode == View.MeasureSpec.AT_MOST || widthMode == View.MeasureSpec.UNSPECIFIED || heightMode == View.MeasureSpec.AT_MOST || heightMode == View.MeasureSpec.UNSPECIFIED) {
float bmWidth = mBitmap.getWidth(), bmHeight = mBitmap.getHeight();
float scaleX = width / bmWidth, scaleY = height / bmHeight;
if (scaleX == scaleY) {
Expand All @@ -135,7 +135,8 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

@Override
protected void onDraw(Canvas canvas) {
int width = getWidth(), height = getHeight();
int width = getWidth();
int height = getHeight();
if (width <= 0 || height <= 0 || mBitmap == null || mBitmapShader == null) {
return;
}
Expand Down Expand Up @@ -226,13 +227,10 @@ private Bitmap getBitmap() {

if (drawable instanceof BitmapDrawable) {
return ((BitmapDrawable) drawable).getBitmap();
} else if (drawable instanceof GifDrawable) {
GifDrawable gifDrawable = (GifDrawable) drawable;
}

try {
Bitmap bitmap;

if (drawable instanceof ColorDrawable) {
bitmap = Bitmap.createBitmap(COLOR_DRAWABLE_DIMEN, COLOR_DRAWABLE_DIMEN, BITMAP_CONFIG);
} else {
Expand All @@ -255,10 +253,9 @@ private void updateBitmapShader() {
if (mBitmapShader == null || mBitmap == null) {
return;
}
final float bmWidth = mBitmap.getWidth();
final float bmHeight = mBitmap.getHeight();
final float scaleX = mWidth / bmWidth;
final float scaleY = mHeight / bmHeight;

final float bmWidth = mBitmap.getWidth(), bmHeight = mBitmap.getHeight();
final float scaleX = mWidth / bmWidth, scaleY = mHeight / bmHeight;
final float scale = Math.max(scaleX, scaleY);
mMatrix.setScale(scale, scale);
mMatrix.postTranslate(-(scale * bmWidth - mWidth) / 2, -(scale * bmHeight - mHeight) / 2);
Expand Down Expand Up @@ -307,19 +304,18 @@ public void setPressedBorderWidth(int selectedBorderWidth) {
}
}

public void setPressedMaskColor(@ColorInt int selectedMaskColor) {
if (mPressedMaskColor != selectedMaskColor) {
mPressedMaskColor = selectedMaskColor;
if (mPressedMaskColor != Color.TRANSPARENT) {
mPressedColorFilter = new PorterDuffColorFilter(mPressedMaskColor, PorterDuff.Mode.DARKEN);
public void setPressedMaskColor(@ColorInt int pressedMaskColor) {
if (mPressedMaskColor != pressedMaskColor) {
if (pressedMaskColor != Color.TRANSPARENT) {
mPressedColorFilter = new PorterDuffColorFilter(pressedMaskColor, PorterDuff.Mode.DARKEN);
} else {
mPressedColorFilter = null;
}
if (mIsPressed) {
invalidate();
}
}
mPressedMaskColor = selectedMaskColor;
mPressedMaskColor = pressedMaskColor;
}


Expand Down Expand Up @@ -378,11 +374,11 @@ public boolean isPressedModeEnabled() {
return mPressedModeEnabled;
}

public void setPressedColorFilter(ColorFilter cf) {
if (mPressedColorFilter == cf) {
public void setPressedColorFilter(ColorFilter colorFilter) {
if (mPressedColorFilter == colorFilter) {
return;
}
mPressedColorFilter = cf;
mPressedColorFilter = colorFilter;
if (mIsPressed) {
invalidate();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.sunfusheng.glideimageview.progress;

import android.content.Context;
import android.support.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.Registry;
Expand All @@ -16,9 +17,8 @@
*/
@GlideModule
public class ProgressAppGlideModule extends AppGlideModule {

@Override
public void registerComponents(Context context, Glide glide, Registry registry) {
public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
super.registerComponents(context, glide, registry);
registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(ProgressManager.getOkHttpClient()));
}
Expand Down
38 changes: 15 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,34 +133,26 @@
<br/>

### 我的微信公众号
### 个人微信公众号

<img src="https://github.com/sfsheng0322/StickyHeaderListView/blob/master/screenshots/%E5%BE%AE%E4%BF%A1%E5%85%AC%E4%BC%97%E5%8F%B7.jpg" style="width: 30%;">
<img src="http://ourvm0t8d.bkt.clouddn.com/wx_gongzhonghao.png">

### 关于我

个人邮箱:sfsheng0322@126.com

[GitHub主页](https://github.com/sfsheng0322)

[简书主页](http://www.jianshu.com/users/88509e7e2ed1/latest_articles)
<br/>

[个人博客](http://sunfusheng.com/)
### 打点赏给作者加点油^_^

[新浪微博](http://weibo.com/u/3852192525)
<img src="http://ourvm0t8d.bkt.clouddn.com/wx_shoukuanma.png" >

License
--
Copyright (C) 2017 sfsheng0322@126.com
<br/>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
### 关于我

http://www.apache.org/licenses/LICENSE-2.0
[GitHub: sfsheng0322](https://github.com/sfsheng0322)

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
[个人邮箱: sfsheng0322@126.com](https://mail.126.com/)

[个人博客: sunfusheng.com](http://sunfusheng.com/)

[简书主页](http://www.jianshu.com/users/88509e7e2ed1/latest_articles)

[新浪微博](http://weibo.com/u/3852192525)
27 changes: 12 additions & 15 deletions Sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "26.0.2"

compileSdkVersion rootProject.compileSdkVersion
defaultConfig {
applicationId "com.sunfusheng.glideimageview.sample"
minSdkVersion 14
targetSdkVersion 26
versionCode 3
versionName "1.2.0"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode rootProject.versionCode
versionName rootProject.versionName
}

compileOptions {
Expand All @@ -30,13 +28,12 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:percent:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.github.chrisbanes:PhotoView:2.1.3'
api 'com.android.support:appcompat-v7:' + rootProject.supportLibraryVersion
api 'com.android.support:percent:' + rootProject.supportLibraryVersion
api 'com.android.support:design:' + rootProject.supportLibraryVersion
api 'com.android.support.constraint:constraint-layout:1.1.0'
api 'com.github.chrisbanes:PhotoView:2.1.3'

compile project(':GlideImageView')
// compile 'com.sunfusheng:glideimageview:1.2.0'
api project(':GlideImageView')
// api 'com.sunfusheng:glideimageview:1.3.0'
}
2 changes: 0 additions & 2 deletions Sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppCompatTheme">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.sunfusheng.glideimageview.sample;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
Expand Down Expand Up @@ -160,7 +159,6 @@ private void line3() {
image34.loadImage(gif3, R.mipmap.ic_launcher);
}

@SuppressLint("CheckResult")
private void line41() {
image41.setOnClickListener(v -> {
Intent intent = new Intent(MainActivity.this, SingleImageActivity.class);
Expand All @@ -186,7 +184,6 @@ private void line41() {
});
}

@SuppressLint("CheckResult")
private void line42() {
image42.setOnClickListener(v -> {
Intent intent = new Intent(MainActivity.this, SingleImageActivity.class);
Expand Down
34 changes: 34 additions & 0 deletions Sample/src/main/res/drawable-v24/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<vector xmlns:aapt="http://schemas.android.com/aapt"
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0"/>
<item
android:color="#00000000"
android:offset="1.0"/>
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1"/>
</vector>
Loading

0 comments on commit 9d820fb

Please sign in to comment.