Skip to content

Commit

Permalink
修改FastManager初始化方式
Browse files Browse the repository at this point in the history
增加快速模板template 开发者可直接拷贝该项目修改继续开发
  • Loading branch information
AriesHoo committed Mar 3, 2020
1 parent 193df11 commit 43a2b30
Show file tree
Hide file tree
Showing 39 changed files with 1,980 additions and 44 deletions.
Binary file modified apk/sample.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
import android.widget.ImageView;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;

import com.aries.library.fast.BuildConfig;
import com.aries.library.fast.FastLifecycleCallbacks;
import com.aries.library.fast.basis.BasisActivity;
Expand Down Expand Up @@ -58,6 +51,13 @@

import java.util.List;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;

import static com.aries.library.fast.demo.App.isControlNavigation;

/**
Expand Down Expand Up @@ -210,11 +210,14 @@ private boolean isLeak(Activity activity) {
*/
@Override
public boolean setNavigationBar(Activity activity, NavigationViewHelper helper, View bottomView) {

Activity previous = FastStackUtil.getInstance().getPrevious();
boolean enable = previous != null && previous instanceof SwipeBackActivity;
//其它默认属性请参考FastLifecycleCallbacks
helper.setLogEnable(BuildConfig.DEBUG)
.setPlusNavigationViewEnable(true)
//此处为配合BGASwipeBackHelper滑动返回效果-如不使用BGASwipeBackHelper推荐使用上面的方法
// .setPlusNavigationViewEnable(true, true, true)
.setPlusNavigationViewEnable(true, enable, enable)
.setNavigationBarLightMode(NavigationBarUtil.isSupportNavigationBarFontChange() && isPlusView(activity))
.setOnKeyboardVisibilityChangedListener(getOnKeyboardVisibilityChangedListener(activity))
.setBottomView(PicturePreviewActivity.class.isAssignableFrom(activity.getClass()) ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void setSwipeBack(Activity activity, BGASwipeBackHelper swipeBackHelper)
//需设置activity window背景为透明避免滑动过程中漏出背景也可减少背景层级降低过度绘制
activity.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
swipeBackHelper.setSwipeBackEnable(true)
.setIsNavigationBarOverlap(true)
.setShadowResId(R.drawable.bga_sbl_shadow);
}

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ ext{
targetSdkVersion = 28
supportVersion = "1.0.0"
widgetVersion = "3.2.25"
versionCode = 247
versionName = "2.3.5"
versionCode = 248
versionName = "2.3.6"
}
2 changes: 1 addition & 1 deletion library/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
public *;
}
# for DexGuard only
-keepresourcexmlelements manifest/application/meta-data@value=GlideModule
#-keepresourcexmlelements manifest/application/meta-data@value=GlideModule
#Glide-END

#EventBus-START
Expand Down
24 changes: 12 additions & 12 deletions library/src/main/java/com/aries/library/fast/FastFileProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import android.content.Context;
import android.util.Log;

import androidx.core.content.FileProvider;

import com.aries.library.fast.util.FastFileUtil;
import com.aries.library.fast.util.FastUtil;

import androidx.core.content.FileProvider;

