重构磁贴状态更新方法
This commit is contained in:
		| @@ -1,8 +1,8 @@ | ||||
| #Created by .winboll/winboll_app_build.gradle | ||||
| #Tue Apr 15 09:08:44 GMT 2025 | ||||
| #Tue Apr 15 09:22:19 GMT 2025 | ||||
| stageCount=1 | ||||
| libraryProject= | ||||
| baseVersion=15.2 | ||||
| publishVersion=15.2.0 | ||||
| buildCount=40 | ||||
| buildCount=54 | ||||
| baseBetaVersion=15.2.1 | ||||
|   | ||||
| @@ -17,53 +17,27 @@ public class AppBaseTileService extends TileService { | ||||
|     public void onStartListening() { | ||||
|         super.onStartListening(); | ||||
|         Tile tile = getQsTile(); | ||||
|  | ||||
|         if (AppConfigs.getInstance(AppBaseTileService.this).isEnableService()) { | ||||
|             tile.setState(Tile.STATE_ACTIVE); | ||||
|             tile.setIcon(android.graphics.drawable.Icon.createWithResource(this, R.drawable.ic_android)); | ||||
|         } else { | ||||
|             tile.setState(Tile.STATE_INACTIVE); | ||||
|             tile.setIcon(android.graphics.drawable.Icon.createWithResource(this, R.drawable.ic_android)); | ||||
|         } | ||||
|         tile.setIcon(android.graphics.drawable.Icon.createWithResource(this, R.drawable.ic_android)); | ||||
|         // 更新磁贴状态 | ||||
|         tile.setState(AppConfigs.getInstance(getApplicationContext()).isEnableService()?Tile.STATE_ACTIVE: Tile.STATE_INACTIVE); | ||||
|         tile.updateTile(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onClick() { | ||||
|         super.onClick(); | ||||
|         Tile tile = getQsTile(); | ||||
|  | ||||
|         if (tile.getState() == Tile.STATE_ACTIVE) { | ||||
|             AppConfigs.getInstance(AppBaseTileService.this).setIsEnableService(false); | ||||
|             AppConfigs.getInstance(AppBaseTileService.this).saveAppConfigs(); | ||||
|             MainActivity.stopMainService(); | ||||
|         } else if (tile.getState() == Tile.STATE_INACTIVE) { | ||||
|             AppConfigs.getInstance(AppBaseTileService.this).setIsEnableService(true); | ||||
|             AppConfigs.getInstance(AppBaseTileService.this).saveAppConfigs(); | ||||
|             MainActivity.startMainService(); | ||||
|         } | ||||
|  | ||||
|         // 更新磁贴状态 | ||||
|         //updateServiceIconStatus(this); | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 更新磁贴状态 | ||||
|     // | ||||
| //    public static void updateServiceIconStatus(Context context) { | ||||
| //        if (_AppBaseTileService == null) { | ||||
| //            return; | ||||
| //        } | ||||
| //        Tile tile = getQsTile(); | ||||
| // | ||||
| //        Tile tile = _AppBaseTileService.getQsTile(); | ||||
| //        MainServiceBean bean = MainServiceBean.loadBean(context, MainServiceBean.class); | ||||
| //        if (bean != null && bean.isEnable()) { | ||||
| //            tile.setState(Tile.STATE_ACTIVE); | ||||
| //            tile.setIcon(android.graphics.drawable.Icon.createWithResource(context, R.drawable.ic_cloud)); | ||||
| //        } else { | ||||
| //        if (tile.getState() == Tile.STATE_ACTIVE) { | ||||
| //            tile.setState(Tile.STATE_INACTIVE); | ||||
| //            tile.setIcon(android.graphics.drawable.Icon.createWithResource(context, R.drawable.ic_cloud_outline)); | ||||
| //            AppConfigs.getInstance(AppBaseTileService.this).setIsEnableService(false); | ||||
| //            AppConfigs.getInstance(AppBaseTileService.this).saveAppConfigs(); | ||||
| //            MainActivity.stopMainService(); | ||||
| //        } else if (tile.getState() == Tile.STATE_INACTIVE) { | ||||
| //            tile.setState(Tile.STATE_ACTIVE); | ||||
| //            AppConfigs.getInstance(AppBaseTileService.this).setIsEnableService(true); | ||||
| //            AppConfigs.getInstance(AppBaseTileService.this).saveAppConfigs(); | ||||
| //            MainActivity.startMainService(); | ||||
| //        } | ||||
| //        tile.updateTile(); | ||||
| //    } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 ZhanGSKen
					ZhanGSKen