feat:add DoricFragment and doric activity

This commit is contained in:
pengfei.zhou 2019-11-23 12:07:37 +08:00
parent b475097c34
commit 876fa98254
6 changed files with 126 additions and 1 deletions

View File

@ -32,6 +32,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import pub.doric.DoricActivity;
import pub.doric.utils.DoricUtils;
public class MainActivity extends AppCompatActivity {
@ -46,6 +47,7 @@ public class MainActivity extends AppCompatActivity {
try {
String[] demos = getAssets().list("demo");
List<String> ret = new ArrayList<>();
ret.add("Navigator");
for (String str : demos) {
if (str.endsWith("js")) {
ret.add(str);
@ -89,6 +91,11 @@ public class MainActivity extends AppCompatActivity {
tv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (position == 0) {
Intent intent = new Intent(tv.getContext(), DoricActivity.class);
tv.getContext().startActivity(intent);
return;
}
Intent intent = new Intent(tv.getContext(), DemoActivity.class);
intent.putExtra("source", data[position]);
tv.getContext().startActivity(intent);

View File

@ -1 +1,16 @@
<manifest package="pub.doric" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pub.doric">
<uses-permission android:name="android.permission.CAMERA" />
<application>
<activity android:name="pub.doric.DoricActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -0,0 +1,45 @@
/*
* Copyright [2019] [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;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
/**
* @Description: pub.doric.demo
* @Author: pengfei.zhou
* @CreateDate: 2019-11-19
*/
public class DoricActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.doric_activity);
if (savedInstanceState == null) {
Fragment doricFragment = getSupportFragmentManager().getFragmentFactory().instantiate(
getClassLoader(),
DoricFragment.class.getName()
);
getSupportFragmentManager().beginTransaction()
.add(R.id.container, doricFragment)
.commit();
}
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright [2019] [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;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
/**
* @Description: pub.doric
* @Author: pengfei.zhou
* @CreateDate: 2019-11-23
*/
public class DoricFragment extends Fragment {
private FrameLayout root;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
root = (FrameLayout) inflater.inflate(R.layout.doric_fragment, container, false);
return root;
}
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>