Переглянути джерело

划分模块,添加常用开发库,重构框架搭建

zhoujuncai 7 роки тому
батько
коміт
08b4534b97

+ 1 - 0
.idea/gradle.xml

@@ -9,6 +9,7 @@
           <set>
             <option value="$PROJECT_DIR$" />
             <option value="$PROJECT_DIR$/app" />
+            <option value="$PROJECT_DIR$/common" />
             <option value="$PROJECT_DIR$/home" />
             <option value="$PROJECT_DIR$/ucrop" />
             <option value="$PROJECT_DIR$/view" />


+ 2 - 0
app/build.gradle

@@ -281,6 +281,8 @@ dependencies {
     compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-14'
 
     compile 'org.greenrobot:greendao:3.2.2'
+
+    compile project(':home')
 }
 
 static def releaseTime() {

+ 0 - 108
app/src/main/java/com/sheep/gamegroup/greendao/download/DaoMaster.java

@@ -1,108 +0,0 @@
-package com.sheep.gamegroup.greendao.download;
-
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteDatabase.CursorFactory;
-import android.util.Log;
-
-import org.greenrobot.greendao.AbstractDaoMaster;
-import org.greenrobot.greendao.database.StandardDatabase;
-import org.greenrobot.greendao.database.Database;
-import org.greenrobot.greendao.database.DatabaseOpenHelper;
-import org.greenrobot.greendao.identityscope.IdentityScopeType;
-
-
-// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
-/**
- * Master of DAO (schema version 11): knows all DAOs.
- */
-public class DaoMaster extends AbstractDaoMaster {
-    public static final int SCHEMA_VERSION = 11;
-
-    /** Creates underlying database table using DAOs. */
-    public static void createAllTables(Database db, boolean ifNotExists) {
-        AppdownloadBeanDao.createTable(db, ifNotExists);
-        DownLoadInfoDao.createTable(db, ifNotExists);
-        ProcessRecordDao.createTable(db, ifNotExists);
-        AcceptTaskRecordDao.createTable(db, ifNotExists);
-        ScreenShotRecordDao.createTable(db, ifNotExists);
-    }
-
-    /** Drops underlying database table using DAOs. */
-    public static void dropAllTables(Database db, boolean ifExists) {
-        AppdownloadBeanDao.dropTable(db, ifExists);
-        DownLoadInfoDao.dropTable(db, ifExists);
-        ProcessRecordDao.dropTable(db, ifExists);
-        AcceptTaskRecordDao.dropTable(db, ifExists);
-        ScreenShotRecordDao.dropTable(db, ifExists);
-    }
-
-    /**
-     * WARNING: Drops all table on Upgrade! Use only during development.
-     * Convenience method using a {@link DevOpenHelper}.
-     */
-    public static DaoSession newDevSession(Context context, String name) {
-        Database db = new DevOpenHelper(context, name).getWritableDb();
-        DaoMaster daoMaster = new DaoMaster(db);
-        return daoMaster.newSession();
-    }
-
-    public DaoMaster(SQLiteDatabase db) {
-        this(new StandardDatabase(db));
-    }
-
-    public DaoMaster(Database db) {
-        super(db, SCHEMA_VERSION);
-        registerDaoClass(AppdownloadBeanDao.class);
-        registerDaoClass(DownLoadInfoDao.class);
-        registerDaoClass(ProcessRecordDao.class);
-        registerDaoClass(AcceptTaskRecordDao.class);
-        registerDaoClass(ScreenShotRecordDao.class);
-    }
-
-    public DaoSession newSession() {
-        return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
-    }
-
-    public DaoSession newSession(IdentityScopeType type) {
-        return new DaoSession(db, type, daoConfigMap);
-    }
-
-    /**
-     * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} -
-     */
-    public static abstract class OpenHelper extends DatabaseOpenHelper {
-        public OpenHelper(Context context, String name) {
-            super(context, name, SCHEMA_VERSION);
-        }
-
-        public OpenHelper(Context context, String name, CursorFactory factory) {
-            super(context, name, factory, SCHEMA_VERSION);
-        }
-
-        @Override
-        public void onCreate(Database db) {
-            Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
-            createAllTables(db, false);
-        }
-    }
-
-    /** WARNING: Drops all table on Upgrade! Use only during development. */
-    public static class DevOpenHelper extends OpenHelper {
-        public DevOpenHelper(Context context, String name) {
-            super(context, name);
-        }
-
-        public DevOpenHelper(Context context, String name, CursorFactory factory) {
-            super(context, name, factory);
-        }
-
-        @Override
-        public void onUpgrade(Database db, int oldVersion, int newVersion) {
-            Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
-            dropAllTables(db, true);
-            onCreate(db);
-        }
-    }
-
-}

+ 0 - 104
app/src/main/java/com/sheep/gamegroup/greendao/download/DaoSession.java

@@ -1,104 +0,0 @@
-package com.sheep.gamegroup.greendao.download;
-
-import java.util.Map;
-
-import org.greenrobot.greendao.AbstractDao;
-import org.greenrobot.greendao.AbstractDaoSession;
-import org.greenrobot.greendao.database.Database;
-import org.greenrobot.greendao.identityscope.IdentityScopeType;
-import org.greenrobot.greendao.internal.DaoConfig;
-
-import com.sheep.gamegroup.greendao.download.AppdownloadBean;
-import com.sheep.gamegroup.greendao.download.DownLoadInfo;
-import com.sheep.gamegroup.greendao.download.ProcessRecord;
-import com.sheep.gamegroup.greendao.download.AcceptTaskRecord;
-import com.sheep.gamegroup.greendao.download.ScreenShotRecord;
-
-import com.sheep.gamegroup.greendao.download.AppdownloadBeanDao;
-import com.sheep.gamegroup.greendao.download.DownLoadInfoDao;
-import com.sheep.gamegroup.greendao.download.ProcessRecordDao;
-import com.sheep.gamegroup.greendao.download.AcceptTaskRecordDao;
-import com.sheep.gamegroup.greendao.download.ScreenShotRecordDao;
-
-// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
-
-/**
- * {@inheritDoc}
- * 
- * @see org.greenrobot.greendao.AbstractDaoSession
- */
-public class DaoSession extends AbstractDaoSession {
-
-    private final DaoConfig appdownloadBeanDaoConfig;
-    private final DaoConfig downLoadInfoDaoConfig;
-    private final DaoConfig processRecordDaoConfig;
-    private final DaoConfig acceptTaskRecordDaoConfig;
-    private final DaoConfig screenShotRecordDaoConfig;
-
-    private final AppdownloadBeanDao appdownloadBeanDao;
-    private final DownLoadInfoDao downLoadInfoDao;
-    private final ProcessRecordDao processRecordDao;
-    private final AcceptTaskRecordDao acceptTaskRecordDao;
-    private final ScreenShotRecordDao screenShotRecordDao;
-
-    public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
-            daoConfigMap) {
-        super(db);
-
-        appdownloadBeanDaoConfig = daoConfigMap.get(AppdownloadBeanDao.class).clone();
-        appdownloadBeanDaoConfig.initIdentityScope(type);
-
-        downLoadInfoDaoConfig = daoConfigMap.get(DownLoadInfoDao.class).clone();
-        downLoadInfoDaoConfig.initIdentityScope(type);
-
-        processRecordDaoConfig = daoConfigMap.get(ProcessRecordDao.class).clone();
-        processRecordDaoConfig.initIdentityScope(type);
-
-        acceptTaskRecordDaoConfig = daoConfigMap.get(AcceptTaskRecordDao.class).clone();
-        acceptTaskRecordDaoConfig.initIdentityScope(type);
-
-        screenShotRecordDaoConfig = daoConfigMap.get(ScreenShotRecordDao.class).clone();
-        screenShotRecordDaoConfig.initIdentityScope(type);
-
-        appdownloadBeanDao = new AppdownloadBeanDao(appdownloadBeanDaoConfig, this);
-        downLoadInfoDao = new DownLoadInfoDao(downLoadInfoDaoConfig, this);
-        processRecordDao = new ProcessRecordDao(processRecordDaoConfig, this);
-        acceptTaskRecordDao = new AcceptTaskRecordDao(acceptTaskRecordDaoConfig, this);
-        screenShotRecordDao = new ScreenShotRecordDao(screenShotRecordDaoConfig, this);
-
-        registerDao(AppdownloadBean.class, appdownloadBeanDao);
-        registerDao(DownLoadInfo.class, downLoadInfoDao);
-        registerDao(ProcessRecord.class, processRecordDao);
-        registerDao(AcceptTaskRecord.class, acceptTaskRecordDao);
-        registerDao(ScreenShotRecord.class, screenShotRecordDao);
-    }
-    
-    public void clear() {
-        appdownloadBeanDaoConfig.clearIdentityScope();
-        downLoadInfoDaoConfig.clearIdentityScope();
-        processRecordDaoConfig.clearIdentityScope();
-        acceptTaskRecordDaoConfig.clearIdentityScope();
-        screenShotRecordDaoConfig.clearIdentityScope();
-    }
-
-    public AppdownloadBeanDao getAppdownloadBeanDao() {
-        return appdownloadBeanDao;
-    }
-
-    public DownLoadInfoDao getDownLoadInfoDao() {
-        return downLoadInfoDao;
-    }
-
-    public ProcessRecordDao getProcessRecordDao() {
-        return processRecordDao;
-    }
-
-    public AcceptTaskRecordDao getAcceptTaskRecordDao() {
-        return acceptTaskRecordDao;
-    }
-
-    public ScreenShotRecordDao getScreenShotRecordDao() {
-        return screenShotRecordDao;
-    }
-
-}

