修改设置弹框,优化页面

old
Administrator 5 years ago
parent 59f9ce7768
commit e435a31697
  1. 2
      app/src/main/assets/litepal.xml
  2. 8
      app/src/main/java/com/novel/read/activity/NovelBookDetailActivity.kt
  3. 12
      app/src/main/java/com/novel/read/activity/NovelRankListActivity.kt
  4. 10
      app/src/main/java/com/novel/read/activity/NovelReadActivity.kt
  5. 8
      app/src/main/java/com/novel/read/adapter/RankListAdapter.java
  6. 6
      app/src/main/java/com/novel/read/event/RankByUpdateEvent.kt
  7. 12
      app/src/main/java/com/novel/read/fragment/BookListFragment.kt
  8. 8
      app/src/main/java/com/novel/read/http/AccountManager.kt
  9. 6
      app/src/main/java/com/novel/read/http/service/AccountService.kt
  10. 1
      app/src/main/java/com/novel/read/model/db/dbManage/BookRepository.java
  11. 57
      app/src/main/java/com/novel/read/model/protocol/CategoryTypeResp.java
  12. 25
      app/src/main/java/com/novel/read/model/protocol/CategoryTypeResp.kt
  13. 21
      app/src/main/java/com/novel/read/model/protocol/ChapterInfoPackage.java
  14. 12
      app/src/main/java/com/novel/read/model/protocol/ChapterInfoPackage.kt
  15. 18
      app/src/main/java/com/novel/read/model/protocol/HotSearchResp.java
  16. 10
      app/src/main/java/com/novel/read/model/protocol/HotSearchResp.kt
  17. 120
      app/src/main/java/com/novel/read/model/protocol/MarkResp.java
  18. 31
      app/src/main/java/com/novel/read/model/protocol/MarkResp.kt
  19. 2
      app/src/main/java/com/novel/read/model/protocol/RankByUpdateResp.java
  20. 18
      app/src/main/java/com/novel/read/model/protocol/UidResp.java
  21. 10
      app/src/main/java/com/novel/read/model/protocol/UidResp.kt
  22. 99
      app/src/main/java/com/novel/read/utlis/StatusBarUtil.java
  23. 106
      app/src/main/java/com/novel/read/utlis/StatusBarUtil.kt
  24. 3
      app/src/main/java/com/novel/read/utlis/StringUtils.java
  25. 162
      app/src/main/java/com/novel/read/utlis/SystemBarUtils.java
  26. 155
      app/src/main/java/com/novel/read/utlis/SystemBarUtils.kt
  27. 59
      app/src/main/java/com/novel/read/widget/dialog/ReadSettingDialog.kt
  28. 18
      app/src/main/java/com/novel/read/widget/page/NetPageLoader.java
  29. 10
      app/src/main/java/com/novel/read/widget/page/PageStyle.java
  30. 3
      app/src/main/java/com/novel/read/widget/page/TxtPage.java
  31. 5
      app/src/main/res/drawable/bg_coner_line.xml
  32. 1
      app/src/main/res/drawable/bg_listen.xml
  33. 2
      app/src/main/res/drawable/text_color.xml
  34. 8
      app/src/main/res/drawable/text_font_color.xml
  35. 2
      app/src/main/res/layout/activity_read.xml
  36. 2
      app/src/main/res/layout/activity_web_read.xml
  37. 4
      app/src/main/res/layout/dialog_listen_layout.xml
  38. 9
      app/src/main/res/layout/item_read_bg.xml
  39. 165
      app/src/main/res/layout/layout_setting.xml
  40. 30
      app/src/main/res/values-night/colors.xml
  41. 30
      app/src/main/res/values-zh-rTW-night/colors.xml
  42. 33
      app/src/main/res/values/colors.xml
  43. 78
      common_lib/src/main/java/com/common_lib/base/utils/DeviceInfoUtil.java
  44. 55
      common_lib/src/main/java/com/common_lib/base/utils/NetworkUtils.java
  45. 2
      common_lib/src/main/java/com/common_lib/base/utils/ObjectAnalysisUtils.java
  46. 14
      common_lib/src/main/java/com/common_lib/base/utils/SecurityUtils.java
  47. 94
      common_lib/src/main/java/com/common_lib/base/utils/StringUtils.java
  48. 48
      common_lib/src/main/java/com/common_lib/base/utils/ToastUtils.java

@ -2,7 +2,7 @@
<litepal>
<dbname value="readDb" />
<version value="7" />
<version value="8" />
<list>
<!--搜索记录表-->

@ -5,7 +5,6 @@ import android.app.ProgressDialog
import android.content.Intent
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.common_lib.base.utils.ToastUtils
import com.mango.mangolib.event.EventManager
import com.novel.read.R
import com.novel.read.adapter.LoveLyAdapter
@ -21,6 +20,7 @@ import com.novel.read.http.AccountManager
import com.novel.read.model.db.CollBookBean
import com.novel.read.model.db.dbManage.BookRepository
import com.novel.read.model.protocol.RecommendBookResp
import com.novel.read.showToast
import com.novel.read.utlis.DateUtli
import com.novel.read.utlis.GlideImageLoader
import com.squareup.otto.Subscribe
@ -152,7 +152,7 @@ class NovelBookDetailActivity : NovelBaseActivity(), View.OnClickListener {
fun getArticle(event: BookArticleEvent) {
if (event.isFail) {
dismiss()
ToastUtils.showNormalToast(this, getString(R.string.net_error))
showToast(getString(R.string.net_error))
} else {
//存储收藏
var success = false
@ -172,12 +172,12 @@ class NovelBookDetailActivity : NovelBaseActivity(), View.OnClickListener {
isCollected = true
} else {
LitePal.deleteAll(CollBookBean::class.java, "bookId =?", mCollBookBean!!.id)
ToastUtils.showNormalToast(this, getString(R.string.net_error))
showToast(getString(R.string.net_error))
}
dismiss()
}
} else {
ToastUtils.showNormalToast(this, getString(R.string.net_error))
showToast(getString(R.string.net_error))
dismiss()
}
}

@ -8,7 +8,7 @@ import com.novel.read.constants.Constant
import com.novel.read.constants.Constant.COMMENT_SIZE
import com.novel.read.http.AccountManager
import com.novel.read.inter.OnLoadMoreListener
import com.novel.read.model.protocol.RankByUpadateResp
import com.novel.read.model.protocol.RankByUpdateResp
import kotlinx.android.synthetic.main.activity_rank_list.*
import retrofit2.Call
import retrofit2.Callback
@ -21,7 +21,7 @@ import java.util.*
class NovelRankListActivity : NovelBaseActivity() {
private var mAdapter: RankListAdapter? = null
private var mList: MutableList<RankByUpadateResp.BookBean> = ArrayList()
private var mList: MutableList<RankByUpdateResp.BookBean> = ArrayList()
private var page = 1
private var loadSize: Int = 0
private var type: String = ""
@ -53,7 +53,7 @@ class NovelRankListActivity : NovelBaseActivity() {
} else {
if (loadSize >= COMMENT_SIZE) {
mAdapter!!.isLoadingMore = true
mList.add(RankByUpadateResp.BookBean())
mList.add(RankByUpdateResp.BookBean())
mAdapter!!.notifyDataSetChanged()
page++
getData()
@ -67,9 +67,9 @@ class NovelRankListActivity : NovelBaseActivity() {
AccountManager.getInstance().getRankList(type, sex, Constant.DateTyp.Week, page.toString(), RankCallBack())
}
private inner class RankCallBack : Callback<RankByUpadateResp> {
private inner class RankCallBack : Callback<RankByUpdateResp> {
override fun onResponse(call: Call<RankByUpadateResp>, response: Response<RankByUpadateResp>) {
override fun onResponse(call: Call<RankByUpdateResp>, response: Response<RankByUpdateResp>) {
if (response.isSuccessful) {
if (response.body() != null) {
loadSize = response.body()!!.book.size
@ -88,7 +88,7 @@ class NovelRankListActivity : NovelBaseActivity() {
}
}
override fun onFailure(call: Call<RankByUpadateResp>, t: Throwable) {
override fun onFailure(call: Call<RankByUpdateResp>, t: Throwable) {
}
}

@ -20,7 +20,6 @@ import androidx.core.content.ContextCompat
import androidx.core.view.GravityCompat
import androidx.drawerlayout.widget.DrawerLayout
import androidx.recyclerview.widget.LinearLayoutManager
import com.common_lib.base.utils.ToastUtils
import com.mango.mangolib.event.EventManager
import com.novel.read.R
import com.novel.read.adapter.CategoryAdapter
@ -40,6 +39,7 @@ import com.novel.read.model.db.DownloadTaskBean
import com.novel.read.model.db.dbManage.BookRepository
import com.novel.read.service.DownloadMessage
import com.novel.read.service.DownloadService
import com.novel.read.showToast
import com.novel.read.utlis.BrightnessUtils
import com.novel.read.utlis.ScreenUtils
import com.novel.read.utlis.SpUtil
@ -305,7 +305,7 @@ class NovelReadActivity : NovelBaseActivity(), DownloadService.OnDownloadListene
if (mCurrentChapter != null) {
mMarkAdapter!!.edit = false
if (BookRepository.getInstance().getSignById(mCurrentChapter!!.chapterId)) {
ToastUtils.showNormalToast(this, getString(R.string.sign_exist))
showToast(getString(R.string.sign_exist))
return@setOnClickListener
}
BookRepository.getInstance()
@ -402,7 +402,7 @@ class NovelReadActivity : NovelBaseActivity(), DownloadService.OnDownloadListene
tvBookReadMode.text = resources.getString(R.string.book_read_mode_day)
val drawable = ContextCompat.getDrawable(this, R.drawable.ic_read_menu_moring)
tvBookReadMode.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null)
cl_layout.setBackgroundColor(ContextCompat.getColor(this, R.color.nb_read_bg_night))
cl_layout.setBackgroundColor(ContextCompat.getColor(this, R.color.read_bg_night))
} else {
tvBookReadMode.text = resources.getString(R.string.book_read_mode_day)
val drawable = ContextCompat.getDrawable(this, R.drawable.ic_read_menu_night)
@ -619,7 +619,7 @@ class NovelReadActivity : NovelBaseActivity(), DownloadService.OnDownloadListene
//下载成功或失败后隐藏下载视图
if (ll_download != null) {
ll_download.visibility = GONE
ToastUtils.showNormalToast(this, msg)
showToast(msg)
}
} else {
if (ll_download != null) {
@ -642,7 +642,7 @@ class NovelReadActivity : NovelBaseActivity(), DownloadService.OnDownloadListene
@Subscribe
fun onDownLoadEvent(message: DownloadMessage) {
ToastUtils.showNormalToast(this, message.message)
showToast(message.message)
}
companion object {

@ -18,7 +18,7 @@ import com.novel.read.adapter.holder.EmptyHolder;
import com.novel.read.adapter.holder.MoreHolder;
import com.novel.read.constants.Constant;
import com.novel.read.inter.OnLoadMoreListener;
import com.novel.read.model.protocol.RankByUpadateResp;
import com.novel.read.model.protocol.RankByUpdateResp;
import com.novel.read.utlis.GlideImageLoader;
import java.util.List;
@ -27,7 +27,7 @@ import static com.novel.read.constants.Constant.COMMENT_SIZE;
public class RankListAdapter extends RecyclerView.Adapter {
private List<RankByUpadateResp.BookBean> mList;
private List<RankByUpdateResp.BookBean> mList;
private Context mContext;
private final int VALUE_ITEM = 100; //正常item
private final int EMPTY_ITEM = 101; //空白item
@ -38,7 +38,7 @@ public class RankListAdapter extends RecyclerView.Adapter {
private int visibleThreshold = 1;
private OnLoadMoreListener mOnLoadMoreListener;
public RankListAdapter(List<RankByUpadateResp.BookBean> mList,RecyclerView recyclerView) {
public RankListAdapter(List<RankByUpdateResp.BookBean> mList, RecyclerView recyclerView) {
this.mList = mList;
if (recyclerView.getLayoutManager() instanceof LinearLayoutManager) {
final LinearLayoutManager llMangager = (LinearLayoutManager) recyclerView.getLayoutManager();
@ -94,7 +94,7 @@ public class RankListAdapter extends RecyclerView.Adapter {
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, final int i) {
if (viewHolder instanceof ViewHolder){
RankByUpadateResp.BookBean bookBean = mList.get(i);
RankByUpdateResp.BookBean bookBean = mList.get(i);
((ViewHolder) viewHolder).tvBookName.setText(bookBean.getTitle());
((ViewHolder) viewHolder).tvBookAuthor.setText(bookBean.getAuthor());
((ViewHolder) viewHolder).tvBookDescription.setText(bookBean.getDescription());

@ -1,15 +1,15 @@
package com.novel.read.event
import com.mango.mangolib.event.BaseEvent
import com.novel.read.model.protocol.RankByUpadateResp
import com.novel.read.model.protocol.RankByUpdateResp
/**
* create by 赵利君 on 2019/6/18
* describe:
*/
class RankByUpdateEvent : BaseEvent<RankByUpadateResp> {
class RankByUpdateEvent : BaseEvent<RankByUpdateResp> {
constructor(result: RankByUpadateResp) : super(result) {}
constructor(result: RankByUpdateResp) : super(result) {}
constructor() {}
}

@ -9,7 +9,7 @@ import com.novel.read.constants.Constant
import com.novel.read.constants.Constant.COMMENT_SIZE
import com.novel.read.http.AccountManager
import com.novel.read.inter.OnLoadMoreListener
import com.novel.read.model.protocol.RankByUpadateResp
import com.novel.read.model.protocol.RankByUpdateResp
import kotlinx.android.synthetic.main.fragment_book_list.*
import retrofit2.Call
import retrofit2.Callback
@ -20,7 +20,7 @@ import java.util.*
class BookListFragment : NovelBaseFragment() {
private var mAdapter: RankListAdapter? = null
private var mList: MutableList<RankByUpadateResp.BookBean> = ArrayList()
private var mList: MutableList<RankByUpdateResp.BookBean> = ArrayList()
private var sex: String = ""
private var dateType: String = ""
private var type: String = ""
@ -54,7 +54,7 @@ class BookListFragment : NovelBaseFragment() {
} else {
if (loadSize >= COMMENT_SIZE) {
mAdapter!!.isLoadingMore = true
mList.add(RankByUpadateResp.BookBean())
mList.add(RankByUpdateResp.BookBean())
mAdapter!!.notifyDataSetChanged()
page++
getData()
@ -69,9 +69,9 @@ class BookListFragment : NovelBaseFragment() {
AccountManager.getInstance().getRankList(type, sex, dateType, page.toString(), RankCallBack())
}
private inner class RankCallBack : Callback<RankByUpadateResp> {
private inner class RankCallBack : Callback<RankByUpdateResp> {
override fun onResponse(call: Call<RankByUpadateResp>, response: Response<RankByUpadateResp>) {
override fun onResponse(call: Call<RankByUpdateResp>, response: Response<RankByUpdateResp>) {
if (response.isSuccessful) {
if (response.body() != null) {
loadSize = response.body()!!.book.size
@ -89,7 +89,7 @@ class BookListFragment : NovelBaseFragment() {
}
}
override fun onFailure(call: Call<RankByUpadateResp>, t: Throwable) {
override fun onFailure(call: Call<RankByUpdateResp>, t: Throwable) {
}
}

@ -24,7 +24,7 @@ import com.novel.read.http.service.AccountService
import com.novel.read.model.db.ChapterInfoBean
import com.novel.read.model.db.dbManage.BookRepository
import com.novel.read.model.protocol.BookDetailResp
import com.novel.read.model.protocol.RankByUpadateResp
import com.novel.read.model.protocol.RankByUpdateResp
import com.novel.read.model.protocol.RecommendListResp
import com.novel.read.utlis.LogUtils
import com.novel.read.utlis.PhoneUtils
@ -122,7 +122,7 @@ class AccountManager private constructor() {
}
fun getRankByUpdate(page: Int, limit: Int, callback: Callback<RankByUpadateResp>) {
fun getRankByUpdate(page: Int, limit: Int, callback: Callback<RankByUpdateResp>) {
val map = HashMap<String, String>()
if (!TextUtils.isEmpty(page.toString())) {
map["page"] = page.toString()
@ -139,7 +139,7 @@ class AccountManager private constructor() {
sex: String,
dateType: String,
page: String,
callback: Callback<RankByUpadateResp>
callback: Callback<RankByUpdateResp>
) {
val map = HashMap<String, String>()
map["type"] = type
@ -248,7 +248,7 @@ class AccountManager private constructor() {
val map = HashMap<String, String>()
map["article_id"] = id
return accountService.getBookArticleDetail(getUrlString(Urls.getDetail, map))
.map { bean -> bean.article[0] }
.map { bean -> bean.article?.get(0) }
}
/**

@ -7,7 +7,7 @@ import com.novel.read.model.protocol.CategoryTypeResp
import com.novel.read.model.protocol.ChapterInfoPackage
import com.novel.read.model.protocol.HotSearchResp
import com.novel.read.model.protocol.MarkResp
import com.novel.read.model.protocol.RankByUpadateResp
import com.novel.read.model.protocol.RankByUpdateResp
import com.novel.read.model.protocol.RecommendBookResp
import com.novel.read.model.protocol.RecommendListResp
import com.novel.read.model.protocol.SearchResp
@ -62,11 +62,11 @@ interface AccountService {
//获取最新排行
@GET
fun getRankByUpdate(@Url url: String): Call<RankByUpadateResp>
fun getRankByUpdate(@Url url: String): Call<RankByUpdateResp>
//获取排行
@GET
fun getRankList(@Url url: String): Call<RankByUpadateResp>
fun getRankList(@Url url: String): Call<RankByUpdateResp>
//获取新版本
@GET

@ -296,7 +296,6 @@ public class BookRepository {
bean.getBookChapters().get(i).saveOrUpdate("chapterId=?", bean.getBookChapters().get(i).getId());
}
}
/**

@ -1,57 +0,0 @@
package com.novel.read.model.protocol;
import com.novel.read.base.MyApp;
import com.novel.read.utlis.StringUtils;
import java.io.Serializable;
import java.util.List;
public class CategoryTypeResp implements Serializable {
private List<CategoryBean> category;
public List<CategoryBean> getCategory() {
return category;
}
public void setCategory(List<CategoryBean> category) {
this.category = category;
}
public static class CategoryBean {
/**
* id : 1
* title : 玄幻奇幻
* cover :
*/
private int id;
private String title;
private String cover;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return StringUtils.convertCC(title == null ? "" : title);
}
public void setTitle(String title) {
this.title = title;
}
public String getCover() {
return cover;
}
public void setCover(String cover) {
this.cover = cover;
}
}
}

@ -0,0 +1,25 @@
package com.novel.read.model.protocol
import com.novel.read.base.MyApp
import com.novel.read.utlis.StringUtils
import java.io.Serializable
class CategoryTypeResp : Serializable {
var category: List<CategoryBean> = arrayListOf()
class CategoryBean {
/**
* id : 1
* title : 玄幻奇幻
* cover :
*/
var id: Int = 0
var title: String = ""
get() = StringUtils.convertCC(field)
var cover: String? = null
}
}

@ -1,21 +0,0 @@
package com.novel.read.model.protocol;
import com.novel.read.model.db.ChapterInfoBean;
import java.io.Serializable;
import java.util.List;
public class ChapterInfoPackage implements Serializable {
private List<ChapterInfoBean> article;
public List<ChapterInfoBean> getArticle() {
return article;
}
public void setArticle(List<ChapterInfoBean> article) {
this.article = article;
}
}

@ -0,0 +1,12 @@
package com.novel.read.model.protocol
import com.novel.read.model.db.ChapterInfoBean
import java.io.Serializable
class ChapterInfoPackage : Serializable {
var article: List<ChapterInfoBean>? = null
}

@ -1,18 +0,0 @@
package com.novel.read.model.protocol;
import java.io.Serializable;
import java.util.List;
public class HotSearchResp implements Serializable {
private List<String> key;
public List<String> getKey() {
return key;
}
public void setKey(List<String> key) {
this.key = key;
}
}

@ -0,0 +1,10 @@
package com.novel.read.model.protocol
import java.io.Serializable
import java.util.ArrayList
class HotSearchResp : Serializable {
var key: List<String> = arrayListOf()
}

@ -1,120 +0,0 @@
package com.novel.read.model.protocol;
import java.util.List;
public class MarkResp {
private List<SignBean> sign;
public List<SignBean> getSign() {
return sign;
}
public void setSign(List<SignBean> sign) {
this.sign = sign;
}
public static class SignBean {
/**
* id : 8
* uid : 1
* book_id : 1
* article_id : 1
* words : 0
* create_time : 1561450031
* update_time : 1561450031
* delete_time : null
*/
private int id;
private int uid;
private int book_id;
private int article_id;
private int words;
private int create_time;
private int update_time;
private Object delete_time;
private String content;
private boolean edit;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
public int getBook_id() {
return book_id;
}
public void setBook_id(int book_id) {
this.book_id = book_id;
}
public int getArticle_id() {
return article_id;
}
public void setArticle_id(int article_id) {
this.article_id = article_id;
}
public int getWords() {
return words;
}
public void setWords(int words) {
this.words = words;
}
public int getCreate_time() {
return create_time;
}
public void setCreate_time(int create_time) {
this.create_time = create_time;
}
public int getUpdate_time() {
return update_time;
}
public void setUpdate_time(int update_time) {
this.update_time = update_time;
}
public Object getDelete_time() {
return delete_time;
}
public void setDelete_time(Object delete_time) {
this.delete_time = delete_time;
}
public String getContent() {
return content == null ? "" : content;
}
public void setContent(String content) {
this.content = content;
}
public boolean isEdit() {
return edit;
}
public void setEdit(boolean edit) {
this.edit = edit;
}
}
}

@ -0,0 +1,31 @@
package com.novel.read.model.protocol
class MarkResp {
var sign: List<SignBean>? = null
class SignBean {
/**
* id : 8
* uid : 1
* book_id : 1
* article_id : 1
* words : 0
* create_time : 1561450031
* update_time : 1561450031
* delete_time : null
*/
var id: Int = 0
var uid: Int = 0
var book_id: Int = 0
var article_id: Int = 0
var words: Int = 0
var create_time: Int = 0
var update_time: Int = 0
var delete_time: Any? = null
var content: String? = null
get() = if (field == null) "" else field
var isEdit: Boolean = false
}
}

@ -11,7 +11,7 @@ import java.util.List;
* create by 赵利君 on 2019/6/20
* describe:
*/
public class RankByUpadateResp implements Serializable {
public class RankByUpdateResp implements Serializable {
private List<BookBean> book;

@ -1,18 +0,0 @@
package com.novel.read.model.protocol;
public class UidResp {
/**
* uid : 3
*/
private int uid;
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
}

@ -0,0 +1,10 @@
package com.novel.read.model.protocol
class UidResp {
/**
* uid : 3
*/
var uid: Int = 0
}

@ -1,99 +0,0 @@
package com.novel.read.utlis;
import android.os.Build;
import android.view.View;
import android.view.WindowManager;
import androidx.appcompat.app.AppCompatActivity;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/**
* @author: LiJun 390057892@qq.com
* @date: 2018/3/7 15:07
*/
public class StatusBarUtil {
public static void setBarsStyle(AppCompatActivity activity, int color, boolean dark) {
MIUISetStatusBarLightMode(activity, dark);
FlymeSetStatusBarLightMode(activity, dark);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//5.0及以上
View decorView = activity.getWindow().getDecorView();
if (dark) {
int option = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
decorView.setSystemUiVisibility(option);
activity.getWindow().setStatusBarColor(activity.getResources().getColor(color));
} else {
int option = View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
decorView.setSystemUiVisibility(option);
activity.getWindow().setStatusBarColor(activity.getResources().getColor(color));
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4到5.0
WindowManager.LayoutParams localLayoutParams = activity.getWindow().getAttributes();
localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags);
}
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {//android6.0以后可以对状态栏文字颜色和图标进行修改
// if (dark){
// activity.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
// }else {
// activity.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
// }
//
// }
}
public static boolean MIUISetStatusBarLightMode(AppCompatActivity activity, boolean dark) {
boolean result = false;
if (activity.getWindow() != null) {
Class clazz = activity.getWindow().getClass();
try {
int darkModeFlag = 0;
Class layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
darkModeFlag = field.getInt(layoutParams);
Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
if (dark) {
extraFlagField.invoke(activity.getWindow(), darkModeFlag, darkModeFlag);//状态栏透明且黑色字体
} else {
extraFlagField.invoke(activity.getWindow(), 0, darkModeFlag);//清除黑色字体
}
result = true;
} catch (Exception e) {
}
}
return result;
}
private static boolean FlymeSetStatusBarLightMode(AppCompatActivity activity, boolean dark) {
boolean result = false;
if (activity.getWindow() != null) {
try {
WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
Field darkFlag = WindowManager.LayoutParams.class
.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
Field meizuFlags = WindowManager.LayoutParams.class
.getDeclaredField("meizuFlags");
darkFlag.setAccessible(true);
meizuFlags.setAccessible(true);
int bit = darkFlag.getInt(null);
int value = meizuFlags.getInt(lp);
if (dark) {
value |= bit;
} else {
value &= ~bit;
}
meizuFlags.setInt(lp, value);
activity.getWindow().setAttributes(lp);
result = true;
} catch (Exception e) {
}
}
return result;
}
}

@ -0,0 +1,106 @@
package com.novel.read.utlis
import android.os.Build
import android.view.View
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
import java.lang.reflect.Field
import java.lang.reflect.Method
/**
* @author: LiJun 390057892@qq.com
* @date: 2018/3/7 15:07
*/
object StatusBarUtil {
fun setBarsStyle(activity: AppCompatActivity, color: Int, dark: Boolean) {
MIUISetStatusBarLightMode(activity, dark)
FlymeSetStatusBarLightMode(activity, dark)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//5.0及以上
val decorView = activity.window.decorView
if (dark) {
val option = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
decorView.systemUiVisibility = option
activity.window.statusBarColor = activity.resources.getColor(color)
} else {
val option = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
decorView.systemUiVisibility = option
activity.window.statusBarColor = activity.resources.getColor(color)
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4到5.0
val localLayoutParams = activity.window.attributes
localLayoutParams.flags =
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS or localLayoutParams.flags
}
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {//android6.0以后可以对状态栏文字颜色和图标进行修改
// if (dark){
// activity.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
// }else {
// activity.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
// }
//
// }
}
fun MIUISetStatusBarLightMode(activity: AppCompatActivity, dark: Boolean): Boolean {
var result = false
if (activity.window != null) {
val clazz = activity.window.javaClass
try {
var darkModeFlag = 0
val layoutParams = Class.forName("android.view.MiuiWindowManager\$LayoutParams")
val field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE")
darkModeFlag = field.getInt(layoutParams)
val extraFlagField = clazz.getMethod(
"setExtraFlags",
Int::class.javaPrimitiveType,
Int::class.javaPrimitiveType
)
if (dark) {
extraFlagField.invoke(activity.window, darkModeFlag, darkModeFlag)//状态栏透明且黑色字体
} else {
extraFlagField.invoke(activity.window, 0, darkModeFlag)//清除黑色字体
}
result = true
} catch (e: Exception) {
}
}
return result
}
private fun FlymeSetStatusBarLightMode(activity: AppCompatActivity, dark: Boolean): Boolean {
var result = false
if (activity.window != null) {
try {
val lp = activity.window.attributes
val darkFlag = WindowManager.LayoutParams::class.java
.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON")
val meizuFlags = WindowManager.LayoutParams::class.java
.getDeclaredField("meizuFlags")
darkFlag.isAccessible = true
meizuFlags.isAccessible = true
val bit = darkFlag.getInt(null)
var value = meizuFlags.getInt(lp)
if (dark) {
value = value or bit
} else {
value = value and bit.inv()
}
meizuFlags.setInt(lp, value)
activity.window.attributes = lp
result = true
} catch (e: Exception) {
}
}
return result
}
}

@ -11,9 +11,6 @@ public class StringUtils {
/**
* 将文本中的半角字符转换成全角字符
*
* @param input
* @return
*/
public static String halfToFull(String input) {
input = deleteImgs(input);

@ -1,162 +0,0 @@
package com.novel.read.utlis;
import android.app.Activity;
import android.os.Build;
import android.view.View;
import android.view.WindowManager;
/**
* Created by newbiechen on 17-5-16.
* 基于 Android 4.4
*
* 主要参数说明:
*
* SYSTEM_UI_FLAG_FULLSCREEN : 隐藏StatusBar
* SYSTEM_UI_FLAG_HIDE_NAVIGATION : 隐藏NavigationBar
* SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN: 视图扩展到StatusBar的位置并且StatusBar不消失
* 这里需要一些处理一般是将StatusBar设置为全透明或者半透明之后还需要使用fitSystemWindows=防止视图扩展到Status
* Bar上面(会在StatusBar上加一层View该View可被移动)
* SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION: 视图扩展到NavigationBar的位置
* SYSTEM_UI_FLAG_LAYOUT_STABLE:稳定效果
* SYSTEM_UI_FLAG_IMMERSIVE_STICKY:保证点击任意位置不会退出
*
* 可设置特效说明:
* 1. 全屏特效
* 2. 全屏点击不退出特效
* 3. 注意在19 <=sdk <=21 时候必须通过Window设置透明栏
*/
public class SystemBarUtils {
private static final int UNSTABLE_STATUS = View.SYSTEM_UI_FLAG_FULLSCREEN;
private static final int UNSTABLE_NAV = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
private static final int STABLE_STATUS = View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
private static final int STABLE_NAV = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
private static final int EXPAND_STATUS = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
private static final int EXPAND_NAV = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
//设置隐藏StatusBar(点击任意地方会恢复)
public static void hideUnStableStatusBar(Activity activity){
//App全屏,隐藏StatusBar
setFlag(activity,UNSTABLE_STATUS);
}
public static void showUnStableStatusBar(Activity activity){
clearFlag(activity,UNSTABLE_STATUS);
}
//隐藏NavigationBar(点击任意地方会恢复)
public static void hideUnStableNavBar(Activity activity){
setFlag(activity,UNSTABLE_NAV);
}
public static void showUnStableNavBar(Activity activity){
clearFlag(activity,UNSTABLE_NAV);
}
public static void hideStableStatusBar(Activity activity){
//App全屏,隐藏StatusBar
setFlag(activity,STABLE_STATUS);
}
public static void showStableStatusBar(Activity activity){
clearFlag(activity,STABLE_STATUS);
}
public static void hideStableNavBar(Activity activity){
//App全屏,隐藏StatusBar
setFlag(activity,STABLE_NAV);
}
public static void showStableNavBar(Activity activity){
clearFlag(activity,STABLE_NAV);
}
/**
* 视图扩充到StatusBar
*/
public static void expandStatusBar(Activity activity){
setFlag(activity, EXPAND_STATUS);
}
/**
* 视图扩充到NavBar
* @param activity
*/
public static void expandNavBar(Activity activity){
setFlag(activity, EXPAND_NAV);
}
public static void transparentStatusBar(Activity activity){
if (Build.VERSION.SDK_INT >= 21){
expandStatusBar(activity);
activity.getWindow()
.setStatusBarColor(activity.getResources().getColor(android.R.color.transparent));
}
else if (Build.VERSION.SDK_INT >= 19){
WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
attrs.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | attrs.flags);
activity.getWindow().setAttributes(attrs);
}
}
public static void transparentNavBar(Activity activity){
if (Build.VERSION.SDK_INT >= 21){
expandNavBar(activity);
//下面这个方法在sdk:21以上才有
activity.getWindow()
.setNavigationBarColor(activity.getResources().getColor(android.R.color.transparent));
}
}
public static void setFlag(Activity activity, int flag){
if (Build.VERSION.SDK_INT >= 19){
View decorView = activity.getWindow().getDecorView();
int option = decorView.getSystemUiVisibility() | flag;
decorView.setSystemUiVisibility(option);
}
}
//取消flag
public static void clearFlag(Activity activity, int flag){
if (Build.VERSION.SDK_INT >= 19){
View decorView = activity.getWindow().getDecorView();
int option = decorView.getSystemUiVisibility() & (~flag);
decorView.setSystemUiVisibility(option);
}
}
public static void setToggleFlag(Activity activity, int option){
if (Build.VERSION.SDK_INT >= 19){
if (isFlagUsed(activity,option)){
clearFlag(activity,option);
}
else {
setFlag(activity,option);
}
}
}
/**
* @param activity
* @return flag是否已被使用
*/
public static boolean isFlagUsed(Activity activity, int flag) {
int currentFlag = activity.getWindow().getDecorView().getSystemUiVisibility();
if((currentFlag & flag)
== flag) {
return true;
}else {
return false;
}
}
}

@ -0,0 +1,155 @@
package com.novel.read.utlis
import android.app.Activity
import android.os.Build
import android.view.View
import android.view.WindowManager
/**
* Created by newbiechen on 17-5-16.
* 基于 Android 4.4
*
* 主要参数说明:
*
* SYSTEM_UI_FLAG_FULLSCREEN : 隐藏StatusBar
* SYSTEM_UI_FLAG_HIDE_NAVIGATION : 隐藏NavigationBar
* SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN: 视图扩展到StatusBar的位置并且StatusBar不消失
* 这里需要一些处理一般是将StatusBar设置为全透明或者半透明之后还需要使用fitSystemWindows=防止视图扩展到Status
* Bar上面(会在StatusBar上加一层View该View可被移动)
* SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION: 视图扩展到NavigationBar的位置
* SYSTEM_UI_FLAG_LAYOUT_STABLE:稳定效果
* SYSTEM_UI_FLAG_IMMERSIVE_STICKY:保证点击任意位置不会退出
*
* 可设置特效说明:
* 1. 全屏特效
* 2. 全屏点击不退出特效
* 3. 注意在19 <=sdk <=21 时候必须通过Window设置透明栏
*/
object SystemBarUtils {
private val UNSTABLE_STATUS = View.SYSTEM_UI_FLAG_FULLSCREEN
private val UNSTABLE_NAV = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
private val STABLE_STATUS = View.SYSTEM_UI_FLAG_FULLSCREEN or
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
private val STABLE_NAV = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
private val EXPAND_STATUS =
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
private val EXPAND_NAV =
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
//设置隐藏StatusBar(点击任意地方会恢复)
fun hideUnStableStatusBar(activity: Activity) {
//App全屏,隐藏StatusBar
setFlag(activity, UNSTABLE_STATUS)
}
fun showUnStableStatusBar(activity: Activity) {
clearFlag(activity, UNSTABLE_STATUS)
}
//隐藏NavigationBar(点击任意地方会恢复)
fun hideUnStableNavBar(activity: Activity) {
setFlag(activity, UNSTABLE_NAV)
}
fun showUnStableNavBar(activity: Activity) {
clearFlag(activity, UNSTABLE_NAV)
}
fun hideStableStatusBar(activity: Activity) {
//App全屏,隐藏StatusBar
setFlag(activity, STABLE_STATUS)
}
fun showStableStatusBar(activity: Activity) {
clearFlag(activity, STABLE_STATUS)
}
fun hideStableNavBar(activity: Activity) {
//App全屏,隐藏StatusBar
setFlag(activity, STABLE_NAV)
}
fun showStableNavBar(activity: Activity) {
clearFlag(activity, STABLE_NAV)
}
/**
* 视图扩充到StatusBar
*/
fun expandStatusBar(activity: Activity) {
setFlag(activity, EXPAND_STATUS)
}
/**
* 视图扩充到NavBar
* @param activity
*/
fun expandNavBar(activity: Activity) {
setFlag(activity, EXPAND_NAV)
}
fun transparentStatusBar(activity: Activity) {
if (Build.VERSION.SDK_INT >= 21) {
expandStatusBar(activity)
activity.window.statusBarColor =
activity.resources.getColor(android.R.color.transparent)
} else if (Build.VERSION.SDK_INT >= 19) {
val attrs = activity.window.attributes
attrs.flags = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS or attrs.flags
activity.window.attributes = attrs
}
}
fun transparentNavBar(activity: Activity) {
if (Build.VERSION.SDK_INT >= 21) {
expandNavBar(activity)
//下面这个方法在sdk:21以上才有
activity.window.navigationBarColor =
activity.resources.getColor(android.R.color.transparent)
}
}
fun setFlag(activity: Activity, flag: Int) {
if (Build.VERSION.SDK_INT >= 19) {
val decorView = activity.window.decorView
val option = decorView.systemUiVisibility or flag
decorView.systemUiVisibility = option
}
}
//取消flag
fun clearFlag(activity: Activity, flag: Int) {
if (Build.VERSION.SDK_INT >= 19) {
val decorView = activity.window.decorView
val option = decorView.systemUiVisibility and flag.inv()
decorView.systemUiVisibility = option
}
}
fun setToggleFlag(activity: Activity, option: Int) {
if (Build.VERSION.SDK_INT >= 19) {
if (isFlagUsed(activity, option)) {
clearFlag(activity, option)
} else {
setFlag(activity, option)
}
}
}
/**
* @param activity
* @return flag是否已被使用
*/
fun isFlagUsed(activity: Activity, flag: Int): Boolean {
val currentFlag = activity.window.decorView.systemUiVisibility
return currentFlag and flag == flag
}
}

@ -10,6 +10,7 @@ import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.GridLayoutManager
import com.novel.read.R
import com.novel.read.adapter.PageStyleAdapter
import com.novel.read.utlis.ScreenUtils
import com.novel.read.widget.page.PageLoader
import com.novel.read.widget.page.PageMode
import com.novel.read.widget.page.PageStyle
@ -20,7 +21,7 @@ class ReadSettingDialog(mActivity: Activity, private var mPageLoader: PageLoader
Dialog(mActivity, R.style.ReadSettingDialog) {
private var mPageStyleAdapter: PageStyleAdapter? = null
private var mSettingManager: ReadSettingManager? = null
private var mSettingManager: ReadSettingManager = ReadSettingManager.getInstance()
private var mPageMode: PageMode? = null
private var mPageStyle: PageStyle? = null
@ -53,15 +54,14 @@ class ReadSettingDialog(mActivity: Activity, private var mPageLoader: PageLoader
}
private fun initData() {
mSettingManager = ReadSettingManager.getInstance()
isBrightnessAuto = mSettingManager!!.isBrightnessAuto
mBrightness = mSettingManager!!.brightness
mTextSize = mSettingManager!!.textSize
isTextDefault = mSettingManager!!.isDefaultTextSize
mPageMode = mSettingManager!!.pageMode
mPageStyle = mSettingManager!!.pageStyle
convertType = mSettingManager!!.convertType
isBrightnessAuto = mSettingManager.isBrightnessAuto
mBrightness = mSettingManager.brightness
mTextSize = mSettingManager.textSize
isTextDefault = mSettingManager.isDefaultTextSize
mPageMode = mSettingManager.pageMode
mPageStyle = mSettingManager.pageStyle
convertType = mSettingManager.convertType
if (convertType == 0) {
tv_simple.isSelected = true
tv_trans.isSelected = false
@ -69,6 +69,7 @@ class ReadSettingDialog(mActivity: Activity, private var mPageLoader: PageLoader
tv_simple.isSelected = false
tv_trans.isSelected = true
}
tv_size.text = "$mTextSize"
}
private fun initWidget() {
@ -77,14 +78,14 @@ class ReadSettingDialog(mActivity: Activity, private var mPageLoader: PageLoader
private fun setUpAdapter() {
val drawables = arrayOf(
getDrawable(R.color.nb_read_bg_1),
getDrawable(R.color.nb_read_bg_2),
getDrawable(R.color.nb_read_bg_4),
getDrawable(R.color.nb_read_bg_5)
getDrawable(R.color.read_bg_one),
getDrawable(R.color.read_bg_two),
getDrawable(R.color.read_bg_four),
getDrawable(R.color.read_bg_five)
)
mPageStyleAdapter = PageStyleAdapter(listOf(*drawables), mPageLoader)
read_setting_rv_bg.layoutManager = GridLayoutManager(context, 5)
read_setting_rv_bg.layoutManager = GridLayoutManager(context, 4)
read_setting_rv_bg.adapter = mPageStyleAdapter
mPageStyleAdapter!!.setPageStyleChecked(mPageStyle!!)
@ -98,17 +99,26 @@ class ReadSettingDialog(mActivity: Activity, private var mPageLoader: PageLoader
private fun initClick() {
//字体大小调节
read_setting_tv_font_minus.setOnClickListener { v ->
val fontSize = mSettingManager!!.textSize - 1
read_setting_tv_font_minus.setOnClickListener {
val fontSize = mSettingManager.textSize - 1
if (fontSize < 0) {
return@setOnClickListener
}
mPageLoader.setTextSize(fontSize)
tv_size.text = "$fontSize"
}
read_setting_tv_font_plus.setOnClickListener {
val fontSize = mSettingManager.textSize + 1
mPageLoader.setTextSize(fontSize)
tv_size.text = "$fontSize"
}
read_setting_tv_font_plus.setOnClickListener { v ->
val fontSize = mSettingManager!!.textSize + 1
tv_font_default.setOnClickListener {
val fontSize = ScreenUtils.spToPx(16)
mSettingManager.textSize = fontSize
mPageLoader.setTextSize(fontSize)
tv_size.text = "$fontSize"
}
tv_simple.setOnClickListener(View.OnClickListener {
@ -117,9 +127,9 @@ class ReadSettingDialog(mActivity: Activity, private var mPageLoader: PageLoader
}
tv_simple.isSelected = true
tv_trans.isSelected = false
mSettingManager!!.convertType = 0
mSettingManager.convertType = 0
convertType = 0
mPageLoader.setTextSize(mSettingManager!!.textSize)
mPageLoader.setTextSize(mSettingManager.textSize)
})
tv_trans.setOnClickListener(View.OnClickListener {
@ -128,9 +138,9 @@ class ReadSettingDialog(mActivity: Activity, private var mPageLoader: PageLoader
}
tv_simple.isSelected = false
tv_trans.isSelected = true
mSettingManager!!.convertType = 1
mSettingManager.convertType = 1
convertType = 1
mPageLoader.setTextSize(mSettingManager!!.textSize)
mPageLoader.setTextSize(mSettingManager.textSize)
})
//Page Mode 切换
@ -153,6 +163,9 @@ class ReadSettingDialog(mActivity: Activity, private var mPageLoader: PageLoader
PageMode.COVER -> read_setting_rb_cover.isChecked = true
PageMode.NONE -> read_setting_rb_none.isChecked = true
PageMode. SCROLL -> read_setting_rb_scroll.isChecked = true
else -> {
}
}
}

@ -67,23 +67,7 @@ public class NetPageLoader extends PageLoader {
+ File.separator + chapter.title + FileUtils.SUFFIX_NB);
if (!file.exists()) return null;
Reader reader = new FileReader(file);
BufferedReader br = new BufferedReader(reader);
// StringBuilder text = new StringBuilder();
// String paragraph;
// while ((paragraph = br.readLine()) != null){
// text.append(paragraph);
// }
//// String a = StringUtils.convertCC(text.toString(), mContext);
// byte[] by = text.toString().getBytes();
//
// InputStream is = new ByteArrayInputStream(by);
//
// InputStreamReader isr = new InputStreamReader(is);
//
// br = new BufferedReader(isr);
return br;
return new BufferedReader(reader);
}
@Override

@ -10,12 +10,12 @@ import com.novel.read.R;
* 页面的展示风格
*/
public enum PageStyle {
BG_0(R.color.nb_read_font_1, R.color.nb_read_bg_1),
BG_1(R.color.nb_read_font_2, R.color.nb_read_bg_2),
BG_0(R.color.read_font_one, R.color.read_bg_one),
BG_1(R.color.read_font_two, R.color.read_bg_two),
// BG_2(R.color.nb_read_font_3, R.color.nb_read_bg_3),
BG_3(R.color.nb_read_font_4, R.color.nb_read_bg_4),
BG_4(R.color.nb_read_font_5, R.color.nb_read_bg_5),
NIGHT(R.color.nb_read_font_night, R.color.nb_read_bg_night),;
BG_3(R.color.read_font_four, R.color.read_bg_four),
BG_4(R.color.read_font_five, R.color.read_bg_five),
NIGHT(R.color.read_font_night, R.color.read_bg_night),;
private int fontColor;
private int bgColor;

@ -26,9 +26,6 @@ public class TxtPage {
if (lines == null) {
return new ArrayList<>();
}
// for (int i = 0; i <lines.size() ; i++) {
// lines.set(i, StringUtils.convertCC(lines.get(i), MyApp.getContext()));
// }
return lines;
}

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="20dp"/>
<stroke android:color="@color/colorDesTitle" android:width="1dp"/>
</shape>

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:drawable="@drawable/listen_select"/>
<item android:state_checked="true" android:drawable="@drawable/listen_select"/>
<item android:state_selected="false" android:drawable="@color/read_menu_color"/>
</selector>

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:color="@color/white"/>
<item android:state_checked="true" android:color="@color/white"/>
<item android:state_selected="false" android:color="@color/smallColor"/>
</selector>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:color="@color/light_yellow"/>
<item android:state_checked="true" android:color="@color/light_yellow"/>
<item android:state_selected="false" android:color="@color/smallColor"/>
</selector>

@ -12,7 +12,7 @@
android:id="@+id/cl_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/nb.read.bg_1">
android:background="@color/read_bg_one">
<com.google.android.material.appbar.AppBarLayout

@ -19,7 +19,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@color/nb.read.bg_1"
android:background="@color/read_bg_one"
android:text="正在拼命加载中..."/>
</androidx.constraintlayout.ConstraintLayout>

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -262,4 +262,4 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_time" />
</androidx.constraintlayout.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,20 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center">
<View
android:id="@+id/read_bg_view"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="@color/nb.read.bg_1"/>
android:layout_gravity="center"
android:background="@color/read_bg_one"/>
<ImageView
android:id="@+id/read_bg_iv_checked"
android:layout_width="30dp"
android:layout_height="40dp"
android:src="@drawable/ic_checked"
android:layout_gravity="center"
android:scaleType="center"
android:visibility="gone"/>
</FrameLayout>

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat 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:id="@+id/ll_setting"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -10,9 +11,10 @@
android:orientation="vertical"
android:padding="5dp">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_height="60dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:orientation="horizontal">
@ -31,125 +33,191 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="5dp"
android:layout_weight="1"
android:gravity="center"
android:text="@string/simple_font"
android:textColor="@drawable/text_color" />
android:layout_marginStart="20dp"
android:textColor="@drawable/text_font_color" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_trans"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:layout_weight="3"
android:gravity="start"
android:padding="5dp"
android:layout_marginEnd="10dp"
android:text="@string/traditional_font"
android:textColor="@drawable/text_color" />
android:textColor="@drawable/text_font_color" />
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_height="60dp"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
<TextView
android:id="@+id/tv_speed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_height="match_parent"
android:layout_marginStart="10dp"
android:gravity="center"
android:text="@string/font_size"
android:textColor="@color/smallColor"
android:textSize="16sp" />
android:textSize="16sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatImageView
<TextView
android:id="@+id/read_setting_tv_font_minus"
android:layout_width="0dp"
android:padding="5dp"
android:layout_height="wrap_content"
android:text="Aa-"
android:textSize="17sp"
android:gravity="center"
android:background="@drawable/bg_coner_line"
android:layout_marginStart="20dp"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@+id/tv_speed"
app:layout_constraintRight_toLeftOf="@+id/tv_size"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
<TextView
android:id="@+id/tv_size"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="@drawable/ic_font_min" />
android:gravity="center"
tools:text="40"
android:textSize="17sp"
app:layout_constraintBottom_toBottomOf="@+id/tv_speed"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@+id/read_setting_tv_font_minus"
app:layout_constraintRight_toLeftOf="@+id/read_setting_tv_font_plus"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatImageView
<TextView
android:id="@+id/read_setting_tv_font_plus"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:src="@drawable/ic_font_add" />
android:padding="5dp"
android:text="Aa+"
android:textSize="17sp"
android:background="@drawable/bg_coner_line"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@+id/tv_size"
app:layout_constraintRight_toLeftOf="@+id/tv_font_default"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.appcompat.widget.LinearLayoutCompat>
<TextView
android:id="@+id/tv_font_default"
android:layout_width="0dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="默认"
android:layout_marginEnd="10dp"
android:textSize="14sp"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@+id/read_setting_tv_font_plus"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp">
android:layout_height="60dp">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_page"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:text="@string/page_mode"
android:textColor="@color/smallColor"
android:layout_marginStart="10dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:gravity="center"
android:textSize="16sp" />
<RadioGroup
android:id="@+id/read_setting_rg_page_mode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_margin="10dp">
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/tv_page"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginStart="20dp"
android:layout_marginEnd="10dp">
<androidx.appcompat.widget.AppCompatRadioButton
android:id="@+id/read_setting_rb_simulation"
android:layout_width="0dp"
android:layout_height="35dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="5dp"
android:layout_weight="1"
android:button="@null"
android:gravity="center|end"
android:gravity="center"
android:text="@string/simulation"
android:textColor="@drawable/text_color"
android:background="@drawable/bg_listen"
android:textSize="14sp" />
<androidx.appcompat.widget.AppCompatRadioButton
android:id="@+id/read_setting_rb_cover"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:button="@null"
android:padding="5dp"
android:gravity="center"
android:text="@string/cover"
android:textColor="@drawable/text_color"
android:background="@drawable/bg_listen"
android:textSize="14sp" />
<androidx.appcompat.widget.AppCompatRadioButton
android:id="@+id/read_setting_rb_scroll"
android:layout_width="0dp"
android:layout_height="35dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:padding="5dp"
android:button="@null"
android:gravity="center"
android:text="@string/scroll"
android:textColor="@drawable/text_color"
android:background="@drawable/bg_listen"
android:textSize="14sp" />
<androidx.appcompat.widget.AppCompatRadioButton
android:id="@+id/read_setting_rb_none"
android:layout_width="0dp"
android:layout_height="35dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:padding="5dp"
android:button="@null"
android:gravity="center|start"
android:gravity="center"
android:text="@string/none"
android:textColor="@drawable/text_color"
android:background="@drawable/bg_listen"
android:textSize="14sp" />
</RadioGroup>
@ -157,32 +225,37 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.appcompat.widget.LinearLayoutCompat
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_height="60dp"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_bg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/font_bg"
android:textColor="@color/smallColor"
android:layout_marginStart="10dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:textSize="16sp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/read_setting_rv_bg"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="4"
android:scrollbars="none" />
android:layout_height="0dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:scrollbars="none"
app:layout_constraintLeft_toRightOf="@+id/tv_bg"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.appcompat.widget.LinearLayoutCompat>

@ -22,23 +22,23 @@
<color name="transparent">#00000000</color>
<!--read-->
<color name="nb.read.bg_1">#EFEFF7</color>
<color name="nb.read.bg_2">#CCEBCC</color>
<color name="nb.read.bg_4">#CEC29C</color>
<color name="nb.read.bg_5">#001C27</color>
<color name="nb.read.bg_6">#DDCEC29C</color>
<color name="read_bg_one">#EFEFF7</color>
<color name="read_bg_two">#CCEBCC</color>
<color name="read_bg_four">#CEC29C</color>
<color name="read_bg_five">#001C27</color>
<color name="read_bg_six">#DDCEC29C</color>
<color name="nb.read.font_1">#383429</color>
<color name="nb.read.font_2">#2F332D</color>
<color name="nb.read.font_3">#92918C</color>
<color name="nb.read.font_4">#2C2C2C</color>
<color name="nb.read.font_5">#627176</color>
<color name="read_font_one">#383429</color>
<color name="read_font_two">#2F332D</color>
<color name="read_font_three">#92918C</color>
<color name="read_font_four">#2C2C2C</color>
<color name="read_font_five">#627176</color>
<color name="nb.read.bg.night">#000000</color>
<color name="nb.read.font_night">#99ffffff</color>
<color name="read_bg_night">#000000</color>
<color name="read_font_night">#99ffffff</color>
<color name="nb.read.menu.bg">#191919</color>
<color name="nb.read.menu.text">#CBCBCB</color>
<color name="nb.read.bar.translucent">#88000000</color>
<color name="read_menu_bg">#191919</color>
<color name="read_menu_text">#CBCBCB</color>
<color name="read_bar_translucent">#88000000</color>
</resources>

@ -22,22 +22,22 @@
<color name="transparent">#00000000</color>
<!--read-->
<color name="nb.read.bg_1">#EFEFF7</color>
<color name="nb.read.bg_2">#CCEBCC</color>
<color name="nb.read.bg_4">#CEC29C</color>
<color name="nb.read.bg_5">#001C27</color>
<color name="nb.read.bg_6">#DDCEC29C</color>
<color name="read_bg_one">#EFEFF7</color>
<color name="read_bg_two">#CCEBCC</color>
<color name="read_bg_four">#CEC29C</color>
<color name="read_bg_five">#001C27</color>
<color name="read_bg_six">#DDCEC29C</color>
<color name="nb.read.font_1">#383429</color>
<color name="nb.read.font_2">#2F332D</color>
<color name="nb.read.font_3">#92918C</color>
<color name="nb.read.font_4">#2C2C2C</color>
<color name="nb.read.font_5">#627176</color>
<color name="read_font_one">#383429</color>
<color name="read_font_two">#2F332D</color>
<color name="read_font_three">#92918C</color>
<color name="read_font_four">#2C2C2C</color>
<color name="read_font_five">#627176</color>
<color name="nb.read.bg.night">#000000</color>
<color name="nb.read.font_night">#99ffffff</color>
<color name="read_bg_night">#000000</color>
<color name="read_font_night">#99ffffff</color>
<color name="nb.read.menu.bg">#191919</color>
<color name="nb.read.menu.text">#CBCBCB</color>
<color name="nb.read.bar.translucent">#88000000</color>
<color name="read_menu_bg">#191919</color>
<color name="read_menu_text">#CBCBCB</color>
<color name="read_bar_translucent">#88000000</color>
</resources>

@ -28,28 +28,29 @@
<color name="transparent">#00000000</color>
<color name="read_menu_color">#C4C4C4</color>
<color name="read_menu_color">#FFFDF6</color>
<color name="read_menu_trans_color">#FCC4C4C4</color>
<color name="light_red">#EC4A48</color>
<color name="light_yellow">#B87324</color>
<!--read-->
<color name="nb.read.bg_1">#EFEFF7</color>
<color name="nb.read.bg_2">#CCEBCC</color>
<color name="nb.read.bg_4">#CEC29C</color>
<color name="nb.read.bg_5">#001C27</color>
<color name="nb.read.bg_6">#DDCEC29C</color>
<color name="read_bg_one">#EFEFF7</color>
<color name="read_bg_two">#CCEBCC</color>
<color name="read_bg_four">#CEC29C</color>
<color name="read_bg_five">#001C27</color>
<color name="read_bg_six">#DDCEC29C</color>
<color name="nb.read.font_1">#383429</color>
<color name="nb.read.font_2">#2F332D</color>
<color name="nb.read.font_3">#92918C</color>
<color name="nb.read.font_4">#2C2C2C</color>
<color name="nb.read.font_5">#627176</color>
<color name="read_font_one">#383429</color>
<color name="read_font_two">#2F332D</color>
<color name="read_font_three">#92918C</color>
<color name="read_font_four">#2C2C2C</color>
<color name="read_font_five">#627176</color>
<color name="nb.read.bg.night">#000000</color>
<color name="nb.read.font_night">#99ffffff</color>
<color name="read_bg_night">#000000</color>
<color name="read_font_night">#99ffffff</color>
<color name="nb.read.menu.bg">#191919</color>
<color name="nb.read.menu.text">#CBCBCB</color>
<color name="nb.read.bar.translucent">#88000000</color>
<color name="read_menu_bg">#191919</color>
<color name="read_menu_text">#CBCBCB</color>
<color name="read_bar_translucent">#88000000</color>
</resources>

@ -1,78 +0,0 @@
package com.common_lib.base.utils;
import android.content.Context;
import android.os.Build;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
/**
* Created by alex on 2017/2/8.
*/
public class DeviceInfoUtil {
public static String getDeviceInfo(Context context){
String A_ID = Settings.System.getString(context.getContentResolver(), Settings.System.ANDROID_ID);
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
StringBuilder sb = new StringBuilder();
sb.append("\nDeviceId(IMEI) = " + tm.getDeviceId());
sb.append("\nDeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion());
sb.append("\nLine1Number = " + tm.getLine1Number());
sb.append("\nNetworkCountryIso = " + tm.getNetworkCountryIso());
sb.append("\nNetworkOperator = " + tm.getNetworkOperator());
sb.append("\nNetworkOperatorName = " + tm.getNetworkOperatorName());
sb.append("\nNetworkType = " + tm.getNetworkType());
sb.append("\nPhoneType = " + tm.getPhoneType());
sb.append("\nSimCountryIso = " + tm.getSimCountryIso());
sb.append("\nSimOperator = " + tm.getSimOperator());
sb.append("\nSimOperatorName = " + tm.getSimOperatorName());
sb.append("\nSimSerialNumber = " + tm.getSimSerialNumber());
sb.append("\nSimState = " + tm.getSimState());
sb.append("\nSubscriberId(IMSI) = " + tm.getSubscriberId());
sb.append("\nVoiceMailNumber = " + tm.getVoiceMailNumber());
sb.append("\nSoftwareVersion=" + tm.getDeviceSoftwareVersion());
sb.append("\nCPU="+getCPUSerial());
sb.append("\nBoard="+ Build.BOARD);
sb.append("\nCPU1="+ Build.CPU_ABI);
sb.append("\nDEVICE="+ Build.DEVICE);
sb.append("\nHARDWARE="+ Build.HARDWARE);
sb.append("\nANDROID_ID = " + A_ID);
return sb.toString();
}
/**
* 获取CPU序列号
*
* @return CPU序列号(16位)
* 读取失败为"0000000000000000"
*/
private static String getCPUSerial() {
String str = "", strCPU = "", cpuAddress = "0000000000000000";
try {
//读取CPU信息
Process pp = Runtime.getRuntime().exec("cat /proc/cpuinfo");
InputStreamReader ir = new InputStreamReader(pp.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
//查找CPU序列号
str = input.readLine();
if (str != null) {
//查找到序列号所在行
if (str.indexOf("Serial") > -1) {
//提取序列号
strCPU = str.substring(str.indexOf(":") + 1,
str.length());
//去空格
cpuAddress = strCPU.trim();
}
} else {
}
} catch (IOException ex) {
//赋予默认值
ex.printStackTrace();
}
return cpuAddress;
}
}

@ -1,55 +0,0 @@
package com.common_lib.base.utils;
import android.annotation.TargetApi;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.provider.Settings;
import com.common_lib.base.BaseConstants;
/**
* Created by alex on 2016/3/2.
*/
public class NetworkUtils {
public static final int TYPE_UNKNOWN = -1;
private static NetworkInfo getActiveNetworkInfo(Context context) {
if (context == null) {
return null;
} else {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
return cm == null ? null : cm.getActiveNetworkInfo();
}
}
private static int getActiveNetworkType(Context context) {
NetworkInfo info = getActiveNetworkInfo(context);
return info != null && info.isConnected() ? info.getType() : -1;
}
public static boolean isNetworkAvailable(Context context) {
NetworkInfo info = getActiveNetworkInfo(context);
return info != null && info.isConnected();
}
public static boolean isWiFiConnected(Context context) {
return getActiveNetworkType(context) == 1;
}
@TargetApi(17)
public static boolean isAirplaneModeOn(Context context) {
return Build.VERSION.SDK_INT < 17 ? Settings.System.getInt(context.getContentResolver(), "airplane_mode_on", 0) != 0 : Settings.Global.getInt(context.getContentResolver(), "airplane_mode_on", 0) != 0;
}
public static boolean checkConnection(Context context) {
if (isNetworkAvailable(context)) {
return true;
} else {
ToastUtils.showNormalToast(context, BaseConstants.No_Internet);
return false;
}
}
}

@ -16,7 +16,7 @@ import java.util.List;
/**
* 这个类是用来解析Object属性的
* Created by alex on 16/7/4.
* Created by zlj
*/
public class ObjectAnalysisUtils {
private static ObjectAnalysisUtils instance = null;

@ -10,7 +10,7 @@ import java.util.HashMap;
import java.util.List;
/**
* Created by alex on 16/7/2.
* Created by zlj
*/
public class SecurityUtils {
private static final String securityKey = "2E8PObAj8HI45Qu9";
@ -92,18 +92,10 @@ public class SecurityUtils {
public String MD5Decode(String info) {
String s1 = md5Utils.getMD5Result(info + securityKey);
// if (isEmpty(s1)) {
// return null;
// }
// s1 = md5Utils.getMD5Result(s1 + securityKey);
return s1;
return md5Utils.getMD5Result(info + securityKey);
}
private boolean isEmpty(String info) {
if (info == null || info.isEmpty()) {
return true;
}
return false;
return info == null || info.isEmpty();
}
}

@ -1,94 +0,0 @@
package com.common_lib.base.utils;
import com.common_lib.base.BaseConstants;
import com.common_lib.base.GsonManager;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
/**
* 用于处理一些奇奇怪怪的String类型转换的工具类
* Created by alex on 16/7/20.
*/
public class StringUtils {
//这个方法是用来处理服务端返回的url列表的
public static List<String> formatStringUrl(String imageContent) {
List<String> res = null;
if (imageContent == null || imageContent.isEmpty()) {
return res;
}
Gson gson = GsonManager.Companion.getInstance().getGson();
Type listType = new TypeToken<ArrayList<String>>() {
}.getType();
res = gson.fromJson(imageContent, listType);
return res;
}
//这个方法是获取url列表的方法,这个方法就是
public static List<String> formatStringUrl(String imageContent, boolean addHead, int maxLength) {
List<String> res;
if (imageContent == null || imageContent.isEmpty()) {
res = new ArrayList<>();
res.add(null);
return res;
}
Gson gson = GsonManager.Companion.getInstance().getGson();
Type listType = new TypeToken<ArrayList<String>>() {
}.getType();
res = gson.fromJson(imageContent, listType);
if (res.size() > 0 && res.size() < maxLength) {
if (addHead && res.get(res.size()-1) != null) {
res.add(res.size(), null);
}
} else if(res.size()==maxLength){
return res;
}else{
res = new ArrayList<>();
res.add(null);
}
return res;
}
//这是将一个字符串的长度增大
public static String increaseGroupMessage(String msg) {
StringBuilder builder = new StringBuilder();
builder.append(msg);
while (builder.length() < 100) {
builder.append(BaseConstants.EMPTY_STRING);
}
return builder.toString();
}
public static String formatList(List<String> info) {
String res = null;
List<String> infoList = new ArrayList<>();
for (int i = 0; i < info.size(); i++) {
if (info.get(i) != null) {
infoList.add(info.get(i));
}
}
if (infoList.size() > -1) {
Gson gson = GsonManager.Companion.getInstance().getGson();
res = gson.toJson(infoList);
}
return res;
}
//从图片的路径当中获取图片的名称
public static String getFileNameFromPath(String path) {
String res;
String[] s = path.split("/");
res = s[s.length - 1];
return res;
}
}

@ -1,48 +0,0 @@
package com.common_lib.base.utils;
import android.content.Context;
import android.widget.Toast;
/**
* Created by alex on 2016/3/2.
*/
public class ToastUtils {
public enum Duration {SHORT, LONG}
private ToastUtils() {
throw new AssertionError();
}
public static void showNormalToast(Context context, int stringResId) {
showToast(context, stringResId, Duration.SHORT);
}
public static void showNormalToast(Context context, String text) {
showToast(context, text, Duration.SHORT);
}
public static void showLongDurationToast(Context context, int stringResId) {
showToast(context, stringResId, Duration.LONG);
}
public static void showLongDurationToast(Context context, String text) {
showToast(context, text, Duration.LONG);
}
private static void showToast(Context context, int text, Duration duration) {
Toast toast = Toast.makeText(context, text,
(duration == Duration.SHORT ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG));
// toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
private static void showToast(Context context, String text, Duration duration) {
Toast toast = Toast.makeText(context, text,
(duration == Duration.SHORT ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG));
// toast.setGravity(Gravity.BOTTOM, 0, 0);
toast.show();
}
}
Loading…
Cancel
Save