-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
423 additions
and
304 deletions.
There are no files selected for viewing
384 changes: 192 additions & 192 deletions
384
app/src/main/java/com/github/jsbxyyx/xbook/DetailActivity.java
Large diffs are not rendered by default.
Oops, something went wrong.
190 changes: 95 additions & 95 deletions
190
app/src/main/java/com/github/jsbxyyx/xbook/LifecycleApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,95 @@ | ||
package com.github.jsbxyyx.xbook; | ||
|
||
import android.app.Application; | ||
import android.os.Looper; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.github.jsbxyyx.xbook.common.Common; | ||
import com.github.jsbxyyx.xbook.common.DataCallback; | ||
import com.github.jsbxyyx.xbook.common.LogUtil; | ||
import com.github.jsbxyyx.xbook.common.SPUtils; | ||
import com.github.jsbxyyx.xbook.common.UiUtils; | ||
import com.github.jsbxyyx.xbook.data.BookNetHelper; | ||
import com.github.jsbxyyx.xbook.data.bean.MLog; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.concurrent.CountDownLatch; | ||
|
||
/** | ||
* @author jsbxyyx | ||
* @since 1.0 | ||
*/ | ||
public class LifecycleApplication extends Application { | ||
|
||
private BookNetHelper bookNetHelper; | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
|
||
UiUtils.initContext(getApplicationContext()); | ||
|
||
bookNetHelper = new BookNetHelper(); | ||
|
||
String languages = "chinese,japanese,traditional chinese,english,korean,"; | ||
String languagesData = SPUtils.getData(getBaseContext(), Common.search_language_key, null); | ||
if (Common.isNull(languagesData)) { | ||
SPUtils.putData(getBaseContext(), Common.search_language_key, languages); | ||
} | ||
|
||
String extData = SPUtils.getData(getBaseContext(), Common.search_ext_key, null); | ||
if (Common.isNull(extData)) { | ||
extData = "EPUB,"; | ||
SPUtils.putData(getBaseContext(), Common.search_ext_key, extData); | ||
} | ||
|
||
String syncData = SPUtils.getData(getBaseContext(), Common.sync_key, null); | ||
if (Common.isNull(syncData)) { | ||
syncData = Common.sync_key_checked; | ||
SPUtils.putData(getBaseContext(), Common.sync_key, syncData); | ||
} | ||
|
||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { | ||
@Override | ||
public void uncaughtException(@NonNull Thread t, @NonNull Throwable e) { | ||
|
||
MLog mLog = new MLog(); | ||
mLog.setTitle(new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()) + Common.log_suffix); | ||
mLog.setRaw(("[OS : " + android.os.Build.MODEL + " | " + android.os.Build.VERSION.RELEASE + "]" | ||
+ "[APP : " + UiUtils.getVersionName() + "]\n\n") | ||
+ LogUtil.getStackTraceString(e)); | ||
CountDownLatch latch = new CountDownLatch(1); | ||
bookNetHelper.cloudLog(mLog, new DataCallback() { | ||
@Override | ||
public void call(Object o, Throwable err) { | ||
try { | ||
if (err != null) { | ||
LogUtil.e(getClass().getSimpleName(), "异常上报失败. %s", LogUtil.getStackTraceString(err)); | ||
} else { | ||
new Thread(() -> { | ||
Looper.prepare(); | ||
UiUtils.showToast("闪退异常上报成功"); | ||
Looper.loop(); | ||
}).start(); | ||
Thread.sleep(2000); | ||
} | ||
} catch (InterruptedException ignore) { | ||
} finally { | ||
latch.countDown(); | ||
} | ||
android.os.Process.killProcess(android.os.Process.myPid()); | ||
System.exit(1); | ||
} | ||
}); | ||
try { | ||
latch.await(); | ||
} catch (InterruptedException ex) { | ||
ex.printStackTrace(); | ||
} | ||
} | ||
}); | ||
|
||
} | ||
} | ||
package com.github.jsbxyyx.xbook; | ||
|
||
import android.app.Application; | ||
import android.os.Looper; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.github.jsbxyyx.xbook.common.Common; | ||
import com.github.jsbxyyx.xbook.common.DataCallback; | ||
import com.github.jsbxyyx.xbook.common.LogUtil; | ||
import com.github.jsbxyyx.xbook.common.SPUtils; | ||
import com.github.jsbxyyx.xbook.common.UiUtils; | ||
import com.github.jsbxyyx.xbook.data.BookNetHelper; | ||
import com.github.jsbxyyx.xbook.data.bean.MLog; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.concurrent.CountDownLatch; | ||
|
||
/** | ||
* @author jsbxyyx | ||
* @since 1.0 | ||
*/ | ||
public class LifecycleApplication extends Application { | ||
|
||
private BookNetHelper bookNetHelper; | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
|
||
UiUtils.initContext(getApplicationContext()); | ||
|
||
bookNetHelper = new BookNetHelper(); | ||
|
||
String languages = "chinese,japanese,traditional chinese,english,korean,"; | ||
String languagesData = SPUtils.getData(getBaseContext(), Common.search_language_key, null); | ||
if (Common.isNull(languagesData)) { | ||
SPUtils.putData(getBaseContext(), Common.search_language_key, languages); | ||
} | ||
|
||
String extData = SPUtils.getData(getBaseContext(), Common.search_ext_key, null); | ||
if (Common.isNull(extData)) { | ||
extData = "EPUB,"; | ||
SPUtils.putData(getBaseContext(), Common.search_ext_key, extData); | ||
} | ||
|
||
String syncData = SPUtils.getData(getBaseContext(), Common.sync_key, null); | ||
if (Common.isNull(syncData)) { | ||
syncData = Common.checked; | ||
SPUtils.putData(getBaseContext(), Common.sync_key, syncData); | ||
} | ||
|
||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { | ||
@Override | ||
public void uncaughtException(@NonNull Thread t, @NonNull Throwable e) { | ||
|
||
MLog mLog = new MLog(); | ||
mLog.setTitle(new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()) + Common.log_suffix); | ||
mLog.setRaw(("[OS : " + android.os.Build.MODEL + " | " + android.os.Build.VERSION.RELEASE + "]" | ||
+ "[APP : " + UiUtils.getVersionName() + "]\n\n") | ||
+ LogUtil.getStackTraceString(e)); | ||
CountDownLatch latch = new CountDownLatch(1); | ||
bookNetHelper.cloudLog(mLog, new DataCallback() { | ||
@Override | ||
public void call(Object o, Throwable err) { | ||
try { | ||
if (err != null) { | ||
LogUtil.e(getClass().getSimpleName(), "异常上报失败. %s", LogUtil.getStackTraceString(err)); | ||
} else { | ||
new Thread(() -> { | ||
Looper.prepare(); | ||
UiUtils.showToast("闪退异常上报成功"); | ||
Looper.loop(); | ||
}).start(); | ||
Thread.sleep(2000); | ||
} | ||
} catch (InterruptedException ignore) { | ||
} finally { | ||
latch.countDown(); | ||
} | ||
android.os.Process.killProcess(android.os.Process.myPid()); | ||
System.exit(1); | ||
} | ||
}); | ||
try { | ||
latch.await(); | ||
} catch (InterruptedException ex) { | ||
ex.printStackTrace(); | ||
} | ||
} | ||
}); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="108dp" | ||
android:height="108dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24" | ||
android:tint="#000000"> | ||
<group android:scaleX="0.58" | ||
android:scaleY="0.58" | ||
android:translateX="5.04" | ||
android:translateY="5.04"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z"/> | ||
</group> | ||
</vector> |
Oops, something went wrong.