修复bug、优化体验

pull/5/head
fengyuecanzhu 4 years ago
parent 103469ea19
commit 10a9b0c5bf
  1. 16
      app/src/main/java/xyz/fycz/myreader/application/App.java
  2. 4
      app/src/main/java/xyz/fycz/myreader/ui/activity/AdSettingActivity.java
  3. 2
      app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java
  4. 3
      app/src/main/java/xyz/fycz/myreader/ui/activity/DonateActivity.java
  5. 1
      app/src/main/java/xyz/fycz/myreader/ui/activity/SplashActivity.java
  6. 134
      app/src/main/java/xyz/fycz/myreader/util/utils/AdUtils.java
  7. 2
      app/version_code.properties

@ -27,11 +27,7 @@ import androidx.appcompat.app.AppCompatDelegate;
import com.liulishuo.filedownloader.FileDownloader;
import com.liulishuo.filedownloader.connection.FileDownloadUrlConnection;
import com.weaction.ddsdk.base.DdSdkHelper;
import com.weaction.ddsdk.util.GsonUtil;
import org.json.JSONException;
import org.json.JSONObject;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
@ -48,37 +44,25 @@ import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import io.reactivex.Single;
import io.reactivex.SingleEmitter;
import io.reactivex.SingleOnSubscribe;
import io.reactivex.annotations.NonNull;
import io.reactivex.internal.functions.Functions;
import io.reactivex.plugins.RxJavaPlugins;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import xyz.fycz.myreader.R;
import xyz.fycz.myreader.base.observer.MySingleObserver;
import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.common.URLCONST;
import xyz.fycz.myreader.entity.Setting;
import xyz.fycz.myreader.model.backup.UserService;
import xyz.fycz.myreader.model.source.BookSourceManager;
import xyz.fycz.myreader.ui.activity.MainActivity;
import xyz.fycz.myreader.ui.activity.SplashActivity;
import xyz.fycz.myreader.ui.dialog.APPDownloadTip;
import xyz.fycz.myreader.ui.dialog.DialogCreator;
import xyz.fycz.myreader.ui.fragment.BookcaseFragment;
import xyz.fycz.myreader.util.DateHelper;
import xyz.fycz.myreader.util.HttpUtil;
import xyz.fycz.myreader.util.SharedPreUtils;
import xyz.fycz.myreader.util.StringHelper;
import xyz.fycz.myreader.util.ToastUtils;
import xyz.fycz.myreader.util.utils.AdUtils;
import xyz.fycz.myreader.util.utils.FileUtils;
import xyz.fycz.myreader.util.utils.NetworkUtils;
import xyz.fycz.myreader.util.utils.OkHttpUtils;
import xyz.fycz.myreader.ui.dialog.UpdateDialog;
import xyz.fycz.myreader.util.utils.RxUtils;
public class App extends Application {

@ -5,21 +5,17 @@ import android.view.View;
import androidx.appcompat.widget.Toolbar;
import io.reactivex.Single;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import xyz.fycz.myreader.R;
import xyz.fycz.myreader.application.SysManager;
import xyz.fycz.myreader.base.BaseActivity;
import xyz.fycz.myreader.base.observer.MySingleObserver;
import xyz.fycz.myreader.databinding.ActivityAdSettingBinding;
import xyz.fycz.myreader.ui.dialog.DialogCreator;
import xyz.fycz.myreader.ui.dialog.LoadingDialog;
import xyz.fycz.myreader.ui.dialog.MyAlertDialog;
import xyz.fycz.myreader.util.DateHelper;
import xyz.fycz.myreader.util.SharedPreUtils;
import xyz.fycz.myreader.util.ToastUtils;
import xyz.fycz.myreader.util.utils.AdUtils;
import xyz.fycz.myreader.util.utils.FileUtils;
/**

@ -47,7 +47,6 @@ import xyz.fycz.myreader.base.observer.MySingleObserver;
import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.common.URLCONST;
import xyz.fycz.myreader.databinding.ActivityBookDetailBinding;
import xyz.fycz.myreader.entity.SearchBookBean;
import xyz.fycz.myreader.entity.SharedBook;
import xyz.fycz.myreader.greendao.entity.Book;
import xyz.fycz.myreader.greendao.entity.Chapter;
@ -65,7 +64,6 @@ import xyz.fycz.myreader.util.ShareUtils;
import xyz.fycz.myreader.util.SharedPreUtils;
import xyz.fycz.myreader.util.StringHelper;
import xyz.fycz.myreader.util.ToastUtils;
import xyz.fycz.myreader.util.utils.AdUtils;
import xyz.fycz.myreader.util.utils.BitmapUtil;
import xyz.fycz.myreader.util.utils.BlurTransformation;
import xyz.fycz.myreader.util.utils.FileUtils;

@ -7,7 +7,6 @@ import android.view.View;
import androidx.appcompat.widget.Toolbar;
import com.sigmob.sdk.common.models.sigdsp.pb.Ad;
import com.weaction.ddsdk.ad.DdSdkFlowAd;
import com.weaction.ddsdk.ad.DdSdkRewardAd;
@ -19,9 +18,7 @@ import xyz.fycz.myreader.base.BaseActivity;
import xyz.fycz.myreader.base.observer.MySingleObserver;
import xyz.fycz.myreader.common.URLCONST;
import xyz.fycz.myreader.databinding.ActivityDonateBinding;
import xyz.fycz.myreader.util.SharedPreUtils;
import xyz.fycz.myreader.util.ToastUtils;
import xyz.fycz.myreader.util.utils.AdUtils;
/**
* @author fengyue

@ -36,7 +36,6 @@ import xyz.fycz.myreader.util.IOUtils;
import xyz.fycz.myreader.util.PermissionsChecker;
import xyz.fycz.myreader.util.SharedPreUtils;
import xyz.fycz.myreader.util.ToastUtils;
import xyz.fycz.myreader.util.utils.AdUtils;
import xyz.fycz.myreader.util.utils.ImageLoader;
import xyz.fycz.myreader.util.utils.MD5Utils;
import xyz.fycz.myreader.util.utils.OkHttpUtils;

@ -1,134 +0,0 @@
package xyz.fycz.myreader.util.utils;
import android.util.Log;
import com.weaction.ddsdk.base.DdSdkHelper;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import io.reactivex.Single;
import io.reactivex.SingleEmitter;
import io.reactivex.SingleOnSubscribe;
import io.reactivex.annotations.NonNull;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import xyz.fycz.myreader.application.App;
import xyz.fycz.myreader.base.observer.MySingleObserver;
import xyz.fycz.myreader.common.URLCONST;
import xyz.fycz.myreader.model.backup.UserService;
import xyz.fycz.myreader.util.DateHelper;
import xyz.fycz.myreader.util.SharedPreUtils;
/**
* @author fengyue
* @date 2021/4/22 19:00
*/
public class AdUtils {
public static final String TAG = AdUtils.class.getSimpleName();
private static boolean hasInitAd = false;
public static Single<Boolean> checkHasAd() {
return Single.create((SingleOnSubscribe<Boolean>) emitter -> {
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
String body = "type=hasAd" + UserService.makeSignalParam();
RequestBody requestBody = RequestBody.create(mediaType, body);
String jsonStr = OkHttpUtils.getHtml(URLCONST.AD_URL, requestBody, "UTF-8");
boolean hasAd = false;
try {
JSONObject jsonObject = new JSONObject(jsonStr);
int code = jsonObject.getInt("code");
if (code > 200) {
Log.e(TAG, "checkHasAd-->errorCode:" + code);
if (code == 213) {
hasAd = true;
}
} else {
hasAd = jsonObject.getBoolean("result");
}
Log.i(TAG, "hasAd:" + hasAd);
} catch (JSONException e) {
e.printStackTrace();
}
emitter.onSuccess(hasAd);
}).compose(RxUtils::toSimpleSingle);
}
public static void adRecord(String type, String name) {
Single.create((SingleOnSubscribe<Boolean>) emitter -> {
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
String body = "adType=" + type + "&type=" + name + UserService.makeSignalParam();
RequestBody requestBody = RequestBody.create(mediaType, body);
OkHttpUtils.getHtml(URLCONST.AD_URL, requestBody, "UTF-8");
emitter.onSuccess(true);
}).compose(RxUtils::toSimpleSingle).subscribe(new MySingleObserver<Boolean>() {
@Override
public void onSuccess(@NonNull Boolean aBoolean) {
Log.i(TAG, name + "上报成功");
}
@Override
public void onError(Throwable e) {
Log.e(TAG, name + "上报失败\n" + e.getLocalizedMessage());
}
});
}
public static Single<int[]> adTimes() {
return Single.create((SingleOnSubscribe<int[]>) emitter -> {
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
String body = "type=adTimes" + UserService.makeSignalParam();
RequestBody requestBody = RequestBody.create(mediaType, body);
String jsonStr = OkHttpUtils.getHtml(URLCONST.AD_URL, requestBody, "UTF-8");
JSONObject jsonObject = new JSONObject(jsonStr);
int[] adTimes = new int[]{-1, 3, 5};
try {
int code = jsonObject.getInt("code");
JSONArray adTimesArr = jsonObject.getJSONArray("result");
Log.i(TAG, "adTimesArr:" + adTimesArr.toString());
if (code > 200) {
Log.e(TAG, "adTimes-->errorCode:" + code);
if (code == 213) {
adTimes = new int[]{-1};
}
} else {
adTimes = new int[adTimesArr.length()];
for (int i = 0; i < adTimesArr.length(); i++) {
adTimes[i] = adTimesArr.getInt(i);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
emitter.onSuccess(adTimes);
}).compose(RxUtils::toSimpleSingle);
}
public static boolean checkTodayShowAd() {
SharedPreUtils spu = SharedPreUtils.getInstance();
String splashAdCount = spu.getString("splashAdCount");
boolean bookDetailAd = spu.getBoolean("bookDetailAd", true);
int adTimes = spu.getInt("curAdTimes", 3);
String[] splashAdCounts = splashAdCount.split(":");
String today = DateHelper.getYearMonthDay1();
int todayAdCount;
if (today.equals(splashAdCounts[0])) {
todayAdCount = Integer.parseInt(splashAdCounts[1]);
} else {
todayAdCount = 0;
}
return adTimes < 0 || todayAdCount < adTimes || bookDetailAd;
}
public static void initAd() {
if (!hasInitAd) {
hasInitAd = true;
DdSdkHelper.init("1234", "216", "51716a16fbdf50905704b6575b1b3b60",
"142364", "35ce0efe5f3cc960b116db227498e238",
"8167", "85bd159309c3da1b",
App.getApplication(), true);
}
}
}

@ -1,2 +1,2 @@
#Sun May 09 12:34:16 CST 2021
#Sun May 09 12:54:40 CST 2021
VERSION_CODE=195

Loading…
Cancel
Save