+ 0 - 0
build.gradle


+ 1 - 0
common/.gitignore

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

+ 3 - 0
common/README.md

@@ -0,0 +1,3 @@
+### 模块说明
+
+#### 存放公共类库,依赖添加的统一模块

+ 56 - 0
common/build.gradle

@@ -0,0 +1,56 @@
+apply plugin: 'com.android.library'
+
+android {
+    compileSdkVersion 27
+    buildToolsVersion "27.0.2"
+
+
+    defaultConfig {
+        minSdkVersion 18
+        targetSdkVersion 27
+        versionCode 1
+        versionName "1.0"
+
+        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+        }
+    }
+
+}
+
+dependencies {
+    compile fileTree(dir: 'libs', include: ['*.jar'])
+    compile 'com.android.support:appcompat-v7:27.1.0'
+    testCompile 'junit:junit:4.12'
+    androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.2', {
+        exclude group: 'com.android.support', module: 'support-annotations'
+    })
+
+    /* SQ全家桶 */
+    compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
+    compile 'com.squareup.retrofit2:retrofit:2.4.0'
+    compile 'com.squareup.retrofit2:converter-gson:2.4.0'
+    compile 'com.squareup.okhttp3:okhttp:3.10.0'
+
+    /* 网络请求生命周期绑定 */
+    compile 'com.trello:rxlifecycle:1.0'
+    compile 'com.trello:rxlifecycle-components:1.0'
+
+    /* RX全家桶 */
+    compile 'io.reactivex.rxjava2:rxandroid:2.1.0'
+    compile 'io.reactivex.rxjava2:rxjava:2.2.2'
+
+    /* JSON解析 */
+    compile 'com.google.code.gson:gson:2.8.2'
+
+    /* 日志打印 */
+    compile 'com.orhanobut:logger:2.2.0'
+
+    /* 媒体选择 */
+    compile 'com.zhihu.android:matisse:0.5.1'
+}

