feat: show DeepSeek balance prominently on phone main screen
This commit is contained in:
@@ -14,6 +14,7 @@ import org.json.JSONObject;
|
|||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private TextView status;
|
private TextView status;
|
||||||
|
private TextView balanceView;
|
||||||
private ServerClient serverClient;
|
private ServerClient serverClient;
|
||||||
private WatchBridge watchBridge;
|
private WatchBridge watchBridge;
|
||||||
private boolean balancePending = false;
|
private boolean balancePending = false;
|
||||||
@@ -24,6 +25,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
status = findViewById(R.id.status_text);
|
status = findViewById(R.id.status_text);
|
||||||
|
balanceView = findViewById(R.id.balance_text);
|
||||||
|
|
||||||
// 服务器客户端
|
// 服务器客户端
|
||||||
serverClient = new ServerClient(new ServerClient.Listener() {
|
serverClient = new ServerClient(new ServerClient.Listener() {
|
||||||
@@ -69,7 +71,10 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
double total = (infos != null && infos.length() > 0 && infos.optJSONObject(0) != null)
|
double total = (infos != null && infos.length() > 0 && infos.optJSONObject(0) != null)
|
||||||
? infos.optJSONObject(0).optDouble("total_balance", 0.0) : 0.0;
|
? infos.optJSONObject(0).optDouble("total_balance", 0.0) : 0.0;
|
||||||
String balance = String.format("%.2f", total);
|
String balance = String.format("%.2f", total);
|
||||||
runOnUiThread(() -> status.setText("余额 ¥ " + balance));
|
runOnUiThread(() -> {
|
||||||
|
status.setText("余额 ¥ " + balance);
|
||||||
|
balanceView.setText("DeepSeek 余额 ¥" + balance);
|
||||||
|
});
|
||||||
JSONObject payload = new JSONObject();
|
JSONObject payload = new JSONObject();
|
||||||
try { payload.put("balance", balance); } catch (Exception e) {}
|
try { payload.put("balance", balance); } catch (Exception e) {}
|
||||||
JSONObject msg = new JSONObject();
|
JSONObject msg = new JSONObject();
|
||||||
|
|||||||
@@ -24,6 +24,16 @@
|
|||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/balance_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="DeepSeek 余额 ¥--"
|
||||||
|
android:textColor="#33B4FF"
|
||||||
|
android:textSize="28sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_refresh"
|
android:id="@+id/btn_refresh"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
Reference in New Issue
Block a user