-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
1 addition
and
83 deletions.
There are no files selected for viewing
84 changes: 1 addition & 83 deletions
84
app/src/main/java/com/kunfei/bookshelf/view/activity/WelcomeBookActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,6 @@ | ||
//Copyright (c) 2017. 章钦豪. All rights reserved. | ||
package com.kunfei.bookshelf.view.activity; | ||
|
||
import android.animation.Animator; | ||
import android.animation.ValueAnimator; | ||
import android.content.Intent; | ||
import android.widget.ImageView; | ||
|
||
import com.kunfei.basemvplib.impl.IPresenter; | ||
import com.kunfei.bookshelf.R; | ||
import com.kunfei.bookshelf.base.MBaseActivity; | ||
import com.kunfei.bookshelf.presenter.ReadBookPresenter; | ||
import com.kunfei.bookshelf.utils.theme.ThemeStore; | ||
|
||
import butterknife.BindView; | ||
import butterknife.ButterKnife; | ||
|
||
public class WelcomeBookActivity extends MBaseActivity { | ||
|
||
@BindView(R.id.iv_bg) | ||
ImageView ivBg; | ||
|
||
@Override | ||
protected IPresenter initInjector() { | ||
return null; | ||
} | ||
|
||
@Override | ||
protected void onCreateActivity() { | ||
// 避免从桌面启动程序后,会重新实例化入口类的activity | ||
if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) { | ||
finish(); | ||
return; | ||
} | ||
setContentView(R.layout.activity_welcome); | ||
ButterKnife.bind(this); | ||
ivBg.setColorFilter(ThemeStore.accentColor(this)); | ||
ValueAnimator welAnimator = ValueAnimator.ofFloat(1f, 0f).setDuration(800); | ||
welAnimator.setStartDelay(500); | ||
welAnimator.addUpdateListener(animation -> { | ||
float alpha = (Float) animation.getAnimatedValue(); | ||
ivBg.setAlpha(alpha); | ||
}); | ||
welAnimator.addListener(new Animator.AnimatorListener() { | ||
@Override | ||
public void onAnimationStart(Animator animation) { | ||
if (preferences.getBoolean(getString(R.string.pk_default_read), false)) { | ||
startReadActivity(); | ||
} else { | ||
startBookshelfActivity(); | ||
} | ||
finish(); | ||
} | ||
|
||
@Override | ||
public void onAnimationEnd(Animator animation) { | ||
|
||
} | ||
|
||
@Override | ||
public void onAnimationCancel(Animator animation) { | ||
|
||
} | ||
|
||
@Override | ||
public void onAnimationRepeat(Animator animation) { | ||
|
||
} | ||
}); | ||
welAnimator.start(); | ||
} | ||
|
||
private void startBookshelfActivity() { | ||
startActivityByAnim(new Intent(this, MainActivity.class), android.R.anim.fade_in, android.R.anim.fade_out); | ||
} | ||
|
||
private void startReadActivity() { | ||
Intent intent = new Intent(this, ReadBookActivity.class); | ||
intent.putExtra("openFrom", ReadBookPresenter.OPEN_FROM_APP); | ||
startActivity(intent); | ||
} | ||
|
||
@Override | ||
protected void initData() { | ||
|
||
} | ||
public class WelcomeBookActivity extends WelcomeActivity { | ||
|
||
} |