+ 21 - 0
common/proguard-rules.pro

@@ -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

+ 26 - 0
common/src/androidTest/java/com/smallsheep/common/ExampleInstrumentedTest.java

@@ -0,0 +1,26 @@
+package com.smallsheep.common;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.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.getTargetContext();
+
+        assertEquals("com.smallsheep.common.test", appContext.getPackageName());
+    }
+}

+ 6 - 0
common/src/main/AndroidManifest.xml

@@ -0,0 +1,6 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.smallsheep.common">
+
+    <!-- 网络请求 -->
+    <uses-permission android:name="android.permission.INTERNET" />
+</manifest>

+ 3 - 0
common/src/main/res/values/strings.xml

@@ -0,0 +1,3 @@
+<resources>
+
+</resources>

+ 17 - 0
common/src/test/java/com/smallsheep/common/ExampleUnitTest.java

@@ -0,0 +1,17 @@
+package com.smallsheep.common;
+
+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);
+    }
+}

+ 0 - 0
gradle.properties



+ 0 - 0
gradlew.bat


+ 3 - 0
home/README.md

@@ -0,0 +1,3 @@
+### 模块说明
+
+#### APP首页拆分重构部分

+ 18 - 7
home/build.gradle

@@ -1,18 +1,22 @@
 apply plugin: 'com.android.library'
 
 android {
-    compileSdkVersion 28
-    buildToolsVersion "28.0.3"
+    compileSdkVersion 27
+    buildToolsVersion "27.0.2"
 
 
     defaultConfig {
-        minSdkVersion 19
-        targetSdkVersion 28
+        minSdkVersion 18
+        targetSdkVersion 27
         versionCode 1
         versionName "1.0"
 
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
-
+        javaCompileOptions {
+            annotationProcessorOptions {
+                arguments = [AROUTER_MODULE_NAME: project.getName()]
+            }
+        }
     }
 
     buildTypes {
@@ -21,15 +25,22 @@ android {
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
     }
-
 }
 
 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
-    compile 'com.android.support:appcompat-v7:28.0.0'
+    compile 'com.android.support:appcompat-v7:27.1.0'
     testCompile 'junit:junit:4.12'
     androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.2', {
         exclude group: 'com.android.support', module: 'support-annotations'
     })
 
