old
zlj 5 years ago
parent 9cb0ef73f2
commit 1701a00435
  1. 5
      app/src/main/java/com/novel/read/adapter/HumanAdapter.java
  2. 3
      app/src/main/java/com/novel/read/base/NovelBaseActivity.kt
  3. 6
      app/src/main/java/com/novel/read/constants/Constant.kt
  4. 17
      app/src/main/java/com/novel/read/fragment/ManFragment.kt
  5. 7
      app/src/main/java/com/novel/read/http/AccountManager.kt
  6. 3
      app/src/main/java/com/novel/read/http/CommonHeadersInterceptor.java
  7. 11
      app/src/main/java/com/novel/read/http/ServiceGenerator.java
  8. 8
      app/src/main/java/com/novel/read/http/Urls.kt
  9. 2
      app/src/main/java/com/novel/read/model/db/SearchListTable.java
  10. 33
      app/src/main/java/com/novel/read/utlis/DateUtli.java
  11. 2
      app/src/main/java/com/novel/read/utlis/DialogUtils.java
  12. 2
      app/src/main/java/com/novel/read/utlis/MyTimeTask.java
  13. 4
      app/src/main/res/layout/fragment_man.xml
  14. 30
      app/src/main/res/layout/rlv_human_item.xml
  15. 2
      common_lib/src/androidTest/java/com/common_lib/common_lib/ExampleInstrumentedTest.kt

@ -47,13 +47,10 @@ public class HumanAdapter extends RecyclerView.Adapter<HumanAdapter.ViewHolder>
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) {
viewHolder.itemView.setOnClickListener(view -> {
Intent intent=new Intent(mContext, NovelBookDetailActivity.class);
intent.putExtra(Constant.Bundle.BookId, mList.get(i).getBook_id());
mContext.startActivity(intent);
}
});
}

@ -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

@ -101,12 +101,6 @@ object Constant {
}
}
interface HasImage {
companion object {
const val has = 1
}
}
interface RequestCode {
companion object {
const val REQUEST_READ = 1

@ -66,10 +66,7 @@ class ManFragment : NovelBaseFragment() {
private inner class HumanCallBack : Callback<RecommendListResp> {
override fun onResponse(
call: Call<RecommendListResp>,
response: Response<RecommendListResp>
) {
override fun onResponse(call: Call<RecommendListResp>, response: Response<RecommendListResp>) {
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<RecommendListResp>, t: Throwable) {
swipe.showError()
}
}
private inner class EditCallBack : Callback<RecommendListResp> {
override fun onResponse(
call: Call<RecommendListResp>,
response: Response<RecommendListResp>
) {
override fun onResponse(call: Call<RecommendListResp>, response: Response<RecommendListResp>) {
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<RecommendListResp> {
override fun onResponse(
call: Call<RecommendListResp>,
response: Response<RecommendListResp>
) {
override fun onResponse(call: Call<RecommendListResp>, response: Response<RecommendListResp>) {
swipe.showFinish()
if (response.isSuccessful && response.body() != null) {
mRankList.clear()

@ -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<String, String>()
map["book_id"] = bookId

@ -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();

@ -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> S createService(Class<S> serviceClass) {
return createService(serviceClass);
}
public static <S> S createService(Class<S> serviceClass, final MyRequestType type) {
Retrofit retrofit = builderTEXT.build();
return retrofit.create(serviceClass);
}
public static String formatResponse(Object obj) {
return gson.toJson(obj);
}

@ -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"//登录

@ -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 {

@ -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));
}

@ -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 {

@ -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 {

@ -9,7 +9,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -28,8 +27,7 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rlv_pop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center" />
android:layout_height="wrap_content" />
<com.novel.read.widget.HeadLayout
android:id="@+id/head_recommend"

@ -1,49 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:layout_marginStart="10dp"
xmlns:app="http://schemas.android.com/apk/res-auto">
android:layout_marginStart="10dp">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_book"
android:layout_width="100dp"
android:layout_height="140dp"
android:src="@drawable/cover_default"
android:scaleType="fitXY"
android:src="@drawable/cover_default"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_book_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
tools:text="黄泉剑主"
android:maxLines="2"
android:ellipsize="end"
android:layout_marginTop="5dp"
android:ellipsize="end"
android:maxLines="2"
android:textColor="@color/colorTitle"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintLeft_toLeftOf="@+id/iv_book"
app:layout_constraintRight_toRightOf="@+id/iv_book"
app:layout_constraintTop_toBottomOf="@+id/iv_book"
app:layout_constraintHorizontal_bias="0"
android:textColor="@color/colorTitle" />
tools:text="黄泉剑主" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_book_author"
android:layout_width="0dp"
android:layout_height="wrap_content"
tools:text="作者"
android:maxLines="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/colorSubTitle"
android:textSize="13sp"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintLeft_toLeftOf="@+id/iv_book"
app:layout_constraintRight_toRightOf="@+id/iv_book"
app:layout_constraintTop_toBottomOf="@+id/tv_book_name"
app:layout_constraintHorizontal_bias="0"
android:textColor="@color/colorSubTitle"
/>
tools:text="作者" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -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

Loading…
Cancel
Save