Skip to content

Commit

Permalink
update RxActivityTool.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamsiree committed Mar 17, 2020
1 parent a9812b6 commit 242ab8c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 27 deletions.
12 changes: 8 additions & 4 deletions RxDemo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' //kapt3插件
//apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'kotlin-android-extensions'

android {

compileSdkVersion 29
buildToolsVersion = '29.0.3'

signingConfigs {
debug {
storeFile file('/home/tamsiree/Documents/TamDocuments/WorkSpace/Android/TamKey.jks')
Expand All @@ -13,8 +17,7 @@ android {
keyPassword 'Ls547817'
}
}
compileSdkVersion 29
buildToolsVersion = '29.0.3'


defaultConfig {
applicationId "com.tamsiree.rxdemo"
Expand Down Expand Up @@ -82,7 +85,8 @@ dependencies {
implementation 'com.orhanobut:logger:2.2.0'

implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
// annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
kapt 'com.jakewharton:butterknife-compiler:10.2.1'

compileOnly 'com.alipay.sdk:alipay-sdk-java:4.9.28.ALL'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ private void setSvg(ModelSVG modelSvg) {
mTvAppName.setVisibility(View.VISIBLE);
mTvVersion.setVisibility(View.VISIBLE);
RxTool.delayToDo(2000, () -> {
RxActivityTool.skipActivityAndFinish(mContext, ActivityMain.class);
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
RxActivityTool.skipActivityAndFinish(mContext, ActivityMain.class, true);
});
break;
default:
Expand Down
1 change: 1 addition & 0 deletions RxDemo/src/main/res/layout/activity_svg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
android:id="@+id/activity_svg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
tools:context="com.tamsiree.rxdemo.activity.ActivitySVG">

<com.tamsiree.rxui.view.RxAutoImageView
Expand Down
67 changes: 47 additions & 20 deletions RxKit/src/main/java/com/tamsiree/rxkit/RxActivityTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public static void launchActivity(Context context, String packageName, String cl
context.startActivity(RxIntentTool.getComponentNameIntent(packageName, className, bundle));
}


/**
* 要求最低API为11
* Activity 跳转
Expand All @@ -154,17 +155,8 @@ public static void launchActivity(Context context, String packageName, String cl
* @param context Context
* @param goal Activity
*/
public static void skipActivityAndFinishAll(Context context, Class<?> goal, Bundle bundle, boolean isFade) {
Intent intent = new Intent(context, goal);
if (bundle != null) {
intent.putExtras(bundle);
}
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivity(intent);
finishActivity(context, false);
if (isFade) {
fadeTransition(context);
}
public static void skipActivityAndFinishAll(Context context, Class<?> goal) {
skipActivityAndFinishAll(context, goal, null, false);
}

/**
Expand All @@ -187,8 +179,17 @@ public static void skipActivityAndFinishAll(Context context, Class<?> goal, bool
* @param context Context
* @param goal Activity
*/
public static void skipActivityAndFinishAll(Context context, Class<?> goal) {
skipActivityAndFinishAll(context, goal, null, false);
public static void skipActivityAndFinishAll(Context context, Class<?> goal, Bundle bundle, boolean isFade) {
Intent intent = new Intent(context, goal);
if (bundle != null) {
intent.putExtras(bundle);
}
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivity(intent);
finishActivity(context, false);
if (isFade) {
fadeTransition(context);
}
}

/**
Expand All @@ -197,9 +198,9 @@ public static void skipActivityAndFinishAll(Context context, Class<?> goal) {
* @param context Context
* @param goal Activity
*/
public static void skipActivityAndFinish(Context context, Class<?> goal, Bundle bundle, boolean isFade, boolean isTransition) {
skipActivity(context, goal, bundle, isFade);
finishActivity(context, isTransition);
public static void skipActivityAndFinish(Context context, Class<?> goal) {
skipActivity(context, goal, null, false);
finishActivity(context, false);
}

/**
Expand All @@ -208,8 +209,8 @@ public static void skipActivityAndFinish(Context context, Class<?> goal, Bundle
* @param context Context
* @param goal Activity
*/
public static void skipActivityAndFinish(Context context, Class<?> goal, Bundle bundle) {
skipActivity(context, goal, bundle, false);
public static void skipActivityAndFinish(Context context, Class<?> goal, boolean isFade) {
skipActivity(context, goal, null, isFade);
finishActivity(context, false);
}

Expand All @@ -219,8 +220,8 @@ public static void skipActivityAndFinish(Context context, Class<?> goal, Bundle
* @param context Context
* @param goal Activity
*/
public static void skipActivityAndFinish(Context context, Class<?> goal) {
skipActivity(context, goal, null, false);
public static void skipActivityAndFinish(Context context, Class<?> goal, Bundle bundle) {
skipActivity(context, goal, bundle, false);
finishActivity(context, false);
}

Expand All @@ -235,6 +236,18 @@ public static void skipActivityAndFinish(Context context, Class<?> goal, boolean
finishActivity(context, isTransition);
}

/**
* Activity 跳转
*
* @param context Context
* @param goal Activity
*/
public static void skipActivityAndFinish(Context context, Class<?> goal, Bundle bundle, boolean isFade, boolean isTransition) {
skipActivity(context, goal, bundle, isFade);
finishActivity(context, isTransition);
}


/**
* Activity 跳转
*
Expand All @@ -245,6 +258,20 @@ public static void skipActivity(Context context, Class<?> goal) {
skipActivity(context, goal, null, false);
}

/**
* Activity 跳转
*
* @param context Context
* @param goal Activity
*/
public static void skipActivity(Context context, Class<?> goal, Bundle bundle) {
Intent intent = new Intent(context, goal);
if (bundle != null) {
intent.putExtras(bundle);
}
context.startActivity(intent);
}

/**
* Activity 跳转
*
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.1'
// classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
// NOTE: Do not place your application dependencies here; they belong
Expand Down

0 comments on commit 242ab8c

Please sign in to comment.