Commit 49bd5ef8 by 宁斌

1、新增 數據下載、餐檯、餐牌、首頁

parent a9ed8c9d
package com.gingersoft.gsa.cloud.main;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.R;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
/**
* @author billy.qi
*/
public class ActivityA extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView textView = new TextView(this);
textView.setGravity(Gravity.CENTER);
textView.setText("ActivityA\nClick to finish this activity");
setContentView(textView);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/login_user_state_observer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
/>
<TextView
android:id="@+id/login_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
>
</ScrollView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:background="#cccccc"
android:scrollbars="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/console"
android:padding="10dp"
/>
</ScrollView>
</LinearLayout>
<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>
...@@ -137,7 +137,7 @@ dependencies { ...@@ -137,7 +137,7 @@ dependencies {
implementation rootProject.ext.dependencies["cardview-v7"] implementation rootProject.ext.dependencies["cardview-v7"]
//test //test
api rootProject.ext.dependencies["timber"] api rootProject.ext.dependencies["timber"]
implementation rootProject.ext.dependencies["retrofit-url-manager"]
//解决Glide找不到Android声明库问题 //解决Glide找不到Android声明库问题
annotationProcessor 'androidx.annotation:annotation:1.1.0' annotationProcessor 'androidx.annotation:annotation:1.1.0'
// testApi rootProject.ext.dependencies["junit"] // testApi rootProject.ext.dependencies["junit"]
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest package="com.jess.arms">
package="com.jess.arms">
</manifest> </manifest>
...@@ -20,7 +20,6 @@ import android.content.Context; ...@@ -20,7 +20,6 @@ import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import com.jess.arms.base.delegate.IActivity; import com.jess.arms.base.delegate.IActivity;
import com.jess.arms.integration.cache.Cache; import com.jess.arms.integration.cache.Cache;
import com.jess.arms.integration.cache.CacheType; import com.jess.arms.integration.cache.CacheType;
...@@ -28,9 +27,7 @@ import com.jess.arms.integration.lifecycle.ActivityLifecycleable; ...@@ -28,9 +27,7 @@ import com.jess.arms.integration.lifecycle.ActivityLifecycleable;
import com.jess.arms.mvp.IPresenter; import com.jess.arms.mvp.IPresenter;
import com.jess.arms.utils.ArmsUtils; import com.jess.arms.utils.ArmsUtils;
import com.trello.rxlifecycle2.android.ActivityEvent; import com.trello.rxlifecycle2.android.ActivityEvent;
import javax.inject.Inject; import javax.inject.Inject;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
...@@ -39,7 +36,6 @@ import butterknife.ButterKnife; ...@@ -39,7 +36,6 @@ import butterknife.ButterKnife;
import butterknife.Unbinder; import butterknife.Unbinder;
import io.reactivex.subjects.BehaviorSubject; import io.reactivex.subjects.BehaviorSubject;
import io.reactivex.subjects.Subject; import io.reactivex.subjects.Subject;
import static com.jess.arms.utils.ThirdViewUtil.convertAutoView; import static com.jess.arms.utils.ThirdViewUtil.convertAutoView;
/** /**
......
...@@ -4,29 +4,29 @@ buildscript { ...@@ -4,29 +4,29 @@ buildscript {
ext.kotlin_version = '1.3.10' ext.kotlin_version = '1.3.10'
repositories { repositories {
maven{ url rootProject.file("repo-local") }
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
google() google()
jcenter() jcenter()
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.0' classpath 'com.android.tools.build:gradle:3.5.0'
// classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.novoda:bintray-release:0.9.2' classpath 'com.novoda:bintray-release:0.9.2'
classpath 'com.billy.android:cc-register:1.1.2' classpath 'com.billy.android:cc-register:1.1.2'
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
} }
} }
allprojects { allprojects {
repositories { repositories {
maven{ url rootProject.file("repo-local") }
maven { url "https://jitpack.io" }
google() google()
jcenter() jcenter()
mavenLocal() mavenLocal()
......
//注: 从CC 1.x升级到CC 2.x的用户,用此文件替换原来的cc-settings.gradle的同时,需要在根目录build.gradle中将插件地址按照如下方式更换一下: //注: 从CC 1.x升级到CC 2.x的用户,用此文件替换原来的cc-settings.gradle的同时,需要在根目录build.gradle中将插件地址按照如下方式更换一下:
// classpath 'com.billy.android:autoregister:x.x.x' -> classpath 'com.billy.android:cc-register:x.x.x' // classpath 'com.billy.android:autoregister:x.x.x' -> classpath 'com.billy.android:cc-register:x.x.x'
//cc-register extension: //cc-register extension:
...@@ -8,6 +7,33 @@ ...@@ -8,6 +7,33 @@
project.apply plugin: 'cc-register' project.apply plugin: 'cc-register'
project.dependencies.add('api', "com.billy.android:cc:2.1.6") //用最新版 project.dependencies.add('api', "com.billy.android:cc:2.1.6") //用最新版
dependencies {
if (project.name != 'public-base' && project.name != 'arms' && project.name !='public-database') {
implementation project(':public-base')
}
if (project.name != 'public-database' && project.name != 'arms' && project.name != 'public-network') {
implementation project(':public-database')
}
if (project.name != 'public-network' && project.name != 'arms' && project.name != 'public-base' && project.name != 'public-database') {
implementation project(':public-network')
}
if (project.name != 'arms') {
implementation project(':arms')
}
if (project.name != 'public-base' && project.name != 'public-database' && project.name != 'public-network' && project.name != 'arms') {
implementation rootProject.ext.dependencies["qmui"]
if (project.name != 'public-ui') {
implementation project(':public-ui')
}
}
implementation rootProject.ext.dependencies["retrofit-url-manager"]
annotationProcessor rootProject.ext.dependencies["butterknife-compiler"]
// annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]//依赖插件
implementation rootProject.ext.dependencies["multidex"]
implementation rootProject.ext.dependencies["constraintlayout"]
implementation 'org.jetbrains:annotations:15.0'
}
//此文件是作为组件化配置的公共gradle脚本文件,在每个组件中都apply此文件,下载到工程根目录后,可以在下方添加一些自己工程中通用的配置 //此文件是作为组件化配置的公共gradle脚本文件,在每个组件中都apply此文件,下载到工程根目录后,可以在下方添加一些自己工程中通用的配置
// 可参考cc-settings-demo.gradle // 可参考cc-settings-demo.gradle
// 例如: // 例如:
......
...@@ -2,7 +2,7 @@ ext { ...@@ -2,7 +2,7 @@ ext {
android = [ android = [
compileSdkVersion: 28, compileSdkVersion: 28,
buildToolsVersion: '28.0.0', buildToolsVersion: '28.0.3',
minSdkVersion : 19, //N5收銀機應用安卓開發環境要求Android OS Version: 5.1Android SDK Min Version: 19 minSdkVersion : 19, //N5收銀機應用安卓開發環境要求Android OS Version: 5.1Android SDK Min Version: 19
targetSdkVersion : 28, targetSdkVersion : 28,
versionCode : 1, versionCode : 1,
...@@ -11,7 +11,7 @@ ext { ...@@ -11,7 +11,7 @@ ext {
version = [ version = [
androidSupportSdkVersion: "28+", androidSupportSdkVersion: "28+",
retrofitSdkVersion : '2.7.0', retrofitSdkVersion : '2.3.0',
dagger2SdkVersion : "2.14.1", dagger2SdkVersion : "2.14.1",
glideSdkVersion : "4.9.0", glideSdkVersion : "4.9.0",
butterknifeSdkVersion : "10.1.0", butterknifeSdkVersion : "10.1.0",
......
import org.checkerframework.checker.units.qual.A
ext.mainApp = true //设置为true,表示此module为主app module,一直以application方式编译
apply from: rootProject.file('cc-settings.gradle') apply from: rootProject.file('cc-settings.gradle')
//获取时间戳
def getDate() {
def date = new Date()
def formattedDate = date.format('yyyyMMddHH')
return formattedDate
}
android { android {
signingConfigs {
GSAndroidNew {
keyAlias 'keycypos'
keyPassword 'qingkeke'
storeFile file('cyposandroid.keyset')
storePassword 'qingkeke'
}
}
compileSdkVersion rootProject.ext.android["compileSdkVersion"] compileSdkVersion rootProject.ext.android["compileSdkVersion"]
compileOptions { compileOptions {
...@@ -31,7 +12,9 @@ android { ...@@ -31,7 +12,9 @@ android {
abortOnError false abortOnError false
} }
defaultConfig { defaultConfig {
applicationId "com.gingersoft.cloud.gsa" if (project.ext.runAsApp) {
applicationId "com.gingersoft.gsa.cloud.download"
}
minSdkVersion rootProject.ext.android["minSdkVersion"] minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"] targetSdkVersion rootProject.ext.android["targetSdkVersion"]
versionCode rootProject.ext.android["versionCode"] versionCode rootProject.ext.android["versionCode"]
...@@ -39,6 +22,8 @@ android { ...@@ -39,6 +22,8 @@ android {
multiDexEnabled true multiDexEnabled true
} }
resourcePrefix "download_data"
buildTypes { buildTypes {
release { release {
postprocessing { postprocessing {
...@@ -47,25 +32,7 @@ android { ...@@ -47,25 +32,7 @@ android {
obfuscate false obfuscate false
optimizeCode false optimizeCode false
proguardFiles 'proguard.cfg' proguardFiles 'proguard.cfg'
signingConfig signingConfigs.GSAndroidNew
}
}
}
//修改生成的apk名字
applicationVariants.all { variant ->
variant.outputs.all {
def fileName
def date = new Date()
def formattedDate = date.format('yyyy-MM-dd')
if (variant.buildType.name == 'release') {
fileName = "${formattedDate}_GsAndroid_${variant.mergedFlavor.versionName}_正式版_.apk"
} else if (variant.buildType.name == 'Test') {
fileName = "${formattedDate}__GsAndroid_${variant.mergedFlavor.versionName}_测试版_.apk"
} else if (variant.buildType.name == 'debug') {
fileName = "${formattedDate}__GsAndroid_${variant.mergedFlavor.versionName}_debug_.apk"
} }
outputFileName = fileName
} }
} }
} }
...@@ -73,17 +40,11 @@ android { ...@@ -73,17 +40,11 @@ android {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
// addComponent 'component_login' annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
// addComponent 'component_register'
implementation project(':public-base')
// implementation project(':arms')
implementation rootProject.ext.dependencies["arms"]
// test // test
testImplementation rootProject.ext.dependencies["junit"] testImplementation rootProject.ext.dependencies["junit"]
debugImplementation rootProject.ext.dependencies["canary-debug"] debugImplementation rootProject.ext.dependencies["canary-debug"]
releaseImplementation rootProject.ext.dependencies["canary-release"] releaseImplementation rootProject.ext.dependencies["canary-release"]
testImplementation rootProject.ext.dependencies["canary-release"] testImplementation rootProject.ext.dependencies["canary-release"]
implementation 'org.jetbrains:annotations:15.0'
} }
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.gsa.cloud.download">
<uses-permission android:name="android.permission.INTERNET" />
<application>
<activity android:name=".mvp.ui.activity.DownloadActivity"></activity>
<!-- arms配置 -->
<meta-data
android:name="network.config.GlobalConfiguration"
android:value="ConfigModule" />
</application>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.gsa.cloud.download">
<application
android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/download_data_app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".mvp.ui.activity.DownloadActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- arms配置 -->
<meta-data
android:name="network.config.GlobalConfiguration"
android:value="ConfigModule" />
<meta-data
android:name="design_width_in_dp"
android:value="360" />
<meta-data
android:name="design_height_in_dp"
android:value="540" />
</application>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RESTART_PACKAGES" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- <uses-permission android:name="android.permission.RESTART_PACKAGES" /> -->
<!-- <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> -->
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" />
<!-- <uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> -->
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!-- 使用照相机权限 -->
<uses-permission android:name="android.permission.VIBRATE" />
<!-- 自动聚焦权限 -->
<uses-permission android:name="android.permission.REORDER_TASKS" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>
\ No newline at end of file
package com.gingersoft.gsa.cloud.application; package debug;
import com.joe.base.application.BaseApplication; import android.app.Application;
import com.billy.cc.core.component.CC;
/** /**
* @author billy.qi * @author billy.qi
* @since 17/11/20 19:28 * @since 17/11/20 20:02
*/ */
public class MyApp extends BaseApplication { public class MyApp extends Application {
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
CC.enableVerboseLog(true);
CC.enableDebug(true);
CC.enableRemoteCC(true);
} }
} }
<resources>
<string name="download_data_app_name">Component-download-data</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="download_data_colorPrimary">#3F51B5</color>
<color name="download_data_colorPrimaryDark">#303F9F</color>
<color name="download_data_colorAccent">#FF4081</color>
</resources>
<resources>
<string name="download_data_app_name">Component-download-data</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="download_data_AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/download_data_colorPrimary</item>
<item name="colorPrimaryDark">@color/download_data_colorPrimaryDark</item>
<item name="colorAccent">@color/download_data_colorAccent</item>
</style>
</resources>
package com.gingersoft.gsa.cloud.download;
import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil;
import com.billy.cc.core.component.IComponent;
import com.gingersoft.gsa.cloud.download.mvp.ui.activity.DownloadActivity;
public class ComponentDownload implements IComponent {
@Override
public String getName() {
//组件的名称,调用此组件的方式:
// CC.obtainBuilder("ComponentA")...build().callAsync()
return "Component.Download";
}
/**
* 组件被调用时的入口
* 要确保每个逻辑分支都会调用到CC.sendCCResult,
* 包括try-catch,if-else,switch-case-default,startActivity
* @param cc 组件调用对象,可从此对象中获取相关信息
* @return true:将异步调用CC.sendCCResult(...),用于异步实现相关功能,例如:文件加载、网络请求等
* false:会同步调用CC.sendCCResult(...),即在onCall方法return之前调用,否则将被视为不合法的实现
*/
@Override
public boolean onCall(CC cc) {
String actionName = cc.getActionName();
switch (actionName) {
case "showDownloadActivity":
openActivity(cc);
break;
case "getLifecycleFragment":
//demo for provide fragment object to other component
getLifecycleFragment(cc);
break;
case "lifecycleFragment.addText":
lifecycleFragmentDoubleText(cc);
break;
case "getInfo":
getInfo(cc);
break;
default:
//这个逻辑分支上没有调用CC.sendCCResult(...),是一种错误的示例
//并且方法的返回值为false,代表不会异步调用CC.sendCCResult(...)
//在LocalCCInterceptor中将会返回错误码为-10的CCResult
break;
}
return false;
}
private void lifecycleFragmentDoubleText(CC cc) {
// LifecycleFragment lifecycleFragment = cc.getParamItem("fragment");
// if (lifecycleFragment != null) {
// String text = cc.getParamItem("text", "");
// lifecycleFragment.addText(text);
// CC.sendCCResult(cc.getCallId(), CCResult.success());
// } else {
// CC.sendCCResult(cc.getCallId(), CCResult.error("no fragment params"));
// }
}
private void getLifecycleFragment(CC cc) {
// CC.sendCCResult(cc.getCallId(), CCResult.successWithNoKey(new LifecycleFragment()));
}
private void getInfo(CC cc) {
String userName = "billy";
CC.sendCCResult(cc.getCallId(), CCResult.success("userName", userName));
}
private void openActivity(CC cc) {
CCUtil.navigateTo(cc, DownloadActivity.class);
CC.sendCCResult(cc.getCallId(), CCResult.success());
}
}
package com.gingersoft.gsa.cloud.download.di.component;
import dagger.BindsInstance;
import dagger.Component;
import com.jess.arms.di.component.AppComponent;
import com.gingersoft.gsa.cloud.download.di.module.DownloadModule;
import com.gingersoft.gsa.cloud.download.mvp.contract.DownloadContract;
import com.jess.arms.di.scope.ActivityScope;
import com.gingersoft.gsa.cloud.download.mvp.ui.activity.DownloadActivity;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 12/26/2019 17:59
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@ActivityScope
@Component(modules = DownloadModule.class, dependencies = AppComponent.class)
public interface DownloadComponent {
void inject(DownloadActivity activity);
@Component.Builder
interface Builder {
@BindsInstance
DownloadComponent.Builder view(DownloadContract.View view);
DownloadComponent.Builder appComponent(AppComponent appComponent);
DownloadComponent build();
}
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.download.di.module;
import dagger.Binds;
import dagger.Module;
import com.gingersoft.gsa.cloud.download.mvp.contract.DownloadContract;
import com.gingersoft.gsa.cloud.download.mvp.model.DownloadModel;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 12/26/2019 17:59
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@Module
public abstract class DownloadModule {
@Binds
abstract DownloadContract.Model bindDownloadModel(DownloadModel model);
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.download.mvp.contract;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodBean;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionBean;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel;
import java.util.HashMap;
import androidx.recyclerview.widget.RecyclerView;
import io.reactivex.Observable;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 12/26/2019 17:59
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public interface DownloadContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
RecyclerView getRecycleDownload();
void setDownLoadListAdapter(DefaultAdapter adapter);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
Observable<FunctionBean> downFunctionList();
Observable<FoodBean> downFoodList(String restaurantId);
}
}
package com.gingersoft.gsa.cloud.download.mvp.model;
import android.app.Application;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodBean;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionBean;
import com.gingersoft.gsa.cloud.download.mvp.model.service.DownloadService;
import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
import com.jess.arms.di.scope.ActivityScope;
import javax.inject.Inject;
import com.gingersoft.gsa.cloud.download.mvp.contract.DownloadContract;
import io.reactivex.Observable;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 12/26/2019 17:59
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@ActivityScope
public class DownloadModel extends BaseModel implements DownloadContract.Model {
@Inject
Gson mGson;
@Inject
Application mApplication;
@Inject
public DownloadModel(IRepositoryManager repositoryManager) {
super(repositoryManager);
}
@Override
public void onDestroy() {
super.onDestroy();
this.mGson = null;
this.mApplication = null;
}
@Override
public Observable<FunctionBean> downFunctionList() {
return mRepositoryManager.obtainRetrofitService(DownloadService.class)
.downFunctionList();
}
@Override
public Observable<FoodBean> downFoodList(String restaurantId) {
return mRepositoryManager.obtainRetrofitService(DownloadService.class)
.downFoodList(restaurantId);
}
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.download.mvp.model.bean;
public class DataDownLoadState {
private String text;
private int state = 0;
public DataDownLoadState() {
}
public DataDownLoadState(String text, int state) {
this.text = text;
this.state = state;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
}
package com.gingersoft.gsa.cloud.download.mvp.model.bean;
import com.gingersoft.gsa.cloud.database.bean.Function;
import java.util.List;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019-12-28
* 修订历史:2019-12-28
* 描述:
*/
public class FunctionBean {
/**
* success : true
* sysTime : -7.619911602086376E7
* data : [{"id":-5.450051876040924E7,"status":-6.594638520577614E7,"resName":"non voluptate dolore","resUrl":"sint commodo e","imageURL":"magna sed amet","effectiveTime":8.640891249642807E7},{"id":1112433.804151535,"status":-3.182369490576437E7,"resName":"ipsum magna consequat","resUrl":"in aute","imageURL":"ex non","effectiveTime":-9849064.144339263},{"id":-2.01689121716702E7,"status":-2.10107447801203E7,"resName":"quis","resUrl":"labore consectetur nulla commodo dolor","imageURL":"reprehenderit elit ut","effectiveTime":-3.802933142238536E7},{"id":2.3366445040371537E7,"status":1.2426946110723421E7,"resName":"exercitation qui consectetur est","resUrl":"aute commodo dolor","imageURL":"ea sunt","effectiveTime":3.1788614539086968E7}]
*/
private boolean success;
private double sysTime;
private List<Function> data;
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public double getSysTime() {
return sysTime;
}
public void setSysTime(double sysTime) {
this.sysTime = sysTime;
}
public List<Function> getData() {
return data;
}
public void setData(List<Function> data) {
this.data = data;
}
public static class DataBean {
/**
* id : 5
* status : 1
* resName : non voluptate dolore
* resUrl : sint commodo e
* imageURL : magna sed amet
* effectiveTime : 640891249642807E7
*/
private int id;
private int status;
private long effectiveTime;
private String resName;
private String resUrl;
private String imageURL;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getResName() {
return resName;
}
public void setResName(String resName) {
this.resName = resName;
}
public String getResUrl() {
return resUrl;
}
public void setResUrl(String resUrl) {
this.resUrl = resUrl;
}
public String getImageURL() {
return imageURL;
}
public void setImageURL(String imageURL) {
this.imageURL = imageURL;
}
public long getEffectiveTime() {
return effectiveTime;
}
public void setEffectiveTime(long effectiveTime) {
this.effectiveTime = effectiveTime;
}
}
}
package com.gingersoft.gsa.cloud.download.mvp.model.service;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodBean;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionBean;
import io.reactivex.Observable;
import me.jessyan.retrofiturlmanager.RetrofitUrlManager;
import retrofit2.http.GET;
import retrofit2.http.Query;
import retrofit2.http.Url;
/**
* Created by Wyh on 2019/12/20.
*/
public interface DownloadService {
@GET("user/resource/list" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<FunctionBean> downFunctionList();
@GET("food/list" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<FoodBean> downFoodList(@Query("restaurantId") String restaurantId);
}
package com.gingersoft.gsa.cloud.download.mvp.presenter;
import android.app.Application;
import android.util.Log;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.base.Api;
import com.gingersoft.gsa.cloud.base.utils.constans.HttpsConstans;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.gsa.cloud.database.greendao.FoodDao;
import com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.FunctionDaoUtils;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.DataDownLoadState;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodBean;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionBean;
import com.gingersoft.gsa.cloud.download.mvp.ui.activity.DownloadActivity;
import com.gingersoft.gsa.cloud.download.mvp.ui.adapter.DataDownLoadAdapter;
import com.jess.arms.integration.AppManager;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.http.imageloader.ImageLoader;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import javax.inject.Inject;
import com.gingersoft.gsa.cloud.download.mvp.contract.DownloadContract;
import com.jess.arms.mvp.IView;
import com.jess.arms.utils.DeviceUtils;
import com.jess.arms.utils.RxLifecycleUtils;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 12/26/2019 17:59
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@ActivityScope
public class DownloadPresenter extends BasePresenter<DownloadContract.Model, DownloadContract.View> {
@Inject
RxErrorHandler mErrorHandler;
@Inject
Application mApplication;
@Inject
ImageLoader mImageLoader;
@Inject
AppManager mAppManager;
private DownloadActivity IActivity;
private DataDownLoadAdapter mAapter;
private List<DataDownLoadState> mList = new ArrayList<>();
private String serverAddress;
private int downLoadCount = 0; //下载数据计数
private boolean downLoadState = false;
private String urlList[] = {HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL2 + Api.download_function_list, Api.download_food_list};
@Inject
public DownloadPresenter(DownloadContract.Model model, DownloadContract.View rootView) {
super(model, rootView);
this.IActivity = (DownloadActivity) rootView;
}
@Override
public void onDestroy() {
super.onDestroy();
this.mErrorHandler = null;
this.mAppManager = null;
this.mImageLoader = null;
this.mApplication = null;
}
public void initAdapter() {
initDataDownItem();
if (mAapter == null) {
mAapter = new DataDownLoadAdapter(mApplication, mList);
mRootView.setDownLoadListAdapter(mAapter);
}
}
public void downAllList() {
if (!DeviceUtils.netIsConnected(mApplication)) {
mRootView.showMessage("Can not connect server, retry?");
}
//初始化下载记录标志
downLoadCount = 0;
downLoadState = false;
down_load_data(urlList);
}
public void down_load_data(String[] url) {
String restaurantId = "26";
Observable.mergeArray(mModel.downFunctionList(), mModel.downFoodList(restaurantId))
.subscribeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<Object>(mErrorHandler) {
@Override
public void onSubscribe(Disposable d) {
//订阅前先清空正在执行的订阅
unDispose();
//将所有 Disposable放入集中处理
addDispose(d);
for (int i = 0; i < mList.size(); i++) {
mList.get(i).setState(0);
if (i == 0) {
if (DeviceUtils.netIsConnected(mApplication)) {
//初始化下载状态
mList.get(0).setState(1);
}
}
}
mAapter.notifyDataSetChanged();
mRootView.getRecycleDownload().smoothScrollToPosition(0);
}
@Override
public void onComplete() {
if (downLoadState) { //下载完成
if (downLoadCount >= mList.size()) {//全部下载成功 返回原来的页面
mRootView.showMessage("下載成功");
endDownReturn();
} else {//部分下载失败
mRootView.showMessage("部分下載失敗,點擊刷新按鈕重新下載");
}
}
}
@Override
public void onNext(Object o) {
if (o instanceof FunctionBean) {
FunctionBean functionBean = (FunctionBean) o;
if (functionBean != null) {
FunctionDaoUtils functionDao = new FunctionDaoUtils(IActivity);
functionDao.deleteAll();
if (functionBean.isSuccess() && functionBean.getData() != null) {
functionDao.insertMultFunction(functionBean.getData());
}
}
downLoadCount++;
mRootView.getRecycleDownload().smoothScrollToPosition(1);
mList.get(0).setState(2);
if (DeviceUtils.netIsConnected(mApplication)) {
mList.get(1).setState(1);
} else {
mRootView.showMessage("Can not connect server, retry?");
}
} else if (o instanceof FoodBean) {
FoodBean foodBean = (FoodBean) o;
if (foodBean != null) {
FoodDaoUtils foodDao = new FoodDaoUtils(IActivity);
foodDao.deleteAll();
if (foodBean.isSuccess() && foodBean.getData() != null) {
foodDao.insertMultFood(foodBean.getData());
}
}
FoodDaoUtils foodDao = new FoodDaoUtils(IActivity);
List<Food> foodList = foodDao.queryAllFood();
downLoadCount++;
mRootView.getRecycleDownload().smoothScrollToPosition(1);
mList.get(1).setState(2);
downLoadState = true;
// if (DeviceUtils.netIsConnected(mApplication)) {
// mList.get(2).setState(1);
// } else {
// mRootView.showMessage("Can not connect server, retry?");
// }
}
mAapter.notifyDataSetChanged();
}
@Override
public void onError(Throwable t) {
//这里报错需要累加一
downLoadCount++;
mRootView.showMessage("部分下載失敗,點擊刷新按鈕重新下載");
}
});
}
private void endDownReturn() {
CC.obtainBuilder("Component.Main")
.setActionName("showMainActivity")
.build()
.call();
mRootView.killMyself();
}
public void initDataDownItem() {
//1
DataDownLoadState downLoadState1 = new DataDownLoadState();
downLoadState1.setState(0);
downLoadState1.setText("功能列表");
mList.add(downLoadState1);
//2
DataDownLoadState downLoadState2 = new DataDownLoadState();
downLoadState2.setState(0);
downLoadState2.setText("食品列表");
mList.add(downLoadState2);
}
}
package com.gingersoft.gsa.cloud.download.mvp.ui.activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import com.gingersoft.gsa.cloud.download.R;
import com.gingersoft.gsa.cloud.download.di.component.DaggerDownloadComponent;
import com.gingersoft.gsa.cloud.ui.dialog.LoadingDialog;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.gingersoft.gsa.cloud.download.mvp.contract.DownloadContract;
import com.gingersoft.gsa.cloud.download.mvp.presenter.DownloadPresenter;
import com.qmuiteam.qmui.widget.QMUITopBar;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import static com.jess.arms.utils.Preconditions.checkNotNull;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 12/26/2019 17:59
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public class DownloadActivity extends BaseActivity<DownloadPresenter> implements DownloadContract.View {
@BindView(R.id.topbar)
QMUITopBar mTopBar;
@BindView(R.id.recycle_download)
RecyclerView recycle_download;
@Override
public void setupActivityComponent(@NonNull AppComponent appComponent) {
DaggerDownloadComponent //如找不到该类,请编译一下项目
.builder()
.appComponent(appComponent)
.view(this)
.build()
.inject(this);
}
@Override
public int initView(@Nullable Bundle savedInstanceState) {
return R.layout.download_data_activity_download; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
}
@Override
public void initData(@Nullable Bundle savedInstanceState) {
mPresenter.initAdapter();
mPresenter.downAllList();
}
@Override
public void initIntent() {
}
@Override
public void initTopBar() {
mTopBar.setBackgroundColor(ContextCompat.getColor(this, R.color.theme_color));
mTopBar.addLeftBackImageButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
killMyself();
}
});
mTopBar.addRightTextButton("刷新", R.id.topbar).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPresenter.downAllList();
}
});
mTopBar.setTitle("數據下載");
}
@Override
public void initLanguage() {
}
@Override
public void initLayoutParams() {
}
@Override
public void initLayoutVisible() {
}
@Override
public void showLoading(String message) {
if (message != null)
LoadingDialog.showDialogForLoading(this, message, true);
else
LoadingDialog.showDialogForLoading(this);
}
@Override
public void hideLoading() {
LoadingDialog.cancelDialogForLoading();
}
@Override
public void showMessage(@NonNull String message) {
checkNotNull(message);
ArmsUtils.snackbarText(message);
}
@Override
public void launchActivity(@NonNull Intent intent) {
checkNotNull(intent);
ArmsUtils.startActivity(intent);
}
@Override
public void killMyself() {
finish();
}
@Override
public RecyclerView getRecycleDownload() {
return recycle_download;
}
@Override
public void setDownLoadListAdapter(DefaultAdapter adapter) {
recycle_download.setAdapter(adapter);
initDownLoadRecycleView();
}
private void initDownLoadRecycleView() {
LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
ArmsUtils.configRecyclerView(recycle_download, manager);
}
}
package com.gingersoft.gsa.cloud.download.mvp.ui.adapter;
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.download.R;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.DataDownLoadState;
import com.jess.arms.base.BaseHolder;
import com.jess.arms.base.DefaultAdapter;
import java.util.List;
import butterknife.BindView;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2018/6/27
* 修订历史:2018/6/27
* 描述:
*/
public class DataDownLoadAdapter extends DefaultAdapter<DataDownLoadState> {
private Context mContext;
public DataDownLoadAdapter(Context context, List<DataDownLoadState> infos) {
super(infos);
this.mContext = context;
}
@Override
public int getItemCount() {
return mInfos.size();
}
@Override
public BaseHolder<DataDownLoadState> getHolder(View v, int viewType) {
return new DataDownLoadItemHolder(v);
}
@Override
public int getLayoutId(int viewType) {
return R.layout.download_data_item_download_list;
}
class DataDownLoadItemHolder extends BaseHolder<DataDownLoadState> {
@BindView(R.id.iv_state)
ImageView iv_state;
@BindView(R.id.tv_title)
TextView tv_title;
@BindView(R.id.pb_progress)
ProgressBar pb_progress;
public DataDownLoadItemHolder(View itemView) {
super(itemView);
}
@Override
public void setData(DataDownLoadState dataDownLoadState, int position) {
tv_title.setText(dataDownLoadState.getText());
switch (dataDownLoadState.getState()) {
case 0:
iv_state.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_down_load_wait));
pb_progress.setVisibility(View.GONE);
break;
case 1:
iv_state.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_down_load_download));
pb_progress.setVisibility(View.VISIBLE);
break;
case 2:
iv_state.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_down_load_success));
pb_progress.setVisibility(View.GONE);
break;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<com.qmuiteam.qmui.widget.QMUIWindowInsetLayout 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">
<com.qmuiteam.qmui.widget.QMUITopBar
android:id="@+id/topbar"
android:layout_width="match_parent"
android:layout_height="?attr/qmui_topbar_height" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycle_download"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadeScrollbars="false"
android:layout_marginTop="?attr/qmui_topbar_height"
android:listSelector="@color/theme_background_color">
</androidx.recyclerview.widget.RecyclerView>
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/theme_white_color"
android:descendantFocusability="blocksDescendants"
android:paddingBottom="10dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="10dp">
<ImageView
android:id="@+id/iv_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:focusable="false"
android:src="@drawable/qmui_icon_tip_new" />
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="TextView01"
android:textColor="@color/theme_color"
android:textSize="20dip" />
<ProgressBar
android:id="@+id/pb_progress"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginRight="16dp"
android:layout_toLeftOf="@+id/iv_state"
android:visibility="gone" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<dimen name="title_text_size">26dp</dimen> </resources>
<dimen name="edit_text_size">18dp</dimen>
</resources>
\ No newline at end of file
<resources> <resources>
<dimen name="fab_margin">16dp</dimen>
</resources> </resources>
<resources> <resources>
<string name="app_name">GSA-Cloud</string>
<string name="action_settings">Settings</string>
</resources> </resources>
apply from: rootProject.file('cc-settings.gradle')
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
// 避免 lint 检测出错时停止构建
lintOptions {
abortOnError false
}
defaultConfig {
if (project.ext.runAsApp) {
applicationId "com.gingersoft.cloud.gsa.main"
}
minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
versionCode rootProject.ext.android["versionCode"]
versionName rootProject.ext.android["versionName"]
}
resourcePrefix "main"
buildTypes {
release {
postprocessing {
removeUnusedCode false
removeUnusedResources false
obfuscate false
optimizeCode false
proguardFiles 'proguard.cfg'
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
// test
testImplementation rootProject.ext.dependencies["junit"]
debugImplementation rootProject.ext.dependencies["canary-debug"]
releaseImplementation rootProject.ext.dependencies["canary-release"]
testImplementation rootProject.ext.dependencies["canary-release"]
}
# 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
package com.gingersoft.cloud.gsa;
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.gingersoft.cloud.gsa", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.gsa.cloud.main">
<application>
<activity android:name=".mvp.ui.activity.MainActivity">
</activity>
</application>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.gsa.cloud"> package="com.gingersoft.gsa.cloud.main">
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application <application
android:name=".application.MyApp" android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme.Base">
<activity android:name=".main.ActivityA"> <activity android:name=".mvp.ui.activity.MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<meta-data
android:name="network.config.GlobalConfiguration"
android:value="ConfigModule" />
<meta-data
android:name="design_width_in_dp"
android:value="360" />
<meta-data
android:name="design_height_in_dp"
android:value="540" />
</application> </application>
</manifest> </manifest>
\ No newline at end of file
package com.joe.base.application; package debug;
import android.app.Application; import android.app.Application;
import android.content.Context;
import com.billy.cc.core.component.CC; import com.billy.cc.core.component.CC;
/** /**
* Created by Wyh on 2019/12/21. * @author billy.qi
* @since 17/11/20 20:02
*/ */
public class BaseApplication extends Application { public class MyApp extends Application {
/**
* 系统上下文
*/
private static Context mAppContext;
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
mAppContext = getApplicationContext();
CC.enableVerboseLog(true); CC.enableVerboseLog(true);
CC.enableDebug(true); CC.enableDebug(true);
CC.enableRemoteCC(true); CC.enableRemoteCC(true);
} }
/**
* 获取系统上下文:用于ToastUtil类
*/
public static Context getAppContext() {
return mAppContext;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment