浏览代码

1.添加chuck

shihuiyun 2 年之前
父节点
当前提交
f1b6927578

+ 1 - 1
.idea/compiler.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="CompilerConfiguration">
-    <bytecodeTargetLevel target="11" />
+    <bytecodeTargetLevel target="1.8" />
   </component>
 </project>

+ 2 - 1
.idea/gradle.xml

@@ -8,7 +8,7 @@
         <option name="disableWrapperSourceDistributionNotification" value="true" />
         <option name="distributionType" value="DEFAULT_WRAPPED" />
         <option name="externalProjectPath" value="$PROJECT_DIR$" />
-        <option name="gradleJvm" value="Embedded JDK" />
+        <option name="gradleJvm" value="1.8" />
         <option name="modules">
           <set>
             <option value="$PROJECT_DIR$" />
@@ -17,6 +17,7 @@
             <option value="$PROJECT_DIR$/basekt" />
           </set>
         </option>
+        <option name="resolveModulePerSourceSet" value="false" />
       </GradleProjectSettings>
     </option>
   </component>

+ 3 - 1
.idea/misc.xml

@@ -170,10 +170,12 @@
         <entry key="..\:/AndroidWorkPlace/XiangLian/purchase_order/src/main/res/layout/p_order_fragment.xml" value="0.33016304347826086" />
         <entry key="..\:/AndroidWorkPlace/XiangLian/sort/src/main/res/layout/fragment_collection.xml" value="0.31637451902522445" />
         <entry key="..\:/AndroidWorkPlace/XiangLian/sort/src/main/res/layout/sort_fragment.xml" value="0.33133817870884996" />
+        <entry key="app/src/main/res/layout/activity_main.xml" value="0.2546875" />
+        <entry key="app/src/main/res/layout/home_fragment.xml" value="0.335" />
       </map>
     </option>
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="11" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/build/classes" />
   </component>
   <component name="ProjectType">

+ 8 - 8
app/src/main/java/com/hdl/xl/service/HttpApi_xie.kt

