纠正错误的打开连接的方法
parent
b672bc0a98
commit
765449a5ab
@ -0,0 +1,69 @@
|
|||||||
|
package com.xypower.mpremote.utils;
|
||||||
|
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.MatrixCursor;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.xypower.common.FilesUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AdbUtils {
|
||||||
|
|
||||||
|
public final static int DEFAULT_ADB_PORT = 5555;
|
||||||
|
|
||||||
|
public static Cursor parseContentResponse(String output) {
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(output) || output.startsWith("No result found")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] rows = FilesUtils.splitLines(output);
|
||||||
|
if (rows == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
MatrixCursor cursor = null;
|
||||||
|
boolean firstRow = true;
|
||||||
|
List<String> columns = new ArrayList<>();
|
||||||
|
List<String> values = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String row : rows) {
|
||||||
|
int pos = row.indexOf(' ', 5);
|
||||||
|
|
||||||
|
if (pos == -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
values.clear();
|
||||||
|
|
||||||
|
String rowContent = row.substring(pos + 1);
|
||||||
|
|
||||||
|
String[] fields = TextUtils.split(rowContent, ", ");
|
||||||
|
if (fields == null || fields.length == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String field : fields) {
|
||||||
|
pos = field.indexOf('=');
|
||||||
|
|
||||||
|
if (firstRow) {
|
||||||
|
columns.add(field.substring(0, pos));
|
||||||
|
}
|
||||||
|
values.add(field.substring(pos + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstRow) {
|
||||||
|
String[] cs = new String[columns.size()];
|
||||||
|
columns.toArray(cs);
|
||||||
|
cursor = new MatrixCursor(cs);
|
||||||
|
firstRow = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor.addRow(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cursor;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
android:paddingTop="20dp"
|
||||||
|
android:paddingBottom="20dp"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/id_channel"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:text="" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/id_datetime"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:text="" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
Loading…
Reference in New Issue