Skip to content

Commit

Permalink
Fix: the crash bug when open the Wechat page again and Release v2.1.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
qingmei2 committed Jul 17, 2018
1 parent f6606e2 commit 1228d59
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 42 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RxImagePicker的设计起源,请参考我的[这篇文章](https://www.jianshu

* **[详细文档,包括进阶使用和拓展功能,请点击查看wiki!](https://github.com/qingmei2/RxImagePicker/wiki)**
* **[常见问题](https://github.com/qingmei2/RxImagePicker/wiki/常见问题)** : 提issue之前查看一下,也许能节省您很多的时间!
* **[更新日志](https://github.com/qingmei2/RxImagePicker/wiki/ChangeLog)** : 升级库之前,请查看新版本关于API有可能出现的变动。
* **[更新日志](https://github.com/qingmei2/RxImagePicker/wiki/ChangeLog)** : 升级库之前,请查看新版本关于API有可能出现的变动,**最新版本v2.1.1**

<h2 id="overview">简介</h2>

Expand Down Expand Up @@ -71,15 +71,16 @@ RxImagePicker是一个用于Android的响应式图片选择器,它将您的图

```groovy
// 最基础的架构,仅提供了系统默认的图片选择器和拍照功能
compile 'com.github.qingmei2:rximagepicker:0.4.0'
compile 'com.github.qingmei2:rximagepicker:2.1.1'
// 提供了自定义UI图片选择器的基本组件,自定义UI的需求需要添加该依赖
compile 'com.github.qingmei2:rximagepicker_support:0.4.0'
compile 'com.github.qingmei2:rximagepicker_support:2.1.1'
// 如果需要额外的UI支持,请选择依赖对应的UI拓展库
compile 'com.github.qingmei2:rximagepicker_support_zhihu:0.4.0' // 知乎图片选择器
compile 'com.github.qingmei2:rximagepicker_support_wechat:0.4.0' // 微信图片选择器
compile 'com.github.qingmei2:rximagepicker_support_zhihu:2.1.1' // 知乎图片选择器
compile 'com.github.qingmei2:rximagepicker_support_wechat:2.1.1' // 微信图片选择器
```

### 2. 接口配置

声明一个接口,并进行基础的配置:
Expand Down Expand Up @@ -144,7 +145,7 @@ private void onButtonClick() {
* [RxCache:Reactive caching library for Android and Java](https://github.com/VictorAlbertos/RxCache)
优秀的RxJava拓展库,用于处理RxJava的数据缓存,库底层通过Dagger完成对配置的处理,我借鉴在了RxImagePicker中。
* [Dagger2:A fast dependency injector for Android and Java.](https://github.com/google/dagger)
Google优秀的依赖注入框架,它是构成RxImagePicker的 **基础组件** 。
Google优秀的依赖注入框架,0.4.0版本之前,它是构成RxImagePicker的 **基础组件** 。
* [Matisse:A well-designed local image and video selector for Android](https://github.com/zhihu/Matisse)
知乎开源,优秀的Android图片选择库,拥有非常 **Material Design** 的设计。在RxImagePicker中,Matisse被抽出来放入了RxImagePicker_Support,成为了 **UI层的基础组件** 。

Expand Down
4 changes: 2 additions & 2 deletions config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ project.ext {

minSdkVersion : 14,
targetSdkVersion : 27,
versionCode : 15,
versionName : "2.0.0"
versionCode : 17,
versionName : "2.1.1"
]

dependencies = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ open class AlbumMediaAdapter(context: Context,
private var mOnMediaClickListener: OnMediaClickListener? = null
private var mImageResize: Int = 0

open val itemLayoutRes: Int
@LayoutRes
get() = R.layout.media_grid_item
open val itemLayoutRes: Int = R.layout.media_grid_item

init {
mSelectionSpec = SelectionSpec.instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ open class CheckView : View {
protected var mDensity: Float = 0.toFloat()
protected var mCheckRect: Rect? = null
protected var mEnabled = true

// rect for drawing checked number or mark
private val checkRect: Rect
get() {
Expand Down Expand Up @@ -216,12 +215,11 @@ open class CheckView : View {
companion object {

const val UNCHECKED = Integer.MIN_VALUE
protected const val STROKE_WIDTH = 3.0f // dp
protected const val SHADOW_WIDTH = 6.0f // dp
@JvmStatic
protected val SIZE = 48 // dp
protected val STROKE_RADIUS = 11.5f // dp
protected const val BG_RADIUS = 11.0f // dp
protected const val CONTENT_SIZE = 16 // dp
const val SIZE = 48 // dp
const val STROKE_RADIUS = 11.5f // dp
const val STROKE_WIDTH = 3.0f // dp
const val SHADOW_WIDTH = 6.0f // dp
const val BG_RADIUS = 11.0f // dp
const val CONTENT_SIZE = 16 // dp
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ open class MediaGrid : SquareFrameLayout, View.OnClickListener {
init(context)
}

protected open fun init(context: Context) {
LayoutInflater.from(context).inflate(R.layout.media_grid_content, this, true)
open fun getLayoutRes(): Int {
return R.layout.media_grid_content
}

fun init(context: Context) {
LayoutInflater.from(context).inflate(getLayoutRes(), this, true)

mThumbnail = findViewById(R.id.media_thumbnail)
mCheckView = findViewById(R.id.check_view)
Expand Down
1 change: 1 addition & 0 deletions rximagepicker_support_wechat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ android {
}
}
}

dependencies {
implementation project(':rximagepicker')
implementation project(':rximagepicker_support')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import android.util.AttributeSet

import com.qingmei2.rximagepicker_extension.ui.widget.CheckView

class WechatCheckView : CheckView {
open class WechatCheckView : CheckView {

private var rect: RectF? = null
private var drawableRect: Rect? = null
Expand All @@ -27,8 +27,8 @@ class WechatCheckView : CheckView {
mStrokePaint.strokeWidth = WECHAT_STROKE_WIDTH * mDensity

// draw white stroke
val dx = mDensity * CheckView.SIZE / 4
val dy = mDensity * CheckView.SIZE / 4
val dx = mDensity * SIZE / 4
val dy = mDensity * SIZE / 4
rect = RectF(2 * dx - PROOFREAD_SIZE, dy - PROOFREAD_SIZE,
3 * dx + PROOFREAD_SIZE, 2 * dy + PROOFREAD_SIZE)
drawableRect = Rect(rect!!.left.toInt(), rect!!.top.toInt(), rect!!.right.toInt(), rect!!.bottom.toInt())
Expand Down Expand Up @@ -89,6 +89,7 @@ class WechatCheckView : CheckView {

private const val WECHAT_STROKE_WIDTH = 1.5f // dp
private const val WECHAT_STROKE_CONNER = 5f // dp
private const val SIZE = 48 // dp

private const val PROOFREAD_SIZE = 8
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@ class WechatMediaGrid : MediaGrid {

constructor(context: Context, attrs: AttributeSet) : super(context, attrs)

override fun init(context: Context) {
LayoutInflater.from(context).inflate(R.layout.wechat_media_grid_content, this, true)

mThumbnail = findViewById(R.id.media_thumbnail)
mCheckView = findViewById(R.id.check_view)
mGifTag = findViewById(R.id.gif)
mVideoDuration = findViewById(R.id.video_duration)

mThumbnail.setOnClickListener(this)
mCheckView.setOnClickListener(this)
override fun getLayoutRes(): Int {
return R.layout.wechat_media_grid_content
}
}
16 changes: 8 additions & 8 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ dependencies {
implementation rootProject.ext.dependencies["design"]
implementation rootProject.ext.dependencies["glide"]
annotationProcessor rootProject.ext.dependencies["glide-compiler"]
implementation project(':rximagepicker')
implementation project(':rximagepicker_support')
implementation project(':rximagepicker_support_wechat')
implementation project(':rximagepicker_support_zhihu')
// implementation project(':rximagepicker')
// implementation project(':rximagepicker_support')
// implementation project(':rximagepicker_support_wechat')
// implementation project(':rximagepicker_support_zhihu')

// implementation 'com.github.qingmei2:rximagepicker:2.0.0'
// implementation 'com.github.qingmei2:rximagepicker_support:2.0.0'
// implementation 'com.github.qingmei2:rximagepicker_support_zhihu:2.0.0'
// implementation 'com.github.qingmei2:rximagepicker_support_wechat:2.0.0'
implementation "com.github.qingmei2:rximagepicker:2.1.1"
implementation "com.github.qingmei2:rximagepicker_support:2.1.1"
implementation "com.github.qingmei2:rximagepicker_support_zhihu:2.1.1"
implementation "com.github.qingmei2:rximagepicker_support_wechat:2.1.1"

testImplementation rootProject.ext.dependencies["junit"]
}

0 comments on commit 1228d59

Please sign in to comment.