Search in sources :

Example 1 with Activity

use of org.holoeverywhere.app.Activity in project HoloEverywhere by Prototik.

the class PreferenceScreen method getThemeResId.

protected int getThemeResId(Context context) {
    try {
        if (context instanceof Activity) {
            int t = ((Activity) context).getLastThemeResourceId();
            if (t > 0) {
                return t;
            }
        }
        Method method = Context.class.getDeclaredMethod("getThemeResId");
        method.setAccessible(true);
        return (Integer) method.invoke(context);
    } catch (Exception e) {
        e.printStackTrace();
        return R.style.Holo_Theme_NoActionBar;
    }
}
Also used : Activity(org.holoeverywhere.app.Activity) Method(java.lang.reflect.Method) SuppressLint(android.annotation.SuppressLint)

Example 2 with Activity

use of org.holoeverywhere.app.Activity in project HoloEverywhere by Prototik.

the class _HoloActivity method onInit.

/**
     * Do not override this method. Use {@link #onPreInit(Holo, Bundle)} and
     * {@link #onPostInit(Holo, Bundle)}
     */
protected void onInit(Holo config, Bundle savedInstanceState) {
    if (mInited) {
        throw new IllegalStateException("This instance was already inited");
    }
    mInited = true;
    if (config == null) {
        config = createConfig(savedInstanceState);
    }
    if (config == null) {
        config = Holo.defaultConfig();
    }
    onPreInit(config, savedInstanceState);
    if (!config.ignoreApplicationInstanceCheck && !(getApplication() instanceof Application)) {
        boolean throwError = true;
        if (config.allowMockApplicationInstance) {
            try {
                throwError = !(getApplication() instanceof MockApplication);
                if (!throwError) {
                    Log.w("HoloEverywhere", "Application instance is MockApplication. Wow. Let's begin tests...");
                }
            } catch (Exception e) {
            }
        }
        if (throwError) {
            String text = "Application instance isn't HoloEverywhere.\n";
            if (getApplication().getClass() == android.app.Application.class) {
                text += "Put attr 'android:name=\"org.holoeverywhere.app.Application\"'" + " in <application> tag of AndroidManifest.xml";
            } else {
                text += "Please sure that you extend " + getApplication().getClass() + " from a org.holoeverywhere.app.Application";
            }
            throw new IllegalStateException(text);
        }
    }
    getLayoutInflater().setFragmentActivity(this);
    if (this instanceof Activity) {
        final Activity activity = (Activity) this;
        ThemeManager.applyTheme(activity, mLastThemeResourceId == 0);
        if (!config.ignoreThemeCheck && ThemeManager.getThemeType(this) == ThemeManager.INVALID) {
            throw new HoloThemeException(activity);
        }
        TypedArray a = obtainStyledAttributes(new int[] { android.R.attr.windowActionBarOverlay, R.attr.windowActionBarOverlay });
        if (a.getBoolean(0, false) || a.getBoolean(1, false)) {
            supportRequestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
        }
        a.recycle();
        a = obtainStyledAttributes(new int[] { android.R.attr.windowActionModeOverlay, R.attr.windowActionBarOverlay });
        if (a.getBoolean(0, false) || a.getBoolean(1, false)) {
            supportRequestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
        }
        a.recycle();
    }
    onPostInit(config, savedInstanceState);
    lockAttaching();
}
Also used : MockApplication(android.test.mock.MockApplication) TypedArray(android.content.res.TypedArray) SuperStartActivity(org.holoeverywhere.ThemeManager.SuperStartActivity) IAddonActivity(org.holoeverywhere.addon.IAddonActivity) ActionBarActivity(android.support.v7.app.ActionBarActivity) Activity(org.holoeverywhere.app.Activity) Application(org.holoeverywhere.app.Application) MockApplication(android.test.mock.MockApplication) ActivityNotFoundException(android.content.ActivityNotFoundException)

Example 3 with Activity

use of org.holoeverywhere.app.Activity in project HoloEverywhere by Prototik.

the class ThemeManager method startActivity.

/**
     * Only for system use
     */
@SuppressLint("NewApi")
public static void startActivity(Context context, Intent intent, int requestCode, Bundle options) {
    final Activity activity = context instanceof Activity ? (Activity) context : null;
    if (activity != null && HoloEverywhere.ALWAYS_USE_PARENT_THEME) {
        ThemeManager.cloneTheme(activity.getIntent(), intent, true);
    }
    final int parentColorScheme = ThemeManager.getThemeType(activity);
    if (parentColorScheme != INVALID) {
        intent.putExtra(_PARENT_SCHEME_TAG, parentColorScheme);
    }
    if (context instanceof SuperStartActivity) {
        ((SuperStartActivity) context).superStartActivity(intent, requestCode, options);
    } else if (VERSION.SDK_INT >= 16) {
        context.startActivity(intent, options);
    } else {
        context.startActivity(intent);
    }
}
Also used : Activity(org.holoeverywhere.app.Activity) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 4 with Activity

use of org.holoeverywhere.app.Activity in project mobile-android by photo.

the class PhotoDetailsFragment method photoSelected.

void photoSelected(final Photo photo) {
    ActionBar actionBar = ((Activity) getSupportActivity()).getSupportActionBar();
    String title = photo.getTitle();
    if (TextUtils.isEmpty(title)) {
        title = photo.getFilenameOriginal();
    }
    actionBar.setTitle(getString(R.string.details_title_and_date_header, title, CommonUtils.formatDateTime(photo.getDateTaken())));
    titleText.setText(title);
    dateText.setText(CommonUtils.formatDateTime(photo.getDateTaken()));
    privateBtn.setVisibility(photo.isPrivate() ? View.VISIBLE : View.GONE);
    ensureThumbVisible(photo);
}
Also used : Activity(org.holoeverywhere.app.Activity) ActionBar(com.actionbarsherlock.app.ActionBar)

Example 5 with Activity

use of org.holoeverywhere.app.Activity in project mobile-android by photo.

the class SyncActionModeHandler method startActionMode.

public void startActionMode() {
    Activity a = mActivity;
    mActionMode = a.startActionMode(this);
    View customView = LayoutInflater.from(a).inflate(mActionModeLayout, null);
    mActionMode.setCustomView(customView);
    mSelectionMenu = new SyncSelectionMenu(R.menu.sync_image_selection2, mHasPopupMenu, a, (Button) customView.findViewById(R.id.selection_menu), this);
    updateSelectionMenu();
    customizeActionModeCloseButton();
}
Also used : Button(android.widget.Button) Activity(org.holoeverywhere.app.Activity) TextView(org.holoeverywhere.widget.TextView) View(android.view.View)

Aggregations

Activity (org.holoeverywhere.app.Activity)8 SuppressLint (android.annotation.SuppressLint)3 ActionBar (com.actionbarsherlock.app.ActionBar)2 Method (java.lang.reflect.Method)2 ActivityNotFoundException (android.content.ActivityNotFoundException)1 TypedArray (android.content.res.TypedArray)1 ActionBarActivity (android.support.v7.app.ActionBarActivity)1 MockApplication (android.test.mock.MockApplication)1 View (android.view.View)1 Animation (android.view.animation.Animation)1 Button (android.widget.Button)1 SuperStartActivity (org.holoeverywhere.ThemeManager.SuperStartActivity)1 IAddonActivity (org.holoeverywhere.addon.IAddonActivity)1 Application (org.holoeverywhere.app.Application)1 TextView (org.holoeverywhere.widget.TextView)1