feat:android add ssr demo
This commit is contained in:
parent
c3b9638434
commit
d416e9dc81
@ -63,7 +63,8 @@ public class DoricSSRActivity extends AppCompatActivity {
|
||||
final DoricPanel doricPanel = findViewById(R.id.doric_panel);
|
||||
RootNode rootNode = new RootNode(DoricContext.MOCK_CONTEXT);
|
||||
rootNode.setRootView(doricPanel);
|
||||
String json = DoricUtils.readAssetFile("src/LayoutDemo.ssr.json");
|
||||
String filePath = getIntent().getStringExtra("file");
|
||||
String json = DoricUtils.readAssetFile("src/"+filePath);
|
||||
try {
|
||||
long start = System.currentTimeMillis();
|
||||
JSONObject jsonObject = new JSONObject(json);
|
||||
|
@ -66,7 +66,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
if (str.endsWith(".es5.js")) {
|
||||
continue;
|
||||
}
|
||||
if (str.endsWith("js")) {
|
||||
if (str.endsWith(".js")
|
||||
|| str.endsWith(".json")) {
|
||||
ret.add(str);
|
||||
}
|
||||
}
|
||||
@ -132,33 +133,31 @@ public class MainActivity extends AppCompatActivity {
|
||||
tv.getContext().startActivity(intent);
|
||||
}
|
||||
});
|
||||
} else if (position == 3) {
|
||||
tv.setText("SSR Example");
|
||||
tv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(tv.getContext(), DoricSSRActivity.class);
|
||||
tv.getContext().startActivity(intent);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
tv.setText(data[position - 4]);
|
||||
tv.setText(data[position - 3]);
|
||||
tv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String filePath = data[position - 3];
|
||||
if (filePath.endsWith(".json")) {
|
||||
Intent intent = new Intent(tv.getContext(), DoricSSRActivity.class);
|
||||
intent.putExtra("file", filePath);
|
||||
tv.getContext().startActivity(intent);
|
||||
} else {
|
||||
Intent intent = new Intent(tv.getContext(), DoricDebugTimingActivity.class);
|
||||
intent.putExtra("source", "assets://src/" + data[position - 4]);
|
||||
intent.putExtra("source", "assets://src/" + data[position - 3]);
|
||||
//intent.putExtra("alias", data[position - 1].replace(".js", ""));
|
||||
intent.putExtra("alias", "__dev__");
|
||||
tv.getContext().startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.length + 4;
|
||||
return data.length + 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user