javadoc文檔生成方式
- 生成目錄:根目錄/dokka/..
- 使用命令
#全部
./gradlew dokkaHtml
#單個(gè)
./gradlew :base:dokkaHtml
./gradlew :library:http-cache:dokkaHtml
A迅细、初始化配置
規(guī)范:
1.初始化代碼放到application工程下;
2.不要直接放到Application子類下去初始化娶眷;
3.規(guī)范使用參考yhdos項(xiàng)目下YHBaseUIConfig類毛甲;
一、base
YHBaseConfigProxy.init(object : IYHBaseConfig {
override fun isAppDebugModel(): Boolean {
return YHBaseUIConfig.isAppDebugModel()
}
override fun isRequestErrorDirectlyShowMessage(): Boolean {
return YHBaseUIConfig.isRequestErrorDirectlyShowMessage()
}
})
二砂轻、http-cache
CacheManager.setHttpCacheConfigInterceptor(object : IHttpCacheConfigInterceptor {
override fun isOpenMock(): Boolean {
return false
}
override fun isSuccessResponseCode(code: Int, request: Request): Boolean {
return (request != null // && request.url().toString().startsWith(UrlUtil.getUrl())
&& code == 200000)
}
override fun isSuccessResponse(response: String, request: Request): Boolean {
return !TextUtils.isEmpty(response) && response.startsWith("{\"code\":200000")
}
})
三、http-core
Https.addInterceptor(AppParamInterceptor())
Https.init(object : IHttpInitConfigInterceptor {
override fun isPrintLog(status: Int): Boolean = isHttpPrintLogDebugModel(status)
override fun configOkHttpClientBuilder(
builder: OkHttpClient.Builder,
url: String,
useCache: Boolean
) {
}
override fun configRetrofitBuilder(
builder: Retrofit.Builder,
url: String,
useCache: Boolean
) {
}
})
四然爆、lib-imageLoader
無
五站粟、lib-log
LogConfig.setIsDebug(UtilsConfig.isAllDebugModel() || BuildConfig.DEBUG)
LogUtils.initLogConfig()
六、lib-utils
UtilsConfig.setContext(context)
//如果使用
MMKV.initialize(context)
七曾雕、lib-widget
無
八奴烙、RecyclerView-Adapter
無
九、lib-baiduMap
十剖张、lib-pay
十一切诀、lib-photoview
十二、lib-picture
B搔弄、使用
一幅虑、base
-
IDelegateUI
關(guān)注方法功能,實(shí)現(xiàn)類BaseActivity顾犹、BaseFragment倒庵、BaseDialogFragment,約束應(yīng)用層代碼規(guī)范炫刷,方便閱讀和維護(hù)擎宝; -
BaseViewModel
數(shù)據(jù)提供,封裝了網(wǎng)絡(luò)請(qǐng)求浑玛;
open class BaseViewModel : ViewModel() {
//需要關(guān)注這些常量的作用绍申,他們可以進(jìn)行邏輯運(yùn)算組合(| or &)
companion object {
//默認(rèn)
const val FLAG_DEFAULT: Int = 0x1 shl 31
//返回不用彈toast(如果不設(shè)置,請(qǐng)求出錯(cuò)會(huì)有默認(rèn)toast)
const val FLAG_NO_TOAST: Int = 0x1
//請(qǐng)求發(fā)起loading動(dòng)畫
const val FLAG_LOADING: Int = 0x1 shl 1
//請(qǐng)求出錯(cuò)頁(yè)面顯示異常頁(yè)面
const val FLAG_ERROR_LAYER: Int = 0x1 shl 2
}
}
-
IRsp
接口锄奢,適配服務(wù)器不同數(shù)據(jù)結(jié)構(gòu)失晴,方便應(yīng)用層統(tǒng)一處理數(shù)據(jù); -
YHRequest
BaseViewModel里內(nèi)部類拘央,封城了網(wǎng)絡(luò)請(qǐng)求,所有請(qǐng)求通過該類來構(gòu)造书在; -
ErrorLayer
接口灰伟,用于覆蓋錯(cuò)誤頁(yè)面等其他情況頁(yè)面;
二儒旬、http-cache
1.CachedInterceptor
核心類
OkHttpClient.Builder.addInterceptor(CachedInterceptor(useCache));
三栏账、http-core
1.Https
核心類
Https.service(UrlUtil.getUrl(), SearchApi::class.java)
四、lib-imageLoader
1.YHImageRequestBuilder
核心類
YHImageLoader.with(context)
.load(url ?: "")
.placeholder(placeholderId)
.error(errorId)
.into(target)
五栈源、lib-log
LogUtils.i("--> 請(qǐng)求Start:");
六挡爵、lib-utils
無
七、lib-widget
無
八甚垦、RecyclerView-Adapter
1.ItemViewDelegate
class SearchEditViewDelegate :
com.yh.base.recyclerview.adapter.ItemViewDelegate<SearchHistoryEntity, SearchItemEditBinding, Boolean> {
override fun isForViewType(bean: Any?, position: Int): Boolean = bean is SearchHistoryEntity
override fun getViewBinding(inflater: LayoutInflater, parent: ViewGroup?): SearchItemEditBinding = SearchItemEditBinding.inflate(inflater, parent, false)
override fun convert(mViewBinding: SearchItemEditBinding, bean: SearchHistoryEntity?, position: Int, flag: Boolean?) {
com.yh.base.lib.log.LogUtils.i("CategoryFirstViewDelegate convert position:$position")
mViewBinding.root.setTag(R.id.tag_position, position)
mViewBinding.root.setTag(R.id.tag_bean, bean)
if (bean == null) {
return
}
with(mViewBinding) {
tvName.text = bean.name
tvName.setBackgroundResource(R.drawable.shape_bg_tag_no)
tvName.setTextColor(ContextCompat.getColor(root.context, R.color.textColor_grey_normal))
}
}
}
2.SingleTypeAdapter
和 MultiItemTypeAdapter
class SearchGoodsAdapter(var context: Context, var isShowEnterShop: Boolean, var isLinear: Boolean) : com.yh.base.recyclerview.adapter.MultiItemTypeAdapter(context) {
init {
addItemViewDelegate(SearchGoodsLinearViewDelegate(isShowEnterShop, isLinear, true))
addItemViewDelegate(SearchGoodsGridViewDelegate(!isLinear, true))
addItemViewDelegate(SearchShopViewDelegate())
}
override fun isDefaultListener(): Boolean = false
}
九茶鹃、lib-baiduMap
十涣雕、lib-pay
十一、lib-photoview
十二闭翩、lib-picture