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