Commit fa73fdf4a98aba86c3c92e09e6e399548cb9f631

Authored by 韩亚云
1 parent d7f4139e

base测试1

app/strike/build.gradle
@@ -149,6 +149,7 @@ dependencies { @@ -149,6 +149,7 @@ dependencies {
149 149
150 implementation 'androidx.appcompat:appcompat:1.1.0' 150 implementation 'androidx.appcompat:appcompat:1.1.0'
151 implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 151 implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
  152 + implementation 'androidx.legacy:legacy-support-v4:1.0.0'
152 testImplementation 'junit:junit:4.12' 153 testImplementation 'junit:junit:4.12'
153 androidTestImplementation 'androidx.test.ext:junit:1.1.1' 154 androidTestImplementation 'androidx.test.ext:junit:1.1.1'
154 androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 155 androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
app/strike/src/main/AndroidManifest.xml
@@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
13 android:roundIcon="@mipmap/ic_launcher_round" 13 android:roundIcon="@mipmap/ic_launcher_round"
14 android:supportsRtl="true" 14 android:supportsRtl="true"
15 android:theme="@style/AppTheme"> 15 android:theme="@style/AppTheme">
  16 + <activity android:name=".MyActivity"></activity>
16 <activity android:name=".MainActivity"> 17 <activity android:name=".MainActivity">
17 <intent-filter> 18 <intent-filter>
18 <action android:name="android.intent.action.MAIN" /> 19 <action android:name="android.intent.action.MAIN" />
@@ -32,17 +33,13 @@ @@ -32,17 +33,13 @@
32 android:value="${BAIDU_APP_KEY}" /> 33 android:value="${BAIDU_APP_KEY}" />
33 <meta-data 34 <meta-data
34 android:name="com.baidu.speech.SECRET_KEY" 35 android:name="com.baidu.speech.SECRET_KEY"
35 - android:value="${BAIDU_APP_SECRET}" />  
36 -  
37 - <!--友盟&渠道配置--> 36 + android:value="${BAIDU_APP_SECRET}" /> <!-- 友盟&渠道配置 -->
38 <meta-data 37 <meta-data
39 android:name="UMENG_APPKEY" 38 android:name="UMENG_APPKEY"
40 android:value="${UMENG_APPKEY}" /> 39 android:value="${UMENG_APPKEY}" />
41 <meta-data 40 <meta-data
42 android:name="UMENG_CHANNEL" 41 android:name="UMENG_CHANNEL"
43 - android:value="debug" />  
44 -  
45 - <!-- OPEN-INSTALL--> 42 + android:value="debug" /> <!-- OPEN-INSTALL -->
46 <meta-data 43 <meta-data
47 android:name="com.openinstall.APP_KEY" 44 android:name="com.openinstall.APP_KEY"
48 android:value="${OPENINSTALL_KEY}" /> 45 android:value="${OPENINSTALL_KEY}" />
app/strike/src/main/java/com/cnlive/strike/MainActivity.java
1 package com.cnlive.strike; 1 package com.cnlive.strike;
2 2
3 -import com.cnlive.libs.base.mvp.BaseActivity;  
4 3
5 -public class MainActivity extends BaseActivity { 4 +import android.content.Context;
  5 +import android.content.Intent;
  6 +import android.os.Bundle;
  7 +import android.util.AttributeSet;
  8 +import android.view.View;
6 9
  10 +import androidx.annotation.NonNull;
  11 +import androidx.annotation.Nullable;
  12 +import androidx.appcompat.app.AppCompatActivity;
  13 +
  14 +public class MainActivity extends AppCompatActivity {
7 15
8 - @Override  
9 - protected int initLayout() {  
10 - return R.layout.activity_main;  
11 - }  
12 16
13 @Override 17 @Override
14 - protected void initView() {  
15 - getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,new MyFragment()).commitAllowingStateLoss(); 18 + protected void onCreate(@Nullable Bundle savedInstanceState) {
  19 + super.onCreate(savedInstanceState);
  20 + setContentView(R.layout.activity_main);
  21 + findViewById(R.id.go_to).setOnClickListener(view -> startActivity(new Intent(this,MyActivity.class)) );
16 22
17 } 23 }
18 24
  25 + @Nullable
19 @Override 26 @Override
20 - protected void initData() {  
21 - 27 + public View onCreateView(@NonNull String name, @NonNull Context context, @NonNull AttributeSet attrs) {
  28 + return super.onCreateView(name, context, attrs);
22 } 29 }
23 } 30 }
app/strike/src/main/java/com/cnlive/strike/MyActivity.java 0 → 100644
  1 +package com.cnlive.strike;
  2 +
  3 +import androidx.appcompat.app.AppCompatActivity;
  4 +
  5 +import android.os.Bundle;
  6 +
  7 +import com.cnlive.libs.base.frame.fragment.BaseFragment;
  8 +
  9 +public class MyActivity extends AppCompatActivity {
  10 +
  11 + @Override
  12 + protected void onCreate(Bundle savedInstanceState) {
  13 + super.onCreate(savedInstanceState);
  14 + setContentView(R.layout.activity_my);
  15 + getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,new MyFragment()).commitAllowingStateLoss();
  16 + }
  17 +}
