Skip to content

Commit f32573b

Browse files
committed
- 新增Base系列
- 新增title系列 - 升级优化gradle
1 parent 0bf64f1 commit f32573b

File tree

12 files changed

+936
-11
lines changed

12 files changed

+936
-11
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ buildscript {
66
jcenter()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:2.3.3'
9+
classpath 'com.android.tools.build:gradle:3.0.1'
1010
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
11-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11+
classpath "com.jakewharton:butterknife-gradle-plugin:8.6.0"
1212
// classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
1313
// NOTE: Do not place your application dependencies here; they belong
1414
// in the individual module build.gradle files
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Sep 20 11:19:41 GMT+08:00 2017
1+
#Tue Mar 27 16:17:31 GMT+08:00 2018
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

myutils/build.gradle

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ apply plugin: 'com.github.dcendents.android-maven'
33
group='com.github.seeways'
44

55
android {
6-
compileSdkVersion 25
6+
compileSdkVersion 26
77
buildToolsVersion "25.0.2"
88

99
defaultConfig {
1010
minSdkVersion 14
11-
targetSdkVersion 25
12-
versionCode 1
13-
versionName "1.0"
11+
targetSdkVersion 26
12+
versionCode 3
13+
versionName "2.0"
1414
}
1515
buildTypes {
1616
release {
@@ -24,6 +24,9 @@ android {
2424

2525
dependencies {
2626
compile fileTree(dir: 'libs', include: ['*.jar'])
27-
compile 'com.android.support:appcompat-v7:25.1.0'
28-
compile 'com.android.support:design:25.1.0'
27+
compile 'com.android.support:appcompat-v7:26+'
28+
compile 'com.android.support:design:26+'
29+
//View注入框架
30+
compile 'com.jakewharton:butterknife:8.6.0'
31+
annotationProcessor "com.jakewharton:butterknife-compiler:8.6.0"
2932
}
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
2+
package com.jty.myutils.base;
3+
4+
import android.app.Activity;
5+
import android.app.ActivityManager;
6+
import android.content.Context;
7+
8+
import java.util.Stack;
9+
10+
/**
11+
* activity管理
12+
*/
13+
public class AppManager {
14+
private static Stack<Activity> activityStack;
15+
private volatile static AppManager instance;
16+
17+
private AppManager() {
18+
19+
}
20+
/**
21+
* 单一实例
22+
*/
23+
public static AppManager getAppManager() {
24+
if (instance == null) {
25+
synchronized (AppManager.class){
26+
if(instance==null){
27+
instance = new AppManager();
28+
instance.activityStack = new Stack();
29+
}
30+
}
31+
32+
}
33+
return instance;
34+
}
35+
36+
/**
37+
* 添加Activity到堆栈
38+
*/
39+
public void addActivity(Activity activity) {
40+
if (activityStack == null) {
41+
activityStack = new Stack<Activity>();
42+
}
43+
activityStack.add(activity);
44+
}
45+
46+
/**
47+
* 获取当前Activity(堆栈中最后一个压入的)
48+
*/
49+
public Activity currentActivity() {
50+
try {
51+
Activity activity = activityStack.lastElement();
52+
return activity;
53+
} catch (Exception e) {
54+
// e.printStackTrace();
55+
return null;
56+
}
57+
}
58+
59+
/**
60+
* 获取当前Activity的前一个Activity
61+
*/
62+
public Activity preActivity() {
63+
int index = activityStack.size() - 2;
64+
if (index < 0) {
65+
return null;
66+
}
67+
Activity activity = activityStack.get(index);
68+
return activity;
69+
}
70+
71+
/**
72+
* 结束当前Activity(堆栈中最后一个压入的)
73+
*/
74+
public void finishActivity() {
75+
Activity activity = activityStack.lastElement();
76+
finishActivity(activity);
77+
}
78+
79+
/**
80+
* 结束指定的Activity
81+
*/
82+
public void finishActivity(Activity activity) {
83+
if (activity != null) {
84+
activityStack.remove(activity);
85+
activity.finish();
86+
activity = null;
87+
}
88+
}
89+
90+
/**
91+
* 移除指定的Activity
92+
*/
93+
public void removeActivity(Activity activity) {
94+
if (activity != null) {
95+
activityStack.remove(activity);
96+
activity = null;
97+
}
98+
}
99+
100+
/**
101+
* 结束指定类名的Activity
102+
*/
103+
public void finishActivity(Class<?> cls) {
104+
try {
105+
for (Activity activity : activityStack) {
106+
if (activity.getClass().equals(cls)) {
107+
finishActivity(activity);
108+
}
109+
}
110+
} catch (Exception e) {
111+
e.printStackTrace();
112+
}
113+
114+
}
115+
116+
/**
117+
* 结束所有Activity
118+
*/
119+
public void finishAllActivity() {
120+
for (int i = 0, size = activityStack.size(); i < size; i++) {
121+
if (null != activityStack.get(i)) {
122+
activityStack.get(i).finish();
123+
}
124+
}
125+
activityStack.clear();
126+
}
127+
128+
/**
129+
* 返回到指定的activity
130+
*
131+
* @param cls
132+
*/
133+
public void returnToActivity(Class<?> cls) {
134+
while (activityStack.size() != 0)
135+
if (activityStack.peek().getClass() == cls) {
136+
break;
137+
} else {
138+
finishActivity(activityStack.peek());
139+
}
140+
}
141+
142+
143+
/**
144+
* 是否已经打开指定的activity
145+
* @param cls
146+
* @return
147+
*/
148+
public boolean isOpenActivity(Class<?> cls) {
149+
if (activityStack!=null){
150+
for (int i = 0, size = activityStack.size(); i < size; i++) {
151+
if (cls == activityStack.peek().getClass()) {
152+
return true;
153+
}
154+
}
155+
}
156+
return false;
157+
}
158+
159+
/**
160+
* 退出应用程序
161+
*
162+
* @param context 上下文
163+
* @param isBackground 是否开开启后台运行
164+
*/
165+
public void AppExit(Context context, Boolean isBackground) {
166+
try {
167+
finishAllActivity();
168+
ActivityManager activityMgr = (ActivityManager) context
169+
.getSystemService(Context.ACTIVITY_SERVICE);
170+
activityMgr.restartPackage(context.getPackageName());
171+
} catch (Exception e) {
172+
173+
} finally {
174+
// 注意,如果您有后台程序运行,请不要支持此句子
175+
if (!isBackground) {
176+
System.exit(0);
177+
}
178+
}
179+
}
180+
}

0 commit comments

Comments
 (0)