feat: 重构下载按钮的实现 https://git.shanqu.cc/halo/android/assistant-android/-/issues/75
This commit is contained in:
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user