feat: 项目初始化

This commit is contained in:
wds
2021-05-25 14:44:35 +08:00
commit 5b5c61e0a7
63 changed files with 1598 additions and 0 deletions

1
app/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

58
app/build.gradle Normal file
View File

@@ -0,0 +1,58 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.navigation:navigation-fragment:2.1.0'
implementation 'androidx.navigation:navigation-ui:2.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//butterknife依赖
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
//网络框架
implementation 'com.lzy.net:okgo:3.0.4'
implementation 'com.google.code.gson:gson:2.8.5'
//retrofit+rxjava
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
//转换器请求结果转换成Model
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
//配合Rxjava 使用
implementation 'io.reactivex.rxjava2:rxjava:2.2.7'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
//加载图片的依赖包
implementation 'com.github.bumptech.glide:glide:4.8.0'
}

21
app/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -0,0 +1,26 @@
package com.example.myapplication;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.myapplication", appContext.getPackageName());
}
}

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".activity.HomeActivity"></activity>
<activity android:name=".activity.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,32 @@
package com.example.myapplication.activity;
import android.os.Bundle;
import com.example.myapplication.base.BaseActivity;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import com.example.myapplication.R;
public class HomeActivity extends BaseActivity {
@Override
protected int getLayout() {
return R.layout.activity_home;
}
@Override
protected void initView() {
super.initView();
}
@Override
protected void initData() {
super.initData();
}
}

View File

@@ -0,0 +1,26 @@
package com.example.myapplication.activity;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.example.myapplication.R;
import com.example.myapplication.base.BaseActivity;
public class MainActivity extends BaseActivity {
@Override
protected int getLayout() {
return R.layout.activity_main;
}
@Override
protected void initData() {
super.initData();
}
@Override
protected void initView() {
super.initView();
}
}

View File

@@ -0,0 +1,4 @@
package com.example.myapplication.api;
public interface ApiService {
}

View File

@@ -0,0 +1,20 @@
package com.example.myapplication.api;
import android.app.Application;
public class UserApplication extends Application {
public static UserApplication userApplication;
@Override
public void onCreate() {
super.onCreate();
userApplication=this;
}
public static UserApplication getUserApplication() {
return userApplication;
}
}

View File

@@ -0,0 +1,55 @@
package com.example.myapplication.base;
import android.os.Bundle;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.example.myapplication.api.UserApplication;
import butterknife.ButterKnife;
import butterknife.Unbinder;
public abstract class BaseActivity extends AppCompatActivity {
private Unbinder bind;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayout());
bind = ButterKnife.bind(this);
initMVP();
initView();
initData();
initListener();
}
protected void toast(String mag){
Toast.makeText(UserApplication.getUserApplication(), mag, Toast.LENGTH_SHORT).show();
}
protected void initMVP() {
}
protected void initListener() {
}
protected abstract int getLayout();
protected void initView() {
}
protected void initData() {
}
@Override
protected void onDestroy() {
super.onDestroy();
bind.unbind();
}
}

View File

@@ -0,0 +1,6 @@
package com.example.myapplication.base;
public interface BaseCallBack<T> {
void onSuccess(T t);
void onFail(String error);
}

View File

@@ -0,0 +1,50 @@
package com.example.myapplication.base;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import butterknife.ButterKnife;
import butterknife.Unbinder;
public abstract class BaseFragment extends Fragment {
private Unbinder bind;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View inflate = inflater.inflate(getLayout(), container, false);
bind = ButterKnife.bind(this, inflate);
initMvp();
initView();
initData();
return inflate;
}
protected void initMvp() {
}
protected abstract int getLayout();
protected void initData() {
}
protected void initView() {
}
@Override
public void onDestroyView() {
super.onDestroyView();
bind.unbind();
}
}

View File

@@ -0,0 +1,18 @@
package com.example.myapplication.base;
public abstract class BaseMVPActivity <P extends BasePresenter,V extends BaseView> extends BaseActivity{
protected P presenter;
@Override
protected void initMVP() {
super.initMVP();
presenter= initMVPPresenter();
if (presenter!=null){
presenter.setView(initMVPView());
} }
protected abstract V initMVPView();
protected abstract P initMVPPresenter();
}

View File

@@ -0,0 +1,19 @@
package com.example.myapplication.base;
public abstract class BaseMVPFragment<P extends BasePresenter,V extends BaseView> extends BaseFragment{
protected P presenter;
@Override
protected void initMvp() {
super.initMvp();
presenter= initMVPPresenter();
if (presenter!=null){
presenter.setView(initMVPView());
}
}
protected abstract V initMVPView();
protected abstract P initMVPPresenter();
}

