android:Optimize DoricDev context list UI
This commit is contained in:
parent
37222a25d8
commit
f3d66b6113
@ -13,6 +13,7 @@ import java.io.EOFException;
|
|||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import pub.doric.Doric;
|
import pub.doric.Doric;
|
||||||
import pub.doric.DoricContext;
|
import pub.doric.DoricContext;
|
||||||
@ -30,10 +31,16 @@ public class DoricDev {
|
|||||||
void onClose(String url);
|
void onClose(String url);
|
||||||
|
|
||||||
void onFailure(Throwable throwable);
|
void onFailure(Throwable throwable);
|
||||||
|
|
||||||
|
void onReload(DoricContext context, String source);
|
||||||
|
|
||||||
|
void onStartDebugging(DoricContext context);
|
||||||
|
|
||||||
|
void onStopDebugging();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Set<StatusCallback> callbacks = new HashSet<>();
|
private final Set<StatusCallback> callbacks = new HashSet<>();
|
||||||
|
private final WeakHashMap<String, DoricContext> reloadingContexts = new WeakHashMap<>();
|
||||||
public final boolean isRunningInEmulator;
|
public final boolean isRunningInEmulator;
|
||||||
private final Handler uiHandler = new Handler(Looper.getMainLooper());
|
private final Handler uiHandler = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
@ -109,7 +116,7 @@ public class DoricDev {
|
|||||||
if (debuggable != null) {
|
if (debuggable != null) {
|
||||||
debuggable.stopDebug(true);
|
debuggable.stopDebug(true);
|
||||||
}
|
}
|
||||||
DoricContext context = matchContext(source);
|
final DoricContext context = matchContext(source);
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
DoricLog.d("Cannot find context source %s for debugging", source);
|
DoricLog.d("Cannot find context source %s for debugging", source);
|
||||||
wsClient.sendToDebugger("DEBUG_STOP", new JSONBuilder()
|
wsClient.sendToDebugger("DEBUG_STOP", new JSONBuilder()
|
||||||
@ -123,6 +130,14 @@ public class DoricDev {
|
|||||||
.toJSONObject());
|
.toJSONObject());
|
||||||
debuggable = new DoricContextDebuggable(wsClient, context);
|
debuggable = new DoricContextDebuggable(wsClient, context);
|
||||||
debuggable.startDebug();
|
debuggable.startDebug();
|
||||||
|
uiHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (StatusCallback callback : callbacks) {
|
||||||
|
callback.onStartDebugging(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,6 +148,14 @@ public class DoricDev {
|
|||||||
if (debuggable != null) {
|
if (debuggable != null) {
|
||||||
debuggable.stopDebug(resume);
|
debuggable.stopDebug(resume);
|
||||||
debuggable = null;
|
debuggable = null;
|
||||||
|
uiHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (StatusCallback callback : callbacks) {
|
||||||
|
callback.onStopDebugging();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,8 +213,8 @@ public class DoricDev {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reload(String source, String script) {
|
public void reload(String source, final String script) {
|
||||||
DoricContext context = matchContext(source);
|
final DoricContext context = matchContext(source);
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
DoricLog.d("Cannot find context source %s for reload", source);
|
DoricLog.d("Cannot find context source %s for reload", source);
|
||||||
} else if (context.getDriver() instanceof DoricDebugDriver) {
|
} else if (context.getDriver() instanceof DoricDebugDriver) {
|
||||||
@ -199,6 +222,22 @@ public class DoricDev {
|
|||||||
} else {
|
} else {
|
||||||
DoricLog.d("Context reload :id %s,source %s ", context.getContextId(), source);
|
DoricLog.d("Context reload :id %s,source %s ", context.getContextId(), source);
|
||||||
context.reload(script);
|
context.reload(script);
|
||||||
|
if (reloadingContexts.get(context.getContextId()) == null) {
|
||||||
|
reloadingContexts.put(context.getContextId(), context);
|
||||||
|
}
|
||||||
|
uiHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (StatusCallback callback : callbacks) {
|
||||||
|
callback.onReload(context, script);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isReloadingContext(DoricContext context) {
|
||||||
|
return reloadingContexts.get(context.getContextId()) != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,14 @@ import android.content.pm.PackageManager;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -23,9 +24,15 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import pub.doric.Doric;
|
||||||
import pub.doric.DoricContext;
|
import pub.doric.DoricContext;
|
||||||
import pub.doric.DoricContextManager;
|
import pub.doric.DoricContextManager;
|
||||||
|
import pub.doric.devkit.DoricDebugDriver;
|
||||||
import pub.doric.devkit.DoricDev;
|
import pub.doric.devkit.DoricDev;
|
||||||
import pub.doric.devkit.R;
|
import pub.doric.devkit.R;
|
||||||
import pub.doric.devkit.qrcode.DisplayUtil;
|
import pub.doric.devkit.qrcode.DisplayUtil;
|
||||||
@ -34,15 +41,22 @@ import pub.doric.devkit.qrcode.activity.CodeUtils;
|
|||||||
|
|
||||||
public class DoricDevActivity extends AppCompatActivity implements DoricDev.StatusCallback {
|
public class DoricDevActivity extends AppCompatActivity implements DoricDev.StatusCallback {
|
||||||
private int REQUEST_CODE = 100;
|
private int REQUEST_CODE = 100;
|
||||||
private String debug_off = "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAANJElEQVR4Xu2dW4hdVxnHv7UnFwlI1KpgBa1FK5ZGNLFtohFa8qJSxbbWgFWQPgzShznrTKIJ0mamglimTvbak4h0fAioLSVqfagaS72hbUzSGrEqotQGFfQlDYaaG87ZS/bkjM1tZvZZl7O/vb7/gWGmzV5rfev3X7+z9jn7XBThBgIgsCgBBTYgAAKLE4AgWB0gsAQBCILlAQIQBGsABNwIYAdx44ZWQghAECFBY5puBCCIGze0EkIAgggJGtN0IwBB3LihlRACogXRWk9UORtjHhCS90DTBB8isYL0w5/sr5hJSHKxO+BznodIQS4Jf2FlQJI+CfB55c5CnCCLhA9JlpZDLB9Rgiwjh9hFsDBx8Ln8IZoYQWqGL1YSrXX1eGz+SYsaNzGnoyIEGVAOcZIMKIcoPskL4iiHmEXgKIcYPkkL4ilH8ovAU47k+ST9NG8gOZJdBIHkSJbPwsSS3EECy5HcIggsx/kLakpN5Hn+pRoP8Ft1SHKCRJIjGUliyPH/e9sEJUlKkMhytF6SmHIswLHWThRFkcxOkowgQ5KjtZIMQ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7yHK80N3GCVBC63e77iOgRa+110gJ3nG8yLz4cdP4iBelLso6ICmvtrYNCE3Z8ci8fGSQ/sYIsQOp0OvdlWXa/tRanXBevnKeJaCKlFx4OIsbCseIFqUBorTdZa3cppT7kAjG1NtbaB8+cObMrlZes++QDQS6gp7XeTkS7iCj5C2CLLJrnyrKcmJmZ+ZHPokqpLQS5JE2t9Xoiup+IPp5S0MvNpXqWavXq1RNtfw/5cvMc9N8hyCLExsfHbyvLcpSIPjoo1JYdP1uW5ezMzMxvWlb3UMqFIMtgTlgUiFFDMQhSA1J1SEKiQIyamVeHQZABYPWf8fowES38tOWl3oeJ6EBZlj/AqdRggUOQwXhddLTWmrMs81JYa39cFEX1N24OBCCIA7QrNblAlurK/A2Buh2kmzkiepaInlRKHcjz/MggjXHslQlAkAgro9vtXluW5Ual1I1EdGP1O8KV+peI6IhS6llr7ZGRkZHD09PTxyNMR3SXEGQI8U9OTmYnTpzYmGXZRiJ6ExG9Rim11lq7tvqbiOZ/V/+vLMuqon8v9pNl2Qu9Xu/wzMzMH4ZQuvghIIj4JQAASxGAIFgfILAEAQiC5QECEARrAATcCGAHceOGVkIIQBAhQWOabgQgiBs3tBJCAIIICRrTdCMAQdy4oZUQAhBESNCYphuB/wHykpIURkXLcgAAAABJRU5ErkJggg==";
|
private ContextCellAdapter cellAdapter;
|
||||||
private String debug_on = "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAANhElEQVR4Xu2dX4xcVR3Hv787ocxdJAVRE0siWHYWJdRoy7/idmcLL2LACIgkoonhoTE8oDaoiQG6mBhMkCAmxlAfSFQIQcUH/1SCsju7gLQUDKjR7p3S+CftS0lWW/buqjs/M7NsKbTdvXPPuXvPPee7L33oPef8fp/v+ew9e3dmR8AvEiCBUxIQsiEBEjg1AQrC3UECyxCgINweJEBBuAdIIB8B3kHyceOoQAhQkECCZpv5CFCQfNw4KhACFCSQoNlmPgIUJB83jgqEQNCCDLbqO7o5t5tz9wSSd19tkg8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JAAAAABJRU5ErkJggg==";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
DisplayUtil.initDisplayOpinion(getApplicationContext());
|
DisplayUtil.initDisplayOpinion(getApplicationContext());
|
||||||
setContentView(R.layout.layout_debug_context);
|
setContentView(R.layout.layout_debug_context);
|
||||||
initViews();
|
initHeaders();
|
||||||
|
initList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initList() {
|
||||||
|
RecyclerView recyclerView = findViewById(R.id.list);
|
||||||
|
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||||
|
this.cellAdapter = new ContextCellAdapter();
|
||||||
|
recyclerView.setAdapter(this.cellAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -86,12 +100,7 @@ public class DoricDevActivity extends AppCompatActivity implements DoricDev.Stat
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Bitmap getIcon(String str) {
|
private void initHeaders() {
|
||||||
byte[] data = Base64.decode(str, Base64.DEFAULT);
|
|
||||||
return BitmapFactory.decodeByteArray(data, 0, data.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initViews() {
|
|
||||||
TextView tvConnection = findViewById(R.id.tv_connect_info);
|
TextView tvConnection = findViewById(R.id.tv_connect_info);
|
||||||
TextView tvInput = findViewById(R.id.tv_input);
|
TextView tvInput = findViewById(R.id.tv_input);
|
||||||
TextView tvScan = findViewById(R.id.tv_scan);
|
TextView tvScan = findViewById(R.id.tv_scan);
|
||||||
@ -167,37 +176,123 @@ public class DoricDevActivity extends AppCompatActivity implements DoricDev.Stat
|
|||||||
DoricDev.getInstance().closeDevMode();
|
DoricDev.getInstance().closeDevMode();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
LinearLayout container = findViewById(R.id.container);
|
|
||||||
LayoutInflater inflater = LayoutInflater.from(this);
|
|
||||||
Bitmap icon_off = getIcon(debug_off);
|
|
||||||
Bitmap icon_on = getIcon(debug_on);
|
|
||||||
container.removeAllViews();
|
|
||||||
for (final DoricContext doricContext : DoricContextManager.aliveContexts()) {
|
|
||||||
View cell = inflater.inflate(R.layout.layout_debug_context_cell, container, false);
|
|
||||||
|
|
||||||
TextView contextIdTextView = cell.findViewById(R.id.context_id_text_view);
|
|
||||||
contextIdTextView.setText(doricContext.getContextId());
|
|
||||||
|
|
||||||
TextView sourceTextView = cell.findViewById(R.id.source_text_view);
|
|
||||||
sourceTextView.setText(doricContext.getSource());
|
|
||||||
ImageView imageView = cell.findViewById(R.id.icon_debug);
|
|
||||||
imageView.setImageBitmap(icon_on);
|
|
||||||
container.addView(cell);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOpen(String url) {
|
public void onOpen(String url) {
|
||||||
initViews();
|
initHeaders();
|
||||||
|
this.cellAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClose(String url) {
|
public void onClose(String url) {
|
||||||
initViews();
|
initHeaders();
|
||||||
|
this.cellAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable throwable) {
|
public void onFailure(Throwable throwable) {
|
||||||
initViews();
|
initHeaders();
|
||||||
|
this.cellAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReload(DoricContext context, String source) {
|
||||||
|
this.cellAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartDebugging(DoricContext context) {
|
||||||
|
this.cellAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStopDebugging() {
|
||||||
|
this.cellAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ContextCellHolder extends RecyclerView.ViewHolder {
|
||||||
|
public TextView tvId;
|
||||||
|
public TextView tvSource;
|
||||||
|
public ImageView ivDebug;
|
||||||
|
public View layoutBtn;
|
||||||
|
|
||||||
|
public ContextCellHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ContextCellAdapter extends RecyclerView.Adapter<ContextCellHolder> {
|
||||||
|
private final ArrayList<DoricContext> contexts = new ArrayList<>();
|
||||||
|
private Bitmap icon_off;
|
||||||
|
private Bitmap icon_on;
|
||||||
|
private String debug_off = "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAANJElEQVR4Xu2dW4hdVxnHv7UnFwlI1KpgBa1FK5ZGNLFtohFa8qJSxbbWgFWQPgzShznrTKIJ0mamglimTvbak4h0fAioLSVqfagaS72hbUzSGrEqotQGFfQlDYaaG87ZS/bkjM1tZvZZl7O/vb7/gWGmzV5rfev3X7+z9jn7XBThBgIgsCgBBTYgAAKLE4AgWB0gsAQBCILlAQIQBGsABNwIYAdx44ZWQghAECFBY5puBCCIGze0EkIAgggJGtN0IwBB3LihlRACogXRWk9UORtjHhCS90DTBB8isYL0w5/sr5hJSHKxO+BznodIQS4Jf2FlQJI+CfB55c5CnCCLhA9JlpZDLB9Rgiwjh9hFsDBx8Ln8IZoYQWqGL1YSrXX1eGz+SYsaNzGnoyIEGVAOcZIMKIcoPskL4iiHmEXgKIcYPkkL4ilH8ovAU47k+ST9NG8gOZJdBIHkSJbPwsSS3EECy5HcIggsx/kLakpN5Hn+pRoP8Ft1SHKCRJIjGUliyPH/e9sEJUlKkMhytF6SmHIswLHWThRFkcxOkowgQ5KjtZIMQ44UJUlJkEEudIU4D27NxbJhytEH2xo2yy2EZASpJoqFcHncYLKcAkv/e1KCQJKLw4YcfnIkex0ECwO7qb8a53tIbgdZACNZEslzDy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V+xQsP78Gx+ujEsm4n92505UInp0eSYfdqchuJd4K0sU01IpvVuAxu8g42zECiv3JaDroMxGvBekdtybi2yF40OcQS+rtaNJMzyxp7VVb1ntBuiQHW/HXBPjWqlH1f6HXkmYaxM93QQjSu5NMxjdC8VP/927hHe5Jmunlha/iyALBCNL7mWSyfrWq/NYR9lUs49GkmQb1cp6gBOlJMl4f1pr8Doo1VdyhZdUsigemR9PtZa1f1rrBCdIFfeEzA5doRx9RxVBZ4Ku0rorc2/bkxYf9cg9SkC6kD7TO2NBB50EFtvYLLaTrfXz5SD/5BSvIEqRGq34nRO7ikett20bwTKS6w6cXHvYjxtK1wQvSeww8EW+OoHeryMfyQPRtTPeR+JlnpHf78pJ1k3woyHH0Gq34DgB3A/D+F2An2zQK7I0gO6abs7822VQ+jaUgb0tzcHJgI6B3ieKTPgW9Ui8ieECidEfV30O+Up/9/j8FOQWxxtTAtejoNgDX9Qu1Wtfrzs5CtHP/VbMvVqvu1amWgqzA2V9RKEYWxShIFkrdl6p4c0fRnZ0o2rl/C+8YWaKnIFkoHXfN0MTANQq9BsA1EFTjpd6C3aq6S6PolxSjv8ApSH+83nK147LsVuguWZDfJFeluw3aDHooBbEU/zFZRLcCcrGlafuZ5n8AXlDok5HIrumRdE8/g3ntyQlQkAJ2RmOqvh4duQLApQpcKoJLrf+mXvGaiu6JJHpBgT2yUNs9vfXI4QLaCXpKCrIa8SuiCybjK0RxhQjeq6pnRZGsVZW1gJ4FwVp0sPgven8oYEaBGQAzIjqjkBlAZ0RlpgNpayfavX/r0T+tRumhr0FBQt8B7H9ZAhSEG4QEliFAQbg9SICCcA+QQD4CvIPk48ZRgRCgIIEEzTbzEaAg+bhxVCAEKEggQbPNfAQoSD5uHBUIAQoSSNBsMx+B/wNQA1oj5tl0JAAAAABJRU5ErkJggg==";
|
||||||
|
|
||||||
|
private ContextCellAdapter() {
|
||||||
|
this.contexts.addAll(DoricContextManager.aliveContexts());
|
||||||
|
this.icon_off = getIcon(debug_off);
|
||||||
|
this.icon_on = getIcon(debug_on);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bitmap getIcon(String str) {
|
||||||
|
byte[] data = Base64.decode(str, Base64.DEFAULT);
|
||||||
|
return BitmapFactory.decodeByteArray(data, 0, data.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public ContextCellHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
View cell = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_debug_context_cell, parent, false);
|
||||||
|
ContextCellHolder cellHolder = new ContextCellHolder(cell);
|
||||||
|
cellHolder.tvId = cell.findViewById(R.id.context_id_text_view);
|
||||||
|
cellHolder.tvSource = cell.findViewById(R.id.source_text_view);
|
||||||
|
cellHolder.ivDebug = cell.findViewById(R.id.icon_debug);
|
||||||
|
cellHolder.layoutBtn = cell.findViewById(R.id.layout_btn);
|
||||||
|
return cellHolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull final ContextCellHolder holder, int position) {
|
||||||
|
final DoricContext context = contexts.get(position);
|
||||||
|
holder.tvId.setText(context.getContextId());
|
||||||
|
holder.tvSource.setText(context.getSource());
|
||||||
|
holder.ivDebug.setImageBitmap(DoricDev.getInstance().isInDevMode() ? icon_on : icon_off);
|
||||||
|
holder.itemView.setBackgroundColor(position % 2 == 0 ? Color.parseColor("#ecf0f1") : Color.parseColor("#bdc3c7"));
|
||||||
|
if (DoricDev.getInstance().isReloadingContext(context)) {
|
||||||
|
holder.itemView.setBackgroundColor(Color.parseColor("#ffeaa7"));
|
||||||
|
}
|
||||||
|
if (context.getDriver() instanceof DoricDebugDriver) {
|
||||||
|
holder.itemView.setBackgroundColor(Color.parseColor("#fab1a0"));
|
||||||
|
}
|
||||||
|
holder.layoutBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (true) {
|
||||||
|
final String items[] = {"View source",};
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(holder.itemView.getContext(), R.style.Theme_Doric_Modal);
|
||||||
|
builder.setTitle(String.format("%s %s", context.getContextId(), context.getSource()));
|
||||||
|
builder.setIcon(new BitmapDrawable(icon_on));
|
||||||
|
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
if (which == 0) {
|
||||||
|
Toast.makeText(Doric.application(), "View source", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.create().show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(Doric.application(), "Please connect to devkit first", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return this.contexts.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@ -52,7 +48,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginLeft="20dp"
|
android:layout_marginLeft="20dp"
|
||||||
android:background="#1e90ff"
|
android:background="#1abc9c"
|
||||||
android:paddingLeft="15dp"
|
android:paddingLeft="15dp"
|
||||||
android:paddingTop="5dp"
|
android:paddingTop="5dp"
|
||||||
android:paddingRight="15dp"
|
android:paddingRight="15dp"
|
||||||
@ -67,7 +63,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:background="#1e90ff"
|
android:background="#1abc9c"
|
||||||
android:paddingLeft="15dp"
|
android:paddingLeft="15dp"
|
||||||
android:paddingTop="5dp"
|
android:paddingTop="5dp"
|
||||||
android:paddingRight="15dp"
|
android:paddingRight="15dp"
|
||||||
@ -82,7 +78,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:background="#1e90ff"
|
android:background="#95a5a6"
|
||||||
android:paddingLeft="15dp"
|
android:paddingLeft="15dp"
|
||||||
android:paddingTop="5dp"
|
android:paddingTop="5dp"
|
||||||
android:paddingRight="15dp"
|
android:paddingRight="15dp"
|
||||||
@ -90,13 +86,13 @@
|
|||||||
android:text="Disconnect"
|
android:text="Disconnect"
|
||||||
android:textColor="#dfe4ea"
|
android:textColor="#dfe4ea"
|
||||||
android:textSize="15dp"
|
android:textSize="15dp"
|
||||||
android:visibility="gone" />
|
android:visibility="visible" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/container"
|
android:id="@+id/list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="0dp"
|
||||||
android:orientation="vertical" />
|
android:layout_weight="1"
|
||||||
|
android:background="#dfe6e9" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
|
@ -1,13 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="60dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/context_id_text_view"
|
android:id="@+id/context_id_text_view"
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="60dp"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="{Context Id}"
|
android:text="{Context Id}"
|
||||||
@ -16,16 +17,22 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/source_text_view"
|
android:id="@+id/source_text_view"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="60dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="{Source}"
|
android:text="{Source}"
|
||||||
android:textSize="20sp" />
|
android:textSize="20sp" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/layout_btn"
|
||||||
|
android:layout_width="60dp"
|
||||||
|
android:layout_height="60dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/icon_debug"
|
android:id="@+id/icon_debug"
|
||||||
android:layout_width="60dp"
|
android:layout_width="20dp"
|
||||||
android:layout_height="60dp"
|
android:layout_height="20dp"
|
||||||
android:background="#ff0000" />
|
android:layout_gravity="center" />
|
||||||
|
</FrameLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
Reference in New Issue
Block a user