WinBollActivityManager测试..
This commit is contained in:
		@@ -1,8 +1,8 @@
 | 
				
			|||||||
#Created by .winboll/winboll_app_build.gradle
 | 
					#Created by .winboll/winboll_app_build.gradle
 | 
				
			||||||
#Tue Mar 25 03:25:01 HKT 2025
 | 
					#Mon Mar 24 21:28:41 GMT 2025
 | 
				
			||||||
stageCount=11
 | 
					stageCount=11
 | 
				
			||||||
libraryProject=libappbase
 | 
					libraryProject=libappbase
 | 
				
			||||||
baseVersion=15.0
 | 
					baseVersion=15.0
 | 
				
			||||||
publishVersion=15.0.10
 | 
					publishVersion=15.0.10
 | 
				
			||||||
buildCount=0
 | 
					buildCount=12
 | 
				
			||||||
baseBetaVersion=15.0.11
 | 
					baseBetaVersion=15.0.11
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,6 +13,7 @@
 | 
				
			|||||||
        <activity
 | 
					        <activity
 | 
				
			||||||
            android:name=".MainActivity"
 | 
					            android:name=".MainActivity"
 | 
				
			||||||
            android:label="@string/app_name"
 | 
					            android:label="@string/app_name"
 | 
				
			||||||
 | 
					            android:launchMode="singleInstance"
 | 
				
			||||||
            android:exported="true">
 | 
					            android:exported="true">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <intent-filter>
 | 
					            <intent-filter>
 | 
				
			||||||
@@ -49,10 +50,12 @@
 | 
				
			|||||||
            android:name=".services.MainService"
 | 
					            android:name=".services.MainService"
 | 
				
			||||||
            android:exported="true"/>
 | 
					            android:exported="true"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <service android:name="cc.winboll.studio.appbase.services.TestDemoBindService"
 | 
					        <service
 | 
				
			||||||
 | 
					            android:name="cc.winboll.studio.appbase.services.TestDemoBindService"
 | 
				
			||||||
            android:exported="true"/>
 | 
					            android:exported="true"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <service android:name="cc.winboll.studio.appbase.services.TestDemoService"
 | 
					        <service
 | 
				
			||||||
 | 
					            android:name="cc.winboll.studio.appbase.services.TestDemoService"
 | 
				
			||||||
            android:exported="true"/>
 | 
					            android:exported="true"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <service android:name=".services.AssistantService"/>
 | 
					        <service android:name=".services.AssistantService"/>
 | 
				
			||||||
@@ -103,6 +106,11 @@
 | 
				
			|||||||
            android:name="android.max_aspect"
 | 
					            android:name="android.max_aspect"
 | 
				
			||||||
            android:value="4.0"/>
 | 
					            android:value="4.0"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <activity android:name=".activities.NewActivity"
 | 
				
			||||||
 | 
					            android:label="NewActivity"
 | 
				
			||||||
 | 
					            android:launchMode="singleInstance"
 | 
				
			||||||
 | 
					            android:exported="true"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    </application>
 | 
					    </application>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</manifest>
 | 
					</manifest>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,7 @@ import android.view.View;
 | 
				
			|||||||
import android.widget.CheckBox;
 | 
					import android.widget.CheckBox;
 | 
				
			||||||
import android.widget.Toolbar;
 | 
					import android.widget.Toolbar;
 | 
				
			||||||
import cc.winboll.studio.appbase.R;
 | 
					import cc.winboll.studio.appbase.R;
 | 
				
			||||||
 | 
					import cc.winboll.studio.appbase.activities.NewActivity;
 | 
				
			||||||
import cc.winboll.studio.appbase.services.MainService;
 | 
					import cc.winboll.studio.appbase.services.MainService;
 | 
				
			||||||
import cc.winboll.studio.appbase.services.TestDemoBindService;
 | 
					import cc.winboll.studio.appbase.services.TestDemoBindService;
 | 
				
			||||||
import cc.winboll.studio.appbase.services.TestDemoService;
 | 
					import cc.winboll.studio.appbase.services.TestDemoService;
 | 
				
			||||||
@@ -17,12 +18,24 @@ import cc.winboll.studio.libappbase.LogView;
 | 
				
			|||||||
import cc.winboll.studio.libappbase.sos.SOS;
 | 
					import cc.winboll.studio.libappbase.sos.SOS;
 | 
				
			||||||
import cc.winboll.studio.libappbase.utils.ToastUtils;
 | 
					import cc.winboll.studio.libappbase.utils.ToastUtils;
 | 
				
			||||||
import cc.winboll.studio.libappbase.widgets.StatusWidget;
 | 
					import cc.winboll.studio.libappbase.widgets.StatusWidget;
 | 
				
			||||||
