This commit is contained in:
叶子维
2022-08-11 11:17:39 +08:00
parent 2ce35ab8a5
commit ab01fac150
33 changed files with 493 additions and 272 deletions

View File

@ -5,6 +5,7 @@ import android.graphics.Color;
import android.text.TextUtils;
import android.widget.TextView;
import com.gh.common.view.DownloadButton;
import com.gh.gamecenter.core.AppExecutor;
import com.gh.common.constant.Config;
import com.gh.common.simulator.SimulatorGameManager;
@ -55,20 +56,19 @@ public class GameUtils {
/**
* 设置下载按钮状态
*/
public static void setDownloadBtnStatus(Context context, GameEntity gameEntity, TextView downloadBtn, PluginLocation pluginLocation) {
public static void setDownloadBtnStatus(Context context, GameEntity gameEntity, DownloadButton downloadBtn, PluginLocation pluginLocation) {
// getDownloadBtnText 里包括查询数据库、根据包名读取包体 meta 信息等
AppExecutor.getLightWeightIoExecutor().execute(() -> {
String status = getDownloadBtnText(context, gameEntity, pluginLocation);
AppExecutor.getUiExecutor().execute(() -> {
downloadBtn.setTextColor(Color.WHITE);
downloadBtn.setText(status);
if (context.getString(R.string.pluggable).equals(status)) {
downloadBtn.setBackgroundResource(R.drawable.download_button_pluggable_style);
downloadBtn.setButtonStyle(DownloadButton.ButtonStyle.PLUGIN);
String pluginDesc = gameEntity.getPluginDesc();
if (pluginDesc.length() > 3) pluginDesc = pluginDesc.substring(0, 3);
downloadBtn.setText((pluginDesc + ""));
} else {
downloadBtn.setBackgroundResource(R.drawable.download_button_normal_style);
downloadBtn.setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
}
});
});