Android Open Source - Android-Pulley-Menu Action Bar Helper






From Project

Back to project page Android-Pulley-Menu.

License

The source code is released under:

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCT...

If you think the Android project Android-Pulley-Menu listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package anshul.pulleymenu.compat;
/*from  w  w  w . jav  a 2  s  .c o m*/
import anshul.pulleymenu.*;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.Log;

import java.lang.reflect.Method;

public final class ActionBarHelper {

    private static final String TAG = "ActionBarHelper";

    private Activity mActivity;

    private Object mIndicatorInfo;

    private boolean mUsesSherlock;

    public ActionBarHelper(Activity activity) {
        mActivity = activity;

        try {
            Class clazz = activity.getClass();
            Method m = clazz.getMethod("getSupportActionBar");
            mUsesSherlock = true;
        } catch (NoSuchMethodException e) {
            if (BuildConfig.DEBUG) {
                Log.e(TAG, "Activity " + activity.getClass().getSimpleName() + " does not use ActionBarSherlock", e);
            }
        }

        mIndicatorInfo = getIndicatorInfo();
    }

    private Object getIndicatorInfo() {
        if (mUsesSherlock && Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            return ActionBarHelperSherlock.getIndicatorInfo(mActivity);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            return ActionBarHelperNative.getIndicatorInfo(mActivity);
        }

        return null;
    }

    public void setActionBarUpIndicator(Drawable drawable, int contentDesc) {
        if (mUsesSherlock && Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            ActionBarHelperSherlock.setActionBarUpIndicator(mIndicatorInfo, mActivity, drawable, contentDesc);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            ActionBarHelperNative.setActionBarUpIndicator(mIndicatorInfo, mActivity, drawable, contentDesc);
        }
    }

    public void setActionBarDescription(int contentDesc) {
        if (mUsesSherlock && Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            ActionBarHelperSherlock.setActionBarDescription(mIndicatorInfo, mActivity, contentDesc);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            ActionBarHelperNative.setActionBarDescription(mIndicatorInfo, mActivity, contentDesc);
        }
    }

    public Drawable getThemeUpIndicator() {
        if (mUsesSherlock && Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            return ActionBarHelperSherlock.getThemeUpIndicator(mIndicatorInfo);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            return ActionBarHelperNative.getThemeUpIndicator(mIndicatorInfo, mActivity);
        }

        return null;
    }

    public void setDisplayShowHomeAsUpEnabled(boolean enabled) {
        if (mUsesSherlock && Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            ActionBarHelperSherlock.setDisplayHomeAsUpEnabled(mIndicatorInfo, enabled);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            ActionBarHelperNative.setDisplayHomeAsUpEnabled(mActivity, enabled);
        }
    }
}




Java Source Code List

anshul.pulleymenu.BuildLayerFrameLayout.java
anshul.pulleymenu.ColorDrawable.java
anshul.pulleymenu.CustomListViewAdapter.java
anshul.pulleymenu.DraggableDrawer.java
anshul.pulleymenu.FloatScroller.java
anshul.pulleymenu.MenuDrawer.java
anshul.pulleymenu.NoClickThroughFrameLayout.java
anshul.pulleymenu.OverlayDrawer.java
anshul.pulleymenu.PeekInterpolator.java
anshul.pulleymenu.Position.java
anshul.pulleymenu.PulleyMenu.java
anshul.pulleymenu.Scroller.java
anshul.pulleymenu.SinusoidalInterpolator.java
anshul.pulleymenu.SlideDrawable.java
anshul.pulleymenu.SlidingDrawer.java
anshul.pulleymenu.SmoothInterpolator.java
anshul.pulleymenu.StaticDrawer.java
anshul.pulleymenu.ViewHelper.java
anshul.pulleymenu.compat.ActionBarHelperNative.java
anshul.pulleymenu.compat.ActionBarHelperSherlock.java
anshul.pulleymenu.compat.ActionBarHelper.java
anshul.pulleymenu.samples.PulleyMenuSample.java
anshul.pulleymenu.test.java