修复SharedPreUtils.getInstance()作为局部变量带来的问题

pull/21/head
fengyuecanzhu 3 years ago
parent c5759ba251
commit 6a10102b7a
  1. 2
      app/build.gradle
  2. 21
      app/src/main/java/xyz/fycz/myreader/application/App.java
  3. 34
      app/src/main/java/xyz/fycz/myreader/model/third3/http/HttpHelper.kt
  4. 14
      app/src/main/java/xyz/fycz/myreader/ui/activity/AdSettingActivity.java
  5. 10
      app/src/main/java/xyz/fycz/myreader/ui/activity/BookstoreActivity.java
  6. 3
      app/src/main/java/xyz/fycz/myreader/ui/activity/SearchBookActivity.java
  7. 8
      app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java
  8. 12
      app/src/main/java/xyz/fycz/myreader/ui/dialog/BookGroupDialog.java
  9. 34
      app/src/main/java/xyz/fycz/myreader/ui/fragment/ProxyFragment.kt
  10. 1
      app/src/main/java/xyz/fycz/myreader/util/SharedPreUtils.java
  11. 7
      app/src/main/java/xyz/fycz/myreader/util/utils/AdUtils.java
  12. 1
      app/src/main/java/xyz/fycz/myreader/webapi/LanZousApi.java
  13. 18
      app/src/main/java/xyz/fycz/myreader/webapi/crawler/ReadCrawlerUtil.java
  14. 3
      app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QiDianFindCrawler.java
  15. 3
      app/src/main/java/xyz/fycz/myreader/webapi/crawler/find/QiDianMobileRank.java
  16. 2
      app/src/main/res/values/strings.xml

@ -277,7 +277,7 @@ dependencies {
} }
greendao { greendao {
schemaVersion 34 schemaVersion 35
daoPackage 'xyz.fycz.myreader.greendao.gen' daoPackage 'xyz.fycz.myreader.greendao.gen'
// targetGenDir 'src/main/java' // targetGenDir 'src/main/java'
} }

