Compare commits
2 Commits
56692db142
...
1e697bc12d
Author | SHA1 | Date | |
---|---|---|---|
1e697bc12d | |||
d5a3c626b3 |
@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Sat May 31 13:31:02 GMT 2025
|
#Sun Jun 01 07:01:34 GMT 2025
|
||||||
stageCount=2
|
stageCount=2
|
||||||
libraryProject=libappbase
|
libraryProject=libappbase
|
||||||
baseVersion=15.8
|
baseVersion=15.8
|
||||||
publishVersion=15.8.1
|
publishVersion=15.8.1
|
||||||
buildCount=25
|
buildCount=45
|
||||||
baseBetaVersion=15.8.2
|
baseBetaVersion=15.8.2
|
||||||
|
@ -166,7 +166,7 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onTestOpenNewActivity(View view) {
|
public void onTestOpenNewActivity(View view) {
|
||||||
GlobalApplication.getWinBoLLActivityManager().startWinBoLLActivity(NewActivity.class);
|
GlobalApplication.getWinBoLLActivityManager().startWinBoLLActivity(this, NewActivity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,7 +59,7 @@ public class New2Activity extends WinBoLLActivity implements IWinBoLLActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onNewActivity(View view) {
|
public void onNewActivity(View view) {
|
||||||
GlobalApplication.getWinBoLLActivityManager().startWinBoLLActivity(NewActivity.class);
|
GlobalApplication.getWinBoLLActivityManager().startWinBoLLActivity(this, NewActivity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class NewActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onNew2Activity(View view) {
|
public void onNew2Activity(View view) {
|
||||||
GlobalApplication.getWinBoLLActivityManager().startWinBoLLActivity(New2Activity.class);
|
GlobalApplication.getWinBoLLActivityManager().startWinBoLLActivity(this, New2Activity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,8 +8,10 @@ package cc.winboll.studio.appbase.activities;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import cc.winboll.studio.appbase.MainActivity;
|
||||||
import cc.winboll.studio.appbase.R;
|
import cc.winboll.studio.appbase.R;
|
||||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||||
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||||
|
|
||||||
public class WinBoLLActivity extends Activity implements IWinBoLLActivity {
|
public class WinBoLLActivity extends Activity implements IWinBoLLActivity {
|
||||||
@ -26,11 +28,19 @@ public class WinBoLLActivity extends Activity implements IWinBoLLActivity {
|
|||||||
return TAG;
|
return TAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
LogUtils.d(TAG, String.format("onResume %s", getTag()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
if (item.getItemId() == R.id.item_log) {
|
if (item.getItemId() == R.id.item_log) {
|
||||||
GlobalApplication.getWinBoLLActivityManager().startLogActivity();
|
GlobalApplication.getWinBoLLActivityManager().startLogActivity(this);
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.item_home) {
|
||||||
|
GlobalApplication.getWinBoLLActivityManager().startWinBoLLActivity(getApplicationContext(), MainActivity.class);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// 在switch语句中处理每个ID,并在处理完后返回true,未处理的情况返回false。
|
// 在switch语句中处理每个ID,并在处理完后返回true,未处理的情况返回false。
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/item_home"
|
||||||
|
android:title="HOME"
|
||||||
|
android:icon="@drawable/ic_winboll"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/item_log"
|
android:id="@+id/item_log"
|
||||||
android:title="LOG"
|
android:title="LOG"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Sat May 31 13:31:02 GMT 2025
|
#Sun Jun 01 07:01:34 GMT 2025
|
||||||
stageCount=2
|
stageCount=2
|
||||||
libraryProject=libappbase
|
libraryProject=libappbase
|
||||||
baseVersion=15.8
|
baseVersion=15.8
|
||||||
publishVersion=15.8.1
|
publishVersion=15.8.1
|
||||||
buildCount=25
|
buildCount=45
|
||||||
baseBetaVersion=15.8.2
|
baseBetaVersion=15.8.2
|
||||||
|
@ -57,7 +57,7 @@ public class WinBoLLActivityManager {
|
|||||||
* 把Activity添加到管理中
|
* 把Activity添加到管理中
|
||||||
*/
|
*/
|
||||||
public <T extends IWinBoLLActivity> void add(T activity) {
|
public <T extends IWinBoLLActivity> void add(T activity) {
|
||||||
if (isActive(activity.getTag())) {
|
if (isActivityActive(activity.getTag())) {
|
||||||
LogUtils.d(TAG, String.format("add(...) %s is active.", activity.getTag()));
|
LogUtils.d(TAG, String.format("add(...) %s is active.", activity.getTag()));
|
||||||
} else {
|
} else {
|
||||||
mActivityListMap.put(activity.getTag(), activity);
|
mActivityListMap.put(activity.getTag(), activity);
|
||||||
@ -71,21 +71,21 @@ public class WinBoLLActivityManager {
|
|||||||
// activity: 不为 null 时,
|
// activity: 不为 null 时,
|
||||||
// intent.putExtra 函数 "tag" 参数为 activity.getTag()
|
// intent.putExtra 函数 "tag" 参数为 activity.getTag()
|
||||||
//
|
//
|
||||||
public <T extends IWinBoLLActivity> void startWinBoLLActivity(Class<T> clazz) {
|
public <T extends IWinBoLLActivity> void startWinBoLLActivity(Context context, Class<T> clazz) {
|
||||||
// 如果窗口已存在就重启窗口
|
// 如果窗口已存在就重启窗口
|
||||||
if (!resumeActivity(clazz)) {
|
if (!resumeActivity(clazz)) {
|
||||||
// 新建一个任务窗口
|
// 新建一个任务窗口
|
||||||
Intent intent = new Intent(mContext, clazz);
|
Intent intent = new Intent(context, clazz);
|
||||||
//打开多任务窗口 flags
|
//打开多任务窗口 flags
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||||
//intent.putExtra("tag", tag);
|
//intent.putExtra("tag", tag);
|
||||||
mContext.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends IWinBoLLActivity> void startWinBoLLActivity(Intent intent, Class<T> clazz) {
|
public <T extends IWinBoLLActivity> void startWinBoLLActivity(Context context, Intent intent, Class<T> clazz) {
|
||||||
// 如果窗口已存在就重启窗口
|
// 如果窗口已存在就重启窗口
|
||||||
if (!resumeActivity(clazz)) {
|
if (!resumeActivity(clazz)) {
|
||||||
// 新建一个任务窗口
|
// 新建一个任务窗口
|
||||||
@ -95,60 +95,52 @@ public class WinBoLLActivityManager {
|
|||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||||
//intent.putExtra("tag", tag);
|
//intent.putExtra("tag", tag);
|
||||||
mContext.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends IWinBoLLActivity> void startLogActivity() {
|
public <T extends IWinBoLLActivity> void startLogActivity(Context context) {
|
||||||
// 如果窗口已存在就重启窗口
|
// 如果窗口已存在就重启窗口
|
||||||
if (!resumeActivity(LogActivity.class)) {
|
//if (!resumeActivity(LogActivity.class)) {
|
||||||
// 新建一个任务窗口
|
// 新建一个任务窗口
|
||||||
Intent intent = new Intent(mContext, LogActivity.class);
|
Intent intent = new Intent(context, LogActivity.class);
|
||||||
//打开多任务窗口 flags
|
//打开多任务窗口 flags
|
||||||
// Define the bounds.
|
// Define the bounds.
|
||||||
// Rect bounds = new Rect(0, 0, 800, 200);
|
// Rect bounds = new Rect(0, 0, 800, 200);
|
||||||
// // Set the bounds as an activity option.
|
// // Set the bounds as an activity option.
|
||||||
// ActivityOptions options = ActivityOptions.makeBasic();
|
// ActivityOptions options = ActivityOptions.makeBasic();
|
||||||
// options.setLaunchBounds(bounds);
|
// options.setLaunchBounds(bounds);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
|
intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||||
|
|
||||||
//intent.putExtra(EXTRA_TAG, tag);
|
//intent.putExtra(EXTRA_TAG, tag);
|
||||||
|
|
||||||
//context.startActivity(intent, options.toBundle());
|
//context.startActivity(intent, options.toBundle());
|
||||||
mContext.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// 判断 tag 绑定的 Activity 是否已经创建
|
// 判断 tag 绑定的 Activity 是否已经创建
|
||||||
//
|
//
|
||||||
public boolean isActive(String tag) {
|
public boolean isActivityActive(String tag) {
|
||||||
Activity activity = getActivityByTag(tag);
|
return mActivityListMap.get(tag) != null;
|
||||||
if (activity != null) {
|
|
||||||
//判断是否正在关闭
|
|
||||||
if (activity.isFinishing() || activity.isDestroyed()) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Activity getActivityByTag(String tag) {
|
Activity getActivityByTag(String tag) {
|
||||||
return (mActivityListMap.get(tag) == null) ?null: mActivityListMap.get(tag).getActivity();
|
return (mActivityListMap.get(tag) == null) ?null: mActivityListMap.get(tag).getActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
|
// 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
|
||||||
//
|
//
|
||||||
public <T extends IWinBoLLActivity> boolean resumeActivity(Class<T> clazz) {
|
public <T extends IWinBoLLActivity> boolean resumeActivity(Class<T> clazz) {
|
||||||
try {
|
try {
|
||||||
Activity activity = getActivityByTag(clazz.newInstance().getTag());
|
Activity activity = getActivityByTag(clazz.newInstance().getTag());
|
||||||
if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) {
|
if (activity != null) {
|
||||||
return resumeActivity(activity);
|
return resumeActivity(activity);
|
||||||
}
|
}
|
||||||
} catch (InstantiationException | IllegalAccessException e) {
|
} catch (InstantiationException | IllegalAccessException e) {
|
||||||
@ -157,18 +149,29 @@ public class WinBoLLActivityManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
|
||||||
|
//
|
||||||
|
public <T extends IWinBoLLActivity> boolean resumeActivity(String tag) {
|
||||||
|
Activity activity = getActivityByTag(tag);
|
||||||
|
if (activity != null) {
|
||||||
|
return resumeActivity(activity);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
|
// 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
|
||||||
//
|
//
|
||||||
public <T extends IWinBoLLActivity> boolean resumeActivity(Activity activity) {
|
public <T extends IWinBoLLActivity> boolean resumeActivity(Activity activity) {
|
||||||
ActivityManager am = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE);
|
ActivityManager am = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
//返回启动它的根任务(home 或者 MainActivity)
|
//返回启动它的根任务(home 或者 MainActivity)
|
||||||
Intent intent = new Intent(mContext, activity.getClass());
|
//Intent intent = new Intent(mContext, activity.getClass());
|
||||||
TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);
|
//TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);
|
||||||
stackBuilder.addNextIntentWithParentStack(intent);
|
//stackBuilder.addNextIntentWithParentStack(intent);
|
||||||
stackBuilder.startActivities();
|
//stackBuilder.startActivities();
|
||||||
am.moveTaskToFront(activity.getTaskId(), ActivityManager.MOVE_TASK_NO_USER_ACTION);
|
am.moveTaskToFront(activity.getTaskId(), ActivityManager.MOVE_TASK_NO_USER_ACTION);
|
||||||
ToastUtils.show("resumeActivity");
|
//ToastUtils.show("resumeActivity");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user