Skip to content

Commit

Permalink
增加动画的插入
Browse files Browse the repository at this point in the history
  • Loading branch information
你需要一台永动机 committed May 14, 2019
1 parent 1ce262c commit 31040c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/src/main/java/com/pmm/metro/demo/BActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ class BActivity : AppCompatActivity() {
setContentView(R.layout.activity_b)

mTvJump.setOnClickListenerPro {
Metro.with(this).path("/main").go()
Metro.with(this).path("/a")
.overridePendingTransition(R.anim.slide_in_from_bottom, R.anim.noting)
.go()
}
}
}
9 changes: 9 additions & 0 deletions lib/src/main/java/com/pmm/metro/Ticket.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Ticket(private var path: String, private val driver: Driver) {

private val Intent: Intent by lazy { Intent() }
private var transferStation: TransferStation? = null//中转站
private var enterAnim = 0//进入动画
private var exitAnim = 0//退出动画


fun attribute(name: String, value: Int) = this.apply {
Expand Down Expand Up @@ -141,6 +143,11 @@ class Ticket(private var path: String, private val driver: Driver) {
this.transferStation = transferStation
}

fun overridePendingTransition(enterAnim: Int, exitAnim: Int) = this.apply {
this.enterAnim = enterAnim
this.exitAnim = exitAnim
}

//执行
fun go(requestCode: Int = -1) {
//做拦截操作 path识别切换
Expand All @@ -165,6 +172,8 @@ class Ticket(private var path: String, private val driver: Driver) {
} else {
activity.startActivity(Intent.setClass(activity, station.destination))
}
if (enterAnim != 0 || exitAnim != 0)
activity.overridePendingTransition(enterAnim, exitAnim)
}
is FragmentDriver -> {
val fragment = driver.target
Expand Down

0 comments on commit 31040c9

Please sign in to comment.