pull/32/head
parent
d35ba56ea1
commit
96048db37d
@ -0,0 +1,50 @@ |
||||
package io.legado.app.ui.welcome |
||||
|
||||
import android.animation.Animator |
||||
import android.animation.ValueAnimator |
||||
import android.os.Bundle |
||||
import androidx.lifecycle.AndroidViewModel |
||||
import io.legado.app.R |
||||
import io.legado.app.base.BaseActivity |
||||
import io.legado.app.lib.theme.ThemeStore |
||||
import io.legado.app.ui.main.MainActivity |
||||
import io.legado.app.utils.getViewModel |
||||
import kotlinx.android.synthetic.main.activity_welcome.* |
||||
import org.jetbrains.anko.startActivity |
||||
|
||||
class WelcomeActivity : BaseActivity<AndroidViewModel>() { |
||||
override val viewModel: AndroidViewModel |
||||
get() = getViewModel(AndroidViewModel::class.java) |
||||
override val layoutID: Int |
||||
get() = R.layout.activity_welcome |
||||
|
||||
override fun onViewModelCreated(viewModel: AndroidViewModel, savedInstanceState: Bundle?) { |
||||
iv_bg.setColorFilter(ThemeStore.accentColor(this)) |
||||
val welAnimator = ValueAnimator.ofFloat(1f, 0f).setDuration(800) |
||||
welAnimator.startDelay = 100 |
||||
welAnimator.addUpdateListener { animation -> |
||||
val alpha = animation.animatedValue as Float |
||||
iv_bg.alpha = alpha |
||||
} |
||||
welAnimator.addListener(object : Animator.AnimatorListener { |
||||
override fun onAnimationStart(animation: Animator) { |
||||
startActivity<MainActivity>() |
||||
finish() |
||||
} |
||||
|
||||
override fun onAnimationEnd(animation: Animator) { |
||||
|
||||
} |
||||
|
||||
override fun onAnimationCancel(animation: Animator) { |
||||
|
||||
} |
||||
|
||||
override fun onAnimationRepeat(animation: Animator) { |
||||
|
||||
} |
||||
}) |
||||
welAnimator.start() |
||||
} |
||||
|
||||
} |
@ -0,0 +1,15 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:orientation="vertical" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent"> |
||||
|
||||
<ImageView |
||||
android:id="@+id/iv_bg" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="match_parent" |
||||
android:src="@drawable/image_welcome" |
||||
android:scaleType="fitCenter" |
||||
android:contentDescription="@string/welcome" /> |
||||
|
||||
</LinearLayout> |
Loading…
Reference in new issue