View File

@@ -0,0 +1,12 @@
package com.example.myapplication.base;
import io.reactivex.disposables.CompositeDisposable;
public abstract class BaseModel {
private CompositeDisposable compositeDisposable;
public void onDestroy(){
if (compositeDisposable!=null){
compositeDisposable.clear();
}
}
}

View File

@@ -0,0 +1,61 @@
package com.example.myapplication.base;
import android.net.ParseException;
import android.util.Log;
import android.widget.Toast;
import com.example.myapplication.api.UserApplication;
import com.google.gson.JsonParseException;
import org.json.JSONException;
import java.io.InterruptedIOException;
import java.net.ConnectException;
import java.net.UnknownHostException;
import io.reactivex.subscribers.ResourceSubscriber;
import retrofit2.HttpException;
public abstract class BaseObserver<T> extends ResourceSubscriber <T> {
@Override
public void onNext(T t) {
onSuccess(t);
}
public abstract void onSuccess(T t);
@Override
public void onError(Throwable e) {
Log.e("TAG", "error:" + e.getMessage());
//对异常进行分类,不同的异常提示用户不同的信息
if (e instanceof HttpException) {
// HTTP错误
onFail("HTTP错误");
} else if (e instanceof ConnectException
|| e instanceof UnknownHostException) {
// 连接错误
onFail("连接错误");
} else if (e instanceof InterruptedIOException) {
// 连接超时
onFail("连接超时");
} else if (e instanceof JsonParseException
|| e instanceof JSONException
|| e instanceof ParseException) {
// 解析错误
onFail("解析错误");
} else {
if (e != null) {
onFail(e.toString());
} else {
onFail("未知错误");
}
}
}
protected void onFail(String error){
Toast.makeText(UserApplication.getUserApplication(), error, Toast.LENGTH_SHORT).show();
}
@Override
public void onComplete() {
}
}

View File

@@ -0,0 +1,28 @@
package com.example.myapplication.base;
import java.util.ArrayList;
public abstract class BasePresenter<V extends BaseView> {
protected V view;
private ArrayList<BaseModel> list=new ArrayList<>();
public void setView(V view) {
this.view = view;
}
public BasePresenter() {
initModel();
}
public void onDestroy(){
view=null;
if (list.size()>0){
for (BaseModel baseModel : list) {
baseModel.onDestroy();
}
list.clear();
}
}
public void addModel(BaseModel baseModel){
list.add(baseModel);
}
protected abstract void initModel();
}

View File

@@ -0,0 +1,6 @@
package com.example.myapplication.base;
public interface BaseView<T> {
void onSuccess(T t);
void onFail(String error);
}

View File

@@ -0,0 +1,25 @@
package com.example.myapplication.fragment;
import com.example.myapplication.R;
import com.example.myapplication.base.BaseFragment;
/**
* 发现的Fragment
* 2021-5-25
*/
public class FindFragment extends BaseFragment {
@Override
protected int getLayout() {
return R.layout.find_fragment;
}
@Override
protected void initView() {
super.initView();
}
@Override
protected void initData() {
super.initData();
}
}

View File

@@ -0,0 +1,25 @@
package com.example.myapplication.fragment;
import com.example.myapplication.R;
import com.example.myapplication.base.BaseFragment;
/**
* 我的的Fragment
* 2021-5-25
*/
public class MineFragment extends BaseFragment {
@Override
protected int getLayout() {
return R.layout.mine_fragment;
}
@Override
protected void initView() {
super.initView();
}
@Override
protected void initData() {
super.initData();
}
}

View File

@@ -0,0 +1,24 @@
package com.example.myapplication.fragment;
import com.example.myapplication.R;
import com.example.myapplication.base.BaseFragment;
/**
* 记录的Fragment
* 2021-5-25
*/
public class RecordFragment extends BaseFragment {
@Override
protected int getLayout() {
return R.layout.record_fragment;
}
@Override
protected void initView() {
super.initView();
}
@Override
protected void initData() {
super.initData();
}
}

View File

@@ -0,0 +1,25 @@
package com.example.myapplication.fragment;
import com.example.myapplication.R;
import com.example.myapplication.base.BaseFragment;
/**
* 寻宝的Fragment
* 2021-5-25
*/
public class TreasureFragment extends BaseFragment {
@Override
protected int getLayout() {
return R.layout.treasure_fragment;
}
@Override
protected void initView() {
super.initView();
}
@Override
protected void initData() {
super.initData();
}
}

View File

