Skip to content

Commit 96b9171

Browse files
author
371718330@qq.com
committed
增加和修改工具类
1 parent 6a1284d commit 96b9171

File tree

12 files changed

+3061
-1577
lines changed

12 files changed

+3061
-1577
lines changed
Lines changed: 2 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
package com.jingewenku.abrahamcaijin.commonutil;
22

33
import android.app.Activity;
4-
import android.content.ActivityNotFoundException;
54
import android.content.Intent;
6-
import android.os.Bundle;
7-
import android.util.Log;
85

9-
import java.io.Serializable;
106
import java.util.HashMap;
117
import java.util.Iterator;
128
import java.util.Map.Entry;
13-
import java.util.Set;
149

1510
/**
1611
* 主要功能:管理Activity跳转
@@ -32,11 +27,8 @@ public AppActivitySkipUtil() {
3227

3328
/**
3429
* 功能描述:简单地Activity的跳转(不携带任何数据)
35-
*
36-
* @param activity
37-
* 发起跳转的Activity实例
38-
* @param TargetActivity
39-
* 目标Activity实例
30+
* @param activity 发起跳转的Activity实例
31+
* @param cls 目标Activity实例
4032
*/
4133
public static void skipAnotherActivity(Activity activity,
4234
Class<? extends Activity> cls) {
@@ -93,129 +85,4 @@ public static void skipAnotherActivity(Activity activity,
9385
// activity.startActivity(intent);
9486
// activity.overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
9587
// }
96-
97-
private static final String TAG = AppActivitySkipUtil.class.getSimpleName();
98-
private static Intent intent;
99-
private static final Object lock = new Object();
100-
101-
/**
102-
*
103-
* @Title: startActivity
104-
*/
105-
public static <T> void doAction(Activity activity, Class<T> class1) {
106-
synchronized (lock) {
107-
try {
108-
intent = new Intent(activity, class1);
109-
activity.startActivity(intent);
110-
// activity.overridePendingTransition(R.anim.zoom_enter,
111-
// R.anim.zoom_exit);
112-
} catch (ActivityNotFoundException e) {
113-
e.printStackTrace();
114-
}
115-
}
116-
117-
}
118-
119-
/**
120-
*
121-
* @Title: startActivity
122-
*/
123-
public static <T> void doAction(Activity activity, Class<T> class1,
124-
String key, Object object) {
125-
synchronized (lock) {
126-
try {
127-
intent = new Intent(activity, class1);
128-
if (object != null && object instanceof String) {
129-
intent.putExtra(key, (String) object);
130-
} else if (object != null && object instanceof Integer) {
131-
intent.putExtra(key, (Integer) object);
132-
}
133-
activity.startActivity(intent);
134-
// activity.overridePendingTransition(R.anim.zoom_enter,
135-
// R.anim.zoom_exit);
136-
} catch (ActivityNotFoundException e) {
137-
e.printStackTrace();
138-
}
139-
}
140-
141-
}
142-
143-
/**
144-
*
145-
* @Title: startActivity
146-
*/
147-
public static <T> void doAction(Activity activity, Class<T> class1,
148-
HashMap<String, Serializable> map) {
149-
synchronized (lock) {
150-
try {
151-
intent = new Intent(activity, class1);
152-
if (null != map) {
153-
Set<String> keys = map.keySet();
154-
for (String key : keys) {
155-
intent.putExtra(key, map.get(key));
156-
}
157-
activity.startActivity(intent);
158-
// activity.overridePendingTransition(R.anim.zoom_enter,
159-
// R.anim.zoom_exit);
160-
}
161-
} catch (ActivityNotFoundException e) {
162-
e.printStackTrace();
163-
}
164-
}
165-
166-
}
167-
168-
/**
169-
*
170-
* @Title: startActivity
171-
*/
172-
public static <T> void doAction(Activity activity, Class<T> class1,
173-
Bundle bundle) {
174-
synchronized (lock) {
175-
try {
176-
intent = new Intent(activity, class1);
177-
if (bundle != null) {
178-
intent.putExtras(bundle);
179-
}
180-
181-
activity.startActivity(intent);
182-
// activity.overridePendingTransition(R.anim.zoom_enter,
183-
// R.anim.zoom_exit);
184-
185-
} catch (ActivityNotFoundException e) {
186-
e.printStackTrace();
187-
}
188-
}
189-
190-
}
191-
192-
public static Intent getLauncherIntent() {
193-
Intent intent = new Intent(Intent.ACTION_MAIN);
194-
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
195-
intent.addCategory(Intent.CATEGORY_HOME);
196-
return intent;
197-
}
198-
199-
public static void logIntent(String tag, Intent intent) {
200-
if (intent == null) {
201-
return;
202-
}
203-
StringBuffer sb = new StringBuffer();
204-
sb.append("\nAction:" + intent.getAction());
205-
sb.append("\nData:" + intent.getData());
206-
sb.append("\nDataStr:" + intent.getDataString());
207-
sb.append("\nScheme:" + intent.getScheme());
208-
sb.append("\nType:" + intent.getType());
209-
Bundle extras = intent.getExtras();
210-
if (extras != null && !extras.isEmpty()) {
211-
for (String key : extras.keySet()) {
212-
Object value = extras.get(key);
213-
sb.append("\nEXTRA: {" + key + "::" + value + "}");
214-
}
215-
} else {
216-
sb.append("\nNO EXTRAS");
217-
}
218-
Log.i(tag, sb.toString());
219-
}
220-
22188
}

0 commit comments

Comments
 (0)