把 WinBoll 改为 WinBoLL
This commit is contained in:
		| @@ -21,9 +21,9 @@ import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.libappbase.sos.SOS; | ||||
| import cc.winboll.studio.libappbase.utils.ToastUtils; | ||||
| import cc.winboll.studio.libappbase.widgets.StatusWidget; | ||||
| import cc.winboll.studio.libappbase.winboll.IWinBollActivity; | ||||
| import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity; | ||||
|  | ||||
| public class MainActivity extends WinBollActivityBase implements IWinBollActivity { | ||||
| public class MainActivity extends WinBoLLActivityBase implements IWinBoLLActivity { | ||||
|  | ||||
|     public static final String TAG = "MainActivity"; | ||||
|  | ||||
| @@ -176,7 +176,7 @@ public class MainActivity extends WinBollActivityBase implements IWinBollActivit | ||||
|     } | ||||
|  | ||||
|     public void onTestOpenNewActivity(View view) { | ||||
|         GlobalApplication.getWinBollActivityManager().startWinBollActivity(this, NewActivity.class); | ||||
|         GlobalApplication.getWinBoLLActivityManager().startWinBoLLActivity(this, NewActivity.class); | ||||
|     } | ||||
|  | ||||
|      | ||||
|   | ||||
| @@ -0,0 +1,81 @@ | ||||
| package cc.winboll.studio.appbase; | ||||
|  | ||||
| /** | ||||
|  * @Author ZhanGSKen@AliYun.Com | ||||
|  * @Date 2025/03/28 15:34:16 | ||||
|  * @Describe 应用活动窗口基类 | ||||
|  */ | ||||
| import android.app.Activity; | ||||
| import android.os.Bundle; | ||||
| import android.os.PersistableBundle; | ||||
| import android.view.MenuItem; | ||||
| import cc.winboll.studio.appbase.App; | ||||
| import cc.winboll.studio.appbase.R; | ||||
| import cc.winboll.studio.libappbase.GlobalApplication; | ||||
| import cc.winboll.studio.libappbase.dialogs.YesNoAlertDialog; | ||||
| import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity; | ||||
| import cc.winboll.studio.libappbase.winboll.WinBoLLActivityManager; | ||||
|  | ||||
| public class WinBoLLActivityBase extends Activity implements IWinBoLLActivity { | ||||
|  | ||||
|     public static final String TAG = "WinBoLLActivityBase"; | ||||
|  | ||||
|     @Override | ||||
|     public Activity getActivity() { | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getTag() { | ||||
|         return TAG; | ||||
|     } | ||||
|  | ||||
|     WinBoLLActivityManager getWinBoLLActivityManager() { | ||||
|         return WinBoLLActivityManager.getInstance(GlobalApplication.getInstance()); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void onCreate(Bundle savedInstanceState) { | ||||
|         super.onCreate(savedInstanceState); | ||||
|         getWinBoLLActivityManager().add(this); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onPostCreate(Bundle savedInstanceState, PersistableBundle persistentState) { | ||||
|         super.onPostCreate(savedInstanceState, persistentState); | ||||
|     } | ||||
|      | ||||
|  | ||||
|     @Override | ||||
|     public boolean onOptionsItemSelected(MenuItem item) { | ||||
|         if (item.getItemId() == cc.winboll.studio.appbase.R.id.item_log) { | ||||
|             GlobalApplication.getWinBoLLActivityManager().startLogActivity(this); | ||||
|             return true; | ||||
|         } else if(item.getItemId() == cc.winboll.studio.appbase.R.id.item_minimal) { | ||||
|             //moveTaskToBack(true); | ||||
|             exit(); | ||||
|         } | ||||
|         // 在switch语句中处理每个ID,并在处理完后返回true,未处理的情况返回false。 | ||||
|         return super.onOptionsItemSelected(item); | ||||
|     } | ||||
|  | ||||
|     void exit() { | ||||
|         YesNoAlertDialog.show(this, "Exit " + getString(R.string.app_name), "Close all activity and exit?", new YesNoAlertDialog.OnDialogResultListener(){ | ||||
|  | ||||
|                 @Override | ||||
|                 public void onYes() { | ||||
|                     App.getWinBoLLActivityManager().finishAll(); | ||||
|                 } | ||||
|  | ||||
|                 @Override | ||||
|                 public void onNo() { | ||||
|                 } | ||||
|             }); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void onDestroy() { | ||||
|         super.onDestroy(); | ||||
|         getWinBoLLActivityManager().registeRemove(this); | ||||
|     } | ||||
| } | ||||
| @@ -13,12 +13,12 @@ import cc.winboll.studio.appbase.App; | ||||
| import cc.winboll.studio.appbase.R; | ||||
| import cc.winboll.studio.libappbase.GlobalApplication; | ||||
| import cc.winboll.studio.libappbase.dialogs.YesNoAlertDialog; | ||||
| import cc.winboll.studio.libappbase.winboll.IWinBollActivity; | ||||
| import cc.winboll.studio.libappbase.winboll.WinBollActivityManager; | ||||
| import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity; | ||||
| import cc.winboll.studio.libappbase.winboll.WinBoLLActivityManager; | ||||
|  | ||||
| public class WinBollActivityBase extends Activity implements IWinBollActivity { | ||||
| public class WinBoLLActivityBase extends Activity implements IWinBoLLActivity { | ||||
|  | ||||
|     public static final String TAG = "WinBollActivityBase"; | ||||
|     public static final String TAG = "WinBoLLActivityBase"; | ||||
|  | ||||
|     @Override | ||||
|     public Activity getActivity() { | ||||
| @@ -30,14 +30,14 @@ public class WinBollActivityBase extends Activity implements IWinBollActivity { | ||||
|         return TAG; | ||||
|     } | ||||
|  | ||||
|     WinBollActivityManager getWinBollActivityManager() { | ||||
|         return WinBollActivityManager.getInstance(GlobalApplication.getInstance()); | ||||
|     WinBoLLActivityManager getWinBoLLActivityManager() { | ||||
|         return WinBoLLActivityManager.getInstance(GlobalApplication.getInstance()); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void onCreate(Bundle savedInstanceState) { | ||||
|         super.onCreate(savedInstanceState); | ||||
|         getWinBollActivityManager().add(this); | ||||
|         getWinBoLLActivityManager().add(this); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
| @@ -49,7 +49,7 @@ public class WinBollActivityBase extends Activity implements IWinBollActivity { | ||||
|     @Override | ||||
|     public boolean onOptionsItemSelected(MenuItem item) { | ||||
|         if (item.getItemId() == cc.winboll.studio.appbase.R.id.item_log) { | ||||
|             GlobalApplication.getWinBollActivityManager().startLogActivity(this); | ||||
|             GlobalApplication.getWinBoLLActivityManager().startLogActivity(this); | ||||
|             return true; | ||||
|         } else if(item.getItemId() == cc.winboll.studio.appbase.R.id.item_minimal) { | ||||
|             //moveTaskToBack(true); | ||||
| @@ -64,7 +64,7 @@ public class WinBollActivityBase extends Activity implements IWinBollActivity { | ||||
|  | ||||
|                 @Override | ||||
|                 public void onYes() { | ||||
|                     App.getWinBollActivityManager().finishAll(); | ||||
|                     App.getWinBoLLActivityManager().finishAll(); | ||||
|                 } | ||||
|  | ||||
|                 @Override | ||||
| @@ -76,6 +76,6 @@ public class WinBollActivityBase extends Activity implements IWinBollActivity { | ||||
|     @Override | ||||
|     protected void onDestroy() { | ||||
|         super.onDestroy(); | ||||
|         getWinBollActivityManager().registeRemove(this); | ||||
|         getWinBoLLActivityManager().registeRemove(this); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -12,11 +12,11 @@ import android.view.MenuItem; | ||||
| import android.view.View; | ||||
| import android.widget.Toolbar; | ||||
| import cc.winboll.studio.appbase.R; | ||||
| import cc.winboll.studio.appbase.WinBollActivityBase; | ||||
| import cc.winboll.studio.appbase.WinBoLLActivityBase; | ||||
| import cc.winboll.studio.libappbase.GlobalApplication; | ||||
| import cc.winboll.studio.libappbase.winboll.IWinBollActivity; | ||||
| import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity; | ||||
|  | ||||
| public class New2Activity extends WinBollActivityBase implements IWinBollActivity { | ||||
| public class New2Activity extends WinBoLLActivityBase implements IWinBoLLActivity { | ||||
|  | ||||
|     public static final String TAG = "New2Activity"; | ||||
|  | ||||
| @@ -52,15 +52,15 @@ public class New2Activity extends WinBollActivityBase implements IWinBollActivit | ||||
|     } | ||||
|  | ||||
|     public void onCloseThisActivity(View view) { | ||||
|         GlobalApplication.getWinBollActivityManager().finish(this); | ||||
|         GlobalApplication.getWinBoLLActivityManager().finish(this); | ||||
|     } | ||||
|  | ||||
|     public void onCloseAllActivity(View view) { | ||||
|         GlobalApplication.getWinBollActivityManager().finishAll(); | ||||
|         GlobalApplication.getWinBoLLActivityManager().finishAll(); | ||||
|     } | ||||
|  | ||||
|     public void onNewActivity(View view) { | ||||
|         GlobalApplication.getWinBollActivityManager().startWinBollActivity(this, NewActivity.class); | ||||
|         GlobalApplication.getWinBoLLActivityManager().startWinBoLLActivity(this, NewActivity.class); | ||||
|     } | ||||
|      | ||||
|  | ||||
| @@ -74,7 +74,7 @@ public class New2Activity extends WinBollActivityBase implements IWinBollActivit | ||||
|     @Override | ||||
|     public boolean onOptionsItemSelected(MenuItem item) { | ||||
|         if (item.getItemId() == cc.winboll.studio.appbase.R.id.item_log) { | ||||
|             GlobalApplication.getWinBollActivityManager().startLogActivity(this); | ||||
|             GlobalApplication.getWinBoLLActivityManager().startLogActivity(this); | ||||
|             return true; | ||||
|         } | ||||
|         // 在switch语句中处理每个ID,并在处理完后返回true,未处理的情况返回false。 | ||||
|   | ||||
| @@ -11,11 +11,11 @@ import android.view.MenuItem; | ||||
| import android.view.View; | ||||
| import android.widget.Toolbar; | ||||
| import cc.winboll.studio.appbase.R; | ||||
| import cc.winboll.studio.appbase.WinBollActivityBase; | ||||
| import cc.winboll.studio.appbase.WinBoLLActivityBase; | ||||
| import cc.winboll.studio.libappbase.GlobalApplication; | ||||
| import cc.winboll.studio.libappbase.winboll.IWinBollActivity; | ||||
| import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity; | ||||
|  | ||||
| public class NewActivity extends WinBollActivityBase implements IWinBollActivity { | ||||
| public class NewActivity extends WinBoLLActivityBase implements IWinBoLLActivity { | ||||
|  | ||||
|     public static final String TAG = "NewActivity"; | ||||
|  | ||||
| @@ -50,15 +50,15 @@ public class NewActivity extends WinBollActivityBase implements IWinBollActivity | ||||
|     } | ||||
|  | ||||
|     public void onCloseThisActivity(View view) { | ||||
|         GlobalApplication.getWinBollActivityManager().finish(this); | ||||
|         GlobalApplication.getWinBoLLActivityManager().finish(this); | ||||
|     } | ||||
|  | ||||
|     public void onCloseAllActivity(View view) { | ||||
|         GlobalApplication.getWinBollActivityManager().finishAll(); | ||||
|         GlobalApplication.getWinBoLLActivityManager().finishAll(); | ||||
|     } | ||||
|  | ||||
|     public void onNew2Activity(View view) { | ||||
|         GlobalApplication.getWinBollActivityManager().startWinBollActivity(this, New2Activity.class); | ||||
|         GlobalApplication.getWinBoLLActivityManager().startWinBoLLActivity(this, New2Activity.class); | ||||
|     } | ||||
|      | ||||
|  | ||||
| @@ -72,7 +72,7 @@ public class NewActivity extends WinBollActivityBase implements IWinBollActivity | ||||
|     @Override | ||||
|     public boolean onOptionsItemSelected(MenuItem item) { | ||||
|         if (item.getItemId() == cc.winboll.studio.appbase.R.id.item_log) { | ||||
|             GlobalApplication.getWinBollActivityManager().startLogActivity(this); | ||||
|             GlobalApplication.getWinBoLLActivityManager().startLogActivity(this); | ||||
|             return true; | ||||
|         } | ||||
|         // 在switch语句中处理每个ID,并在处理完后返回true,未处理的情况返回false。 | ||||
|   | ||||
| @@ -0,0 +1,72 @@ | ||||
| package cc.winboll.studio.appbase.models; | ||||
|  | ||||
| /** | ||||
|  * @Author ZhanGSKen@AliYun.Com | ||||
|  * @Date 2025/02/17 10:05:09 | ||||
|  * @Describe APPSOSReportBean | ||||
|  */ | ||||
| import android.util.JsonReader; | ||||
| import android.util.JsonWriter; | ||||
| import cc.winboll.studio.libappbase.BaseBean; | ||||
| import java.io.IOException; | ||||
|  | ||||
| public class WinBoLLNewsBean extends BaseBean { | ||||
|      | ||||
|     public static final String TAG = "WinBoLLNewsBean"; | ||||
|      | ||||
|     protected String message; | ||||
|      | ||||
|     public WinBoLLNewsBean() { | ||||
|         this.message = ""; | ||||
|     } | ||||
|  | ||||
|     public WinBoLLNewsBean(String message) { | ||||
|         this.message = message; | ||||
|     } | ||||
|  | ||||
|     public void setMessage(String message) { | ||||
|         this.message = message; | ||||
|     } | ||||
|  | ||||
|     public String getMessage() { | ||||
|         return message; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getName() { | ||||
|         return WinBoLLNewsBean.class.getName(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException { | ||||
|         super.writeThisToJsonWriter(jsonWriter); | ||||
|         jsonWriter.name("message").value(getMessage()); | ||||
|  | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException { | ||||
|         if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else { | ||||
|             if (name.equals("message")) { | ||||
|                 setMessage(jsonReader.nextString()); | ||||
|             } else { | ||||
|                 return false; | ||||
|             } | ||||
|         } | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException { | ||||
|         jsonReader.beginObject(); | ||||
|         while (jsonReader.hasNext()) { | ||||
|             String name = jsonReader.nextName(); | ||||
|             if (!initObjectsFromJsonReader(jsonReader, name)) { | ||||
|                 jsonReader.skipValue(); | ||||
|             } | ||||
|         } | ||||
|         // 结束 JSON 对象 | ||||
|         jsonReader.endObject(); | ||||
|         return this; | ||||
|     } | ||||
| } | ||||
| @@ -10,17 +10,17 @@ import android.util.JsonWriter; | ||||
| import cc.winboll.studio.libappbase.BaseBean; | ||||
| import java.io.IOException; | ||||
|  | ||||
| public class WinBollNewsBean extends BaseBean { | ||||
| public class WinBoLLNewsBean extends BaseBean { | ||||
|      | ||||
|     public static final String TAG = "WinBollNewsBean"; | ||||
|     public static final String TAG = "WinBoLLNewsBean"; | ||||
|      | ||||
|     protected String message; | ||||
|      | ||||
|     public WinBollNewsBean() { | ||||
|     public WinBoLLNewsBean() { | ||||
|         this.message = ""; | ||||
|     } | ||||
|  | ||||
|     public WinBollNewsBean(String message) { | ||||
|     public WinBoLLNewsBean(String message) { | ||||
|         this.message = message; | ||||
|     } | ||||
|  | ||||
| @@ -34,7 +34,7 @@ public class WinBollNewsBean extends BaseBean { | ||||
|  | ||||
|     @Override | ||||
|     public String getName() { | ||||
|         return WinBollNewsBean.class.getName(); | ||||
|         return WinBoLLNewsBean.class.getName(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -10,7 +10,7 @@ import android.content.ComponentName; | ||||
| import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import android.content.IntentFilter; | ||||
| import cc.winboll.studio.appbase.models.WinBollNewsBean; | ||||
| import cc.winboll.studio.appbase.models.WinBoLLNewsBean; | ||||
| import cc.winboll.studio.appbase.services.MainService; | ||||
| import cc.winboll.studio.appbase.widgets.APPNewsWidget; | ||||
| import cc.winboll.studio.libappbase.AppUtils; | ||||
| @@ -18,7 +18,7 @@ import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.libappbase.sos.APPModel; | ||||
| import cc.winboll.studio.libappbase.sos.SOS; | ||||
| import cc.winboll.studio.libappbase.sos.SOSObject; | ||||
| import cc.winboll.studio.libappbase.sos.WinBoll; | ||||
| import cc.winboll.studio.libappbase.sos.WinBoLL; | ||||
| import cc.winboll.studio.libappbase.utils.ToastUtils; | ||||
| import java.io.IOException; | ||||
| import java.lang.ref.WeakReference; | ||||
| @@ -42,11 +42,11 @@ public class MainReceiver extends BroadcastReceiver { | ||||
|         String szAction = intent.getAction(); | ||||
|         if (szAction.equals(ACTION_BOOT_COMPLETED)) { | ||||
|             ToastUtils.show("ACTION_BOOT_COMPLETED"); | ||||
|         } else if (szAction.equals(WinBoll.ACTION_BIND)) { | ||||
|         } else if (szAction.equals(WinBoLL.ACTION_BIND)) { | ||||
|             LogUtils.d(TAG, "ACTION_BIND"); | ||||
|             LogUtils.d(TAG, String.format("context.getPackageName() %s", context.getPackageName())); | ||||
|             LogUtils.d(TAG, String.format("intent.getAction() %s", intent.getAction())); | ||||
|             String szAPPModel = intent.getStringExtra(WinBoll.EXTRA_APPMODEL); | ||||
|             String szAPPModel = intent.getStringExtra(WinBoLL.EXTRA_APPMODEL); | ||||
|             LogUtils.d(TAG, String.format("szAPPModel %s", szAPPModel)); | ||||
|             if (szAPPModel != null && !szAPPModel.equals("")) { | ||||
|                 try { | ||||
| @@ -80,7 +80,7 @@ public class MainReceiver extends BroadcastReceiver { | ||||
|  | ||||
|                     String appName = AppUtils.getAppNameByPackageName(context, szObjectPackageName); | ||||
|                     LogUtils.d(TAG, String.format("appName %s", appName)); | ||||
|                     WinBollNewsBean appWinBollNewsBean = new WinBollNewsBean(appName); | ||||
|                     WinBoLLNewsBean appWinBoLLNewsBean = new WinBoLLNewsBean(appName); | ||||
|                     SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); | ||||
|                     String currentTime = sdf.format(new Date()); | ||||
|                     StringBuilder sbLine = new StringBuilder(); | ||||
| @@ -88,9 +88,9 @@ public class MainReceiver extends BroadcastReceiver { | ||||
|                     sbLine.append(currentTime); | ||||
|                     sbLine.append("] Power to "); | ||||
|                     sbLine.append(appName); | ||||
|                     appWinBollNewsBean.setMessage(sbLine.toString()); | ||||
|                     appWinBoLLNewsBean.setMessage(sbLine.toString()); | ||||
|  | ||||
|                     APPNewsWidget.addWinBollNewsBean(context, appWinBollNewsBean); | ||||
|                     APPNewsWidget.addWinBoLLNewsBean(context, appWinBoLLNewsBean); | ||||
|  | ||||
|                     Intent intentWidget = new Intent(context, APPNewsWidget.class); | ||||
|                     intentWidget.setAction(APPNewsWidget.ACTION_RELOAD_REPORT); | ||||
| @@ -110,7 +110,7 @@ public class MainReceiver extends BroadcastReceiver { | ||||
|         IntentFilter filter=new IntentFilter(); | ||||
|         filter.addAction(ACTION_BOOT_COMPLETED); | ||||
|         filter.addAction(SOS.ACTION_SOS); | ||||
|         filter.addAction(WinBoll.ACTION_BIND); | ||||
|         filter.addAction(WinBoLL.ACTION_BIND); | ||||
|         //filter.addAction(Intent.ACTION_BATTERY_CHANGED); | ||||
|         service.registerReceiver(this, filter); | ||||
|     } | ||||
|   | ||||
| @@ -12,7 +12,7 @@ import android.os.Binder; | ||||
| import android.os.IBinder; | ||||
| import cc.winboll.studio.appbase.models.TestDemoBindServiceBean; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.libappbase.sos.WinBoll; | ||||
| import cc.winboll.studio.libappbase.sos.WinBoLL; | ||||
| import cc.winboll.studio.appbase.App; | ||||
| import cc.winboll.studio.libappbase.sos.SOS; | ||||
|  | ||||
| @@ -156,9 +156,9 @@ public class TestDemoBindService extends Service { | ||||
|                 super.run(); | ||||
|                 LogUtils.d(TAG, "run() start"); | ||||
|                 if (App.isDebuging()) { | ||||
|                     WinBoll.bindToAPPBaseBeta(mContext, TestDemoBindService.class.getName()); | ||||
|                     WinBoLL.bindToAPPBaseBeta(mContext, TestDemoBindService.class.getName()); | ||||
|                 } else { | ||||
|                     WinBoll.bindToAPPBase(mContext, TestDemoBindService.class.getName()); | ||||
|                     WinBoLL.bindToAPPBase(mContext, TestDemoBindService.class.getName()); | ||||
|                 } | ||||
|  | ||||
|                 while (!isExit()) { | ||||
|   | ||||
| @@ -12,7 +12,7 @@ import android.os.Binder; | ||||
| import android.os.IBinder; | ||||
| import cc.winboll.studio.appbase.models.TestDemoServiceBean; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.libappbase.sos.WinBoll; | ||||
| import cc.winboll.studio.libappbase.sos.WinBoLL; | ||||
|  | ||||
| public class TestDemoService extends Service { | ||||
|  | ||||
|   | ||||
| @@ -12,12 +12,12 @@ import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import android.widget.RemoteViews; | ||||
| import cc.winboll.studio.appbase.R; | ||||
| import cc.winboll.studio.appbase.models.WinBollNewsBean; | ||||
| import cc.winboll.studio.appbase.models.WinBoLLNewsBean; | ||||
| import cc.winboll.studio.appbase.receivers.APPNewsWidgetClickListener; | ||||
| import cc.winboll.studio.libappbase.AppUtils; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.libappbase.sos.APPModel; | ||||
| import cc.winboll.studio.libappbase.sos.WinBoll; | ||||
| import cc.winboll.studio.libappbase.sos.WinBoLL; | ||||
| import java.io.IOException; | ||||
| import java.text.SimpleDateFormat; | ||||
| import java.util.ArrayList; | ||||
| @@ -31,14 +31,14 @@ public class APPNewsWidget extends AppWidgetProvider { | ||||
|     public static final String ACTION_RELOAD_REPORT = APPNewsWidget.class.getName() + ".ACTION_RELOAD_REPORT"; | ||||
|  | ||||
|  | ||||
|     volatile static ArrayList<WinBollNewsBean> _WinBollNewsBeanList; | ||||
|     volatile static ArrayList<WinBoLLNewsBean> _WinBoLLNewsBeanList; | ||||
|     final static int _MAX_PAGES = 10; | ||||
|     final static int _OnePageLinesCount = 5; | ||||
|     volatile static int _CurrentPageIndex = 0; | ||||
|  | ||||
|     @Override | ||||
|     public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { | ||||
|         initWinBollNewsBeanList(context); | ||||
|         initWinBoLLNewsBeanList(context); | ||||
|         for (int appWidgetId : appWidgetIds) { | ||||
|             updateAppWidget(context, appWidgetManager, appWidgetId); | ||||
|         } | ||||
| @@ -47,7 +47,7 @@ public class APPNewsWidget extends AppWidgetProvider { | ||||
|     @Override | ||||
|     public void onReceive(Context context, Intent intent) { | ||||
|         super.onReceive(context, intent); | ||||
|         initWinBollNewsBeanList(context); | ||||
|         initWinBoLLNewsBeanList(context); | ||||
|         if (intent.getAction().equals(ACTION_RELOAD_REPORT)) { | ||||
|             LogUtils.d(TAG, "ACTION_RELOAD_REPORT"); | ||||
|             AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); | ||||
| @@ -57,7 +57,7 @@ public class APPNewsWidget extends AppWidgetProvider { | ||||
|             } | ||||
|         }else if (intent.getAction().equals(ACTION_WAKEUP_SERVICE)) { | ||||
|             LogUtils.d(TAG, "ACTION_WAKEUP_SERVICE"); | ||||
|             String szAPPModel = intent.getStringExtra(WinBoll.EXTRA_APPMODEL); | ||||
|             String szAPPModel = intent.getStringExtra(WinBoLL.EXTRA_APPMODEL); | ||||
|             LogUtils.d(TAG, String.format("szAPPModel %s", szAPPModel)); | ||||
|             if (szAPPModel != null && !szAPPModel.equals("")) { | ||||
|                 try { | ||||
| @@ -71,7 +71,7 @@ public class APPNewsWidget extends AppWidgetProvider { | ||||
|                          | ||||
|                         String appName = AppUtils.getAppNameByPackageName(context, szAppPackageName); | ||||
|                         LogUtils.d(TAG, String.format("appName %s", appName)); | ||||
|                         WinBollNewsBean winBollNewsBean = new WinBollNewsBean(appName); | ||||
|                         WinBoLLNewsBean winBollNewsBean = new WinBoLLNewsBean(appName); | ||||
|                         SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); | ||||
|                         String currentTime = sdf.format(new Date()); | ||||
|                         StringBuilder sbLine = new StringBuilder(); | ||||
| @@ -81,7 +81,7 @@ public class APPNewsWidget extends AppWidgetProvider { | ||||
|                         sbLine.append(appName); | ||||
|                         winBollNewsBean.setMessage(sbLine.toString()); | ||||
|                          | ||||
|                         addWinBollNewsBean(context, winBollNewsBean); | ||||
|                         addWinBoLLNewsBean(context, winBollNewsBean); | ||||
|  | ||||
|                         AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); | ||||
|                         int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, APPNewsWidget.class)); | ||||
| @@ -99,24 +99,24 @@ public class APPNewsWidget extends AppWidgetProvider { | ||||
|     // | ||||
|     // 加入新报告信息 | ||||
|     // | ||||
|     public synchronized static void addWinBollNewsBean(Context context, WinBollNewsBean bean) { | ||||
|         initWinBollNewsBeanList(context); | ||||
|         _WinBollNewsBeanList.add(0, bean); | ||||
|     public synchronized static void addWinBoLLNewsBean(Context context, WinBoLLNewsBean bean) { | ||||
|         initWinBoLLNewsBeanList(context); | ||||
|         _WinBoLLNewsBeanList.add(0, bean); | ||||
|         // 控制记录总数 | ||||
|         while (_WinBollNewsBeanList.size() > _MAX_PAGES * _OnePageLinesCount) { | ||||
|             _WinBollNewsBeanList.remove(_WinBollNewsBeanList.size() - 1); | ||||
|         while (_WinBoLLNewsBeanList.size() > _MAX_PAGES * _OnePageLinesCount) { | ||||
|             _WinBoLLNewsBeanList.remove(_WinBoLLNewsBeanList.size() - 1); | ||||
|         } | ||||
|         WinBollNewsBean.saveBeanList(context, _WinBollNewsBeanList, WinBollNewsBean.class); | ||||
|         WinBoLLNewsBean.saveBeanList(context, _WinBoLLNewsBeanList, WinBoLLNewsBean.class); | ||||
|     } | ||||
|  | ||||
|     synchronized static void initWinBollNewsBeanList(Context context) { | ||||
|         if (_WinBollNewsBeanList == null) { | ||||
|             _WinBollNewsBeanList = new ArrayList<WinBollNewsBean>(); | ||||
|             WinBollNewsBean.loadBeanList(context, _WinBollNewsBeanList, WinBollNewsBean.class); | ||||
|     synchronized static void initWinBoLLNewsBeanList(Context context) { | ||||
|         if (_WinBoLLNewsBeanList == null) { | ||||
|             _WinBoLLNewsBeanList = new ArrayList<WinBoLLNewsBean>(); | ||||
|             WinBoLLNewsBean.loadBeanList(context, _WinBoLLNewsBeanList, WinBoLLNewsBean.class); | ||||
|         } | ||||
|         if (_WinBollNewsBeanList == null) { | ||||
|             _WinBollNewsBeanList = new ArrayList<WinBollNewsBean>(); | ||||
|             WinBollNewsBean.saveBeanList(context, _WinBollNewsBeanList, WinBollNewsBean.class); | ||||
|         if (_WinBoLLNewsBeanList == null) { | ||||
|             _WinBoLLNewsBeanList = new ArrayList<WinBoLLNewsBean>(); | ||||
|             WinBoLLNewsBean.saveBeanList(context, _WinBoLLNewsBeanList, WinBoLLNewsBean.class); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -141,11 +141,11 @@ public class APPNewsWidget extends AppWidgetProvider { | ||||
|  | ||||
|     public static String getMessage() { | ||||
|         ArrayList<String> msgTemp = new ArrayList<String>(); | ||||
|         if (_WinBollNewsBeanList != null) { | ||||
|         if (_WinBoLLNewsBeanList != null) { | ||||
|             int start = _OnePageLinesCount * _CurrentPageIndex; | ||||
|             start = _WinBollNewsBeanList.size() > start ? start : _WinBollNewsBeanList.size() - 1; | ||||
|             for (int i = start, j = 0; i < _WinBollNewsBeanList.size() && j < _OnePageLinesCount && start > -1; i++, j++) { | ||||
|                 msgTemp.add(_WinBollNewsBeanList.get(i).getMessage()); | ||||
|             start = _WinBoLLNewsBeanList.size() > start ? start : _WinBoLLNewsBeanList.size() - 1; | ||||
|             for (int i = start, j = 0; i < _WinBoLLNewsBeanList.size() && j < _OnePageLinesCount && start > -1; i++, j++) { | ||||
|                 msgTemp.add(_WinBoLLNewsBeanList.get(i).getMessage()); | ||||
|             } | ||||
|             String message = String.join("\n", msgTemp); | ||||
|             return message; | ||||
| @@ -154,7 +154,7 @@ public class APPNewsWidget extends AppWidgetProvider { | ||||
|     } | ||||
|  | ||||
|     public static void prePage(Context context) { | ||||
|         if (_WinBollNewsBeanList != null) { | ||||
|         if (_WinBoLLNewsBeanList != null) { | ||||
|             if (_CurrentPageIndex > 0) { | ||||
|                 _CurrentPageIndex = _CurrentPageIndex - 1; | ||||
|             } | ||||
| @@ -165,8 +165,8 @@ public class APPNewsWidget extends AppWidgetProvider { | ||||
|     } | ||||
|  | ||||
|     public static void nextPage(Context context) { | ||||
|         if (_WinBollNewsBeanList != null) { | ||||
|             if ((_CurrentPageIndex + 1) * _OnePageLinesCount < _WinBollNewsBeanList.size()) { | ||||
|         if (_WinBoLLNewsBeanList != null) { | ||||
|             if ((_CurrentPageIndex + 1) * _OnePageLinesCount < _WinBoLLNewsBeanList.size()) { | ||||
|                 _CurrentPageIndex = _CurrentPageIndex + 1; | ||||
|             } | ||||
|             Intent intentWidget = new Intent(context, APPNewsWidget.class); | ||||
| @@ -176,11 +176,11 @@ public class APPNewsWidget extends AppWidgetProvider { | ||||
|     } | ||||
|  | ||||
|     String getPageInfo() { | ||||
|         if (_WinBollNewsBeanList == null) { | ||||
|         if (_WinBoLLNewsBeanList == null) { | ||||
|             return "0/0"; | ||||
|         } | ||||
|         int leftCount = _WinBollNewsBeanList.size() % _OnePageLinesCount; | ||||
|         int currentPageCount = _WinBollNewsBeanList.size() / _OnePageLinesCount + (leftCount == 0 ?0: 1); | ||||
|         int leftCount = _WinBoLLNewsBeanList.size() % _OnePageLinesCount; | ||||
|         int currentPageCount = _WinBoLLNewsBeanList.size() / _OnePageLinesCount + (leftCount == 0 ?0: 1); | ||||
|         return String.format("%d/%d", _CurrentPageIndex + 1, currentPageCount); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -32,7 +32,7 @@ | ||||
| 				<TextView | ||||
| 					android:layout_width="wrap_content" | ||||
| 					android:layout_height="wrap_content" | ||||
| 					android:text="Hello, WinBoll!"/> | ||||
| 					android:text="Hello, WinBoLL!"/> | ||||
|  | ||||
| 				<TextView | ||||
| 					android:layout_width="wrap_content" | ||||
|   | ||||
| @@ -18,7 +18,7 @@ | ||||
| 			android:layout_height="wrap_content" | ||||
| 			android:id="@+id/tv_title" | ||||
| 			android:layout_weight="1.0" | ||||
| 			android:text="WinBollNews" | ||||
| 			android:text="WinBoLLNews" | ||||
| 			android:textStyle="bold" | ||||
| 			android:textSize="16sp"/> | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <resources> | ||||
|     <string name="app_name">AppBase</string> | ||||
|     <string name="tileservice_name">WinBoll</string> | ||||
|     <string name="tileservice_name">WinBoLL</string> | ||||
| </resources> | ||||
|   | ||||
| @@ -12,7 +12,7 @@ import android.content.pm.PackageManager; | ||||
| import android.os.Handler; | ||||
| import android.os.Looper; | ||||
| import cc.winboll.studio.libappbase.utils.ToastUtils; | ||||
| import cc.winboll.studio.libappbase.winboll.WinBollActivityManager; | ||||
| import cc.winboll.studio.libappbase.winboll.WinBoLLActivityManager; | ||||
| import cc.winboll.studio.libappbase.winboll.MyActivityLifecycleCallbacks; | ||||
|  | ||||
| public class GlobalApplication extends Application { | ||||
| @@ -46,8 +46,8 @@ public class GlobalApplication extends Application { | ||||
|         return isDebuging; | ||||
|     } | ||||
|  | ||||
|     public static WinBollActivityManager getWinBollActivityManager() { | ||||
|         return WinBollActivityManager.getInstance(_GlobalApplication); | ||||
|     public static WinBoLLActivityManager getWinBoLLActivityManager() { | ||||
|         return WinBoLLActivityManager.getInstance(_GlobalApplication); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
| @@ -77,7 +77,7 @@ public class GlobalApplication extends Application { | ||||
|             setIsDebuging(appBaseModel.isDebuging()); | ||||
|         } | ||||
|          | ||||
|         getWinBollActivityManager().setWinBollUI_TYPE(WinBollActivityManager.WinBollUI_TYPE.Service); | ||||
|         getWinBoLLActivityManager().setWinBoLLUI_TYPE(WinBoLLActivityManager.WinBoLLUI_TYPE.Service); | ||||
|         // 注册窗口回调监听 | ||||
|         mMyActivityLifecycleCallbacks = new MyActivityLifecycleCallbacks(); | ||||
|         registerActivityLifecycleCallbacks(mMyActivityLifecycleCallbacks); | ||||
|   | ||||
| @@ -1,3 +0,0 @@ | ||||
| package cc.winboll.studio.libappbase; | ||||
|  | ||||
|  | ||||
| @@ -3,7 +3,7 @@ package cc.winboll.studio.libappbase.sos; | ||||
| /** | ||||
|  * @Author ZhanGSKen@AliYun.Com | ||||
|  * @Date 2025/03/02 09:36:29 | ||||
|  * @Describe WinBoll 应用 SOS 机理保护类 | ||||
|  * @Describe WinBoLL 应用 SOS 机理保护类 | ||||
|  */ | ||||
| import android.content.Context; | ||||
| import android.content.Intent; | ||||
|   | ||||
| @@ -0,0 +1,39 @@ | ||||
| package cc.winboll.studio.libappbase.sos; | ||||
|  | ||||
| /** | ||||
|  * @Author ZhanGSKen@AliYun.Com | ||||
|  * @Date 2025/03/02 09:54:28 | ||||
|  * @Describe WinBoLL 系列应用通用管理类 | ||||
|  */ | ||||
| import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
|  | ||||
| public class WinBoLL { | ||||
|  | ||||
|     public static final String TAG = "WinBoLL"; | ||||
|  | ||||
|     public static final String ACTION_BIND = WinBoLL.class.getName() + ".ACTION_BIND"; | ||||
|     public static final String EXTRA_APPMODEL = "EXTRA_APPMODEL"; | ||||
|  | ||||
|     public static void bindToAPPBase(Context context, String appMainService) { | ||||
|         LogUtils.d(TAG, "bindToAPPBase(...)"); | ||||
|         String toPackage = "cc.winboll.studio.appbase"; | ||||
|         startBind(context, toPackage, appMainService); | ||||
|     } | ||||
|  | ||||
|     public static void bindToAPPBaseBeta(Context context, String appMainService) { | ||||
|         LogUtils.d(TAG, "bindToAPPBaseBeta(...)"); | ||||
|         String toPackage = "cc.winboll.studio.appbase.beta"; | ||||
|         startBind(context, toPackage, appMainService); | ||||
|     } | ||||
|  | ||||
|     static void startBind(Context context, String toPackage, String appMainService) { | ||||
|         Intent intent = new Intent(ACTION_BIND); | ||||
|         intent.putExtra(EXTRA_APPMODEL, (new APPModel(toPackage, appMainService)).toString()); | ||||
|         intent.setPackage(toPackage); | ||||
|         LogUtils.d(TAG, String.format("ACTION_BIND :\nTo Package : %s\nAPP Main Service : %s", toPackage, appMainService)); | ||||
|         context.sendBroadcast(intent); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -3,17 +3,17 @@ package cc.winboll.studio.libappbase.sos; | ||||
| /** | ||||
|  * @Author ZhanGSKen@AliYun.Com | ||||
|  * @Date 2025/03/02 09:54:28 | ||||
|  * @Describe WinBoll 系列应用通用管理类 | ||||
|  * @Describe WinBoLL 系列应用通用管理类 | ||||
|  */ | ||||
| import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
|  | ||||
| public class WinBoll { | ||||
| public class WinBoLL { | ||||
|  | ||||
|     public static final String TAG = "WinBoll"; | ||||
|     public static final String TAG = "WinBoLL"; | ||||
|  | ||||
|     public static final String ACTION_BIND = WinBoll.class.getName() + ".ACTION_BIND"; | ||||
|     public static final String ACTION_BIND = WinBoLL.class.getName() + ".ACTION_BIND"; | ||||
|     public static final String EXTRA_APPMODEL = "EXTRA_APPMODEL"; | ||||
|  | ||||
|     public static void bindToAPPBase(Context context, String appMainService) { | ||||
|   | ||||
| @@ -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(); | ||||
| } | ||||
| @@ -3,14 +3,14 @@ package cc.winboll.studio.libappbase.winboll; | ||||
| /** | ||||
|  * @Author ZhanGSKen@AliYun.Com | ||||
|  * @Date 2025/03/24 08:23:40 | ||||
|  * @Describe WinBoll 活动窗口通用接口 | ||||
|  * @Describe WinBoLL 活动窗口通用接口 | ||||
|  */ | ||||
| import android.app.Activity; | ||||
| import android.widget.Toolbar; | ||||
|  | ||||
| public interface IWinBollActivity { | ||||
| public interface IWinBoLLActivity { | ||||
|  | ||||
|     public static final String TAG = "IWinBollActivity"; | ||||
|     public static final String TAG = "IWinBoLLActivity"; | ||||
|  | ||||
|     // 获取活动窗口 | ||||
|     abstract public Activity getActivity(); | ||||
|   | ||||
| @@ -13,7 +13,7 @@ import cc.winboll.studio.libappbase.LogView; | ||||
| import cc.winboll.studio.libappbase.R; | ||||
| import cc.winboll.studio.libappbase.utils.ToastUtils; | ||||
|  | ||||
| public class LogActivity extends Activity implements IWinBollActivity { | ||||
| public class LogActivity extends Activity implements IWinBoLLActivity { | ||||
|  | ||||
|     public static final String TAG = "LogActivity"; | ||||
|  | ||||
|   | ||||
| @@ -0,0 +1,356 @@ | ||||
| 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.GlobalApplication; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.libappbase.utils.ToastUtils; | ||||
| 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 // 退出应用后,清理所有最近任务栏任务记录窗口 | ||||
|         }; | ||||
|  | ||||
|     // 应用类型标志 | ||||
|     static volatile WinBoLLUI_TYPE _mWinBoLLUI_TYPE = WinBoLLUI_TYPE.Service; | ||||
|  | ||||
|     GlobalApplication mGlobalApplication; | ||||
|     static volatile WinBoLLActivityManager _Instance; | ||||
|     static volatile Map<String, IWinBoLLActivity> _mapIWinBoLLList; | ||||
|     volatile IWinBoLLActivity mFirstIWinBoLLActivity; | ||||
|  | ||||
|     WinBoLLActivityManager(GlobalApplication application) { | ||||
|         mGlobalApplication = application; | ||||
|         _mapIWinBoLLList = new HashMap<String, IWinBoLLActivity>(); | ||||
|     } | ||||
|  | ||||
|     public static synchronized WinBoLLActivityManager getInstance(GlobalApplication application) { | ||||
|         LogUtils.d(TAG, "getInstance"); | ||||
|         if (_Instance == null) { | ||||
|             LogUtils.d(TAG, "_Instance == null"); | ||||
|             _Instance = new WinBoLLActivityManager(application); | ||||
|         } | ||||
|         return _Instance; | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 设置 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) { | ||||
|         String tag = ((IWinBoLLActivity)iWinBoLL).getTag(); | ||||
|         LogUtils.d(TAG, String.format("add(T iWinBoLL) tag is %s", tag)); | ||||
|         if (isActive(tag)) { | ||||
|             LogUtils.d(TAG, String.format("isActive(tag) is true, tag : %s.", tag)); | ||||
|         } else { | ||||
|             // 设置起始活动窗口,以便最后退出时提问 | ||||
|             if (mFirstIWinBoLLActivity == null && _mapIWinBoLLList.size() == 0) { | ||||
|                 LogUtils.d(TAG, "Set firstIWinBoLLActivity, iWinBoLL.getTag() is %s" + iWinBoLL.getTag()); | ||||
|                 mFirstIWinBoLLActivity = 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 = ((IWinBoLLActivity)clazz.newInstance()).getTag(); | ||||
|             LogUtils.d(TAG, String.format("startWinBoLLActivity(Context context, Class<T> clazz) tag is %s", tag)); | ||||
|             if (isActive(tag)) { | ||||
|                 resumeActivity(context, tag); | ||||
|                 return; | ||||
|             } | ||||
|             //ToastUtils.show("startWinBoLLActivity(Context context, Class<T> clazz)"); | ||||
|  | ||||
|             // 新建一个任务窗口 | ||||
|             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); | ||||
|             context.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 = ((IWinBoLLActivity)clazz.newInstance()).getTag(); | ||||
|             LogUtils.d(TAG, String.format("startWinBoLLActivity(Context context, Intent intent, Class<T> clazz) tag is %s", tag)); | ||||
|             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); | ||||
|             context.startActivity(intent); | ||||
|         } catch (InstantiationException | IllegalAccessException e) { | ||||
|             LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public <T extends IWinBoLLActivity> void startLogActivity(Context context) { | ||||
|         // 如果窗口已存在就重启窗口 | ||||
|         String tag = LogActivity.TAG; | ||||
|         if (isActive(tag)) { | ||||
|             resumeActivity(context, tag); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         // 新建一个任务窗口 | ||||
|         Intent intent = new Intent(context, LogActivity.class); | ||||
|         //打开多任务窗口 flags | ||||
|         // Define the bounds. | ||||
| //        Rect bounds = new Rect(0, 0, 800, 200); | ||||
| //        // Set the bounds as an activity option. | ||||
| //        ActivityOptions options = ActivityOptions.makeBasic(); | ||||
| //        options.setLaunchBounds(bounds); | ||||
|         intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT); | ||||
|         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||||
|         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); | ||||
|         intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); | ||||
|  | ||||
|         intent.putExtra(EXTRA_TAG, tag); | ||||
|  | ||||
|         //context.startActivity(intent, options.toBundle()); | ||||
|         context.startActivity(intent); | ||||
|     } | ||||
|  | ||||
|     public boolean isFirstIWinBoLLActivity(IWinBoLLActivity iWinBoLLActivity) { | ||||
|         return mFirstIWinBoLLActivity != null && mFirstIWinBoLLActivity == iWinBoLLActivity; | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 判断 tag绑定的 MyActivity是否存在 | ||||
|     // | ||||
|     public boolean isActive(String tag) { | ||||
|         LogUtils.d(TAG, String.format("isActive(String tag) tag is %s", tag)); | ||||
|         //printIWinBoLLListInfo(); | ||||
|         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(...) iWinBoLL is null tag by %s", tag)); | ||||
|             return false; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     static IWinBoLLActivity getIWinBoLL(String tag) { | ||||
|         LogUtils.d(TAG, String.format("getIWinBoLL(String tag) %s", tag)); | ||||
|         return _mapIWinBoLLList.get(tag); | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台 | ||||
|     // | ||||
|     public <T extends IWinBoLLActivity> void resumeActivity(Context context, String tag) { | ||||
|         LogUtils.d(TAG, "resumeActivity(Context context, String tag)"); | ||||
|         T iWinBoLL = (T)getIWinBoLL(tag); | ||||
|         LogUtils.d(TAG, String.format("iWinBoLL.getTag() %s", iWinBoLL.getTag())); | ||||
|         //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) { | ||||
|         LogUtils.d(TAG, "resumeActivity(Context context, T iWinBoLL)"); | ||||
|         ActivityManager am = (ActivityManager) mGlobalApplication.getSystemService(Context.ACTIVITY_SERVICE); | ||||
|         //返回启动它的根任务(home 或者 MainActivity) | ||||
|         Intent intent = new Intent(mGlobalApplication, iWinBoLL.getClass()); | ||||
|         TaskStackBuilder stackBuilder = TaskStackBuilder.create(mGlobalApplication); | ||||
|         stackBuilder.addNextIntentWithParentStack(intent); | ||||
|         stackBuilder.startActivities(); | ||||
|         //moveTaskToFront(YourTaskId, 0); | ||||
|         //ToastUtils.show("resumeActivity am.moveTaskToFront"); | ||||
|         LogUtils.d(TAG, String.format("iWinBoLL.getActivity().getTaskId() %d", iWinBoLL.getActivity().getTaskId())); | ||||
|         am.moveTaskToFront(iWinBoLL.getActivity().getTaskId(), ActivityManager.MOVE_TASK_NO_USER_ACTION); | ||||
|         LogUtils.d(TAG, "am.moveTaskToFront"); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     // | ||||
|     // 结束所有 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(mGlobalApplication, 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."); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -19,70 +19,70 @@ import java.util.HashMap; | ||||
| import java.util.Iterator; | ||||
| import java.util.Map; | ||||
|  | ||||
| public class WinBollActivityManager { | ||||
| public class WinBoLLActivityManager { | ||||
|  | ||||
|     public static final String TAG = "WinBollActivityManager"; | ||||
|     public static final String TAG = "WinBoLLActivityManager"; | ||||
|     public static final String EXTRA_TAG = "EXTRA_TAG"; | ||||
|  | ||||
|     public static enum WinBollUI_TYPE { | ||||
|     public static enum WinBoLLUI_TYPE { | ||||
|         Aplication, // 退出应用后,保持最近任务栏任务记录主窗口 | ||||
|         Service // 退出应用后,清理所有最近任务栏任务记录窗口 | ||||
|         }; | ||||
|  | ||||
|     // 应用类型标志 | ||||
|     static volatile WinBollUI_TYPE _mWinBollUI_TYPE = WinBollUI_TYPE.Service; | ||||
|     static volatile WinBoLLUI_TYPE _mWinBoLLUI_TYPE = WinBoLLUI_TYPE.Service; | ||||
|  | ||||
|     GlobalApplication mGlobalApplication; | ||||
|     static volatile WinBollActivityManager _Instance; | ||||
|     static volatile Map<String, IWinBollActivity> _mapIWinBollList; | ||||
|     volatile IWinBollActivity mFirstIWinBollActivity; | ||||
|     static volatile WinBoLLActivityManager _Instance; | ||||
|     static volatile Map<String, IWinBoLLActivity> _mapIWinBoLLList; | ||||
|     volatile IWinBoLLActivity mFirstIWinBoLLActivity; | ||||
|  | ||||
|     WinBollActivityManager(GlobalApplication application) { | ||||
|     WinBoLLActivityManager(GlobalApplication application) { | ||||
|         mGlobalApplication = application; | ||||
|         _mapIWinBollList = new HashMap<String, IWinBollActivity>(); | ||||
|         _mapIWinBoLLList = new HashMap<String, IWinBoLLActivity>(); | ||||
|     } | ||||
|  | ||||
|     public static synchronized WinBollActivityManager getInstance(GlobalApplication application) { | ||||
|     public static synchronized WinBoLLActivityManager getInstance(GlobalApplication application) { | ||||
|         LogUtils.d(TAG, "getInstance"); | ||||
|         if (_Instance == null) { | ||||
|             LogUtils.d(TAG, "_Instance == null"); | ||||
|             _Instance = new WinBollActivityManager(application); | ||||
|             _Instance = new WinBoLLActivityManager(application); | ||||
|         } | ||||
|         return _Instance; | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 设置 WinBoll 应用 UI 类型 | ||||
|     // 设置 WinBoLL 应用 UI 类型 | ||||
|     // | ||||
|     public synchronized static void setWinBollUI_TYPE(WinBollUI_TYPE mWinBollUI_TYPE) { | ||||
|         _mWinBollUI_TYPE = mWinBollUI_TYPE; | ||||
|     public synchronized static void setWinBoLLUI_TYPE(WinBoLLUI_TYPE mWinBoLLUI_TYPE) { | ||||
|         _mWinBoLLUI_TYPE = mWinBoLLUI_TYPE; | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 获取 WinBoll 应用 UI 类型 | ||||
|     // 获取 WinBoLL 应用 UI 类型 | ||||
|     // | ||||
|     public synchronized static WinBollUI_TYPE getWinBollUI_TYPE() { | ||||
|         return _mWinBollUI_TYPE; | ||||
|     public synchronized static WinBoLLUI_TYPE getWinBoLLUI_TYPE() { | ||||
|         return _mWinBoLLUI_TYPE; | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 把Activity添加到管理中 | ||||
|     // | ||||
|     public <T extends IWinBollActivity> void add(T iWinBoll) { | ||||
|         String tag = ((IWinBollActivity)iWinBoll).getTag(); | ||||
|         LogUtils.d(TAG, String.format("add(T iWinBoll) tag is %s", tag)); | ||||
|     public <T extends IWinBoLLActivity> void add(T iWinBoLL) { | ||||
|         String tag = ((IWinBoLLActivity)iWinBoLL).getTag(); | ||||
|         LogUtils.d(TAG, String.format("add(T iWinBoLL) tag is %s", tag)); | ||||
|         if (isActive(tag)) { | ||||
|             LogUtils.d(TAG, String.format("isActive(tag) is true, tag : %s.", tag)); | ||||
|         } else { | ||||
|             // 设置起始活动窗口,以便最后退出时提问 | ||||
|             if (mFirstIWinBollActivity == null && _mapIWinBollList.size() == 0) { | ||||
|                 LogUtils.d(TAG, "Set firstIWinBollActivity, iWinBoll.getTag() is %s" + iWinBoll.getTag()); | ||||
|                 mFirstIWinBollActivity = iWinBoll; | ||||
|             if (mFirstIWinBoLLActivity == null && _mapIWinBoLLList.size() == 0) { | ||||
|                 LogUtils.d(TAG, "Set firstIWinBoLLActivity, iWinBoLL.getTag() is %s" + iWinBoLL.getTag()); | ||||
|                 mFirstIWinBoLLActivity = iWinBoLL; | ||||
|             } | ||||
|  | ||||
|             // 添加到活动窗口列表 | ||||
|             _mapIWinBollList.put(iWinBoll.getTag(), iWinBoll); | ||||
|             LogUtils.d(TAG, String.format("Add activity : %s\n_mapActivityList.size() : %d", iWinBoll.getTag(), _mapIWinBollList.size())); | ||||
|             _mapIWinBoLLList.put(iWinBoLL.getTag(), iWinBoLL); | ||||
|             LogUtils.d(TAG, String.format("Add activity : %s\n_mapActivityList.size() : %d", iWinBoLL.getTag(), _mapIWinBoLLList.size())); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -93,16 +93,16 @@ public class WinBollActivityManager { | ||||
|     // activity: 不为 null 时, | ||||
|     // intent.putExtra 函数 "tag" 参数为 activity.getTag() | ||||
|     // | ||||
|     public <T extends IWinBollActivity> void startWinBollActivity(Context context, Class<T> clazz) { | ||||
|     public <T extends IWinBoLLActivity> void startWinBoLLActivity(Context context, Class<T> clazz) { | ||||
|         try { | ||||
|             // 如果窗口已存在就重启窗口 | ||||
|             String tag = ((IWinBollActivity)clazz.newInstance()).getTag(); | ||||
|             LogUtils.d(TAG, String.format("startWinBollActivity(Context context, Class<T> clazz) tag is %s", tag)); | ||||
|             String tag = ((IWinBoLLActivity)clazz.newInstance()).getTag(); | ||||
|             LogUtils.d(TAG, String.format("startWinBoLLActivity(Context context, Class<T> clazz) tag is %s", tag)); | ||||
|             if (isActive(tag)) { | ||||
|                 resumeActivity(context, tag); | ||||
|                 return; | ||||
|             } | ||||
|             //ToastUtils.show("startWinBollActivity(Context context, Class<T> clazz)"); | ||||
|             //ToastUtils.show("startWinBoLLActivity(Context context, Class<T> clazz)"); | ||||
|  | ||||
|             // 新建一个任务窗口 | ||||
|             Intent intent = new Intent(context, clazz); | ||||
| @@ -117,11 +117,11 @@ public class WinBollActivityManager { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public <T extends IWinBollActivity> void startWinBollActivity(Context context, Intent intent, Class<T> clazz) { | ||||
|     public <T extends IWinBoLLActivity> void startWinBoLLActivity(Context context, Intent intent, Class<T> clazz) { | ||||
|         try { | ||||
|             // 如果窗口已存在就重启窗口 | ||||
|             String tag = ((IWinBollActivity)clazz.newInstance()).getTag(); | ||||
|             LogUtils.d(TAG, String.format("startWinBollActivity(Context context, Intent intent, Class<T> clazz) tag is %s", tag)); | ||||
|             String tag = ((IWinBoLLActivity)clazz.newInstance()).getTag(); | ||||
|             LogUtils.d(TAG, String.format("startWinBoLLActivity(Context context, Intent intent, Class<T> clazz) tag is %s", tag)); | ||||
|             if (isActive(tag)) { | ||||
|                 resumeActivity(context, tag); | ||||
|                 return; | ||||
| @@ -140,7 +140,7 @@ public class WinBollActivityManager { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public <T extends IWinBollActivity> void startLogActivity(Context context) { | ||||
|     public <T extends IWinBoLLActivity> void startLogActivity(Context context) { | ||||
|         // 如果窗口已存在就重启窗口 | ||||
|         String tag = LogActivity.TAG; | ||||
|         if (isActive(tag)) { | ||||
| @@ -167,8 +167,8 @@ public class WinBollActivityManager { | ||||
|         context.startActivity(intent); | ||||
|     } | ||||
|  | ||||
|     public boolean isFirstIWinBollActivity(IWinBollActivity iWinBollActivity) { | ||||
|         return mFirstIWinBollActivity != null && mFirstIWinBollActivity == iWinBollActivity; | ||||
|     public boolean isFirstIWinBoLLActivity(IWinBoLLActivity iWinBoLLActivity) { | ||||
|         return mFirstIWinBoLLActivity != null && mFirstIWinBoLLActivity == iWinBoLLActivity; | ||||
|     } | ||||
|  | ||||
|     // | ||||
| @@ -176,15 +176,15 @@ public class WinBollActivityManager { | ||||
|     // | ||||
|     public boolean isActive(String tag) { | ||||
|         LogUtils.d(TAG, String.format("isActive(String tag) tag is %s", tag)); | ||||
|         //printIWinBollListInfo(); | ||||
|         IWinBollActivity iWinBoll = getIWinBoll(tag); | ||||
|         if (iWinBoll != null) { | ||||
|         //printIWinBoLLListInfo(); | ||||
|         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); | ||||
|             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 { | ||||
| @@ -192,44 +192,44 @@ public class WinBollActivityManager { | ||||
|                 return true; | ||||
|             } | ||||
|         } else { | ||||
|             LogUtils.d(TAG, String.format("isActive(...) iWinBoll is null tag by %s", tag)); | ||||
|             LogUtils.d(TAG, String.format("isActive(...) iWinBoLL is null tag by %s", tag)); | ||||
|             return false; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     static IWinBollActivity getIWinBoll(String tag) { | ||||
|         LogUtils.d(TAG, String.format("getIWinBoll(String tag) %s", tag)); | ||||
|         return _mapIWinBollList.get(tag); | ||||
|     static IWinBoLLActivity getIWinBoLL(String tag) { | ||||
|         LogUtils.d(TAG, String.format("getIWinBoLL(String tag) %s", tag)); | ||||
|         return _mapIWinBoLLList.get(tag); | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台 | ||||
|     // | ||||
|     public <T extends IWinBollActivity> void resumeActivity(Context context, String tag) { | ||||
|     public <T extends IWinBoLLActivity> void resumeActivity(Context context, String tag) { | ||||
|         LogUtils.d(TAG, "resumeActivity(Context context, String tag)"); | ||||
|         T iWinBoll = (T)getIWinBoll(tag); | ||||
|         LogUtils.d(TAG, String.format("iWinBoll.getTag() %s", iWinBoll.getTag())); | ||||
|         T iWinBoLL = (T)getIWinBoLL(tag); | ||||
|         LogUtils.d(TAG, String.format("iWinBoLL.getTag() %s", iWinBoLL.getTag())); | ||||
|         //LogUtils.d(TAG, "activity " + activity.getTag()); | ||||
|         if (iWinBoll != null && !iWinBoll.getActivity().isFinishing() && !iWinBoll.getActivity().isDestroyed()) { | ||||
|             resumeActivity(context, iWinBoll); | ||||
|         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) { | ||||
|         LogUtils.d(TAG, "resumeActivity(Context context, T iWinBoll)"); | ||||
|     public <T extends IWinBoLLActivity> void resumeActivity(Context context, T iWinBoLL) { | ||||
|         LogUtils.d(TAG, "resumeActivity(Context context, T iWinBoLL)"); | ||||
|         ActivityManager am = (ActivityManager) mGlobalApplication.getSystemService(Context.ACTIVITY_SERVICE); | ||||
|         //返回启动它的根任务(home 或者 MainActivity) | ||||
|         Intent intent = new Intent(mGlobalApplication, iWinBoll.getClass()); | ||||
|         Intent intent = new Intent(mGlobalApplication, iWinBoLL.getClass()); | ||||
|         TaskStackBuilder stackBuilder = TaskStackBuilder.create(mGlobalApplication); | ||||
|         stackBuilder.addNextIntentWithParentStack(intent); | ||||
|         stackBuilder.startActivities(); | ||||
|         //moveTaskToFront(YourTaskId, 0); | ||||
|         //ToastUtils.show("resumeActivity am.moveTaskToFront"); | ||||
|         LogUtils.d(TAG, String.format("iWinBoll.getActivity().getTaskId() %d", iWinBoll.getActivity().getTaskId())); | ||||
|         am.moveTaskToFront(iWinBoll.getActivity().getTaskId(), ActivityManager.MOVE_TASK_NO_USER_ACTION); | ||||
|         LogUtils.d(TAG, String.format("iWinBoLL.getActivity().getTaskId() %d", iWinBoLL.getActivity().getTaskId())); | ||||
|         am.moveTaskToFront(iWinBoLL.getActivity().getTaskId(), ActivityManager.MOVE_TASK_NO_USER_ACTION); | ||||
|         LogUtils.d(TAG, "am.moveTaskToFront"); | ||||
|     } | ||||
|  | ||||
| @@ -239,23 +239,23 @@ public class WinBollActivityManager { | ||||
|     // | ||||
|     public void finishAll() { | ||||
|         try { | ||||
|             for (String key : _mapIWinBollList.keySet()) { | ||||
|             for (String key : _mapIWinBoLLList.keySet()) { | ||||
|                 //System.out.println("Key: " + key + ", Value: " + _mapActivityList.get(key)); | ||||
|                 IWinBollActivity iWinBoll = _mapIWinBollList.get(key); | ||||
|                 IWinBoLLActivity iWinBoLL = _mapIWinBoLLList.get(key); | ||||
|                 //ToastUtils.show("finishAll() activity"); | ||||
|                 if (iWinBoll != null && !iWinBoll.getActivity().isFinishing() && !iWinBoll.getActivity().isDestroyed()) { | ||||
|                 if (iWinBoLL != null && !iWinBoLL.getActivity().isFinishing() && !iWinBoLL.getActivity().isDestroyed()) { | ||||
|                     //ToastUtils.show("activity != null ..."); | ||||
|                     if (getWinBollUI_TYPE() == WinBollUI_TYPE.Service) { | ||||
|                     if (getWinBoLLUI_TYPE() == WinBoLLUI_TYPE.Service) { | ||||
|                         // 结束窗口和最近任务栏, 建议前台服务类应用使用,可以方便用户再次调用 UI 操作。 | ||||
|                         iWinBoll.getActivity().finishAndRemoveTask(); | ||||
|                         iWinBoLL.getActivity().finishAndRemoveTask(); | ||||
|                         //ToastUtils.show("finishAll() activity.finishAndRemoveTask();"); | ||||
|                     } else if (getWinBollUI_TYPE() == WinBollUI_TYPE.Aplication) { | ||||
|                     } else if (getWinBoLLUI_TYPE() == WinBoLLUI_TYPE.Aplication) { | ||||
|                         // 结束窗口保留最近任务栏,建议前台服务类应用使用,可以保持应用的系统自觉性。 | ||||
|                         iWinBoll.getActivity().finish(); | ||||
|                         iWinBoLL.getActivity().finish(); | ||||
|                         //ToastUtils.show("finishAll() activity.finish();"); | ||||
|                     } else { | ||||
|                         LogUtils.d(TAG, "WinBollApplication.WinBollUI_TYPE error."); | ||||
|                         //ToastUtils.show("WinBollApplication.WinBollUI_TYPE error."); | ||||
|                         LogUtils.d(TAG, "WinBoLLApplication.WinBoLLUI_TYPE error."); | ||||
|                         //ToastUtils.show("WinBoLLApplication.WinBoLLUI_TYPE error."); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
| @@ -267,14 +267,14 @@ public class WinBollActivityManager { | ||||
|     // | ||||
|     // 结束指定Activity | ||||
|     // | ||||
|     public <T extends IWinBollActivity> void finish(T iWinBoll) { | ||||
|     public <T extends IWinBoLLActivity> void finish(T iWinBoLL) { | ||||
|         try { | ||||
|             if (iWinBoll != null && !iWinBoll.getActivity().isFinishing() && !iWinBoll.getActivity().isDestroyed()) { | ||||
|             if (iWinBoLL != null && !iWinBoLL.getActivity().isFinishing() && !iWinBoLL.getActivity().isDestroyed()) { | ||||
|                 //根据tag 移除 MyActivity | ||||
|                 //String tag= activity.getTag(); | ||||
|                 //_mWinBollActivityList.remove(tag); | ||||
|                 //_mWinBoLLActivityList.remove(tag); | ||||
|                 //ToastUtils.show("remove"); | ||||
|                 //ToastUtils.show("_mWinBollActivityArrayMap.size() " + Integer.toString(_mWinBollActivityArrayMap.size())); | ||||
|                 //ToastUtils.show("_mWinBoLLActivityArrayMap.size() " + Integer.toString(_mWinBoLLActivityArrayMap.size())); | ||||
|  | ||||
|                 // 窗口回调规则: | ||||
|                 // [] 当前窗口位置 >> 调度出的窗口位置 | ||||
| @@ -284,10 +284,10 @@ public class WinBollActivityManager { | ||||
|                 // ★:0 1 2 3 [4] >> 3 | ||||
|                 // ★:[0] >> 直接关闭当前窗口 | ||||
|                 //LogUtils.d(TAG, "finish no yet."); | ||||
|                 IWinBollActivity preIWinBoll = getPreIWinBoll(iWinBoll); | ||||
|                 iWinBoll.getActivity().finish(); | ||||
|                 if (preIWinBoll != null) { | ||||
|                     resumeActivity(mGlobalApplication, preIWinBoll); | ||||
|                 IWinBoLLActivity preIWinBoLL = getPreIWinBoLL(iWinBoLL); | ||||
|                 iWinBoLL.getActivity().finish(); | ||||
|                 if (preIWinBoLL != null) { | ||||
|                     resumeActivity(mGlobalApplication, preIWinBoLL); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
| @@ -299,21 +299,21 @@ public class WinBollActivityManager { | ||||
|     // | ||||
|     // 获取窗口队列中的前一个窗口 | ||||
|     // | ||||
|     IWinBollActivity getPreIWinBoll(IWinBollActivity iWinBoll) { | ||||
|     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())) { | ||||
|             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(); | ||||
|                 preIWinBoLL = entity.getValue(); | ||||
|             } | ||||
|  | ||||
|             if (bingo) { | ||||
|                 return preIWinBoll; | ||||
|                 return preIWinBoLL; | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); | ||||
| @@ -325,10 +325,10 @@ public class WinBollActivityManager { | ||||
|     // | ||||
|     // 从管理列表中移除管理项 | ||||
|     // | ||||
|     public <T extends IWinBollActivity> boolean registeRemove(T activity) { | ||||
|         IWinBollActivity iWinBollTest = _mapIWinBollList.get(activity.getTag()); | ||||
|         if (iWinBollTest != null) { | ||||
|             _mapIWinBollList.remove(activity.getTag()); | ||||
|     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; | ||||
| @@ -337,13 +337,13 @@ public class WinBollActivityManager { | ||||
|     // | ||||
|     // 打印管理列表项列表里的信息 | ||||
|     // | ||||
|     public static void printIWinBollListInfo() { | ||||
|     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(); | ||||
|         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(); | ||||
|                 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()); | ||||
|             } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 ZhanGSKen
					ZhanGSKen