From 93a2ee24d32627cc3cc3c64849be7146f572c21c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B6=9B?= Date: Mon, 27 Apr 2020 17:26:36 +0800 Subject: [PATCH] android:change dev disconnect action --- .../pub/doric/devkit/ui/DoricDevActivity.java | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricDevActivity.java b/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricDevActivity.java index 7eb140cc..64fac4fe 100644 --- a/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricDevActivity.java +++ b/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricDevActivity.java @@ -5,9 +5,8 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.os.Bundle; import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuItem; import android.view.View; +import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; @@ -40,9 +39,9 @@ public class DoricDevActivity extends AppCompatActivity { protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); EventBus.getDefault().register(this); - + setContentView(R.layout.layout_debug_context); + initDisconnect(); if (DoricDev.getInstance().isInDevMode()) { - setContentView(R.layout.layout_debug_context); initViews(); } else { if (DevKit.isRunningInEmulator) { @@ -65,27 +64,10 @@ public class DoricDevActivity extends AppCompatActivity { } } - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.doric_devkit_menu, menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - int id = item.getItemId(); - if (id == R.id.doric_action_disconnect) { - DoricDev.getInstance().closeDevMode(); - finish(); - return true; - } - return super.onOptionsItemSelected(item); - } @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); - if (requestCode == 1) { for (int i = 0; i < permissions.length; i++) { if (grantResults[i] == PackageManager.PERMISSION_GRANTED) { @@ -105,7 +87,6 @@ public class DoricDevActivity extends AppCompatActivity { @Subscribe(threadMode = ThreadMode.MAIN) public void onOpenEvent(OpenEvent openEvent) { - setContentView(R.layout.layout_debug_context); initViews(); } @@ -119,10 +100,22 @@ public class DoricDevActivity extends AppCompatActivity { finish(); } + private void initDisconnect(){ + LinearLayout container = findViewById(R.id.container); + Button button=new Button(this); + button.setText("断开连接"); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + DoricDev.getInstance().closeDevMode(); + finish(); + } + }); + container.addView(button); + } private void initViews() { LinearLayout container = findViewById(R.id.container); LayoutInflater inflater = LayoutInflater.from(this); - for (final DoricContext doricContext : DoricContextManager.aliveContexts()) { View cell = inflater.inflate(R.layout.layout_debug_context_cell, container, false);