Skip to content

Commit eb228d2

Browse files
committed
1、增加FastConfig配置TitleBarView 并抽离FastTitleConfigEntity管理可全局设置TitleBarView众多自定义属性效果
1 parent cad8d75 commit eb228d2

24 files changed

+742
-198
lines changed

apk/sample.apk

345 Bytes
Binary file not shown.

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ android {
1414
applicationId "com.aries.library.fast.demo"
1515
minSdkVersion ext.minSdkVersion
1616
targetSdkVersion ext.targetSdkVersion
17-
versionCode 213
18-
versionName "2.1.5-alpha1"
17+
versionCode 215
18+
versionName "2.1.5"
1919
multiDexEnabled true
2020
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
2121
buildConfigField "String", "BASE_URL", "\"https://api.douban.com/\""
@@ -83,7 +83,7 @@ dependencies {
8383
//webView库 继承FastWebActivity需要,不需要内置WebView可以不compile
8484
compile 'com.just.agentweb:agentweb:2.0.1'
8585
//常用UI控件(TitleBarView、RadiusView、UIAlertView、UIActionSheetView、UIProgressView等),快速标题栏fast_layout_title_bar,继承FastTitleXXX类需要
86-
compile 'com.github.AriesHoo:UIWidget:2.0.1'
86+
compile 'com.github.AriesHoo:UIWidget:2.0.2'
8787
//下拉刷新库注意刷新头SmartRefreshHeader版本要对应
8888
compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.3'
8989
//图片加载

app/src/main/java/com/aries/library/fast/demo/App.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
import com.aries.library.fast.FastApplication;
77
import com.aries.library.fast.FastConfig;
88
import com.aries.library.fast.demo.helper.RefreshHeaderHelper;
9+
import com.aries.library.fast.entity.FastTitleConfigEntity;
910
import com.aries.library.fast.manager.LoggerManager;
1011
import com.aries.library.fast.retrofit.FastRetrofit;
1112
import com.aries.library.fast.util.SizeUtil;
1213
import com.aries.library.fast.util.ToastUtil;
13-
import com.chad.library.adapter.base.animation.SlideInRightAnimation;
14+
import com.chad.library.adapter.base.animation.ScaleInAnimation;
1415
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreater;
1516
import com.scwang.smartrefresh.layout.api.RefreshHeader;
1617
import com.scwang.smartrefresh.layout.api.RefreshLayout;
@@ -19,7 +20,7 @@
1920
/**
2021
* Created: AriesHoo on 2017/7/20 14:11
2122
* Function: 基础配置Application
22-
* Desc:
23+
* Desc: 是否继承根据情况而定--滑动返回设置请查看 {@link FastApplication}
2324
*/
2425
public class App extends FastApplication {
2526
private static Context mContext;
@@ -30,7 +31,6 @@ public class App extends FastApplication {
3031
public void onCreate() {
3132
super.onCreate();
3233
mContext = this;
33-
3434
//初始化Logger日志打印
3535
LoggerManager.init(TAG, BuildConfig.DEBUG);
3636
//初始化toast工具
@@ -53,26 +53,37 @@ public void onCreate() {
5353
//增加一个Header配置注意FastMultiUrl.BASE_URL_NAME_HEADER是必须后面"test"作为标记
5454
// FastMultiUrl里增加的拦截器才找得到对应的BaseUrl
5555

56-
LoggerManager.d("context:" + this);
5756

5857
//全局配置参数
58+
//推荐先获取library里默认TitleBarView配置再按需修改的模式 FastTitleConfigEntity
59+
FastTitleConfigEntity titleConfig = FastConfig.getInstance(mContext).getTitleConfig();
5960
FastConfig.getInstance(mContext)
60-
.setTitleBackgroundResource(R.color.colorTitleBackground)//设置TitleBarView背景资源
61+
// 其它属性请查看getInstance默认设置
62+
.setTitleConfig(titleConfig
63+
//设置TitleBarView 所有TextView颜色
64+
.setTitleTextColor(mContext.getResources().getColor(R.color.colorTitleText))
65+
//设置TitleBarView背景资源
66+
.setTitleBackgroundResource(R.color.colorTitleBackground)
67+
//设置是否状态栏浅色模式(深色状态栏文字及图标)
68+
.setLightStatusBarEnable(true)
69+
//设置TitleBarView海拔高度
70+
.setTitleElevation(mContext.getResources().getDimension(R.dimen.dp_elevation)))
71+
//设置Glide背景色
72+
.setPlaceholderColor(mContext.getResources().getColor(R.color.colorPlaceholder))
73+
//设置Glide圆角背景弧度
74+
.setPlaceholderRoundRadius(mContext.getResources().getDimension(R.dimen.dp_placeholder_radius))
6175
.setContentViewBackgroundResource(R.color.colorBackground)//设置Activity或Fragment根布局背景资源
62-
.setTitleTextColor(mContext.getResources().getColor(R.color.colorTitleText))//设置TitleBarView 所有TextView颜色
63-
.setLightStatusBarEnable(true)//设置是否状态栏浅色模式(深色状态栏文字及图标)
64-
.setSwipeBackEnable(true)//设置Activity是否支持滑动返回
76+
.setSwipeBackEnable(true)//设置Activity是否支持滑动返回--注意设置透明主题参考demo
6577
.setAdapterAnimationEnable(true) //是否设置Adapter加载动画
66-
.setDefaultAdapterAnimation(new SlideInRightAnimation())//设置全局Adapter加载动画--设置该方法内部同步调用setAdapterAnimationEnable(true)
78+
.setDefaultAdapterAnimation(new ScaleInAnimation())//设置全局Adapter加载动画--设置该方法内部同步调用setAdapterAnimationEnable(true)
6779
.setDefaultRefreshHeader(new DefaultRefreshHeaderCreater() {//设置SmartRefreshLayout刷新头-自定加载使用BaseRecyclerViewAdapterHelper
6880
@NonNull
6981
@Override
7082
public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) {
7183
layout.setEnableHeaderTranslationContent(false);
7284
return RefreshHeaderHelper.getInstance().getRefreshHeader(mContext);
7385
}
74-
})
75-
.setTitleElevation(mContext.getResources().getDimension(R.dimen.dp_elevation));
86+
});
7687
}
7788

7889
/**

app/src/main/java/com/aries/library/fast/demo/module/WebViewActivity.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
import android.app.Activity;
44
import android.os.Build;
55
import android.os.Bundle;
6-
import android.support.v4.view.ViewCompat;
76
import android.view.View;
87
import android.webkit.WebView;
98

10-
import com.aries.library.fast.demo.R;
119
import com.aries.library.fast.manager.LoggerManager;
1210
import com.aries.library.fast.module.activity.FastWebActivity;
1311
import com.aries.ui.view.title.TitleBarView;
@@ -39,13 +37,11 @@ public boolean isLightStatusBarEnable() {
3937

4038
@Override
4139
public void setTitleBar(TitleBarView titleBar) {
42-
ViewCompat.setElevation(titleBar,
43-
mContext.getResources().
44-
getDimensionPixelSize(R.dimen.dp_elevation));
4540
if (!mIsShowTitle) {
4641
titleBar.setVisibility(View.GONE);
4742
}
48-
titleBar.setDividerVisible(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP);
43+
titleBar.setTitleMainTextMarquee(true)
44+
.setDividerVisible(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP);
4945
}
5046

5147
@Override

app/src/main/java/com/aries/library/fast/demo/module/main/MainActivity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.aries.library.fast.demo.module.activity.ActivityFragment;
77
import com.aries.library.fast.demo.module.mine.MineFragment;
88
import com.aries.library.fast.entity.FastTabEntity;
9-
import com.aries.library.fast.manager.LoggerManager;
109
import com.aries.library.fast.module.activity.FastMainActivity;
1110
import com.flyco.tablayout.CommonTabLayout;
1211

@@ -41,7 +40,6 @@ public void setTabLayout(CommonTabLayout tabLayout) {
4140

4241
@Override
4342
public void initView(Bundle savedInstanceState) {
44-
LoggerManager.d(TAG, "context:" + this.getApplicationContext());
4543
}
4644

4745
}

app/src/main/res/layout/fragment_mine.xml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<ScrollView
3-
xmlns:android="http://schemas.android.com/apk/res/android"
2+
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
43
xmlns:app="http://schemas.android.com/apk/res-auto"
54
android:layout_width="match_parent"
65
android:layout_height="match_parent"
@@ -12,7 +11,7 @@
1211
android:layout_height="wrap_content"
1312
android:orientation="vertical">
1413

15-
<include layout="@layout/fast_layout_title_bar"/>
14+
<include layout="@layout/fast_layout_title_bar" />
1615

1716
<com.allen.library.SuperTextView
1817
android:id="@+id/stv_infoMine"
@@ -32,7 +31,7 @@
3231
app:sLeftBottomTextString="简书:"
3332
app:sLeftIconHeight="75dp"
3433
app:sLeftIconMarginLeft="@dimen/dp_margin_item"
35-
app:sLeftIconRes="@drawable/fast_shape_placeholder_circle"
34+
app:sLeftIconRes="@color/colorPlaceholder"
3635
app:sLeftIconWidth="75dp"
3736
app:sLeftMaxEms="2000"
3837
app:sLeftTextColor="@color/colorTextBlackLight"
@@ -52,20 +51,20 @@
5251
android:id="@+id/stv_setting"
5352
style="@style/SupperTextStyleItem"
5453
app:sLeftIconRes="@drawable/ic_setting"
55-
app:sLeftTextString="@string/setting"/>
54+
app:sLeftTextString="@string/setting" />
5655

5756
<com.allen.library.SuperTextView
5857
android:id="@+id/stv_libraryMine"
5958
style="@style/SupperTextStyleItem"
6059
app:sDividerLineType="none"
6160
app:sLeftIconRes="@drawable/ic_github"
62-
app:sLeftTextString="@string/library_address"/>
61+
app:sLeftTextString="@string/library_address" />
6362

6463
<com.allen.library.SuperTextView
6564
android:id="@+id/stv_thirdLibMine"
6665
style="@style/SupperTextStyleItem"
6766
app:sLeftIconRes="@drawable/ic_project"
68-
app:sLeftTextString="@string/third_part"/>
67+
app:sLeftTextString="@string/third_part" />
6968

7069
<com.allen.library.SuperTextView
7170
android:id="@+id/stv_shareMine"
@@ -75,6 +74,6 @@
7574
app:sLeftIconMarginLeft="13dp"
7675
app:sLeftIconRes="@drawable/ic_share"
7776
app:sLeftIconWidth="22dp"
78-
app:sLeftTextString="@string/share"/>
77+
app:sLeftTextString="@string/share" />
7978
</LinearLayout>
8079
</ScrollView>

app/src/main/res/layout/item_subject_movie.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
android:layout_margin="10dp"
1515
android:minHeight="100dp"
1616
android:minWidth="72dp"
17-
android:src="@drawable/fast_shape_placeholder_round"
17+
android:src="@color/colorPlaceholder"
1818
android:scaleType="centerCrop"/>
1919

2020
<TextView

app/src/main/res/layout/layout_banner.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
android:layout_height="200dp"
1313
app:banner_indicatorGravity="bottom|left"
1414
app:banner_isNeedShowIndicatorOnOnlyOnePage="true"
15-
app:banner_placeholderDrawable="@drawable/fast_shape_placeholder_common"
15+
app:banner_placeholderDrawable="@color/colorPlaceholder"
1616
app:banner_pointAutoPlayInterval="2500"
1717
app:banner_pointContainerBackground="#80000000"
1818
app:banner_pointContainerLeftRightPadding="10dp"

library/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
defaultConfig {
99
minSdkVersion 15
1010
targetSdkVersion 25
11-
versionCode 213
12-
versionName "2.1.5-alpha1"
11+
versionCode 215
12+
versionName "2.1.5"
1313
}
1414
buildTypes {
1515
release {
@@ -49,7 +49,7 @@ dependencies {
4949
//webView库
5050
provided 'com.just.agentweb:agentweb:2.0.1'
5151
//常用UI控件(TitleBarView、RadiusView等)
52-
provided 'com.github.AriesHoo:UIWidget:2.0.1'
52+
provided 'com.github.AriesHoo:UIWidget:2.0.2'
5353
//下拉刷新库
5454
provided 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.3'
5555
//图片加载

library/src/main/java/com/aries/library/fast/FastApplication.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import android.app.Application;
44
import android.os.Build;
55

6-
import com.aries.library.fast.util.ToastUtil;
7-
86
import java.util.Arrays;
97

108
import cn.bingoogolapple.swipebacklayout.BGASwipeBackManager;
@@ -19,7 +17,7 @@ public class FastApplication extends Application {
1917
@Override
2018
public void onCreate() {
2119
super.onCreate();
22-
ToastUtil.init(getApplicationContext());//初始化Toast工具类
20+
2321
BGASwipeBackManager.getInstance().init(this);//初始化滑动返回关闭Activity功能
2422
// 导航栏处理--不设置会预留一块导航栏高度的空白
2523
BGASwipeBackManager.ignoreNavigationBarModels(Arrays.asList(Build.MODEL));

0 commit comments

Comments
 (0)