mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-06 03:23:21 +01:00
fixed crashes on pre-marshmallow devices
This commit is contained in:
parent
05e76a1fd4
commit
7f48a7342c
@ -14,7 +14,7 @@ android {
|
||||
applicationId "org.mariotaku.twidere"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 23
|
||||
versionCode 126
|
||||
versionCode 128
|
||||
versionName "0.3.0"
|
||||
multiDexEnabled true
|
||||
}
|
||||
|
@ -424,7 +424,6 @@ public class HomeActivity extends BaseAppCompatActivity implements OnClickListen
|
||||
if (Utils.isStreamingEnabled()) {
|
||||
startService(new Intent(this, StreamingService.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,7 +64,8 @@ import static org.mariotaku.twidere.util.Utils.initAccountColor;
|
||||
import static org.mariotaku.twidere.util.Utils.startRefreshServiceIfNeeded;
|
||||
|
||||
@ReportsCrashes(formUri = "https://twidere-bugreport.herokuapp.com/reports",
|
||||
buildConfigClass = BuildConfig.class)
|
||||
buildConfigClass = BuildConfig.class, sendReportsInDevMode = false,
|
||||
sendReportsAtShutdown = false)
|
||||
public class TwidereApplication extends MultiDexApplication implements Constants,
|
||||
OnSharedPreferenceChangeListener {
|
||||
|
||||
@ -170,9 +171,7 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
||||
private void initBugReport() {
|
||||
final SharedPreferences preferences = getSharedPreferences();
|
||||
if (!preferences.getBoolean(KEY_BUG_REPORTS, true)) return;
|
||||
if (!BuildConfig.DEBUG) {
|
||||
AbsLogger.setImplementation(new TwidereLogger());
|
||||
}
|
||||
AbsLogger.setImplementation(new TwidereLogger());
|
||||
AbsLogger.init(this);
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
@ -43,10 +42,12 @@ public class BaseFragment extends Fragment implements Constants {
|
||||
@Inject
|
||||
protected SharedPreferencesWrapper mPreferences;
|
||||
|
||||
|
||||
@SuppressWarnings("deprecated")
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(context)).build().inject(this);
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(activity)).build().inject(this);
|
||||
}
|
||||
|
||||
public TwidereApplication getApplication() {
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.mariotaku.twidere.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceFragment;
|
||||
|
||||
@ -38,10 +38,11 @@ public class BasePreferenceFragment extends PreferenceFragment implements Consta
|
||||
@Inject
|
||||
protected UserColorNameManager mUserColorNameManager;
|
||||
|
||||
@SuppressWarnings("deprecated")
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(context)).build().inject(this);
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
DaggerGeneralComponent.builder().applicationModule(ApplicationModule.get(activity)).build().inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,6 +25,7 @@ import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import org.acra.ACRA;
|
||||
import org.acra.ACRAConfiguration;
|
||||
import org.mariotaku.twidere.BuildConfig;
|
||||
import org.mariotaku.twidere.Constants;
|
||||
|
||||
@ -70,15 +71,16 @@ public class TwidereLogger extends AbsLogger implements Constants {
|
||||
protected void initImpl(final Application application) {
|
||||
// ACRA sets it self as DefaultUncaughtExceptionHandler, we hijack it to suppress some errors
|
||||
ACRA.init(application);
|
||||
final ACRAConfiguration conf = ACRA.getNewDefaultConfig(application);
|
||||
ACRA.setConfig(conf);
|
||||
// handler should be ACRA's ErrorReporter now
|
||||
final Thread.UncaughtExceptionHandler handler = Thread.getDefaultUncaughtExceptionHandler();
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable ex) {
|
||||
// We can't fix OOM, so just don't report it and try to save VM
|
||||
if (!Utils.isOutOfMemory(ex)) {
|
||||
handler.uncaughtException(thread, ex);
|
||||
}
|
||||
if (Utils.isOutOfMemory(ex)) return;
|
||||
handler.uncaughtException(thread, ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -86,6 +86,11 @@ public class ApplicationModule {
|
||||
}
|
||||
sharedPreferences = SharedPreferencesWrapper.getInstance(application, Constants.SHARED_PREFERENCES_NAME,
|
||||
Context.MODE_PRIVATE, SharedPreferenceConstants.class);
|
||||
|
||||
if (sharedPreferences == null) {
|
||||
throw new RuntimeException("SharedPreferences must not be null");
|
||||
}
|
||||
|
||||
activityTracker = new ActivityTracker();
|
||||
bus = new Bus(ThreadEnforcer.MAIN);
|
||||
asyncTaskManager = AsyncTaskManager.getInstance();
|
||||
|
Loading…
x
Reference in New Issue
Block a user