/**
* @Author: AriesHoo on 2018/7/23 14:39
* @E-Mail: [email protected]
Expand All @@ -17,14 +17,14 @@
* 1、2019-9-16 14:34:51 增加FastManager初始化
*/
public class FastFileProvider extends FileProvider {
// @Override
// public boolean onCreate() {
// Context context = getContext().getApplicationContext();
// if(context==null){
// context = FastUtil.getApplication();
// }
// Log.d("FastFileProvider", "context:" + context);
// FastManager.init((Application) context);
// return super.onCreate();
// }
@Override
public boolean onCreate() {
Context context = getContext().getApplicationContext();
if(context==null){
context = FastUtil.getApplication();
}
Log.d("FastFileProvider", "context:" + context);
FastManager.init((Application) context);
return super.onCreate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;

import com.aries.library.fast.delegate.FastRefreshDelegate;
import com.aries.library.fast.delegate.FastTitleDelegate;
import com.aries.library.fast.i.ActivityFragmentControl;
Expand All @@ -37,6 +32,10 @@
import com.aries.ui.view.tab.CommonTabLayout;
import com.aries.ui.view.title.TitleBarView;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import cn.bingoogolapple.swipebacklayout.BGASwipeBackHelper;

/**
Expand Down Expand Up @@ -307,7 +306,8 @@ public void onSwipeBackLayoutExecuted() {
mSwipeBackControl.onSwipeBackLayoutExecuted(activity);
}
}
});
})
.setIsNavigationBarOverlap(true);
//用于全局控制
if (mSwipeBackControl != null) {
mSwipeBackControl.setSwipeBack(activity, swipeBackHelper);
Expand Down
11 changes: 5 additions & 6 deletions library/src/main/java/com/aries/library/fast/FastManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import android.util.Log;

import com.aries.library.fast.delegate.FastRefreshDelegate;
import com.aries.library.fast.delegate.FastRefreshLoadDelegate;
Expand All @@ -23,7 +21,6 @@
import com.aries.library.fast.i.TitleBarViewControl;
import com.aries.library.fast.i.ToastControl;
import com.aries.library.fast.manager.GlideManager;
import com.aries.library.fast.manager.LoggerManager;
import com.aries.library.fast.retrofit.FastLoadingObserver;
import com.aries.library.fast.retrofit.FastObserver;
import com.aries.library.fast.util.FastUtil;
Expand All @@ -32,6 +29,8 @@
import com.aries.ui.widget.progress.UIProgressDialog;
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator;

import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import cn.bingoogolapple.swipebacklayout.BGASwipeBackHelper;

/**
Expand All @@ -47,7 +46,7 @@ public class FastManager {
static {
Application application = FastUtil.getApplication();
if (application != null) {
LoggerManager.i("FastManager", "initSuccess");
Log.i("FastManager", "initSuccess");
init(application);
}
}
Expand Down Expand Up @@ -137,7 +136,7 @@ public Application getApplication() {
* @return
*/
static FastManager init(Application application) {
LoggerManager.i("init_mApplication:" + mApplication + ";application;" + application);
Log.i("FastManager","init_mApplication:" + mApplication + ";application;" + application);
//保证只执行一次初始化属性
if (mApplication == null && application != null) {
mApplication = application;
Expand Down
14 changes: 7 additions & 7 deletions library/src/main/java/com/aries/library/fast/util/FastUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;

import com.aries.library.fast.FastConstant;
import com.aries.library.fast.manager.LoggerManager;
import com.aries.ui.util.DrawableUtil;

import java.lang.reflect.Method;
Expand Down Expand Up @@ -59,7 +59,7 @@ public static Application getApplication() {
try {
//兼容android P,直接调用@hide注解的方法来获取application对象
Application app = ActivityThread.currentApplication();
LoggerManager.e("getApplication0:" + app);
Log.e("FastUtil", "getApplication0:" + app);
if (app != null) {
return app;
}
Expand All @@ -68,7 +68,7 @@ public static Application getApplication() {
try {
//兼容android P,直接调用@hide注解的方法来获取application对象
Application app = AppGlobals.getInitialApplication();
LoggerManager.e("getApplication1:" + app);
Log.e("FastUtil", "getApplication1:" + app);
if (app != null) {
return app;
}
Expand All @@ -91,7 +91,7 @@ public static CharSequence getAppName(Context context) {
int labelRes = packageInfo.applicationInfo.labelRes;
return context.getResources().getText(labelRes);
} catch (PackageManager.NameNotFoundException e) {
LoggerManager.e("FastUtil", "getAppName:" + e.getMessage());
Log.e("FastUtil", "getAppName:" + e.getMessage());
}
return null;
}
Expand Down Expand Up @@ -184,7 +184,7 @@ public static String getVersionName(Context context) {
}
}
} catch (PackageManager.NameNotFoundException e) {
LoggerManager.e("FastUtil", "getVersionName:" + e.getMessage());
Log.e("FastUtil", "getVersionName:" + e.getMessage());
}
return "";
}
Expand All @@ -203,7 +203,7 @@ public static int getVersionCode(Context context) {
}
}
} catch (PackageManager.NameNotFoundException e) {
LoggerManager.e("FastUtil", "getVersionCode:" + e.getMessage());
Log.e("FastUtil", "getVersionCode:" + e.getMessage());
}
return -1;
}
Expand Down Expand Up @@ -334,7 +334,7 @@ public static void jumpMarket(Context mContext, String packageName) {
marketIntent.setData(Uri.parse(mAddress));
mContext.startActivity(marketIntent);
} catch (Exception e) {
LoggerManager.e("FastUtil", "jumpMarket:" + e.getMessage());
Log.e("FastUtil", "jumpMarket:" + e.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
* @Author: AriesHoo on 2018/7/23 14:37
* @E-Mail: [email protected]
* Function: Toast 工具
* Description:
* Description: 本工具类只是对系统Toast进行简单的效果样式处理有系统权限问题;如果有更进一步需求推荐使用
* https://github.com/Dovar66/DToast
* 1、2018-7-11 15:40:26 去掉Toast返回值并新增子线程弹出Toast功能
* 2、2019-1-18 18:09:07 新增{@link ToastControl} 全局
*/
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':app', ':library'
include ':app', ':template',':library'
1 change: 1 addition & 0 deletions template/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
114 changes: 114 additions & 0 deletions template/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion rootProject.compileSdkVersion
defaultConfig {
applicationId "com.aries.template"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode rootProject.versionCode
versionName rootProject.versionName
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "Boolean", "LOG_ENABALE", "true"
buildConfigField "String", "BASE_URL", "\"https://api.xxx.com/\""
}

dexOptions {
javaMaxHeapSize "Xg"
preDexLibraries = false
}
signingConfigs {
release {
storeFile file('../fast.jks')
storePassword 'fast123#@!'
keyAlias 'fast'
keyPassword 'fast123#@!'
}
}
// 忽略打包资源错误
lintOptions {
checkReleaseBuilds false
abortOnError false
}
buildTypes {
debug {
//是否debug模式用于控制是否打印log等
debuggable true
zipAlignEnabled false //是否支持Zip Align
shrinkResources false //是否清理无用资源
minifyEnabled false //是否启动混淆
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
release {
debuggable false
zipAlignEnabled true //是否支持Zip Align
shrinkResources true //是否清理无用资源
minifyEnabled true //是否启动混淆
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation" << '-Xlint:-unchecked'
}
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// implementation project(':library')
implementation 'com.github.AriesHoo:FastLib:2.3.5'

//以下库FastLib里使用compileOnly只是编译,使用时需根据项目选择相应版本
implementation 'com.google.android.material:material:'.concat(supportVersion)
implementation 'androidx.appcompat:appcompat:'.concat(supportVersion)
implementation 'androidx.recyclerview:recyclerview:'.concat(supportVersion)
//快速Tab库-继承FastMainActivity使用
implementation "com.github.AriesHoo.UIWidget:tab-layout:$rootProject.widgetVersion"
//页面事件交互-androideventbus-停止维护-按需导入
// implementation 'org.simple:androideventbus:1.0.5.1'
//页面事件交互-eventbus-按需导入
// implementation 'org.greenrobot:eventbus:3.1.1'
//万能适配器--一般都需要吧
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.49-androidx'
//webView库 继承FastWebActivity需要,不需要内置WebView可以不implementation
implementation 'com.just.agentweb:agentweb:4.1.2'
//webView提供下载功能
implementation 'com.download.library:Downloader:4.1.2'
//下拉刷新库注意刷新头SmartRefreshHeader版本最好对应尤其头版本不要低于SmartRefreshLayout版本
implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-andx-14'
//Glide图片加载
implementation 'com.github.bumptech.glide:glide:4.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
//以上库FastLib里使用compileOnly只是编译,使用时需根据项目选择相应版本
// implementation 'cn.bingoogolapple:bga-banner:2.1.7@aar'
implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.1.0-andx-14'
// implementation 'com.github.lygttpod:SuperTextView:2.1.8'
//文件选择器
// implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.2.5'
//友盟统计
// implementation 'com.umeng.analytics:analytics:latest.integration'
//Bugly
// implementation 'com.tencent.bugly:crashreport:2.8.6.0'
//哆啦A梦
// implementation 'com.didichuxing.doraemonkit:doraemonkit:1.2.1'
// debugImplementation 'com.didichuxing.doraemonkit:doraemonkit:1.2.1'
// releaseImplementation 'com.didichuxing.doraemonkit:doraemonkit-no-op:1.2.1'
//Multidex 5.0以下
// implementation 'androidx.multidex:multidex:2.0.0'
//蒲公英
// implementation 'com.pgyersdk:sdk:3.0.5'
//保活组件
// implementation 'com.fanjun:keeplive:1.1.18'
//滑动返回Activity-类全面屏手势效果
// implementation 'com.github.ParfoisMeng:SlideBack:1.0.7'
}
Loading

0 comments on commit 43a2b30

Please sign in to comment.