From 1701a0043568be5c186fd0378a63f9148fd425f2 Mon Sep 17 00:00:00 2001 From: zlj <390057892@qq.com> Date: Tue, 5 Nov 2019 17:27:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/novel/read/adapter/HumanAdapter.java | 11 +++---- .../com/novel/read/base/NovelBaseActivity.kt | 3 +- .../java/com/novel/read/constants/Constant.kt | 6 ---- .../com/novel/read/fragment/ManFragment.kt | 17 +++------- .../com/novel/read/http/AccountManager.kt | 7 ++-- .../read/http/CommonHeadersInterceptor.java | 3 ++ .../com/novel/read/http/ServiceGenerator.java | 11 ++----- app/src/main/java/com/novel/read/http/Urls.kt | 8 ++--- .../novel/read/model/db/SearchListTable.java | 2 +- .../java/com/novel/read/utlis/DateUtli.java | 33 +++---------------- .../com/novel/read/utlis/DialogUtils.java | 2 +- .../java/com/novel/read/utlis/MyTimeTask.java | 2 +- app/src/main/res/layout/fragment_man.xml | 4 +-- app/src/main/res/layout/rlv_human_item.xml | 30 ++++++++--------- .../common_lib/ExampleInstrumentedTest.kt | 2 +- 15 files changed, 46 insertions(+), 95 deletions(-) diff --git a/app/src/main/java/com/novel/read/adapter/HumanAdapter.java b/app/src/main/java/com/novel/read/adapter/HumanAdapter.java index 6a958c8..45182b7 100644 --- a/app/src/main/java/com/novel/read/adapter/HumanAdapter.java +++ b/app/src/main/java/com/novel/read/adapter/HumanAdapter.java @@ -47,13 +47,10 @@ public class HumanAdapter extends RecyclerView.Adapter viewHolder.mTvBookName.setText(mList.get(i).getBook_title()); viewHolder.mTvAuthor.setText(mList.get(i).getAuthor()); GlideImageLoader.displayCornerImage(mContext,mList.get(i).getBook_cover(),viewHolder.mIvBook); - viewHolder.itemView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Intent intent=new Intent(mContext, NovelBookDetailActivity.class); - intent.putExtra(Constant.Bundle.BookId, mList.get(i).getBook_id()); - mContext.startActivity(intent); - } + viewHolder.itemView.setOnClickListener(view -> { + Intent intent=new Intent(mContext, NovelBookDetailActivity.class); + intent.putExtra(Constant.Bundle.BookId, mList.get(i).getBook_id()); + mContext.startActivity(intent); }); } diff --git a/app/src/main/java/com/novel/read/base/NovelBaseActivity.kt b/app/src/main/java/com/novel/read/base/NovelBaseActivity.kt index 9e4059b..f78b3a3 100644 --- a/app/src/main/java/com/novel/read/base/NovelBaseActivity.kt +++ b/app/src/main/java/com/novel/read/base/NovelBaseActivity.kt @@ -17,8 +17,7 @@ import com.novel.read.utlis.StatusBarUtil * describe: */ abstract class NovelBaseActivity : AppCompatActivity() { - var isCheckNet = true//是否检查网络连接 - var isNetworkChange = false//获取网络是否连接 + private var mNowMode: Boolean = false protected abstract val layoutId: Int diff --git a/app/src/main/java/com/novel/read/constants/Constant.kt b/app/src/main/java/com/novel/read/constants/Constant.kt index d137f4d..630e97d 100644 --- a/app/src/main/java/com/novel/read/constants/Constant.kt +++ b/app/src/main/java/com/novel/read/constants/Constant.kt @@ -101,12 +101,6 @@ object Constant { } } - interface HasImage { - companion object { - const val has = 1 - } - } - interface RequestCode { companion object { const val REQUEST_READ = 1 diff --git a/app/src/main/java/com/novel/read/fragment/ManFragment.kt b/app/src/main/java/com/novel/read/fragment/ManFragment.kt index e8bff7b..7b47998 100644 --- a/app/src/main/java/com/novel/read/fragment/ManFragment.kt +++ b/app/src/main/java/com/novel/read/fragment/ManFragment.kt @@ -66,10 +66,7 @@ class ManFragment : NovelBaseFragment() { private inner class HumanCallBack : Callback { - override fun onResponse( - call: Call, - response: Response - ) { + override fun onResponse(call: Call, response: Response) { if (response.isSuccessful && response.body() != null) { mHumanList.clear() mHumanList.addAll(response.body()!!.list) @@ -80,16 +77,13 @@ class ManFragment : NovelBaseFragment() { } override fun onFailure(call: Call, t: Throwable) { - + swipe.showError() } } private inner class EditCallBack : Callback { - override fun onResponse( - call: Call, - response: Response - ) { + override fun onResponse(call: Call, response: Response) { if (response.isSuccessful && response.body() != null) { mEditList.clear() mEditList.addAll(response.body()!!.list) @@ -107,10 +101,7 @@ class ManFragment : NovelBaseFragment() { private inner class HotSearchCallBack : Callback { - override fun onResponse( - call: Call, - response: Response - ) { + override fun onResponse(call: Call, response: Response) { swipe.showFinish() if (response.isSuccessful && response.body() != null) { mRankList.clear() diff --git a/app/src/main/java/com/novel/read/http/AccountManager.kt b/app/src/main/java/com/novel/read/http/AccountManager.kt index fa3c37f..208d55e 100644 --- a/app/src/main/java/com/novel/read/http/AccountManager.kt +++ b/app/src/main/java/com/novel/read/http/AccountManager.kt @@ -51,14 +51,11 @@ import java.util.Map class AccountManager private constructor() { - private val accountService: AccountService + private val accountService: AccountService = + ServiceGenerator.createService(AccountService::class.java, MyRequestType.URL_TEXT) private var mChapterSub: Subscription? = null - init { - accountService = ServiceGenerator.createService(AccountService::class.java, MyRequestType.URL_TEXT) - } - fun getRecommendBook(bookId: String, limit: String) { val map = HashMap() map["book_id"] = bookId diff --git a/app/src/main/java/com/novel/read/http/CommonHeadersInterceptor.java b/app/src/main/java/com/novel/read/http/CommonHeadersInterceptor.java index 4602b06..053d655 100644 --- a/app/src/main/java/com/novel/read/http/CommonHeadersInterceptor.java +++ b/app/src/main/java/com/novel/read/http/CommonHeadersInterceptor.java @@ -5,6 +5,8 @@ import com.common_lib.base.utils.SecurityUtils; import com.novel.read.constants.Constant; import com.novel.read.utlis.SpUtil; +import org.jetbrains.annotations.NotNull; + import java.io.IOException; import okhttp3.Interceptor; @@ -16,6 +18,7 @@ import okhttp3.Response; */ public class CommonHeadersInterceptor implements Interceptor { + @NotNull @Override public Response intercept(@NonNull Interceptor.Chain chain) throws IOException { Request request = chain.request(); diff --git a/app/src/main/java/com/novel/read/http/ServiceGenerator.java b/app/src/main/java/com/novel/read/http/ServiceGenerator.java index b78ede0..c6700e2 100644 --- a/app/src/main/java/com/novel/read/http/ServiceGenerator.java +++ b/app/src/main/java/com/novel/read/http/ServiceGenerator.java @@ -34,25 +34,20 @@ public class ServiceGenerator { return new OkHttpClient() .newBuilder() .addInterceptor(new CommonHeadersInterceptor()) - .connectTimeout(30, TimeUnit.SECONDS) - .writeTimeout(30, TimeUnit.SECONDS) - .readTimeout(30, TimeUnit.SECONDS) + .connectTimeout(15, TimeUnit.SECONDS) + .writeTimeout(15, TimeUnit.SECONDS) + .readTimeout(15, TimeUnit.SECONDS) .build(); } private ServiceGenerator() { } - public static S createService(Class serviceClass) { - return createService(serviceClass); - } - public static S createService(Class serviceClass, final MyRequestType type) { Retrofit retrofit = builderTEXT.build(); return retrofit.create(serviceClass); } - public static String formatResponse(Object obj) { return gson.toJson(obj); } diff --git a/app/src/main/java/com/novel/read/http/Urls.kt b/app/src/main/java/com/novel/read/http/Urls.kt index 37e326c..eb0731d 100644 --- a/app/src/main/java/com/novel/read/http/Urls.kt +++ b/app/src/main/java/com/novel/read/http/Urls.kt @@ -17,10 +17,10 @@ object Urls { internal const val getRecommendList = "api/rank/getRecommendList/" //获取推荐列表 internal const val getRankByUpdate = "api/rank/getRankByUpdate/" //最新更新 internal const val getRankList = "api/rank/getRankList/" //获取排行榜 - internal const val checkVersion = " api/version/checkVersion/" //检测新版本 - internal const val addBookSign = " api/sign/addBookSign/" //添加书签 - internal const val getBookSign = " api/sign/getBookSignList/" //获取书签 - internal const val deleteSign = " api/sign/deleteSign/" //获取书签 + internal const val checkVersion = "api/version/checkVersion/" //检测新版本 + internal const val addBookSign = "api/sign/addBookSign/" //添加书签 + internal const val getBookSign = "api/sign/getBookSignList/" //获取书签 + internal const val deleteSign = "api/sign/deleteSign/" //获取书签 internal const val login = "api/login/checkLogin"//登录 diff --git a/app/src/main/java/com/novel/read/model/db/SearchListTable.java b/app/src/main/java/com/novel/read/model/db/SearchListTable.java index afdfdaa..1dd57d0 100644 --- a/app/src/main/java/com/novel/read/model/db/SearchListTable.java +++ b/app/src/main/java/com/novel/read/model/db/SearchListTable.java @@ -8,7 +8,7 @@ import org.litepal.crud.LitePalSupport; import java.io.Serializable; /** - * create by 赵利君 on 2019/6/19 + * create by zlj on 2019/6/19 * describe: */ public class SearchListTable extends LitePalSupport implements Serializable { diff --git a/app/src/main/java/com/novel/read/utlis/DateUtli.java b/app/src/main/java/com/novel/read/utlis/DateUtli.java index d67ed99..dd258af 100644 --- a/app/src/main/java/com/novel/read/utlis/DateUtli.java +++ b/app/src/main/java/com/novel/read/utlis/DateUtli.java @@ -9,6 +9,7 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; +@SuppressLint("SimpleDateFormat") public class DateUtli { private static final int HOUR_OF_DAY = 24; @@ -25,26 +26,13 @@ public class DateUtli { public static String dateConvert(long timesamp, int flag) { timesamp = timesamp * 1000; - String result = ""; + String result; Calendar todayCalendar = Calendar.getInstance(); Calendar otherCalendar = Calendar.getInstance(); otherCalendar.setTimeInMillis(timesamp); String timeFormat = "M月d日"; String yearTimeFormat = "yyyy年M月d日"; - String am_pm = ""; - int hour = otherCalendar.get(Calendar.HOUR_OF_DAY); - if (hour >= 0 && hour < 6) { - am_pm = "凌晨"; - } else if (hour >= 6 && hour < 12) { - am_pm = "早上"; - } else if (hour == 12) { - am_pm = "中午"; - } else if (hour > 12 && hour < 18) { - am_pm = "下午"; - } else if (hour >= 18) { - am_pm = "晚上"; - } boolean yearTemp = todayCalendar.get(Calendar.YEAR) == otherCalendar.get(Calendar.YEAR); if (yearTemp) { @@ -100,35 +88,24 @@ public class DateUtli { /** * 当天的显示时间格式 - * - * @param time - * @return */ - public static String getHourAndMin(long time) { + private static String getHourAndMin(long time) { SimpleDateFormat format = new SimpleDateFormat("HH:mm"); return format.format(new Date(time)); } /** * 不同一周的显示时间格式 - * - * @param time - * @param timeFormat - * @return */ - public static String getTime(long time, String timeFormat) { + private static String getTime(long time, String timeFormat) { SimpleDateFormat format = new SimpleDateFormat(timeFormat); return format.format(new Date(time)); } /** * 不同年的显示时间格式 - * - * @param time - * @param yearTimeFormat - * @return */ - public static String getYearTime(long time, String yearTimeFormat) { + private static String getYearTime(long time, String yearTimeFormat) { SimpleDateFormat format = new SimpleDateFormat(yearTimeFormat); return format.format(new Date(time)); } diff --git a/app/src/main/java/com/novel/read/utlis/DialogUtils.java b/app/src/main/java/com/novel/read/utlis/DialogUtils.java index 1331546..f56ef7b 100644 --- a/app/src/main/java/com/novel/read/utlis/DialogUtils.java +++ b/app/src/main/java/com/novel/read/utlis/DialogUtils.java @@ -5,7 +5,7 @@ import android.content.Context; import android.content.DialogInterface; /** - * create by 赵利君 on 2019/6/19 + * create by zlj on 2019/6/19 * describe: */ public class DialogUtils { diff --git a/app/src/main/java/com/novel/read/utlis/MyTimeTask.java b/app/src/main/java/com/novel/read/utlis/MyTimeTask.java index b08f069..1a57a5c 100644 --- a/app/src/main/java/com/novel/read/utlis/MyTimeTask.java +++ b/app/src/main/java/com/novel/read/utlis/MyTimeTask.java @@ -4,7 +4,7 @@ import java.util.Timer; import java.util.TimerTask; /** - * create by 赵利君 on 2019/7/15 + * create by zlj on 2019/7/15 * describe: */ public class MyTimeTask { diff --git a/app/src/main/res/layout/fragment_man.xml b/app/src/main/res/layout/fragment_man.xml index 394dc49..03f00d8 100644 --- a/app/src/main/res/layout/fragment_man.xml +++ b/app/src/main/res/layout/fragment_man.xml @@ -9,7 +9,6 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + android:layout_height="wrap_content" /> + android:layout_marginStart="10dp"> + app:layout_constraintTop_toTopOf="parent" /> + tools:text="黄泉剑主" /> + tools:text="作者" /> \ No newline at end of file diff --git a/common_lib/src/androidTest/java/com/common_lib/common_lib/ExampleInstrumentedTest.kt b/common_lib/src/androidTest/java/com/common_lib/common_lib/ExampleInstrumentedTest.kt index b332467..99b7b69 100644 --- a/common_lib/src/androidTest/java/com/common_lib/common_lib/ExampleInstrumentedTest.kt +++ b/common_lib/src/androidTest/java/com/common_lib/common_lib/ExampleInstrumentedTest.kt @@ -1,7 +1,7 @@ package com.common_lib.common_lib import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.runner.AndroidJUnit4 import org.junit.Test import org.junit.runner.RunWith