@@ -18,7 +18,7 @@ import retrofit2.http.POST
 interface HttpApi_xie {
     @POST("api/Index/getBanner")
     fun getBanner(
-        @Header("Authorization") Authorization: String
+        @Header("Authorization") Authorization: String?
     ): Observable<CommonResultEntity<BannerBean>>
 
     /**
@@ -27,7 +27,7 @@ interface HttpApi_xie {
     @FormUrlEncoded
     @POST("api/Index/indexCollectionList")
     fun indexCollectionList(
-        @Header("Authorization") Authorization: String,
+        @Header("Authorization") Authorization: String?,
         @Field("type") type: Int,
         @Field("issue_mode") issue_mode: Int
     ): Observable<CommonResultEntity<CollectionListBean>>
@@ -38,7 +38,7 @@ interface HttpApi_xie {
     @FormUrlEncoded
     @POST("api/Index/CollectionCalendar")
     fun CollectionCalendar(
-        @Header("Authorization") Authorization: String,
+        @Header("Authorization") Authorization: String?,
         @Field("type") type: Int
     ): Observable<CommonResultEntity<CalendarListBean>>
 
@@ -48,7 +48,7 @@ interface HttpApi_xie {
     @FormUrlEncoded
     @POST("api/Index/setRemind")
     fun setRemind(
-        @Header("Authorization") Authorization: String,
+        @Header("Authorization") Authorization: String?,
         @Field("id") id: Int
     ): Observable<CommonResultEntity<CalendarListBean>>
 
@@ -58,7 +58,7 @@ interface HttpApi_xie {
     @FormUrlEncoded
     @POST("api/Index/CollectionDetail")
     fun CollectionDetail(
-        @Header("Authorization") Authorization: String,
+        @Header("Authorization") Authorization: String?,
         @Field("id") id: Int
     ): Observable<CommonResultEntity2<CollectionDetailBean>>
 
@@ -67,7 +67,7 @@ interface HttpApi_xie {
      */
     @POST("api/Index/certificate")
     fun certificate(
-        @Header("Authorization") Authorization: String
+        @Header("Authorization") Authorization: String?
     ): Observable<CommonResultEntity2<CertificateBean>>
 
     /**
@@ -75,7 +75,7 @@ interface HttpApi_xie {
      */
     @POST("api/User_center/getUserInfo")
     fun getUserInfo(
-        @Header("Authorization") Authorization: String
+        @Header("Authorization") Authorization: String?
     ): Observable<CommonResultEntity2<PersonalBean>>
 
     /**
@@ -136,4 +136,4 @@ interface HttpApi_xie {
 
 
 
-}
+}

+ 1 - 3
app/src/main/java/com/hdl/xl/ui/activitys/MainActivity.kt

@@ -15,11 +15,9 @@ import com.hdl.xl.bean.LoginOutEvent
 import com.hdl.xl.databinding.ActivityMainBinding
 import com.hdl.xl.ui.fragments.BrandFragment
 import com.laike.basekt.BaseActivity
-import com.laike.basekt.utils.HawkConstant
 import com.hdl.xl.ui.fragments.HomeFragment
 import com.hdl.xl.ui.fragments.MineFragment
 import com.hdl.xl.ui.fragments.SortFragment
-import com.orhanobut.hawk.Hawk
 import org.greenrobot.eventbus.EventBus
 import org.greenrobot.eventbus.Subscribe
 import org.greenrobot.eventbus.ThreadMode
@@ -167,4 +165,4 @@ class MainActivity : BaseActivity(), RadioGroup.OnCheckedChangeListener {
         EventBus.getDefault().unregister(this)
     }
 
-}
+}

+ 25 - 16
app/src/main/java/com/hdl/xl/ui/fragments/FragmentRecommend.kt

@@ -2,6 +2,7 @@ package com.hdl.xl.ui.fragments
 
 import android.annotation.SuppressLint
 import android.os.Bundle
+import android.text.TextUtils
 import android.util.Log
 import android.view.LayoutInflater
 import android.view.View
@@ -24,6 +25,7 @@ import com.orhanobut.hawk.Hawk
 import org.greenrobot.eventbus.EventBus
 import org.greenrobot.eventbus.Subscribe
 import org.greenrobot.eventbus.ThreadMode
+import java.lang.Exception
 
 class FragmentRecommend : BaseFragment(), View.OnClickListener {
     var mBinding: FragmentRecommendBinding? = null
@@ -67,27 +69,33 @@ class FragmentRecommend : BaseFragment(), View.OnClickListener {
 
     @SuppressLint("CheckResult")
     fun indexCollectionList() {
-        HttpRetrofitRequest.retrofit(HttpApi_xie::class.java)
-            .indexCollectionList(Hawk.get(HawkConstant.TOKEN), 0, 0)
-            .compose(RxSchedulers.applySchedulers())
-            .subscribe({
-                if (it.code == 1) {
 
-                    it.data?.let { it1 -> mAdapter.addDataAll(it1) }
-                    mAdapter.notifyDataSetChanged()
+                HttpRetrofitRequest.retrofit(HttpApi_xie::class.java)
+                    .indexCollectionList(Hawk.get(HawkConstant.TOKEN), 0, 0)
+                    .compose(RxSchedulers.applySchedulers())
+                    .subscribe({
+                        if (it.code == 1) {
+
+                            it.data?.let { it1 -> mAdapter.addDataAll(it1) }
+                            mAdapter.notifyDataSetChanged()
+
+                            mAdapter.addOnItemClickListener { view, entity, position ->
+                                bundle.putInt("id", entity.id ?: 0)
+                                startKtActivityOrForResult<ActivityCollectionDetail>(bundle = bundle)
+                            }
+                        }
+                    }, {
+                        Log.e("searchGoodsDetail", it.message.toString())
+                    })
+
 
-                    mAdapter.addOnItemClickListener { view, entity, position ->
-                        bundle.putInt("id", entity.id ?: 0)
-                        startKtActivityOrForResult<ActivityCollectionDetail>(bundle = bundle)
-                    }
-                }
-            }, {
-                Log.e("searchGoodsDetail", it.message.toString())
-            })
     }
 
     @SuppressLint("CheckResult")
     fun CollectionCalendar() {
+
+
+
         HttpRetrofitRequest.retrofit(HttpApi_xie::class.java)
             .CollectionCalendar(Hawk.get(HawkConstant.TOKEN), 0)
             .compose(RxSchedulers.applySchedulers())
@@ -103,6 +111,7 @@ class FragmentRecommend : BaseFragment(), View.OnClickListener {
             }, {
                 Log.e("searchGoodsDetail", it.message.toString())
             })
+
     }
 
     override fun onClick(v: View?) {
@@ -118,4 +127,4 @@ class FragmentRecommend : BaseFragment(), View.OnClickListener {
     fun eventBusLogin(logOutEvent: LogOutEvent) {
         CollectionCalendar()
     }
-}
+}

+ 7 - 1
app/src/main/java/com/hdl/xl/ui/fragments/HomeFragment.kt

@@ -31,6 +31,7 @@ import com.orhanobut.hawk.Hawk
 import com.youth.banner.Banner
 import com.youth.banner.indicator.CircleIndicator
 import com.youth.banner.listener.OnBannerListener
+import java.lang.Exception
 
 
 /**
@@ -116,6 +117,9 @@ class HomeFragment : BaseFragment(), View.OnClickListener, OnBannerListener<Bann
 
     @SuppressLint("CheckResult")
     fun searchBanner() {
+
+
+
         HttpRetrofitRequest.retrofit(HttpApi_xie::class.java)
             .getBanner(Hawk.get(HawkConstant.TOKEN))
             .compose(RxSchedulers.applySchedulers())
@@ -133,6 +137,8 @@ class HomeFragment : BaseFragment(), View.OnClickListener, OnBannerListener<Bann
             }, {
                 Log.e("searchHomeData", it.message.toString())
             })
+
+
     }
 
     private fun setGradientColor() {
@@ -267,4 +273,4 @@ class HomeFragment : BaseFragment(), View.OnClickListener, OnBannerListener<Bann
             }
         }
     }
-}
+}

+ 5 - 1
basekt/build.gradle

@@ -36,6 +36,10 @@ dependencies {
     implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
     implementation 'androidx.core:core-ktx:1.3.2'
 
+    debugImplementation 'com.readystatesoftware.chuck:library:1.1.0'
+    releaseImplementation 'com.readystatesoftware.chuck:library-no-op:1.1.0'
+
+
     api project(path: ':base')
     api rootProject.dependLibs.appcompt
     api rootProject.dependLibs.design
@@ -54,4 +58,4 @@ dependencies {
     api rootProject.dependLibs.pickerView
     api rootProject.dependLibs.bugly
     api rootProject.dependLibs.hbanner
-}
+}

+ 5 - 0
basekt/src/main/java/com/laike/basekt/coremodel/datemodel/client/RetrofitInitialization.kt

@@ -1,8 +1,10 @@
 package com.laike.basekt.coremodel.datemodel.client
 
+import com.laike.basekt.BaseApplication
 import com.laike.basekt.bean.LogOutEvent
 import com.laike.basekt.coremodel.datemodel.common.ApiConstants
 import com.laike.basekt.utils.LogCommon
+import com.readystatesoftware.chuck.ChuckInterceptor
 import okhttp3.*
 import okhttp3.logging.HttpLoggingInterceptor
 import org.greenrobot.eventbus.EventBus
@@ -42,6 +44,8 @@ internal class RetrofitInitialization {
 //            .addInterceptor(retryInterceptor())//重试次数 maxRetry
             .addInterceptor(loginEventInterceptor())
             .connectTimeout(5, TimeUnit.SECONDS)
+            .addInterceptor(ChuckInterceptor(BaseApplication.getIns().applicationContext))
+
             .readTimeout(10, TimeUnit.SECONDS)
         okHttpClient = if ("" == ApiConstants.CACHE_PATH) {
             builder.build()
@@ -55,6 +59,7 @@ internal class RetrofitInitialization {
             .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
             .addCallAdapterFactory(LiveDataCallAdapterFactory())
             .addConverterFactory(GsonConverterFactory.create())
+
             .build()
     }
 

+ 10 - 4
build.gradle

@@ -1,14 +1,20 @@
 // Top-level build file where you can add configuration options common to all sub-projects/modules.
 apply from: "libversion.gradle"
 buildscript {
-    ext.kotlin_version = '1.4.0-rc'
-    ext.kotlin_version = "1.3.72"
+//    ext.kotlin_version = '1.4.0-rc'
+//    ext.kotlin_version = "1.3.72"
+    ext.kotlin_version = '1.5.0'
+    ext.hilt_version = '2.29.1-alpha'
+
     repositories {
         google()
         jcenter()
     }
     dependencies {
-        classpath "com.android.tools.build:gradle:4.0.1"
+               classpath 'com.android.tools.build:gradle:4.2.1'
+
+
+
         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
 
         // NOTE: Do not place your application dependencies here; they belong
@@ -32,4 +38,4 @@ allprojects {
 
 task clean(type: Delete) {
     delete rootProject.buildDir
-}
+}

+ 1 - 1
gradle/wrapper/gradle-wrapper.properties

@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip