fixed several crashes
This commit is contained in:
parent
1eada0f072
commit
900c83c363
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package android.support.v7.app;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/4/27.
|
||||
*/
|
||||
public class AppCompatDelegateAccessor {
|
||||
|
||||
@Nullable
|
||||
public static ActionBar peekActionBar(@Nullable AppCompatDelegate delegate) {
|
||||
if (delegate instanceof AppCompatDelegateImplBase)
|
||||
return ((AppCompatDelegateImplBase) delegate).peekSupportActionBar();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isFloating(AppCompatDelegate delegate) {
|
||||
if (delegate instanceof AppCompatDelegateImplBase)
|
||||
return ((AppCompatDelegateImplBase) delegate).mIsFloating;
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package android.support.v7.app;
|
||||
|
||||
import android.support.v7.widget.DecorToolbar;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/10/12.
|
||||
*/
|
||||
public class AppCompatUtils {
|
||||
|
||||
public static Toolbar findToolbarForActionBar(ActionBar actionBar) {
|
||||
if (actionBar instanceof ToolbarActionBar) {
|
||||
final Object decorToolbar = Utils.findFieldOfTypes(actionBar, ToolbarActionBar.class, DecorToolbar.class);
|
||||
if (decorToolbar instanceof DecorToolbar) {
|
||||
return (Toolbar) ((DecorToolbar) decorToolbar).getViewGroup();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package android.support.v7.view;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 16/3/1.
|
||||
*/
|
||||
public class SupportActionModeWrapperAccessor {
|
||||
|
||||
@Nullable
|
||||
public static android.support.v7.view.ActionMode getWrappedObject(android.view.ActionMode mode) {
|
||||
if (mode instanceof SupportActionModeWrapper) {
|
||||
return ((SupportActionModeWrapper) mode).mWrappedObject;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package android.support.v7.widget;
|
||||
|
||||
import android.support.v7.widget.RecyclerView.ViewHolder;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 14/12/6.
|
||||
*/
|
||||
public class ViewHolderAccessor {
|
||||
|
||||
public static boolean isRemoved(ViewHolder holder) {
|
||||
return holder.isRemoved();
|
||||
}
|
||||
|
||||
public static boolean isUpdated(ViewHolder holder) {
|
||||
return holder.isUpdated();
|
||||
}
|
||||
}
|
|
@ -277,10 +277,15 @@ public class BaseActivity extends ATEActivity implements Constants, IExtendedAct
|
|||
mCurrentThemeBackgroundAlpha = getThemeBackgroundAlpha();
|
||||
mCurrentThemeBackgroundOption = getThemeBackgroundOption();
|
||||
super.onApplyThemeResource(theme, resId, first);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
final Window window = getWindow();
|
||||
if (shouldApplyWindowBackground()) {
|
||||
ThemeUtils.applyWindowBackground(this, window, mCurrentThemeBackgroundOption,
|
||||
mCurrentThemeBackgroundAlpha);
|
||||
if (window != null && shouldApplyWindowBackground()) {
|
||||
ThemeUtils.applyWindowBackground(this, window, getThemeBackgroundOption(),
|
||||
getThemeBackgroundAlpha());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1398,7 +1398,11 @@ public class ComposeActivity extends BaseActivity implements OnMenuItemClickList
|
|||
private void requestOrUpdateLocation() {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED ||
|
||||
ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
|
||||
try {
|
||||
startLocationUpdateIfEnabled();
|
||||
} catch (SecurityException e) {
|
||||
Toast.makeText(this, R.string.cannot_get_location, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else {
|
||||
final String[] permissions = {Manifest.permission.ACCESS_COARSE_LOCATION,
|
||||
Manifest.permission.ACCESS_FINE_LOCATION};
|
||||
|
|
|
@ -60,7 +60,6 @@ import android.view.View.OnClickListener;
|
|||
import android.view.View.OnLongClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.MarginLayoutParams;
|
||||
import android.view.Window;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
@ -861,10 +860,6 @@ public class HomeActivity extends BaseActivity implements OnClickListener, OnPag
|
|||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_start, GravityCompat.START);
|
||||
mDrawerLayout.addDrawerListener(mDrawerToggle);
|
||||
mDrawerLayout.addDrawerListener(this);
|
||||
final Window window = getWindow();
|
||||
ThemeUtils.applyWindowBackground(this, mHomeContent,
|
||||
getThemeBackgroundOption(), getCurrentThemeBackgroundAlpha());
|
||||
window.setBackgroundDrawable(new EmptyDrawable());
|
||||
}
|
||||
|
||||
private void showDataProfilingRequest() {
|
||||
|
|
|
@ -26,7 +26,6 @@ import android.util.Log;
|
|||
import org.mariotaku.twidere.R;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
|
||||
public class ClearCachePreference extends AsyncTaskPreference {
|
||||
|
||||
|
@ -48,17 +47,23 @@ public class ClearCachePreference extends AsyncTaskPreference {
|
|||
if (context == null) return;
|
||||
final File externalCacheDir = context.getExternalCacheDir();
|
||||
if (externalCacheDir != null) {
|
||||
for (final File file : externalCacheDir.listFiles((FileFilter) null)) {
|
||||
final File[] files = externalCacheDir.listFiles();
|
||||
if (files != null) {
|
||||
for (final File file : files) {
|
||||
deleteRecursive(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
final File internalCacheDir = context.getCacheDir();
|
||||
if (internalCacheDir != null) {
|
||||
for (final File file : internalCacheDir.listFiles((FileFilter) null)) {
|
||||
final File[] files = internalCacheDir.listFiles();
|
||||
if (files != null) {
|
||||
for (final File file : files) {
|
||||
deleteRecursive(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void deleteRecursive(final File f) {
|
||||
if (f.isDirectory()) {
|
||||
|
|
|
@ -107,23 +107,12 @@ public class ThemeUtils implements Constants {
|
|||
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
|
||||
window.setBackgroundDrawable(getWindowBackgroundFromThemeApplyAlpha(context, alpha));
|
||||
} else if (VALUE_THEME_BACKGROUND_SOLID.equals(option)) {
|
||||
window.setBackgroundDrawable(new ColorDrawable(!isLightTheme(context) ? Color.BLACK : Color.WHITE));
|
||||
window.setBackgroundDrawable(new ColorDrawable(isLightTheme(context) ? Color.WHITE : Color.BLACK));
|
||||
} else {
|
||||
window.setBackgroundDrawable(getWindowBackgroundFromTheme(context));
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyWindowBackground(Context context, View window, String option, int alpha) {
|
||||
if (isWindowFloating(context)) return;
|
||||
if (VALUE_THEME_BACKGROUND_TRANSPARENT.equals(option)) {
|
||||
ViewSupport.setBackground(window, getWindowBackgroundFromThemeApplyAlpha(context, alpha));
|
||||
} else if (VALUE_THEME_BACKGROUND_SOLID.equals(option)) {
|
||||
ViewSupport.setBackground(window, new ColorDrawable(!isLightTheme(context) ? Color.BLACK : Color.WHITE));
|
||||
} else {
|
||||
ViewSupport.setBackground(window, getWindowBackgroundFromTheme(context));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static int getCardBackgroundColor(final Context context, String backgroundOption, int themeAlpha) {
|
||||
final TypedArray a = context.obtainStyledAttributes(new int[]{R.attr.cardItemBackgroundColor});
|
||||
|
|
|
@ -1652,9 +1652,13 @@ public final class Utils implements Constants {
|
|||
}
|
||||
|
||||
public static boolean isNetworkAvailable(final Context context) {
|
||||
try {
|
||||
final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
final NetworkInfo info = cm.getActiveNetworkInfo();
|
||||
return info != null && info.isConnected();
|
||||
} catch (SecurityException e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
|
Loading…
Reference in New Issue