android: extract base activity for obtain doric context
This commit is contained in:
parent
0cc9417cb6
commit
ba3635769a
@ -12,5 +12,6 @@
|
||||
android:theme="@style/Theme.Design.Light.NoActionBar" />
|
||||
<activity android:name=".qrcode.activity.CaptureActivity" />
|
||||
<activity android:name=".ui.DoricShowNodeTreeActivity" />
|
||||
<activity android:name=".ui.DoricDevPerfActivity" />
|
||||
</application>
|
||||
</manifest>
|
||||
|
@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright [2020] [Doric.Pub]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.devkit.ui;
|
||||
|
||||
import android.Manifest;
|
||||
@ -399,19 +414,21 @@ public class DoricDevActivity extends AppCompatActivity implements DoricDev.Stat
|
||||
actionMap.put("Performance", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Map<String, Long> anchorMap = context.getPerformanceProfile().getAnchorMap();
|
||||
|
||||
Intent intent = new Intent(holder.itemView.getContext(), DoricDevPerfActivity.class);
|
||||
intent.putExtra(DORIC_CONTEXT_ID_KEY, context.getContextId());
|
||||
v.getContext().startActivity(intent);
|
||||
((Activity) v.getContext()).finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
actionMap.put("Show node tree", new DialogInterface.OnClickListener() {
|
||||
actionMap.put("View node tree", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent(holder.itemView.getContext(), DoricShowNodeTreeActivity.class);
|
||||
intent.putExtra(DORIC_CONTEXT_ID_KEY, context.getContextId());
|
||||
v.getContext().startActivity(intent);
|
||||
((Activity) v.getContext()).finish();
|
||||
}
|
||||
});
|
||||
final String[] items = actionMap.keySet().toArray(new String[0]);
|
||||
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright [2021] [Doric.Pub]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.devkit.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import pub.doric.DoricContext;
|
||||
import pub.doric.DoricContextManager;
|
||||
|
||||
/**
|
||||
* @Description: pub.doric.devkit.ui
|
||||
* @Author: pengfei.zhou
|
||||
* @CreateDate: 2021/7/19
|
||||
*/
|
||||
public class DoricDevBaseActivity extends AppCompatActivity {
|
||||
public static final String DORIC_CONTEXT_ID_KEY = "DORIC_CONTEXT_ID";
|
||||
protected DoricContext doricContext;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
String contextId = getIntent().getStringExtra(DORIC_CONTEXT_ID_KEY);
|
||||
doricContext = DoricContextManager.getContext(contextId);
|
||||
}
|
||||
}
|
@ -1,17 +1,31 @@
|
||||
/*
|
||||
* Copyright [2021] [Doric.Pub]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.devkit.ui;
|
||||
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
/**
|
||||
* @Description: pub.doric.devkit.ui
|
||||
* @Author: pengfei.zhou
|
||||
* @CreateDate: 2021/7/19
|
||||
*/
|
||||
public class DoricDevPerfActivity extends AppCompatActivity {
|
||||
public class DoricDevPerfActivity extends DoricDevBaseActivity {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -1,8 +1,22 @@
|
||||
/*
|
||||
* Copyright [2021] [Doric.Pub]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.devkit.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
@ -12,8 +26,6 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
|
||||
import pub.doric.DoricContext;
|
||||
import pub.doric.DoricContextManager;
|
||||
import pub.doric.devkit.R;
|
||||
import pub.doric.devkit.ui.treeview.DoricViewNodeLayoutItemType;
|
||||
import pub.doric.devkit.ui.treeview.DoricViewNodeTreeViewBinder;
|
||||
@ -22,20 +34,14 @@ import pub.doric.devkit.ui.treeview.TreeViewAdapter;
|
||||
import pub.doric.shader.GroupNode;
|
||||
import pub.doric.shader.ViewNode;
|
||||
|
||||
public class DoricShowNodeTreeActivity extends AppCompatActivity {
|
||||
|
||||
public static final String DORIC_CONTEXT_ID_KEY = "DORIC_CONTEXT_ID";
|
||||
public class DoricShowNodeTreeActivity extends DoricDevBaseActivity {
|
||||
|
||||
private RecyclerView rv;
|
||||
private TreeViewAdapter adapter;
|
||||
|
||||
private DoricContext doricContext;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
String contextId = getIntent().getStringExtra(DORIC_CONTEXT_ID_KEY);
|
||||
doricContext = DoricContextManager.getContext(contextId);
|
||||
|
||||
setContentView(R.layout.layout_show_node_tree);
|
||||
initView();
|
||||
|
Reference in New Issue
Block a user