@ -285,29 +285,28 @@ public class App extends Application {
isForceUpdate = Boolean.parseBoolean(contents[1].substring(contents[1].indexOf(":") + 1)); isForceUpdate = Boolean.parseBoolean(contents[1].substring(contents[1].indexOf(":") + 1));
downloadLink = contents[2].substring(contents[2].indexOf(":") + 1).trim(); downloadLink = contents[2].substring(contents[2].indexOf(":") + 1).trim();
updateContent = contents[3].substring(contents[3].indexOf(":") + 1); updateContent = contents[3].substring(contents[3].indexOf(":") + 1);
SharedPreUtils spu = SharedPreUtils.getInstance(); SharedPreUtils.getInstance().putString(getmContext().getString(R.string.lanzousKeyStart), contents[4].substring(contents[4].indexOf(":") + 1));
spu.putString(getmContext().getString(R.string.lanzousKeyStart), contents[4].substring(contents[4].indexOf(":") + 1));
String newSplashTime = contents[5].substring(contents[5].indexOf(":") + 1); String newSplashTime = contents[5].substring(contents[5].indexOf(":") + 1);
String oldSplashTime = spu.getString("splashTime"); String oldSplashTime = SharedPreUtils.getInstance().getString("splashTime");
spu.putBoolean("needUdSI", !oldSplashTime.equals(newSplashTime)); SharedPreUtils.getInstance().putBoolean("needUdSI", !oldSplashTime.equals(newSplashTime));
spu.putString("splashTime", contents[5].substring(contents[5].indexOf(":") + 1)); SharedPreUtils.getInstance().putString("splashTime", contents[5].substring(contents[5].indexOf(":") + 1));
spu.putString("splashImageUrl", contents[6].substring(contents[6].indexOf(":") + 1)); SharedPreUtils.getInstance().putString("splashImageUrl", contents[6].substring(contents[6].indexOf(":") + 1));
spu.putString("splashImageMD5", contents[7].substring(contents[7].indexOf(":") + 1)); SharedPreUtils.getInstance().putString("splashImageMD5", contents[7].substring(contents[7].indexOf(":") + 1));
forceUpdateVersion = Integer.parseInt(contents[8].substring(contents[8].indexOf(":") + 1)); forceUpdateVersion = Integer.parseInt(contents[8].substring(contents[8].indexOf(":") + 1));
spu.putInt("forceUpdateVersion", forceUpdateVersion); SharedPreUtils.getInstance().putInt("forceUpdateVersion", forceUpdateVersion);
String domain = contents[9].substring(contents[9].indexOf(":") + 1); String domain = contents[9].substring(contents[9].indexOf(":") + 1);
spu.putString("domain", domain); SharedPreUtils.getInstance().putString("domain", domain);
int versionCode = getVersionCode(); int versionCode = getVersionCode();
isForceUpdate = isForceUpdate && forceUpdateVersion > versionCode; isForceUpdate = isForceUpdate && forceUpdateVersion > versionCode;
if (!StringHelper.isEmpty(downloadLink)) { if (!StringHelper.isEmpty(downloadLink)) {
spu.putString(getmContext().getString(R.string.downloadLink), downloadLink); SharedPreUtils.getInstance().putString(getmContext().getString(R.string.downloadLink), downloadLink);
} else { } else {
spu.putString(getmContext().getString(R.string.downloadLink), URLCONST.APP_DIR_URL); SharedPreUtils.getInstance().putString(getmContext().getString(R.string.downloadLink), URLCONST.APP_DIR_URL);
} }
String[] updateContents = updateContent.split("/"); String[] updateContents = updateContent.split("/");
for (String string : updateContents) { for (String string : updateContents) {

@ -1,5 +1,6 @@
package xyz.fycz.myreader.model.third3.http package xyz.fycz.myreader.model.third3.http
import android.util.Log
import okhttp3.ConnectionSpec import okhttp3.ConnectionSpec
import okhttp3.Credentials import okhttp3.Credentials
import okhttp3.Interceptor import okhttp3.Interceptor
@ -47,24 +48,31 @@ val okHttpClient: OkHttpClient by lazy {
builder.build() builder.build()
} }
val globalProxy by lazy { val globalProxy: String
val spu = SharedPreUtils.getInstance() get() {
val type = if (spu.getInt("proxyType") == 0) { val enableProxy = SharedPreUtils.getInstance().getBoolean("enableProxy")
"http" if (!enableProxy) {
} else { return ""
"socks5" }
val type = if (SharedPreUtils.getInstance().getInt("proxyType") == 0) {
"http"
} else {
"socks5"
}
val host = SharedPreUtils.getInstance().getString("proxyHost")
val port = SharedPreUtils.getInstance().getString("proxyPort")
val username = SharedPreUtils.getInstance().getString("proxyUsername")
val password = SharedPreUtils.getInstance().getString("proxyPassword")
return "$type://$host:$port@$username@$password"
} }
val host = spu.getString("proxyHost")
val port = spu.getString("proxyPort")
val username = spu.getString("proxyUsername")
val password = spu.getString("proxyPassword")
"$type://$host:$port@$username@$password"
}
/** /**
* 缓存代理okHttp * 缓存代理okHttp
*/ */
fun getProxyClient(proxy: String? = globalProxy, noProxy: Boolean = false): OkHttpClient { fun getProxyClient(proxy0: String? = null, noProxy: Boolean = false): OkHttpClient {
var proxy = proxy0
if (proxy.isNullOrEmpty()) proxy = globalProxy
Log.d("getProxyClient", "proxy=$proxy")
if (proxy.isNullOrBlank() || noProxy) { if (proxy.isNullOrBlank() || noProxy) {
return okHttpClient return okHttpClient
} }

@ -30,7 +30,6 @@ import xyz.fycz.myreader.util.utils.FileUtils;
public class AdSettingActivity extends BaseActivity<ActivityAdSettingBinding> { public class AdSettingActivity extends BaseActivity<ActivityAdSettingBinding> {
private LoadingDialog loadingDialog; private LoadingDialog loadingDialog;
private SharedPreUtils spu;
private int curAdTimes; private int curAdTimes;
private int curAdCount; private int curAdCount;
private boolean bookDetailAd; private boolean bookDetailAd;
@ -51,9 +50,8 @@ public class AdSettingActivity extends BaseActivity<ActivityAdSettingBinding> {
@Override @Override
protected void initData(Bundle savedInstanceState) { protected void initData(Bundle savedInstanceState) {
spu = SharedPreUtils.getInstance(); curAdTimes = SharedPreUtils.getInstance().getInt("curAdTimes", 3);
curAdTimes = spu.getInt("curAdTimes", 3); String splashAdCount = SharedPreUtils.getInstance().getString("splashAdCount");
String splashAdCount = spu.getString("splashAdCount");
String[] splashAdCounts = splashAdCount.split(":"); String[] splashAdCounts = splashAdCount.split(":");
String today = DateHelper.getYearMonthDay1(); String today = DateHelper.getYearMonthDay1();
if (today.equals(splashAdCounts[0])){ if (today.equals(splashAdCounts[0])){
@ -61,7 +59,7 @@ public class AdSettingActivity extends BaseActivity<ActivityAdSettingBinding> {
}else { }else {
curAdCount = 0; curAdCount = 0;
} }
bookDetailAd = spu.getBoolean("bookDetailAd", false); bookDetailAd = SharedPreUtils.getInstance().getBoolean("bookDetailAd", false);
} }
@Override @Override
@ -135,7 +133,7 @@ public class AdSettingActivity extends BaseActivity<ActivityAdSettingBinding> {
.setTitle(getString(R.string.splash_ad_times)) .setTitle(getString(R.string.splash_ad_times))
.setSingleChoiceItems(adTimes, checked, (dialog, which) -> { .setSingleChoiceItems(adTimes, checked, (dialog, which) -> {
curAdTimes = ints[which]; curAdTimes = ints[which];
spu.putInt("curAdTimes", curAdTimes); SharedPreUtils.getInstance().putInt("curAdTimes", curAdTimes);
binding.tvSplashCurAdTimes.setText(getString(R.string.splash_cur_ad_times, adTimes[which], curAdCount + "次")); binding.tvSplashCurAdTimes.setText(getString(R.string.splash_cur_ad_times, adTimes[which], curAdCount + "次"));
dialog.dismiss(); dialog.dismiss();
}).setNegativeButton("取消", null).show();*/ }).setNegativeButton("取消", null).show();*/
@ -143,7 +141,7 @@ public class AdSettingActivity extends BaseActivity<ActivityAdSettingBinding> {
.setSelection(checked) .setSelection(checked)
.setOnMenuItemClickListener((dialog, text, which) -> { .setOnMenuItemClickListener((dialog, text, which) -> {
curAdTimes = ints[which]; curAdTimes = ints[which];
spu.putInt("curAdTimes", curAdTimes); SharedPreUtils.getInstance().putInt("curAdTimes", curAdTimes);
binding.tvSplashCurAdTimes.setText(getString(R.string.splash_cur_ad_times, adTimes[which], curAdCount + "次")); binding.tvSplashCurAdTimes.setText(getString(R.string.splash_cur_ad_times, adTimes[which], curAdCount + "次"));
return false; return false;
}).setCancelButton(R.string.cancel); }).setCancelButton(R.string.cancel);
@ -157,7 +155,7 @@ public class AdSettingActivity extends BaseActivity<ActivityAdSettingBinding> {
}); });
binding.rlBookDetailAd.setOnClickListener(v -> { binding.rlBookDetailAd.setOnClickListener(v -> {
bookDetailAd = !bookDetailAd; bookDetailAd = !bookDetailAd;
spu.putBoolean("bookDetailAd", bookDetailAd); SharedPreUtils.getInstance().putBoolean("bookDetailAd", bookDetailAd);
binding.scBookDetailAd.setChecked(bookDetailAd); binding.scBookDetailAd.setChecked(bookDetailAd);
}); });
binding.rlDeleteAdFile.setOnClickListener(v -> { binding.rlDeleteAdFile.setOnClickListener(v -> {

@ -182,12 +182,11 @@ public class BookstoreActivity extends BaseActivity<ActiityBookstoreBinding> {
super.processLogic(); super.processLogic();
getData(); getData();
if (findCrawler3.needSearch()) { if (findCrawler3.needSearch()) {
SharedPreUtils spu = SharedPreUtils.getInstance(); boolean isReadTopTip = SharedPreUtils.getInstance().getBoolean(getString(R.string.isReadTopTip), false);
boolean isReadTopTip = spu.getBoolean(getString(R.string.isReadTopTip), false);
if (!isReadTopTip) { if (!isReadTopTip) {
DialogCreator.createCommonDialog(this, "提示", getResources().getString(R.string.top_sort_tip, title), DialogCreator.createCommonDialog(this, "提示", getResources().getString(R.string.top_sort_tip, title),
true, "知道了", "不再提示", null, true, "知道了", "不再提示", null,
(dialog, which) -> spu.putBoolean(getString(R.string.isReadTopTip), true)); (dialog, which) -> SharedPreUtils.getInstance().putBoolean(getString(R.string.isReadTopTip), true));
} }
} }
} }
@ -197,13 +196,12 @@ public class BookstoreActivity extends BaseActivity<ActiityBookstoreBinding> {
*/ */
private void getData() { private void getData() {
if (findCrawler3 instanceof QiDianMobileRank) { if (findCrawler3 instanceof QiDianMobileRank) {
SharedPreUtils spu = SharedPreUtils.getInstance(); if (SharedPreUtils.getInstance().getString(getString(R.string.qdCookie), "").equals("")) {
if (spu.getString(getString(R.string.qdCookie), "").equals("")) {
((QiDianMobileRank) findCrawler3).initCookie(this, new ResultCallback() { ((QiDianMobileRank) findCrawler3).initCookie(this, new ResultCallback() {
@Override @Override
public void onFinish(Object o, int code) { public void onFinish(Object o, int code) {
if (App.isDestroy(BookstoreActivity.this)) return; if (App.isDestroy(BookstoreActivity.this)) return;
spu.putString(getString(R.string.qdCookie), (String) o); SharedPreUtils.getInstance().putString(getString(R.string.qdCookie), (String) o);
mBookTypes = findCrawler3.getBookTypes(); mBookTypes = findCrawler3.getBookTypes();
initBooks(); initBooks();
} }

@ -485,9 +485,8 @@ public class SearchBookActivity extends BaseActivity<ActivitySearchBookBinding>
mHotKeys.addAll(Arrays.asList(suggestion)); mHotKeys.addAll(Arrays.asList(suggestion));
initSuggestionList(); initSuggestionList();
} else { } else {
SharedPreUtils spu = SharedPreUtils.getInstance();
Single.create((SingleOnSubscribe<Boolean>) emitter -> { Single.create((SingleOnSubscribe<Boolean>) emitter -> {
String cookie = spu.getString(getString(R.string.qdCookie), ""); String cookie = SharedPreUtils.getInstance().getString(getString(R.string.qdCookie), "");
String url = "https://m.qidian.com/majax/search/auto?kw=&"; String url = "https://m.qidian.com/majax/search/auto?kw=&";
if (cookie.equals("")) { if (cookie.equals("")) {
cookie = "_csrfToken=eXRDlZxmRDLvFAmdgzqvwWAASrxxp2WkVlH4ZM7e; newstatisticUUID=1595991935_2026387981"; cookie = "_csrfToken=eXRDlZxmRDLvFAmdgzqvwWAASrxxp2WkVlH4ZM7e; newstatisticUUID=1595991935_2026387981";

@ -48,7 +48,6 @@ public class SplashActivity extends BaseActivity<ActivitySplashBinding> {
public static final String TAG = SplashActivity.class.getSimpleName(); public static final String TAG = SplashActivity.class.getSimpleName();
public static int WAIT_INTERVAL = 0; public static int WAIT_INTERVAL = 0;
private SharedPreUtils spu;
private int todayAdCount; private int todayAdCount;
private int adTimes; private int adTimes;
private boolean hasStart = false; private boolean hasStart = false;
@ -137,9 +136,8 @@ public class SplashActivity extends BaseActivity<ActivitySplashBinding> {
@Override @Override
protected void initData(Bundle savedInstanceState) { protected void initData(Bundle savedInstanceState) {
startToAd = getIntent().getBooleanExtra(INTENT_TO_AD, false); startToAd = getIntent().getBooleanExtra(INTENT_TO_AD, false);
spu = SharedPreUtils.getInstance(); String splashAdCount = SharedPreUtils.getInstance().getString("splashAdCount");
String splashAdCount = spu.getString("splashAdCount"); adTimes = SharedPreUtils.getInstance().getInt("curAdTimes", 3);
adTimes = spu.getInt("curAdTimes", 3);
String[] splashAdCounts = splashAdCount.split(":"); String[] splashAdCounts = splashAdCount.split(":");
String today = DateHelper.getYearMonthDay1(); String today = DateHelper.getYearMonthDay1();
if (today.equals(splashAdCounts[0])) { if (today.equals(splashAdCounts[0])) {
@ -374,6 +372,6 @@ public class SplashActivity extends BaseActivity<ActivitySplashBinding> {
private void countTodayAd() { private void countTodayAd() {
String today = DateHelper.getYearMonthDay1(); String today = DateHelper.getYearMonthDay1();
todayAdCount++; todayAdCount++;
spu.putString("splashAdCount", today + ":" + todayAdCount); SharedPreUtils.getInstance().putString("splashAdCount", today + ":" + todayAdCount);
} }
} }

@ -139,9 +139,8 @@ public class BookGroupDialog {
mBookGroupService.addBookGroup(bookGroup); mBookGroupService.addBookGroup(bookGroup);
} else { } else {
mBookGroupService.updateEntity(bookGroup); mBookGroupService.updateEntity(bookGroup);
SharedPreUtils spu = SharedPreUtils.getInstance(); if (SharedPreUtils.getInstance().getString(mContext.getString(R.string.curBookGroupName), "").equals(oldName)) {
if (spu.getString(mContext.getString(R.string.curBookGroupName), "").equals(oldName)) { SharedPreUtils.getInstance().putString(mContext.getString(R.string.curBookGroupName), newGroupName);
spu.putString(mContext.getString(R.string.curBookGroupName), newGroupName);
if (onGroup != null) onGroup.change(); if (onGroup != null) onGroup.change();
} }
} }
@ -172,10 +171,9 @@ public class BookGroupDialog {
if (sb.length() > 0) { if (sb.length() > 0) {
sb.deleteCharAt(sb.lastIndexOf("、")); sb.deleteCharAt(sb.lastIndexOf("、"));
} }
SharedPreUtils spu = SharedPreUtils.getInstance(); if (mBookGroupService.getGroupById(SharedPreUtils.getInstance().getString(mContext.getString(R.string.curBookGroupId), "")) == null) {
if (mBookGroupService.getGroupById(spu.getString(mContext.getString(R.string.curBookGroupId), "")) == null) { SharedPreUtils.getInstance().putString(mContext.getString(R.string.curBookGroupId), "");
spu.putString(mContext.getString(R.string.curBookGroupId), ""); SharedPreUtils.getInstance().putString(mContext.getString(R.string.curBookGroupName), "");
spu.putString(mContext.getString(R.string.curBookGroupName), "");
onGroup.change(); onGroup.change();
} }
ToastUtils.showSuccess("分组[" + sb.toString() + "]删除成功!"); ToastUtils.showSuccess("分组[" + sb.toString() + "]删除成功!");

@ -2,6 +2,7 @@ package xyz.fycz.myreader.ui.fragment
import android.content.DialogInterface import android.content.DialogInterface
import android.os.Bundle import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -37,7 +38,6 @@ class ProxyFragment : BaseFragment() {
private lateinit var proxyPassword: String private lateinit var proxyPassword: String
private var mNoProxySourcesDia: AlertDialog? = null private var mNoProxySourcesDia: AlertDialog? = null
private val proxyTypeArr = arrayOf("http", "socks5") private val proxyTypeArr = arrayOf("http", "socks5")
private val spu: SharedPreUtils = SharedPreUtils.getInstance()
override fun bindView(inflater: LayoutInflater, container: ViewGroup?): View { override fun bindView(inflater: LayoutInflater, container: ViewGroup?): View {
binding = FragmentProxySettingBinding.inflate(inflater, container, false) binding = FragmentProxySettingBinding.inflate(inflater, container, false)
@ -45,12 +45,13 @@ class ProxyFragment : BaseFragment() {
} }
override fun initData(savedInstanceState: Bundle?) { override fun initData(savedInstanceState: Bundle?) {
enableProxy = spu.getBoolean("enableProxy") enableProxy = SharedPreUtils.getInstance().getBoolean("enableProxy")
proxyType = spu.getInt("proxyType") Log.d("ProxyFragment", "enableProxy=$enableProxy")
proxyHost = spu.getString("proxyHost") proxyType = SharedPreUtils.getInstance().getInt("proxyType")
proxyPort = spu.getString("proxyHost") proxyHost = SharedPreUtils.getInstance().getString("proxyHost")
proxyUsername = spu.getString("proxyUsername") proxyPort = SharedPreUtils.getInstance().getString("proxyPort")
proxyPassword = spu.getString("proxyPassword") proxyUsername = SharedPreUtils.getInstance().getString("proxyUsername")
proxyPassword = SharedPreUtils.getInstance().getString("proxyPassword")
} }
override fun initWidget(savedInstanceState: Bundle?) { override fun initWidget(savedInstanceState: Bundle?) {
@ -58,16 +59,17 @@ class ProxyFragment : BaseFragment() {
if (enableProxy) binding.llContent.visibility = View.VISIBLE if (enableProxy) binding.llContent.visibility = View.VISIBLE
binding.tvProxyType.text = proxyTypeArr[proxyType] binding.tvProxyType.text = proxyTypeArr[proxyType]
binding.tvProxyHost.text = proxyHost.ifEmpty { "请输入代理服务器地址" } binding.tvProxyHost.text = proxyHost.ifEmpty { "请输入代理服务器地址" }
binding.tvProxyPort.text = proxyHost.ifEmpty { "输入代理服务器端口" } binding.tvProxyPort.text = proxyPort.ifEmpty { "选择代理服务器端口" }
binding.tvProxyUsername.text = proxyHost.ifEmpty { "请输入代理认证用户名" } binding.tvProxyUsername.text = proxyUsername.ifEmpty { "请输入代理认证用户名" }
binding.tvProxyPassword.text = proxyHost.ifEmpty { "请输入代理认证密码" } binding.tvProxyPassword.text = proxyPassword.ifEmpty { "请输入代理认证密码" }
} }
override fun initClick() { override fun initClick() {
binding.rlEnableProxy.onClick { binding.rlEnableProxy.onClick {
enableProxy = !enableProxy enableProxy = !enableProxy
binding.scEnableProxy.isChecked = enableProxy binding.scEnableProxy.isChecked = enableProxy
spu.putBoolean("enableProxy", enableProxy) SharedPreUtils.getInstance().putBoolean("enableProxy", enableProxy)
Log.d("ProxyFragment", "putBoolean=$enableProxy")
binding.llContent.visibility = if (enableProxy) View.VISIBLE else View.GONE binding.llContent.visibility = if (enableProxy) View.VISIBLE else View.GONE
} }
@ -90,7 +92,7 @@ class ProxyFragment : BaseFragment() {
) { dialog: DialogInterface, _: Int -> ) { dialog: DialogInterface, _: Int ->
proxyHost = tem proxyHost = tem
binding.tvProxyHost.text = proxyHost binding.tvProxyHost.text = proxyHost
spu.putString("proxyHost", proxyHost) SharedPreUtils.getInstance().putString("proxyHost", proxyHost)
dialog.dismiss() dialog.dismiss()
} }
} }
@ -100,14 +102,14 @@ class ProxyFragment : BaseFragment() {
val threadPick = view.findViewById<NumberPicker>(R.id.number_picker) val threadPick = view.findViewById<NumberPicker>(R.id.number_picker)
threadPick.maxValue = 99999 threadPick.maxValue = 99999
threadPick.minValue = 10 threadPick.minValue = 10
threadPick.value = proxyPort.toInt() threadPick.value = if (proxyPort.isEmpty()) 1080 else proxyPort.toInt()
threadPick.setOnScrollListener { _: NumberPicker?, _: Int -> } threadPick.setOnScrollListener { _: NumberPicker?, _: Int -> }
MyAlertDialog.build(context) MyAlertDialog.build(context)
.setTitle(R.string.proxy_port) .setTitle(R.string.proxy_port)
.setView(view) .setView(view)
.setPositiveButton(R.string.confirm) { _: DialogInterface?, _: Int -> .setPositiveButton(R.string.confirm) { _: DialogInterface?, _: Int ->
proxyPort = threadPick.value.toString() proxyPort = threadPick.value.toString()
spu.putString("proxyPort", proxyPort) SharedPreUtils.getInstance().putString("proxyPort", proxyPort)
binding.tvProxyPort.text = proxyPort binding.tvProxyPort.text = proxyPort
}.setNegativeButton(R.string.cancel, null) }.setNegativeButton(R.string.cancel, null)
.show() .show()
@ -121,7 +123,7 @@ class ProxyFragment : BaseFragment() {
) { dialog: DialogInterface, _: Int -> ) { dialog: DialogInterface, _: Int ->
proxyUsername = tem proxyUsername = tem
binding.tvProxyUsername.text = proxyUsername binding.tvProxyUsername.text = proxyUsername
spu.putString("proxyUsername", proxyUsername) SharedPreUtils.getInstance().putString("proxyUsername", proxyUsername)
dialog.dismiss() dialog.dismiss()
} }
} }
@ -134,7 +136,7 @@ class ProxyFragment : BaseFragment() {
) { dialog: DialogInterface, _: Int -> ) { dialog: DialogInterface, _: Int ->
proxyPassword = tem proxyPassword = tem
binding.tvProxyPassword.text = proxyPassword binding.tvProxyPassword.text = proxyPassword
spu.putString("proxyPassword", proxyPassword) SharedPreUtils.getInstance().putString("proxyPassword", proxyPassword)
dialog.dismiss() dialog.dismiss()
} }
} }

@ -26,6 +26,7 @@ public class SharedPreUtils {
}; };
} }
//不能
public static SharedPreUtils getInstance() { public static SharedPreUtils getInstance() {
return getInstance(false); return getInstance(false);
} }

@ -158,10 +158,9 @@ public class AdUtils {
} }
public static boolean checkTodayShowAd() { public static boolean checkTodayShowAd() {
SharedPreUtils spu = SharedPreUtils.getInstance(); String splashAdCount = SharedPreUtils.getInstance().getString("splashAdCount");
String splashAdCount = spu.getString("splashAdCount"); boolean bookDetailAd = SharedPreUtils.getInstance().getBoolean("bookDetailAd", true);
boolean bookDetailAd = spu.getBoolean("bookDetailAd", true); int adTimes = SharedPreUtils.getInstance().getInt("curAdTimes", 3);
int adTimes = spu.getInt("curAdTimes", 3);
String[] splashAdCounts = splashAdCount.split(":"); String[] splashAdCounts = splashAdCount.split(":");
String today = DateHelper.getYearMonthDay1(); String today = DateHelper.getYearMonthDay1();
int todayAdCount; int todayAdCount;

@ -155,7 +155,6 @@ public class LanZousApi {
} }
private static String getKey(String html) { private static String getKey(String html) {
//SharedPreUtils spu = SharedPreUtils.getInstance();
String lanzousKeyStart = "var pposturl = '"; String lanzousKeyStart = "var pposturl = '";
String keyName = StringHelper.getSubString(html, "'sign':", ","); String keyName = StringHelper.getSubString(html, "'sign':", ",");
if (keyName.endsWith("'")) { if (keyName.endsWith("'")) {

@ -41,21 +41,20 @@ public class ReadCrawlerUtil {
} }
public static ArrayList<ReadCrawler> getReadCrawlers() { public static ArrayList<ReadCrawler> getReadCrawlers() {
SharedPreUtils spu = SharedPreUtils.getInstance(); String searchSource = SharedPreUtils.getInstance().getString(App.getmContext().getString(R.string.searchSource), null);
String searchSource = spu.getString(App.getmContext().getString(R.string.searchSource), null);
ArrayList<ReadCrawler> readCrawlers = new ArrayList<>(); ArrayList<ReadCrawler> readCrawlers = new ArrayList<>();
if (searchSource == null) { if (searchSource == null) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (LocalBookSource bookSource : LocalBookSource.values()) { for (LocalBookSource bookSource : LocalBookSource.values()) {
if (bookSource.equals(LocalBookSource.fynovel) || bookSource.equals(LocalBookSource.local)) if (bookSource.equals(LocalBookSource.fynovel) || bookSource.equals(LocalBookSource.local))
continue; continue;
sb.append(bookSource.toString()); sb.append(bookSource);
sb.append(","); sb.append(",");
readCrawlers.add(getReadCrawler(bookSource.toString())); readCrawlers.add(getReadCrawler(bookSource.toString()));
} }
sb.deleteCharAt(sb.lastIndexOf(",")); sb.deleteCharAt(sb.lastIndexOf(","));
searchSource = sb.toString(); searchSource = sb.toString();
spu.putString(App.getmContext().getString(R.string.searchSource), searchSource); SharedPreUtils.getInstance().putString(App.getmContext().getString(R.string.searchSource), searchSource);
} else if (!"".equals(searchSource)) { } else if (!"".equals(searchSource)) {
String[] sources = searchSource.split(","); String[] sources = searchSource.split(",");
for (String source : sources) { for (String source : sources) {
@ -76,8 +75,7 @@ public class ReadCrawlerUtil {
} }
public static HashMap<CharSequence, Boolean> getDisableSources() { public static HashMap<CharSequence, Boolean> getDisableSources() {
SharedPreUtils spu = SharedPreUtils.getInstance(); String searchSource = SharedPreUtils.getInstance().getString(App.getmContext().getString(R.string.searchSource), null);
String searchSource = spu.getString(App.getmContext().getString(R.string.searchSource), null);
HashMap<CharSequence, Boolean> mSources = new LinkedHashMap<>(); HashMap<CharSequence, Boolean> mSources = new LinkedHashMap<>();
if (searchSource == null) { if (searchSource == null) {
for (LocalBookSource bookSource : LocalBookSource.values()) { for (LocalBookSource bookSource : LocalBookSource.values()) {
@ -116,8 +114,7 @@ public class ReadCrawlerUtil {
} }
public synchronized static void addReadCrawler(LocalBookSource... bookSources) { public synchronized static void addReadCrawler(LocalBookSource... bookSources) {
SharedPreUtils spu = SharedPreUtils.getInstance(); String searchSource = SharedPreUtils.getInstance().getString(App.getmContext().getString(R.string.searchSource));
String searchSource = spu.getString(App.getmContext().getString(R.string.searchSource));
if ("".equals(searchSource)) { if ("".equals(searchSource)) {
resetReadCrawlers(); resetReadCrawlers();
return; return;
@ -131,8 +128,7 @@ public class ReadCrawlerUtil {
} }
public synchronized static void removeReadCrawler(String... bookSources) { public synchronized static void removeReadCrawler(String... bookSources) {
SharedPreUtils spu = SharedPreUtils.getInstance(); String searchSource = SharedPreUtils.getInstance().getString(App.getmContext().getString(R.string.searchSource), null);
String searchSource = spu.getString(App.getmContext().getString(R.string.searchSource), null);
if (searchSource == null) { if (searchSource == null) {
return; return;
} }
@ -153,7 +149,7 @@ public class ReadCrawlerUtil {
sb.append(","); sb.append(",");
} }
sb.deleteCharAt(sb.lastIndexOf(",")); sb.deleteCharAt(sb.lastIndexOf(","));
spu.putString(App.getmContext().getString(R.string.searchSource), sb.toString()); SharedPreUtils.getInstance().putString(App.getmContext().getString(R.string.searchSource), sb.toString());
} }
public static ReadCrawler getReadCrawler(String bookSource) { public static ReadCrawler getReadCrawler(String bookSource) {

@ -147,8 +147,7 @@ public class QiDianFindCrawler extends BaseFindCrawler {
kind.setMaxPage(5); kind.setMaxPage(5);
} }
url = url.replace("{sex}", !isFemale ? sex[0] : sex[1]); url = url.replace("{sex}", !isFemale ? sex[0] : sex[1]);
SharedPreUtils spu = SharedPreUtils.getInstance(); String cookie = SharedPreUtils.getInstance().getString(App.getmContext().getString(R.string.qdCookie), "");
String cookie = spu.getString(App.getmContext().getString(R.string.qdCookie), "");
if (!cookie.equals("")) { if (!cookie.equals("")) {
url = url.replace("{cookie}", StringHelper.getSubString(cookie, "_csrfToken=", ";")); url = url.replace("{cookie}", StringHelper.getSubString(cookie, "_csrfToken=", ";"));
} else { } else {

@ -144,8 +144,7 @@ public class QiDianMobileRank extends FindCrawler3 {
url = sortUrl.replace("{catId}", sortName.get(name) + ""); url = sortUrl.replace("{catId}", sortName.get(name) + "");
} }
url = url.replace("{sex}", !isFemale ? sex[0] : sex[1]); url = url.replace("{sex}", !isFemale ? sex[0] : sex[1]);
SharedPreUtils spu = SharedPreUtils.getInstance(); String cookie = SharedPreUtils.getInstance().getString(App.getmContext().getString(R.string.qdCookie), "");
String cookie = spu.getString(App.getmContext().getString(R.string.qdCookie), "");
if (!cookie.equals("")) { if (!cookie.equals("")) {
url = url.replace("{cookie}", StringHelper.getSubString(cookie, "_csrfToken=", ";")); url = url.replace("{cookie}", StringHelper.getSubString(cookie, "_csrfToken=", ";"));
} else { } else {

@ -570,7 +570,7 @@
<string name="net_error_10003">数据解析失败</string> <string name="net_error_10003">数据解析失败</string>
<!--error string end--> <!--error string end-->
<string name="proxy_setting">代理设置</string> <string name="proxy_setting">软件代理设置</string>
<string name="proxy_setting_tip">设置软件及书源代理</string> <string name="proxy_setting_tip">设置软件及书源代理</string>
<string name="proxy_type">代理类型</string> <string name="proxy_type">代理类型</string>
<string name="proxy_host">代理服务器地址</string> <string name="proxy_host">代理服务器地址</string>

Loading…
Cancel
Save