app/strike/src/main/java/com/cnlive/strike/MyFragment.java
1 package com.cnlive.strike; 1 package com.cnlive.strike;
2 2
3 -import android.util.Log; 3 +import android.os.Bundle;
  4 +import android.view.LayoutInflater;
  5 +import android.view.View;
  6 +import android.view.ViewGroup;
  7 +import android.widget.TextView;
4 8
5 -import com.cnlive.libs.base.mvp.BaseFragment;  
6 9
7 -public class MyFragment extends BaseFragment<MyFragmentView,MyPresenter> { 10 +import com.cnlive.libs.base.frame.fragment.BaseFragment;
  11 +
  12 +import androidx.annotation.Nullable;
  13 +
  14 +
  15 +public class MyFragment extends BaseFragment <MyFragmentView,MyPresenter> implements MyFragmentView{
  16 +
  17 + public TextView tx;
  18 +
  19 +
  20 + @Override
  21 + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  22 + super.onViewCreated(view, savedInstanceState);
  23 + tx = view.findViewById(R.id.my_tx);
  24 + if(getPresenter() != null) getPresenter().setData("hah");
  25 + }
  26 +
  27 + @Override
  28 + public void setData(String msg) {
  29 + tx.setText(msg);
  30 + }
8 31
9 @Override 32 @Override
10 - protected int initLayout() {  
11 - return R.layout.activity_main1; 33 + public MyPresenter createPresenter() {
  34 + return new MyPresenter();
12 } 35 }
13 36
14 @Override 37 @Override
15 - protected void init() {  
16 - Log.e(TAG, "init: "+TAG ); 38 + protected int getLayoutId() {
  39 + return R.layout.fragment_my;
17 } 40 }
18 } 41 }
app/strike/src/main/java/com/cnlive/strike/MyFragmentView.java
1 package com.cnlive.strike; 1 package com.cnlive.strike;
2 2
3 -import com.cnlive.libs.base.mvp.BaseFragment;  
4 -import com.cnlive.libs.base.mvp.BaseView; 3 +import com.hannesdorfmann.mosby3.mvp.MvpView;
5 4
6 -public class MyFragmentView extends BaseView {  
7 -  
8 -  
9 - public MyFragmentView(BaseFragment fragment) {  
10 - super(fragment);  
11 - }  
12 -  
13 - @Override  
14 - protected void initView() {  
15 - }  
16 -  
17 - @Override  
18 - protected void initData() {  
19 -  
20 - }  
21 -  
22 - public void test() {  
23 - } 5 +public interface MyFragmentView extends MvpView {
  6 + void setData(String msg);
24 } 7 }
app/strike/src/main/java/com/cnlive/strike/MyPresenter.java
1 package com.cnlive.strike; 1 package com.cnlive.strike;
2 2
3 -import com.cnlive.libs.base.mvp.BasePresenter; 3 +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
4 4
5 -public class MyPresenter extends BasePresenter<MyFragmentView> {  
6 -  
7 - public void test() {  
8 - getView().test(); 5 +public class MyPresenter extends MvpBasePresenter<MyFragmentView> {
  6 + public void setData(String msg){
  7 + getView().setData(msg);
9 } 8 }
10 } 9 }
app/strike/src/main/res/layout/activity_main.xml
@@ -8,10 +8,11 @@ @@ -8,10 +8,11 @@
8 android:orientation="vertical" 8 android:orientation="vertical"
9 tools:context=".ui.activity.AllDeviceActivity"> 9 tools:context=".ui.activity.AllDeviceActivity">
10 10
11 - <RelativeLayout  
12 - android:id="@+id/fragment_container"  
13 - android:layout_width="match_parent"  
14 - android:layout_height="match_parent"></RelativeLayout> 11 + <Button
  12 + android:id="@+id/go_to"
  13 + android:layout_width="wrap_content"
  14 + android:layout_height="wrap_content"
  15 + android:text="跳转"/>
15 16
16 </RelativeLayout> 17 </RelativeLayout>
17 </layout> 18 </layout>
18 \ No newline at end of file 19 \ No newline at end of file
app/strike/src/main/res/layout/activity_my.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:app="http://schemas.android.com/apk/res-auto"
  4 + xmlns:tools="http://schemas.android.com/tools"
  5 + android:layout_width="match_parent"
  6 + android:layout_height="match_parent"
  7 + tools:context="com.cnlive.strike.MyActivity">
  8 + <RelativeLayout
  9 + android:id="@+id/fragment_container"
  10 + android:layout_width="match_parent"
  11 + android:layout_height="match_parent">
  12 +
  13 + </RelativeLayout>
  14 +</RelativeLayout>
app/strike/src/main/res/layout/fragment_my.xml 0 → 100644
  1 +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2 + xmlns:tools="http://schemas.android.com/tools"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="match_parent"
  5 + tools:context="com.cnlive.strike.MyFragment">
  6 +
  7 + <!-- TODO: Update blank fragment layout -->
  8 + <TextView
  9 + android:id="@+id/my_tx"
  10 + android:layout_width="match_parent"
  11 + android:layout_height="match_parent" />
  12 +
  13 +</FrameLayout>
app/strike/src/main/res/values/strings.xml
1 <resources> 1 <resources>
2 -<!-- <string name="app_name">strike</string>--> 2 + <!-- <string name="app_name">strike</string>-->
  3 +
  4 +
  5 + <!-- TODO: Remove or change this placeholder text -->
  6 + <string name="hello_blank_fragment">Hello blank fragment</string>
3 </resources> 7 </resources>