import cc.winboll.studio.libappbase.APPBaseModel;
 | 
					import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
 | 
				
			||||||
 | 
					import cc.winboll.studio.libappbase.winboll.WinBollActivityManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class MainActivity extends Activity {
 | 
					public class MainActivity extends Activity implements IWinBollActivity {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static final String TAG = "MainActivity";
 | 
					    public static final String TAG = "MainActivity";
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public Activity getActivity() {
 | 
				
			||||||
 | 
					        return this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getTag() {
 | 
				
			||||||
 | 
					        return TAG;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Toolbar mToolbar;
 | 
				
			||||||
    LogView mLogView;
 | 
					    LogView mLogView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -31,8 +44,8 @@ public class MainActivity extends Activity {
 | 
				
			|||||||
        ToastUtils.show("onCreate");
 | 
					        ToastUtils.show("onCreate");
 | 
				
			||||||
        setContentView(R.layout.activity_main);
 | 
					        setContentView(R.layout.activity_main);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Toolbar toolbar = findViewById(R.id.activitymainToolbar1);
 | 
					        mToolbar = findViewById(R.id.toolbar);
 | 
				
			||||||
        setActionBar(toolbar);
 | 
					        setActionBar(mToolbar);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        CheckBox cbIsDebugMode = findViewById(R.id.activitymainCheckBox1);
 | 
					        CheckBox cbIsDebugMode = findViewById(R.id.activitymainCheckBox1);
 | 
				
			||||||
        cbIsDebugMode.setChecked(GlobalApplication.isDebuging());
 | 
					        cbIsDebugMode.setChecked(GlobalApplication.isDebuging());
 | 
				
			||||||
@@ -142,4 +155,8 @@ public class MainActivity extends Activity {
 | 
				
			|||||||
        Intent intent = new Intent(this, TestDemoBindService.class);
 | 
					        Intent intent = new Intent(this, TestDemoBindService.class);
 | 
				
			||||||
        stopService(intent);
 | 
					        stopService(intent);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void onTestOpenNewActivity(View view) {
 | 
				
			||||||
 | 
					        WinBollActivityManager.getInstance(this).startWinBollActivity(this, NewActivity.class);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.appbase.activities;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.app.Activity;
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import cc.winboll.studio.appbase.R;
 | 
				
			||||||
 | 
					import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
 | 
				
			||||||
 | 
					import cc.winboll.studio.libappbase.winboll.WinBollActivityManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @Author ZhanGSKen@AliYun.Com
 | 
				
			||||||
 | 
					 * @Date 2025/03/25 05:04:22
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class NewActivity extends Activity implements IWinBollActivity {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static final String TAG = "NewActivity";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public Activity getActivity() {
 | 
				
			||||||
 | 
					        return this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getTag() {
 | 
				
			||||||
 | 
					        return TAG;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					        setContentView(R.layout.activity_new);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void onCloseThisActivity(View view) {
 | 
				
			||||||
 | 
					        WinBollActivityManager.getInstance(this).finish(this);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void onCloseAllActivity(View view) {
 | 
				
			||||||
 | 
					        WinBollActivityManager.getInstance(this).finishAll();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -8,7 +8,7 @@
 | 
				
			|||||||
	<android.widget.Toolbar
 | 
						<android.widget.Toolbar
 | 
				
			||||||
		android:layout_width="match_parent"
 | 
							android:layout_width="match_parent"
 | 
				
			||||||
		android:layout_height="wrap_content"
 | 
							android:layout_height="wrap_content"
 | 
				
			||||||
		android:id="@+id/activitymainToolbar1"/>
 | 
							android:id="@+id/toolbar"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	<ScrollView
 | 
						<ScrollView
 | 
				
			||||||
		android:layout_width="match_parent"
 | 
							android:layout_width="match_parent"
 | 
				
			||||||
@@ -181,7 +181,14 @@
 | 
				
			|||||||
							android:text="TestDemoServiceSOS"
 | 
												android:text="TestDemoServiceSOS"
 | 
				
			||||||
							android:textAllCaps="false"
 | 
												android:textAllCaps="false"
 | 
				
			||||||
							android:onClick="onTestDemoServiceSOS"/>
 | 
												android:onClick="onTestDemoServiceSOS"/>
 | 
				
			||||||
 | 
					                        
 | 
				
			||||||
 | 
					                        <Button
 | 
				
			||||||
 | 
					                            android:layout_width="wrap_content"
 | 
				
			||||||
 | 
					                            android:layout_height="wrap_content"
 | 
				
			||||||
 | 
					                            android:text="TestOpenNewActivity"
 | 
				
			||||||
 | 
					                            android:textAllCaps="false"
 | 
				
			||||||
 | 
					                            android:onClick="onTestOpenNewActivity"/>
 | 
				
			||||||
 | 
					                        
 | 
				
			||||||
					</LinearLayout>
 | 
										</LinearLayout>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				</ScrollView>
 | 
									</ScrollView>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										34
									
								
								appbase/src/main/res/layout/activity_new.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								appbase/src/main/res/layout/activity_new.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
 | 
					<LinearLayout
 | 
				
			||||||
 | 
						xmlns:android="http://schemas.android.com/apk/res/android"
 | 
				
			||||||
 | 
						xmlns:app="http://schemas.android.com/apk/res-auto"
 | 
				
			||||||
 | 
						android:orientation="vertical"
 | 
				
			||||||
 | 
						android:layout_width="match_parent"
 | 
				
			||||||
 | 
						android:layout_height="match_parent">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<android.widget.Toolbar
 | 
				
			||||||
 | 
							android:layout_width="match_parent"
 | 
				
			||||||
 | 
							android:layout_height="wrap_content"
 | 
				
			||||||
 | 
							android:id="@+id/toolbar"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<TextView
 | 
				
			||||||
 | 
							android:layout_width="wrap_content"
 | 
				
			||||||
 | 
							android:layout_height="wrap_content"
 | 
				
			||||||
 | 
							android:text="NewActivity"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <Button
 | 
				
			||||||
 | 
					        android:layout_width="wrap_content"
 | 
				
			||||||
 | 
					        android:layout_height="wrap_content"
 | 
				
			||||||
 | 
					        android:text="CloseThisActivity"
 | 
				
			||||||
 | 
					        android:textAllCaps="false"
 | 
				
			||||||
 | 
					        android:onClick="onCloseThisActivity"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <Button
 | 
				
			||||||
 | 
					        android:layout_width="wrap_content"
 | 
				
			||||||
 | 
					        android:layout_height="wrap_content"
 | 
				
			||||||
 | 
					        android:text="CloseAllActivity"
 | 
				
			||||||
 | 
					        android:textAllCaps="false"
 | 
				
			||||||
 | 
					        android:onClick="onCloseAllActivity"/>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					</LinearLayout>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1,8 +1,8 @@
 | 
				
			|||||||
#Created by .winboll/winboll_app_build.gradle
 | 
					#Created by .winboll/winboll_app_build.gradle
 | 
				
			||||||
#Tue Mar 25 03:24:44 HKT 2025
 | 
					#Mon Mar 24 21:28:41 GMT 2025
 | 
				
			||||||
stageCount=11
 | 
					stageCount=11
 | 
				
			||||||
libraryProject=libappbase
 | 
					libraryProject=libappbase
 | 
				
			||||||
baseVersion=15.0
 | 
					baseVersion=15.0
 | 
				
			||||||
publishVersion=15.0.10
 | 
					publishVersion=15.0.10
 | 
				
			||||||
buildCount=0
 | 
					buildCount=12
 | 
				
			||||||
baseBetaVersion=15.0.11
 | 
					baseBetaVersion=15.0.11
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,6 +12,8 @@ import android.content.pm.PackageManager;
 | 
				
			|||||||
import android.os.Handler;
 | 
					import android.os.Handler;
 | 
				
			||||||
import android.os.Looper;
 | 
					import android.os.Looper;
 | 
				
			||||||
import cc.winboll.studio.libappbase.utils.ToastUtils;
 | 
					import cc.winboll.studio.libappbase.utils.ToastUtils;
 | 
				
			||||||
 | 
					import cc.winboll.studio.libappbase.winboll.WinBollActivityManager;
 | 
				
			||||||
 | 
					import cc.winboll.studio.libappbase.winboll.MyActivityLifecycleCallbacks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class GlobalApplication extends Application {
 | 
					public class GlobalApplication extends Application {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -25,6 +27,8 @@ public class GlobalApplication extends Application {
 | 
				
			|||||||
    volatile static GlobalApplication _GlobalApplication;
 | 
					    volatile static GlobalApplication _GlobalApplication;
 | 
				
			||||||
    // 是否处于调试状态
 | 
					    // 是否处于调试状态
 | 
				
			||||||
    volatile static boolean isDebuging = false;
 | 
					    volatile static boolean isDebuging = false;
 | 
				
			||||||
 | 
					    WinBollActivityManager mWinBollActivityManager;
 | 
				
			||||||
 | 
					    MyActivityLifecycleCallbacks mMyActivityLifecycleCallbacks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static void setIsDebuging(boolean isDebuging) {
 | 
					    public static void setIsDebuging(boolean isDebuging) {
 | 
				
			||||||
        if (_GlobalApplication != null) {
 | 
					        if (_GlobalApplication != null) {
 | 
				
			||||||
@@ -82,6 +86,20 @@ public class GlobalApplication extends Application {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // 初始化 Toast 框架
 | 
					        // 初始化 Toast 框架
 | 
				
			||||||
        ToastUtils.init(this);
 | 
					        ToastUtils.init(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        mWinBollActivityManager = WinBollActivityManager.getInstance(this);
 | 
				
			||||||
 | 
					        mWinBollActivityManager.setWinBollUI_TYPE(WinBollActivityManager.WinBollUI_TYPE.Service);
 | 
				
			||||||
 | 
					        // 注册回调
 | 
				
			||||||
 | 
					        mMyActivityLifecycleCallbacks = new MyActivityLifecycleCallbacks(mWinBollActivityManager);
 | 
				
			||||||
 | 
					        registerActivityLifecycleCallbacks(mMyActivityLifecycleCallbacks);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onTerminate() {
 | 
				
			||||||
 | 
					        super.onTerminate();
 | 
				
			||||||
 | 
					        // 注销回调(非必须,但建议释放资源)
 | 
				
			||||||
 | 
					        unregisterActivityLifecycleCallbacks(mMyActivityLifecycleCallbacks);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static String getAppName(Context context) {
 | 
					    public static String getAppName(Context context) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.libappbase.winboll;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @Author ZhanGSKen@AliYun.Com
 | 
				
			||||||
 | 
					 * @Date 2025/03/24 08:23:40
 | 
				
			||||||
 | 
					 * @Describe WinBoll 活动窗口通用接口
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					import android.app.Activity;
 | 
				
			||||||
 | 
					import android.widget.Toolbar;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public interface IWinBollActivity {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static final String TAG = "IWinBollActivity";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 获取活动窗口
 | 
				
			||||||
 | 
					    abstract public Activity getActivity();
 | 
				
			||||||
 | 
					    abstract public String getTag();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,103 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.libappbase.winboll;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @Author ZhanGSKen@AliYun.Com
 | 
				
			||||||
 | 
					 * @Date 2025/03/25 04:29:19
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					import android.app.Activity;
 | 
				
			||||||
 | 
					import android.app.Application;
 | 
				
			||||||
 | 
					import android.content.Context;
 | 
				
			||||||
 | 
					import android.content.Intent;
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import cc.winboll.studio.libappbase.LogUtils;
 | 
				
			||||||
 | 
					import cc.winboll.studio.libappbase.utils.ToastUtils; 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class MyActivityLifecycleCallbacks implements Application.ActivityLifecycleCallbacks { 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static final String TAG = "MyActivityLifecycleCallbacks";
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    WinBollActivityManager mWinBollActivityManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String mInfo = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public MyActivityLifecycleCallbacks(WinBollActivityManager winBollActivityManager) {
 | 
				
			||||||
 | 
					        mWinBollActivityManager = winBollActivityManager;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void createActivityeInfo(Activity activity) {
 | 
				
			||||||
 | 
					        StringBuilder sb = new StringBuilder();
 | 
				
			||||||
 | 
					        Intent receivedIntent = activity.getIntent();
 | 
				
			||||||
 | 
					        sb.append("\nCallingActivity : \n");
 | 
				
			||||||
 | 
					        if (activity.getCallingActivity() != null) {
 | 
				
			||||||
 | 
					            sb.append(activity.getCallingActivity().getPackageName());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        sb.append("\nReceived Intent Package : \n");
 | 
				
			||||||
 | 
					        sb.append(receivedIntent.getPackage());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Bundle extras = receivedIntent.getExtras();
 | 
				
			||||||
 | 
					        if (extras != null) {
 | 
				
			||||||
 | 
					            for (String key : extras.keySet()) {
 | 
				
			||||||
 | 
					                sb.append("\nIntentInfo");
 | 
				
			||||||
 | 
					                sb.append("\n键: ");
 | 
				
			||||||
 | 
					                sb.append(key);
 | 
				
			||||||
 | 
					                sb.append(", 值: ");
 | 
				
			||||||
 | 
					                sb.append(extras.get(key));
 | 
				
			||||||
 | 
					                //Log.d("IntentInfo", "键: " + key + ", 值: " + extras.get(key));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        mInfo = sb.toString();
 | 
				
			||||||
 | 
					        //Log.d("IntentInfo", "发送Intent的应用包名: " + senderPackage);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void showActivityeInfo() {
 | 
				
			||||||
 | 
					        ToastUtils.show("ActivityeInfo : " + mInfo);
 | 
				
			||||||
 | 
					        LogUtils.d(TAG, "ActivityeInfo : " + mInfo);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override 
 | 
				
			||||||
 | 
					    public void onActivityCreated(Activity activity, Bundle savedInstanceState) { 
 | 
				
			||||||
 | 
					        // 在这里可以做一些初始化相关的操作,例如记录Activity的创建时间等 
 | 
				
			||||||
 | 
					        //System.out.println(activity.getLocalClassName() + " was created"); 
 | 
				
			||||||
 | 
					        LogUtils.d(TAG, activity.getLocalClassName() + " was created");
 | 
				
			||||||
 | 
					        createActivityeInfo(activity);
 | 
				
			||||||
 | 
					        mWinBollActivityManager.add((IWinBollActivity)activity);
 | 
				
			||||||
 | 
					    } 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override 
 | 
				
			||||||
 | 
					    public void onActivityStarted(Activity activity) { 
 | 
				
			||||||
 | 
					        //System.out.println(activity.getLocalClassName() + " was started");
 | 
				
			||||||
 | 
					        LogUtils.d(TAG, activity.getLocalClassName() + " was started");
 | 
				
			||||||
 | 
					        //createActivityeInfo(activity);
 | 
				
			||||||
 | 
					    } 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override 
 | 
				
			||||||
 | 
					    public void onActivityResumed(Activity activity) { 
 | 
				
			||||||
 | 
					        //System.out.println(activity.getLocalClassName() + " was resumed");
 | 
				
			||||||
 | 
					        LogUtils.d(TAG, activity.getLocalClassName() + " was resumed");
 | 
				
			||||||
 | 
					        //createActivityeInfo(activity);
 | 
				
			||||||
 | 
					    } 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override 
 | 
				
			||||||
 | 
					    public void onActivityPaused(Activity activity) { 
 | 
				
			||||||
 | 
					        //System.out.println(activity.getLocalClassName() + " was paused");
 | 
				
			||||||
 | 
					        LogUtils.d(TAG, activity.getLocalClassName() + " was paused");
 | 
				
			||||||
 | 
					    } 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override 
 | 
				
			||||||
 | 
					    public void onActivityStopped(Activity activity) { 
 | 
				
			||||||
 | 
					        //System.out.println(activity.getLocalClassName() + " was stopped");
 | 
				
			||||||
 | 
					        LogUtils.d(TAG, activity.getLocalClassName() + " was stopped");
 | 
				
			||||||
 | 
					    } 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override 
 | 
				
			||||||
 | 
					    public void onActivitySaveInstanceState(Activity activity, Bundle outState) { 
 | 
				
			||||||
 | 
					        // 可以在这里添加保存状态的自定义逻辑 
 | 
				
			||||||
 | 
					    } 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override 
 | 
				
			||||||
 | 
					    public void onActivityDestroyed(Activity activity) { 
 | 
				
			||||||
 | 
					        //System.out.println(activity.getLocalClassName() + " was destroyed");
 | 
				
			||||||
 | 
					        LogUtils.d(TAG, activity.getLocalClassName() + " was destroyed");
 | 
				
			||||||
 | 
					        mWinBollActivityManager.registeRemove((IWinBollActivity)activity);
 | 
				
			||||||
 | 
					    } 
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,318 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.libappbase.winboll;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @Author ZhanGSKen@AliYun.Com
 | 
				
			||||||
 | 
					 * @Date 2025/03/24 08:25:43
 | 
				
			||||||
 | 
					 * @Describe 应用活动窗口管理器
 | 
				
			||||||
 | 
					 * 参考 :
 | 
				
			||||||
 | 
					 * android 类似微信小程序多任务窗口 及 设置 TaskDescription 修改 icon 和 label
 | 
				
			||||||
 | 
					 * https://blog.csdn.net/qq_29364417/article/details/109379915?app_version=6.4.2&code=app_1562916241&csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22109379915%22%2C%22source%22%3A%22weixin_38986226%22%7D&uLinkId=usr1mkqgl919blen&utm_source=app
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					import android.app.ActivityManager;
 | 
				
			||||||
 | 
					import android.app.TaskStackBuilder;
 | 
				
			||||||
 | 
					import android.content.Context;
 | 
				
			||||||
 | 
					import android.content.Intent;
 | 
				
			||||||
 | 
					import cc.winboll.studio.libappbase.LogUtils;
 | 
				
			||||||
 | 
					import java.util.HashMap;
 | 
				
			||||||
 | 
					import java.util.Iterator;
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class WinBollActivityManager {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static final String TAG = "WinBollActivityManager";
 | 
				
			||||||
 | 
					    public static final String EXTRA_TAG = "EXTRA_TAG";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static enum WinBollUI_TYPE {
 | 
				
			||||||
 | 
					        Aplication, // 退出应用后,保持最近任务栏任务记录主窗口
 | 
				
			||||||
 | 
					        Service // 退出应用后,清理所有最近任务栏任务记录窗口
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 应用类型标志
 | 
				
			||||||
 | 
					    volatile static WinBollUI_TYPE _mWinBollUI_TYPE = WinBollUI_TYPE.Service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Context mContext;
 | 
				
			||||||
 | 
					    MyActivityLifecycleCallbacks mMyActivityLifecycleCallbacks;
 | 
				
			||||||
 | 
					    static WinBollActivityManager _mWinBollActivityManager;
 | 
				
			||||||
 | 
					    static Map<String, IWinBollActivity> _mapIWinBollList;
 | 
				
			||||||
 | 
					    IWinBollActivity firstIWinBollActivity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public WinBollActivityManager(Context context) {
 | 
				
			||||||
 | 
					        mContext = context;
 | 
				
			||||||
 | 
					        LogUtils.d(TAG, "WinBollActivityManager()");
 | 
				
			||||||
 | 
					        _mapIWinBollList = new HashMap<String, IWinBollActivity>();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static synchronized WinBollActivityManager getInstance(Context context) {
 | 
				
			||||||
 | 
					        LogUtils.d(TAG, "getInstance");
 | 
				
			||||||
 | 
					        if (_mWinBollActivityManager == null) {
 | 
				
			||||||
 | 
					            LogUtils.d(TAG, "_mWinBollActivityManager == null");
 | 
				
			||||||
 | 
					            _mWinBollActivityManager = new WinBollActivityManager(context);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return _mWinBollActivityManager;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    // 设置 WinBoll 应用 UI 类型
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    public synchronized static void setWinBollUI_TYPE(WinBollUI_TYPE mWinBollUI_TYPE) {
 | 
				
			||||||
 | 
					        _mWinBollUI_TYPE = mWinBollUI_TYPE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    // 获取 WinBoll 应用 UI 类型
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    public synchronized static WinBollUI_TYPE getWinBollUI_TYPE() {
 | 
				
			||||||
 | 
					        return _mWinBollUI_TYPE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    // 把Activity添加到管理中
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    public <T extends IWinBollActivity> void add(T iWinBoll) {
 | 
				
			||||||
 | 
					        if (isActive(iWinBoll.getTag())) {
 | 
				
			||||||
 | 
					            LogUtils.d(TAG, String.format("add(...) %s is active.", iWinBoll.getTag()));
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            // 设置起始活动窗口,以便最后退出时提问
 | 
				
			||||||
 | 
					            if (firstIWinBollActivity == null && _mapIWinBollList.size() == 0) {
 | 
				
			||||||
 | 
					                firstIWinBollActivity = iWinBoll;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 添加到活动窗口列表
 | 
				
			||||||
 | 
					            _mapIWinBollList.put(iWinBoll.getTag(), iWinBoll);
 | 
				
			||||||
 | 
					            LogUtils.d(TAG, String.format("Add activity : %s\n_mapActivityList.size() : %d", iWinBoll.getTag(), _mapIWinBollList.size()));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    // activity: 为 null 时,
 | 
				
			||||||
 | 
					    // intent.putExtra 函数 EXTRA_TAG 参数为 tag
 | 
				
			||||||
 | 
					    // activity: 不为 null 时,
 | 
				
			||||||
 | 
					    // intent.putExtra 函数 "tag" 参数为 activity.getTag()
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    public <T extends IWinBollActivity> void startWinBollActivity(Context context, Class<T> clazz) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            // 如果窗口已存在就重启窗口
 | 
				
			||||||
 | 
					            String tag = clazz.newInstance().getTag();
 | 
				
			||||||
 | 
					            if (isActive(tag)) {
 | 
				
			||||||
 | 
					                resumeActivity(context, tag);
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 新建一个任务窗口
 | 
				
			||||||
 | 
					            Intent intent = new Intent(context, clazz);
 | 
				
			||||||
 | 
					            //打开多任务窗口 flags
 | 
				
			||||||
 | 
					            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
 | 
				
			||||||
 | 
					            intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
 | 
				
			||||||
 | 
					            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 | 
				
			||||||
 | 
					            intent.putExtra(EXTRA_TAG, tag);
 | 
				
			||||||
 | 
					            mContext.startActivity(intent);
 | 
				
			||||||
 | 
					        } catch (InstantiationException | IllegalAccessException e) {
 | 
				
			||||||
 | 
					            LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public <T extends IWinBollActivity> void startWinBollActivity(Context context, Intent intent, Class<T> clazz) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            // 如果窗口已存在就重启窗口
 | 
				
			||||||
 | 
					            String tag = clazz.newInstance().getTag();
 | 
				
			||||||
 | 
					            if (isActive(tag)) {
 | 
				
			||||||
 | 
					                resumeActivity(context, tag);
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 新建一个任务窗口
 | 
				
			||||||
 | 
					            //Intent intent = new Intent(context, clazz);
 | 
				
			||||||
 | 
					            //打开多任务窗口 flags
 | 
				
			||||||
 | 
					            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
 | 
				
			||||||
 | 
					            intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
 | 
				
			||||||
 | 
					            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 | 
				
			||||||
 | 
					            intent.putExtra(EXTRA_TAG, tag);
 | 
				
			||||||
 | 
					            mContext.startActivity(intent);
 | 
				
			||||||
 | 
					        } catch (InstantiationException | IllegalAccessException e) {
 | 
				
			||||||
 | 
					            LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean isFirstIWinBollActivity(IWinBollActivity iWinBollActivity) {
 | 
				
			||||||
 | 
					        return firstIWinBollActivity != null && firstIWinBollActivity == iWinBollActivity;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    // 判断 tag绑定的 MyActivity是否存在
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    public boolean isActive(String tag) {
 | 
				
			||||||
 | 
					        //printAvtivityListInfo();
 | 
				
			||||||
 | 
					        IWinBollActivity iWinBoll = getIWinBoll(tag);
 | 
				
			||||||
 | 
					        if (iWinBoll != null) {
 | 
				
			||||||
 | 
					            LogUtils.d(TAG, "isActive(...) activity != null tag " + tag);
 | 
				
			||||||
 | 
					            //ToastUtils.show("activity != null tag " + tag);
 | 
				
			||||||
 | 
					            //判断是否为 BaseActivity,如果已经销毁,则移除
 | 
				
			||||||
 | 
					            if (iWinBoll.getActivity().isFinishing() || iWinBoll.getActivity().isDestroyed()) {
 | 
				
			||||||
 | 
					                _mapIWinBollList.remove(iWinBoll.getTag());
 | 
				
			||||||
 | 
					                //_mWinBollActivityList.remove(activity);
 | 
				
			||||||
 | 
					                LogUtils.d(TAG, String.format("isActive(...) remove activity.\ntag : %s", tag));
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                LogUtils.d(TAG, String.format("isActive(...) activity is exist.\ntag : %s", tag));
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            LogUtils.d(TAG, String.format("isActive(...) activity == null\ntag : %s", tag));
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    static IWinBollActivity getIWinBoll(String tag) {
 | 
				
			||||||
 | 
					        return _mapIWinBollList.get(tag);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    // 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    public <T extends IWinBollActivity> void resumeActivity(Context context, String tag) {
 | 
				
			||||||
 | 
					        LogUtils.d(TAG, "resumeActivty");
 | 
				
			||||||
 | 
					        T iWinBoll = (T)getIWinBoll(tag);
 | 
				
			||||||
 | 
					        //LogUtils.d(TAG, "activity " + activity.getTag());
 | 
				
			||||||
 | 
					        if (iWinBoll != null && !iWinBoll.getActivity().isFinishing() && !iWinBoll.getActivity().isDestroyed()) {
 | 
				
			||||||
 | 
					            resumeActivity(context, iWinBoll);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    // 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    public <T extends IWinBollActivity> void resumeActivity(Context context, T iWinBoll) {
 | 
				
			||||||
 | 
					        ActivityManager am = (ActivityManager) iWinBoll.getActivity().getSystemService(Context.ACTIVITY_SERVICE);
 | 
				
			||||||
 | 
					        //返回启动它的根任务(home 或者 MainActivity)
 | 
				
			||||||
 | 
					        Intent intent = new Intent(context, iWinBoll.getClass());
 | 
				
			||||||
 | 
					        TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
 | 
				
			||||||
 | 
					        stackBuilder.addNextIntentWithParentStack(intent);
 | 
				
			||||||
 | 
					        stackBuilder.startActivities();
 | 
				
			||||||
 | 
					        //moveTaskToFront(YourTaskId, 0);
 | 
				
			||||||
 | 
					        LogUtils.d(TAG, "am.moveTaskToFront");
 | 
				
			||||||
 | 
					        //ToastUtils.show("resumeActivity am.moveTaskToFront");
 | 
				
			||||||
 | 
					        am.moveTaskToFront(iWinBoll.getActivity().getTaskId(), ActivityManager.MOVE_TASK_NO_USER_ACTION);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    // 结束所有 Activity
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    public void finishAll() {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            for (String key : _mapIWinBollList.keySet()) {
 | 
				
			||||||
 | 
					                //System.out.println("Key: " + key + ", Value: " + _mapActivityList.get(key));
 | 
				
			||||||
 | 
					                IWinBollActivity iWinBoll = _mapIWinBollList.get(key);
 | 
				
			||||||
 | 
					                //ToastUtils.show("finishAll() activity");
 | 
				
			||||||
 | 
					                if (iWinBoll != null && !iWinBoll.getActivity().isFinishing() && !iWinBoll.getActivity().isDestroyed()) {
 | 
				
			||||||
 | 
					                    //ToastUtils.show("activity != null ...");
 | 
				
			||||||
 | 
					                    if (getWinBollUI_TYPE() == WinBollUI_TYPE.Service) {
 | 
				
			||||||
 | 
					                        // 结束窗口和最近任务栏, 建议前台服务类应用使用,可以方便用户再次调用 UI 操作。
 | 
				
			||||||
 | 
					                        iWinBoll.getActivity().finishAndRemoveTask();
 | 
				
			||||||
 | 
					                        //ToastUtils.show("finishAll() activity.finishAndRemoveTask();");
 | 
				
			||||||
 | 
					                    } else if (getWinBollUI_TYPE() == WinBollUI_TYPE.Aplication) {
 | 
				
			||||||
 | 
					                        // 结束窗口保留最近任务栏,建议前台服务类应用使用,可以保持应用的系统自觉性。
 | 
				
			||||||
 | 
					                        iWinBoll.getActivity().finish();
 | 
				
			||||||
 | 
					                        //ToastUtils.show("finishAll() activity.finish();");
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        LogUtils.d(TAG, "WinBollApplication.WinBollUI_TYPE error.");
 | 
				
			||||||
 | 
					                        //ToastUtils.show("WinBollApplication.WinBollUI_TYPE error.");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					            LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    // 结束指定Activity
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    public <T extends IWinBollActivity> void finish(T iWinBoll) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            if (iWinBoll != null && !iWinBoll.getActivity().isFinishing() && !iWinBoll.getActivity().isDestroyed()) {
 | 
				
			||||||
 | 
					                //根据tag 移除 MyActivity
 | 
				
			||||||
 | 
					                //String tag= activity.getTag();
 | 
				
			||||||
 | 
					                //_mWinBollActivityList.remove(tag);
 | 
				
			||||||
 | 
					                //ToastUtils.show("remove");
 | 
				
			||||||
 | 
					                //ToastUtils.show("_mWinBollActivityArrayMap.size() " + Integer.toString(_mWinBollActivityArrayMap.size()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // 窗口回调规则:
 | 
				
			||||||
 | 
					                // [] 当前窗口位置 >> 调度出的窗口位置
 | 
				
			||||||
 | 
					                // ★:[0] 1 2 3 4 >> 1
 | 
				
			||||||
 | 
					                // ★:0 1 [2] 3 4 >> 1
 | 
				
			||||||
 | 
					                // ★:0 1 2 [3] 4 >> 2
 | 
				
			||||||
 | 
					                // ★:0 1 2 3 [4] >> 3
 | 
				
			||||||
 | 
					                // ★:[0] >> 直接关闭当前窗口
 | 
				
			||||||
 | 
					                LogUtils.d(TAG, "finish no yet.");
 | 
				
			||||||
 | 
					                IWinBollActivity preIWinBoll = getPreIWinBoll(iWinBoll);
 | 
				
			||||||
 | 
					                iWinBoll.getActivity().finish();
 | 
				
			||||||
 | 
					                if (preIWinBoll != null) {
 | 
				
			||||||
 | 
					                    resumeActivity(mContext, preIWinBoll);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					            LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    // 获取窗口队列中的前一个窗口
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    IWinBollActivity getPreIWinBoll(IWinBollActivity iWinBoll) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            boolean bingo = false;
 | 
				
			||||||
 | 
					            IWinBollActivity preIWinBoll = null;
 | 
				
			||||||
 | 
					            for (Map.Entry<String, IWinBollActivity> entity : _mapIWinBollList.entrySet()) {
 | 
				
			||||||
 | 
					                if (entity.getKey().equals(iWinBoll.getTag())) {
 | 
				
			||||||
 | 
					                    bingo = true;
 | 
				
			||||||
 | 
					                    LogUtils.d(TAG, "bingo");
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                preIWinBoll = entity.getValue();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (bingo) {
 | 
				
			||||||
 | 
					                return preIWinBoll;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					            LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    // 从管理列表中移除管理项
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    public <T extends IWinBollActivity> boolean registeRemove(T activity) {
 | 
				
			||||||
 | 
					        IWinBollActivity iWinBollTest = _mapIWinBollList.get(activity.getTag());
 | 
				
			||||||
 | 
					        if (iWinBollTest != null) {
 | 
				
			||||||
 | 
					            _mapIWinBollList.remove(activity.getTag());
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    // 打印管理列表项列表里的信息
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    public static void printIWinBollListInfo() {
 | 
				
			||||||
 | 
					        //LogUtils.d(TAG, "printAvtivityListInfo");
 | 
				
			||||||
 | 
					        if (!_mapIWinBollList.isEmpty()) {
 | 
				
			||||||
 | 
					            StringBuilder sb = new StringBuilder("Map entries : " + Integer.toString(_mapIWinBollList.size()));
 | 
				
			||||||
 | 
					            Iterator<Map.Entry<String, IWinBollActivity>> iterator = _mapIWinBollList.entrySet().iterator();
 | 
				
			||||||
 | 
					            while (iterator.hasNext()) {
 | 
				
			||||||
 | 
					                Map.Entry<String, IWinBollActivity> entry = iterator.next();
 | 
				
			||||||
 | 
					                sb.append("\nKey: " + entry.getKey() + ", \nValue: " + entry.getValue().getTag());
 | 
				
			||||||
 | 
					                //ToastUtils.show("\nKey: " + entry.getKey() + ", Value: " + entry.getValue().getTag());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            sb.append("\nMap entries end.");
 | 
				
			||||||
 | 
					            LogUtils.d(TAG, sb.toString());
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            LogUtils.d(TAG, "The map is empty.");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user