@@ -0,0 +1,80 @@
package com.example.myapplication.net;
import com.lzy.okgo.interceptor.HttpLoggingInterceptor;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import retrofit2.Converter;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
public class DataService {
private static final long DEFAULT_TIMEOUT = 20000; // 默认超时20s
private static Object mApiService;
private static ArrayList<Interceptor> mInterceptors;
private static Converter.Factory mFactor;
private static Class mServiceClass;
private static String mBaseUrl;
public static void init(Class aClass, String baseUrl, ArrayList<Interceptor> interceptor, Converter.Factory factor) {
mServiceClass = aClass;
mBaseUrl = baseUrl;
mInterceptors = interceptor;
mFactor = factor;
}
public static void init(Class aClass, String baseUrl, ArrayList<Interceptor> interceptor) {
init(aClass, baseUrl, interceptor, null);
}
public static void init(Class aClass, String baseUrl, Converter.Factory factor) {
init(aClass, baseUrl, null, factor);
}
public static void init(Class aClass, String baseUrl) {
init(aClass, baseUrl, null, null);
}
public static synchronized Object getApiService() {
if (mServiceClass == null) {
throw new NullPointerException("在调用 DataService 的 getApiService 之前必须调用 init 方法惊喜初始化");
}
if (mApiService == null) {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
if (mInterceptors != null && mInterceptors.size() > 0) {
for (Interceptor interceptor : mInterceptors) {
builder.addInterceptor(interceptor);
}
}
builder.connectTimeout(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS)
.writeTimeout(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS)
.readTimeout(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS)
.build();
Retrofit retrofit = new Retrofit.Builder()
.client(builder.build())
.addConverterFactory(mFactor == null ? GsonConverterFactory.create() : mFactor) // 帮我们把json 窜转为 entity 对象
.addCallAdapterFactory(RxJava2CallAdapterFactory.create()) // 结合 rxjava 使用
.baseUrl(mBaseUrl)
.build();
mApiService = retrofit.create(mServiceClass);
}
return mApiService;
}
}

View File

@@ -0,0 +1,64 @@
package com.example.myapplication.util;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.ViewPager;
//自定义不可滑动的VI
public class NoSlideViewPager extends ViewPager {
// 定义一个是否可以滑动的boolean 值
private boolean isCanScroll = false;
public NoSlideViewPager(@NonNull Context context) {
super(context);
}
public NoSlideViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
// 滑动到指定位置
@Override
public void scrollTo(int x, int y) {
super.scrollTo(x, y);
}
// 触摸事件
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (isCanScroll) {
return super.onTouchEvent(ev);
} else {
return false;
}
}
// 设置当前显示的布局
@Override
public void setCurrentItem(int item) {
super.setCurrentItem(item);
}
// 设置当前显示的布局,并定义滑动方式
@Override
public void setCurrentItem(int item, boolean smoothScroll) {
super.setCurrentItem(item, smoothScroll);
}
// 拦截触摸事件
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (isCanScroll) {
return super.onInterceptTouchEvent(ev);
} else {
return false;
}
}
}

View File

@@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

View File

@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.HomeActivity">
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ic_launcher_background"
tools:context=".activity.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="启动页"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="发现的Fragment"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

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

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="记录的Fragment"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_launcher_foreground" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_graph"
app:startDestination="@id/FirstFragment">
<fragment
android:id="@+id/FirstFragment"
android:name="com.example.myapplication.activity.FirstFragment"
android:label="@string/first_fragment_label"
tools:layout="@layout/fragment_first">
<action
android:id="@+id/action_FirstFragment_to_SecondFragment"
app:destination="@id/SecondFragment" />
</fragment>
<fragment
android:id="@+id/SecondFragment"
android:name="com.example.myapplication.activity.SecondFragment"
android:label="@string/second_fragment_label"
tools:layout="@layout/fragment_second">
<action
android:id="@+id/action_SecondFragment_to_FirstFragment"
app:destination="@id/FirstFragment" />
</fragment>
</navigation>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorAccent">#03DAC5</color>
</resources>

View File

@@ -0,0 +1,3 @@
<resources>
<dimen name="fab_margin">16dp</dimen>
</resources>

View File

@@ -0,0 +1,12 @@
<resources>
<string name="app_name">MyApplication</string>
<string name="title_activity_home">HomeActivity</string>
<!-- Strings used for fragments for navigation -->
<string name="first_fragment_label">First Fragment</string>
<string name="second_fragment_label">Second Fragment</string>
<string name="next">Next</string>
<string name="previous">Previous</string>
<string name="hello_first_fragment">Hello first fragment</string>
<string name="hello_second_fragment">Hello second fragment. Arg: %1$s</string>
</resources>

View File

@@ -0,0 +1,19 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>

View File

@@ -0,0 +1,17 @@
package com.example.myapplication;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}