Skip to content

Commit

Permalink
更改普通动画弹出名称,增加gif图,更改readme
Browse files Browse the repository at this point in the history
  • Loading branch information
wanglu1209 committed Sep 21, 2018
1 parent 5ac5e18 commit c762115
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 6 deletions.
72 changes: 71 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,71 @@
# WLikeView
# WLikeAnim - 简单的点赞动画


<p >
<a><img src="https://img.shields.io/github/release/wanglu1209/WLikeAnim.svg"/></a>
<a><img src="https://img.shields.io/github/last-commit/wanglu1209/WLikeAnim.svg"/></a>
<a><img src="https://img.shields.io/github/issues/wanglu1209/WLikeAnim.svg"/></a>
<a><img src="https://img.shields.io/github/issues-closed/wanglu1209/WLikeAnim.svg"/></a>
<a><img src="https://img.shields.io/github/issues-pr/wanglu1209/WLikeAnim.svg"/></a>
<a><img src="https://img.shields.io/github/issues-pr-closed/wanglu1209/WLikeAnim.svg"/></a>
<a><img src="https://img.shields.io/github/forks/wanglu1209/WLikeAnim.svg"/></a>
<a><img src="https://img.shields.io/github/stars/wanglu1209/WLikeAnim.svg"/></a>
</p>

<div>
<img src="https://raw.githubusercontent.com/wanglu1209/WPopup/master/img/anim_gif.gif" width="200" height="350" />
&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<img src="https://raw.githubusercontent.com/wanglu1209/WLikeAnim/master/img/gif.gif" width="200" height="350" />
</div>
## 依赖

```gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.wanglu1209:WLikeAnim:lastRelease'
}
```

## 使用

### 普通的动画效果
效果看第一个图 或者[WPopup](https://github.com/wanglu1209/WPopup)(只是简单的缩放)

```Kotlin
WCommonAnim(iv).show()
```

### 类似于掘金的动画效果

```Kotlin
// 第一个参数为点赞的ImageView,第二个参数为想要替换的res
WJueJinLikeAnim.Builder(ImageView, R.mipmap.xxx).create().show()
```

## 解释

**该动画库只有动画,完全不参与逻辑**

类似于下面,所有的逻辑都要自己写:

```Kotlin
var isLiked = false
val likeAnim = WJueJinLikeAnim.Builder(iv, R.mipmap.fd_zan_press).create()
iv.setOnClickListener {
if(isLiked){
iv.setImageResource(R.mipmap.fd_zan)
isLiked = false
}else{
iv.setImageResource(R.mipmap.fd_zan_press)
isLiked = true
likeAnim.show()
}
}
```

11 changes: 7 additions & 4 deletions app/src/main/java/com/wanglu/wlikeview/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.wanglu.wlikeview

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.wanglu.lib.WCommonAnim
import com.wanglu.lib.juejin.WJueJinLikeAnim
import kotlinx.android.synthetic.main.activity_main.*

Expand All @@ -11,15 +12,17 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

var liked = false
WCommonAnim(iv).show()

var isLiked = false
val likeAnim = WJueJinLikeAnim.Builder(iv, R.mipmap.fd_zan_press).create()
iv.setOnClickListener {
if(liked){
if(isLiked){
iv.setImageResource(R.mipmap.fd_zan)
liked = false
isLiked = false
}else{
iv.setImageResource(R.mipmap.fd_zan_press)
liked = true
isLiked = true
likeAnim.show()
}
}
Expand Down
Binary file added gif/gif.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion lib/src/main/java/com/wanglu/lib/WCommonAnim.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class WCommonAnim(private val view: View) {
animSet.duration = 200
}

fun start() {
fun show() {
if (animSet.isRunning)
animSet.cancel()

Expand Down

0 comments on commit c762115

Please sign in to comment.