diff --git a/doric-android/app/src/main/AndroidManifest.xml b/doric-android/app/src/main/AndroidManifest.xml
index 51db1467..06a41022 100644
--- a/doric-android/app/src/main/AndroidManifest.xml
+++ b/doric-android/app/src/main/AndroidManifest.xml
@@ -28,6 +28,10 @@
+
+
diff --git a/doric-android/app/src/main/java/pub/doric/demo/DoricPanelListActivity.java b/doric-android/app/src/main/java/pub/doric/demo/DoricPanelListActivity.java
new file mode 100644
index 00000000..f9c71b91
--- /dev/null
+++ b/doric-android/app/src/main/java/pub/doric/demo/DoricPanelListActivity.java
@@ -0,0 +1,137 @@
+package pub.doric.demo;
+
+import android.annotation.SuppressLint;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import pub.doric.DoricContext;
+import pub.doric.DoricPanel;
+import pub.doric.DoricSingleton;
+import pub.doric.async.AsyncResult;
+import pub.doric.navigator.IDoricNavigator;
+import pub.doric.performance.DoricPerformanceProfile;
+import pub.doric.utils.DoricLog;
+import pub.doric.utils.DoricUtils;
+
+public class DoricPanelListActivity extends AppCompatActivity {
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_doric_panel_list);
+
+ RecyclerView recyclerView = findViewById(R.id.doric_panel_rv);
+ recyclerView.setBackgroundColor(Color.WHITE);
+ recyclerView.setLayoutManager(new LinearLayoutManager(this));
+ recyclerView.setNestedScrollingEnabled(true);
+ recyclerView.setAdapter(new MyAdapter(new String[]{
+ "Counter.js",
+ "EffectsDemo.js",
+ "FlowLayoutDemo.js",
+ "Gobang.js",
+ "HelloDoric.js",
+ "LayoutDemo.js",
+ "TextAnimationDemo.js",
+ }));
+ }
+
+ public static class MyAdapter extends RecyclerView.Adapter {
+
+ private final String[] data;
+ private final Map panels = new HashMap<>();
+ private static final int PANEL_HEIGHT = 300;
+ final long pefStart = System.currentTimeMillis();
+
+ public MyAdapter(String[] demos) {
+ this.data = demos;
+ }
+
+ @NonNull
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ DoricPanel doricPanel = new DoricPanel(parent.getContext());
+ doricPanel.setLayoutParams(new ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ DoricUtils.dp2px(PANEL_HEIGHT)));
+ return new RecyclerView.ViewHolder(doricPanel) {
+ @NonNull
+ @Override
+ public String toString() {
+ return super.toString();
+ }
+ };
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ return position;
+ }
+
+ @SuppressLint("SetTextI18n")
+ @Override
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") final int position) {
+ if (panels.containsKey(position)) {
+ //TODO at here to handle on bind
+ } else {
+ panels.put(position, (DoricPanel) holder.itemView);
+ String source = "assets://src/" + data[position];
+ final String alias = "__dev__";
+ final String extra = "{}";
+
+ final DoricPanel doricPanel = (DoricPanel) holder.itemView;
+ DoricSingleton.getInstance().getJSLoaderManager().loadJSBundle(source).setCallback(new AsyncResult.Callback() {
+ @Override
+ public void onResult(String result) {
+ doricPanel.config(result, alias, extra);
+ DoricContext context = doricPanel.getDoricContext();
+ context.setDoricNavigator(new IDoricNavigator() {
+ @Override
+ public void push(String source, String alias, String extra) {
+
+ }
+
+ @Override
+ public void pop() {
+
+ }
+ });
+ doricPanel.getDoricContext().getPerformanceProfile().addAnchorHook(new DoricPerformanceProfile.AnchorHook() {
+ @Override
+ public void onAnchor(String name, long prepare, long start, long end) {
+ if (name.equals(DoricPerformanceProfile.STEP_RENDER)) {
+ long cost = end - pefStart;
+ Log.d("Timing", "Cost " + cost + "ms");
+ }
+ }
+ });
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ DoricLog.e("Doric load JS error:" + t.getLocalizedMessage());
+ }
+
+ @Override
+ public void onFinish() {
+
+ }
+ });
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ return data.length;
+ }
+ }
+}
diff --git a/doric-android/app/src/main/java/pub/doric/demo/MainActivity.java b/doric-android/app/src/main/java/pub/doric/demo/MainActivity.java
index 7c4b1133..78cb8958 100644
--- a/doric-android/app/src/main/java/pub/doric/demo/MainActivity.java
+++ b/doric-android/app/src/main/java/pub/doric/demo/MainActivity.java
@@ -34,13 +34,13 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import pub.doric.DoricActivity;
import pub.doric.devkit.DoricDev;
import pub.doric.refresh.DoricSwipeLayout;
import pub.doric.utils.DoricUtils;
public class MainActivity extends AppCompatActivity {
+ @SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -77,7 +77,7 @@ public class MainActivity extends AppCompatActivity {
}
}
- public class MyAdapter extends RecyclerView.Adapter {
+ public static class MyAdapter extends RecyclerView.Adapter {
private final String[] data;
@@ -95,6 +95,7 @@ public class MainActivity extends AppCompatActivity {
DoricUtils.dp2px(50)));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
return new RecyclerView.ViewHolder(textView) {
+ @NonNull
@Override
public String toString() {
return super.toString();
@@ -102,6 +103,7 @@ public class MainActivity extends AppCompatActivity {
};
}
+ @SuppressLint("SetTextI18n")
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") final int position) {
final TextView tv = (TextView) holder.itemView;
@@ -113,13 +115,22 @@ public class MainActivity extends AppCompatActivity {
DoricDev.getInstance().openDevMode();
}
});
+ } else if (position == 1) {
+ tv.setText("Doric Panel List");
+ tv.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(tv.getContext(), DoricPanelListActivity.class);
+ tv.getContext().startActivity(intent);
+ }
+ });
} else {
- tv.setText(data[position - 1]);
+ tv.setText(data[position - 2]);
tv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(tv.getContext(), DoricDebugTimingActivity.class);
- intent.putExtra("source", "assets://src/" + data[position - 1]);
+ intent.putExtra("source", "assets://src/" + data[position - 2]);
//intent.putExtra("alias", data[position - 1].replace(".js", ""));
intent.putExtra("alias", "__dev__");
tv.getContext().startActivity(intent);
@@ -130,7 +141,7 @@ public class MainActivity extends AppCompatActivity {
@Override
public int getItemCount() {
- return data.length + 1;
+ return data.length + 2;
}
}
}
diff --git a/doric-android/app/src/main/res/layout/activity_doric_panel_list.xml b/doric-android/app/src/main/res/layout/activity_doric_panel_list.xml
new file mode 100644
index 00000000..54ddcf06
--- /dev/null
+++ b/doric-android/app/src/main/res/layout/activity_doric_panel_list.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
\ No newline at end of file