+    compile project(':common')
+
+    /* 模块路由 */
+    compile 'com.alibaba:arouter-api:1.4.0'
+    annotationProcessor 'com.alibaba:arouter-compiler:1.2.1'
+    /* 视图注入 */
+    compile 'com.jakewharton:butterknife:8.8.1'
+    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
 }

+ 3 - 1
home/src/main/AndroidManifest.xml

@@ -1,2 +1,4 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.samllsheep.home" />
+    package="com.samllsheep.home" >
+
+</manifest>

+ 25 - 0
home/src/main/java/com/samllsheep/home/filter/SchemeFilter.java

@@ -0,0 +1,25 @@
+package com.samllsheep.home.filter;
+
+import android.app.Activity;
+import android.net.Uri;
+import android.os.Bundle;
+
+import com.alibaba.android.arouter.launcher.ARouter;
+
+/**
+ * Created by: zhoujuncai.
+ * Created Date: 18-10-8.
+ * Description: 路由过滤
+ */
+public class SchemeFilter extends Activity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        Uri uri = getIntent().getData();
+        if (uri != null) {
+            ARouter.getInstance().build(uri).navigation();
+        }
+        finish();
+    }
+}

+ 12 - 0
home/src/main/java/com/samllsheep/home/maps/RouterMap.java

@@ -0,0 +1,12 @@
+package com.samllsheep.home.maps;
+
+/**
+ * Created by: zhoujuncai.
+ * Created Date: 18-10-8.
+ * Description: 路由映射
+ */
+public class RouterMap {
+
+    /* 主页 */
+    public static final String ACTIVITY_HOME = "/home/act/home";
+}

+ 68 - 0
home/src/main/java/com/samllsheep/home/ui/activity/BaseActivity.java

@@ -0,0 +1,68 @@
+package com.samllsheep.home.ui.activity;
+
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+
+import butterknife.ButterKnife;
+import butterknife.Unbinder;
+
+/**
+ * Created by: zhoujuncai.
+ * Created Date: 18-10-8.
+ * Description: 基础界面
+ */
+public abstract class BaseActivity extends AppCompatActivity {
+
+    private Unbinder ub;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        int layout = this.initContentView();
+        if (layout != 0) {
+            this.setContentView(layout);
+            this.ub = ButterKnife.bind(this);
+            this.initObjects();
+            this.initViews();
+            this.initActions();
+            this.initData();
+        }
+    }
+
+    /**
+     * 初始化布局
+     *
+     * @return 返回布局资源id
+     */
+    protected abstract int initContentView();
+
+    /**
+     * 初始化对象
+     */
+    protected abstract void initObjects();
+
+    /**
+     * 初始化视图
+     */
+    protected abstract void initViews();
+
+    /**
+     * 初始化事件
+     */
+    protected abstract void initActions();
+
+    /**
+     * 初始化数据
+     */
+    protected abstract void initData();
+
+    @Override
+    protected void onDestroy() {
+        if (this.ub != null && this.ub != Unbinder.EMPTY) {
+            this.ub.unbind();
+            this.ub = null;
+        }
+        super.onDestroy();
+    }
+}

+ 38 - 0
home/src/main/java/com/samllsheep/home/ui/activity/HomeActivity.java

@@ -0,0 +1,38 @@
+package com.samllsheep.home.ui.activity;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.samllsheep.home.maps.RouterMap;
+
+/**
+ * Created by: zhoujuncai.
+ * Created Date: 18-10-8.
+ * Description: 主页
+ */
+@Route(path = RouterMap.ACTIVITY_HOME)
+public class HomeActivity extends BaseActivity {
+
+    @Override
+    protected int initContentView() {
+        return 0;
+    }
+
+    @Override
+    protected void initObjects() {
+
+    }
+
+    @Override
+    protected void initViews() {
+
+    }
+
+    @Override
+    protected void initActions() {
+
+    }
+
+    @Override
+    protected void initData() {
+
+    }
+}

+ 0 - 0
mavenpush.gradle


+ 1 - 1
settings.gradle

@@ -1 +1 @@
-include ':app', ':view', ':ucrop', ':home'//, ':Aria', ':datashare', ':AriaAnnotations'
+include ':app', ':view', ':ucrop', ':home', ':common'//, ':Aria', ':datashare', ':AriaAnnotations'


+ 0 - 0
small_sheep_android.iml