fixed ClassCastException caused by ActionBarActivity migrated to AppCompatActivity

This commit is contained in:
Mariotaku Lee 2015-04-22 22:45:52 +08:00
parent 16baa2c966
commit 2d4be1f7e7
2 changed files with 7 additions and 7 deletions

View File

@ -59,7 +59,7 @@ import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.ActionMenuView;
import android.support.v7.widget.Toolbar;
import android.text.Html;
@ -415,7 +415,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
}
private void updateSubtitle() {
final ActionBarActivity activity = (ActionBarActivity) getActivity();
final AppCompatActivity activity = (AppCompatActivity) getActivity();
if (activity == null) return;
final ActionBar actionBar = activity.getSupportActionBar();
if (actionBar == null) return;
@ -1328,7 +1328,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
if (mActionBarBackground == null) {
setupBaseActionBar();
}
final ActionBarActivity activity = (ActionBarActivity) getActivity();
final AppCompatActivity activity = (AppCompatActivity) getActivity();
final IThemedActivity themed = (IThemedActivity) activity;
final int themeRes = themed.getCurrentThemeResourceId();
if (ThemeUtils.isDarkTheme(themeRes)) {

View File

@ -79,7 +79,7 @@ import android.support.v4.util.Pair;
import android.support.v4.view.ActionProvider;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.view.accessibility.AccessibilityEventCompat;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.ShareActionProvider;
import android.text.Editable;
import android.text.SpannableStringBuilder;
@ -3398,8 +3398,8 @@ public final class Utils implements Constants, TwitterConstants {
public static int getInsetsTopWithoutActionBarHeight(Context context, int top) {
final int actionBarHeight;
if (context instanceof ActionBarActivity) {
actionBarHeight = getActionBarHeight(((ActionBarActivity) context).getSupportActionBar());
if (context instanceof AppCompatActivity) {
actionBarHeight = getActionBarHeight(((AppCompatActivity) context).getSupportActionBar());
} else if (context instanceof Activity) {
actionBarHeight = getActionBarHeight(((Activity) context).getActionBar());
} else {
@ -4086,7 +4086,7 @@ public final class Utils implements Constants, TwitterConstants {
public static int getActionBarHeight(Context context) {
final TypedValue tv = new TypedValue();
final Theme theme = context.getTheme();
final int attr = context instanceof ActionBarActivity ? R.attr.actionBarSize : android.R.attr.actionBarSize;
final int attr = context instanceof AppCompatActivity ? R.attr.actionBarSize : android.R.attr.actionBarSize;
if (theme.resolveAttribute(attr, tv, true)) {
return TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics());
}