Java Code Examples for android.app.ActionBar#getThemedContext()

The following examples show how to use android.app.ActionBar#getThemedContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PullMenuAttacher.java    From AndroidPullMenu with Apache License 2.0 6 votes vote down vote up
protected EnvironmentDelegate createDefaultEnvironmentDelegate() {
    return new EnvironmentDelegate() {
        @Override
        public Context getContextForInflater(Activity activity) {
            Context context = null;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                ActionBar ab = activity.getActionBar();
                if (ab != null) {
                    context = ab.getThemedContext();
                }
            }
            if (context == null) {
                context = activity;
            }
            return context;
        }
    };
}
 
Example 2
Source File: MainListFragment.java    From Android-Applications-Info with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);
    mProgressDialog = new ProgressDialog(mActivity);
    mProgressDialog.setTitle(R.string.loading_apps);
    mProgressDialog.setCancelable(false);

    ActionBar actionBar = getActivity().getActionBar();
    actionBar.setDisplayShowCustomEnabled(true);

    SearchView searchView = new SearchView(actionBar.getThemedContext());
    searchView.setOnQueryTextListener(this);

    ActionBar.LayoutParams layoutParams = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    actionBar.setCustomView(searchView, layoutParams);

    if (savedInstanceState != null) {
        int sortBy = savedInstanceState.getInt(INSTANCE_STATE_SORT_BY, -1);
        if (sortBy != -1)
            setSortBy(sortBy);
    }
}
 
Example 3
Source File: PullToRefreshAttacher.java    From KlyphMessenger with MIT License 6 votes vote down vote up
protected EnvironmentDelegate createDefaultEnvironmentDelegate() {
    return new EnvironmentDelegate() {
        @Override
        public Context getContextForInflater(Activity activity) {
            Context context = null;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                ActionBar ab = activity.getActionBar();
                if (ab != null) {
                    context = ab.getThemedContext();
                }
            }
            if (context == null) {
                context = activity;
            }
            return context;
        }
    };
}
 
Example 4
Source File: PullToRefreshAttacher.java    From Bitocle with Apache License 2.0 6 votes vote down vote up
protected EnvironmentDelegate createDefaultEnvironmentDelegate() {
    return new EnvironmentDelegate() {
        @Override
        public Context getContextForInflater(Activity activity) {
            Context context = null;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                ActionBar ab = activity.getActionBar();
                if (ab != null) {
                    context = ab.getThemedContext();
                }
            }
            if (context == null) {
                context = activity;
            }
            return context;
        }
    };
}
 
Example 5
Source File: PullToRefreshAttacher.java    From Bitocle with Apache License 2.0 6 votes vote down vote up
protected EnvironmentDelegate createDefaultEnvironmentDelegate() {
    return new EnvironmentDelegate() {
        @Override
        public Context getContextForInflater(Activity activity) {
            Context context = null;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                ActionBar ab = activity.getActionBar();
                if (ab != null) {
                    context = ab.getThemedContext();
                }
            }
            if (context == null) {
                context = activity;
            }
            return context;
        }
    };
}
 
Example 6
Source File: PullToRefreshAttacher.java    From Bitocle with Apache License 2.0 6 votes vote down vote up
protected EnvironmentDelegate createDefaultEnvironmentDelegate() {
    return new EnvironmentDelegate() {
        @Override
        public Context getContextForInflater(Activity activity) {
            Context context = null;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                ActionBar ab = activity.getActionBar();
                if (ab != null) {
                    context = ab.getThemedContext();
                }
            }
            if (context == null) {
                context = activity;
            }
            return context;
        }
    };
}
 
Example 7
Source File: PullToRefreshAttacher.java    From Klyph with MIT License 6 votes vote down vote up
protected EnvironmentDelegate createDefaultEnvironmentDelegate() {
    return new EnvironmentDelegate() {
        @Override
        public Context getContextForInflater(Activity activity) {
            Context context = null;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                ActionBar ab = activity.getActionBar();
                if (ab != null) {
                    context = ab.getThemedContext();
                }
            }
            if (context == null) {
                context = activity;
            }
            return context;
        }
    };
}
 
Example 8
Source File: DuoDrawerToggle.java    From duo-navigation-drawer with Apache License 2.0 5 votes vote down vote up
@Override
public Context getActionBarThemedContext() {
    final ActionBar actionBar = mActivity.getActionBar();
    final Context context;
    if (actionBar != null) {
        context = actionBar.getThemedContext();
    } else {
        context = mActivity;
    }
    return context;
}
 
Example 9
Source File: MainActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);

	// Set up the action bar to show a dropdown list.
	final ActionBar actionBar = getActionBar();
	actionBar.setDisplayShowTitleEnabled(false);
	actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

	final String[] dropdownValues = getResources().getStringArray(
			R.array.dropdown);

	// Specify a SpinnerAdapter to populate the dropdown list.
	ArrayAdapter<String> adapter = new ArrayAdapter<String>(
			actionBar.getThemedContext(),
			android.R.layout.simple_spinner_item, android.R.id.text1,
			dropdownValues);

	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

	// Set up the dropdown list navigation in the action bar.
	actionBar.setListNavigationCallbacks(adapter, this);

	// Use getActionBar().getThemedContext() to ensure
	// that the text color is always appropriate for the action bar
	// background rather than the activity background.
}
 
Example 10
Source File: JToggle.java    From jus with Apache License 2.0 5 votes vote down vote up
@Override
public Context getActionBarThemedContext() {
    final ActionBar actionBar = mActivity.getActionBar();
    final Context context;
    if (actionBar != null) {
        context = actionBar.getThemedContext();
    } else {
        context = mActivity;
    }
    return context;
}
 
Example 11
Source File: JToggle.java    From jus with Apache License 2.0 5 votes vote down vote up
@Override
public Context getActionBarThemedContext() {
    final ActionBar actionBar = mActivity.getActionBar();
    final Context context;
    if (actionBar != null) {
        context = actionBar.getThemedContext();
    } else {
        context = mActivity;
    }
    return context;
}
 
Example 12
Source File: ActionBarDrawerToggleJellybeanMR2.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
public static Drawable getThemeUpIndicator(Activity activity) {
    final ActionBar actionBar = activity.getActionBar();
    final Context context;
    if (actionBar != null) {
        context = actionBar.getThemedContext();
    } else {
        context = activity;
    }

    final TypedArray a = context.obtainStyledAttributes(null, THEME_ATTRS,
            R.attr.actionBarStyle, 0);
    final Drawable result = a.getDrawable(0);
    a.recycle();
    return result;
}
 
Example 13
Source File: ActionBarDrawerToggle.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Context getActionBarThemedContext() {
    final ActionBar actionBar = mActivity.getActionBar();
    final Context context;
    if (actionBar != null) {
        context = actionBar.getThemedContext();
    } else {
        context = mActivity;
    }
    return context;
}
 
Example 14
Source File: ActionBarDrawerToggle.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
public Context getActionBarThemedContext() {
    final ActionBar actionBar = mActivity.getActionBar();
    final Context context;
    if (actionBar != null) {
        context = actionBar.getThemedContext();
    } else {
        context = mActivity;
    }
    return context;
}
 
Example 15
Source File: DuoDrawerToggle.java    From duo-navigation-drawer with Apache License 2.0 5 votes vote down vote up
@Override
public Context getActionBarThemedContext() {
    final ActionBar actionBar = mActivity.getActionBar();
    final Context context;
    if (actionBar != null) {
        context = actionBar.getThemedContext();
    } else {
        context = mActivity;
    }
    return context;
}
 
Example 16
Source File: PostActivity.java    From Onosendai with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate (final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.post);

	Collection<Account> accounts;
	try {
		this.prefs = new Prefs(getBaseContext());
		accounts = this.prefs.readAccounts();
		this.conf = this.prefs.asConfig();
	}
	catch (final Exception e) { // No point continuing if any exception.
		DialogHelper.alertAndClose(this, e);
		return;
	}

	this.imageCache = new HybridBitmapCache(getBaseContext(), C.MAX_MEMORY_IMAGE_CACHE);
	this.exec = ExecUtils.newBoundedCachedThreadPool(C.NET_MAX_THREADS, LOG);

	this.intentExtras = getIntent().getExtras();
	if (this.intentExtras != null) {
		this.inReplyToUid = this.intentExtras.getLong(ARG_IN_REPLY_TO_UID);
		this.inReplyToSid = this.intentExtras.getString(ARG_IN_REPLY_TO_SID);
		this.altReplyToSid = this.intentExtras.getString(ARG_ALT_REPLY_TO_SID);
		this.mentions = this.intentExtras.getStringArray(ARG_MENTIONS);

		final long outboxUidOrDefault = this.intentExtras.getLong(ARG_OUTBOX_UID, -1);
		if (outboxUidOrDefault >= 0) this.outboxUid = outboxUidOrDefault;
	}
	LOG.i("inReplyToUid=%d inReplyToSid=%s altReplyToSid=%s mentions=%s outboxUid=%s",
			this.inReplyToUid, this.inReplyToSid, this.altReplyToSid, Arrays.toString(this.mentions), this.outboxUid);

	final ActionBar ab = getActionBar();
	ab.setDisplayHomeAsUpEnabled(true);
	ab.setDisplayShowTitleEnabled(false);
	ab.setDisplayShowCustomEnabled(true);

	this.spnAccount = new Spinner(ab.getThemedContext());
	this.spnAccount.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
	this.spnAccount.setPadding(0, 0, 0, 0);
	ab.setCustomView(this.spnAccount);

	setupAccounts(savedInstanceState, accounts, this.conf);

	setupAttachemnt(savedInstanceState);
	setupTextBody();
}
 
Example 17
Source File: MainActivity.java    From Onosendai with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate (final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	this.prefs = new Prefs(getBaseContext());
	if (!this.prefs.isConfigured()) {
		startActivity(new Intent(getApplicationContext(), SetupActivity.class));
		finish();
		return;
	}
	this.prefs.getSharedPreferences().registerOnSharedPreferenceChangeListener(this);

	requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
	setContentView(R.layout.activity_main);

	try {
		this.conf = this.prefs.asConfig();
	}
	catch (final Exception e) { // No point continuing if any exception.
		LOG.wtf("Unparsable config.", e);
		DialogHelper.alertAndClose(this, e);
		return;
	}

	this.imageCache = new HybridBitmapCache(this, C.MAX_MEMORY_IMAGE_CACHE);

	if (this.prefs.getSharedPreferences().getBoolean(AdvancedPrefFragment.KEY_THREAD_INSPECTOR, false)) {
		final TextView jobStatus = (TextView) findViewById(R.id.jobStatus);
		jobStatus.setVisibility(View.VISIBLE);
		this.executorStatus = new ExecutorStatus(jobStatus);
	}

	this.localEs = ExecUtils.newBoundedCachedThreadPool(C.LOCAL_MAX_THREADS, new LogWrapper("LES"), this.executorStatus);
	this.netEs = ExecUtils.newBoundedCachedThreadPool(C.NET_MAX_THREADS, new LogWrapper("NES"), this.executorStatus);
	this.msgHandler = new MessageHandler(this);

	final float columnWidth = UiPrefFragment.readColumnWidth(this, this.prefs);
	this.columnsRtl = UiPrefFragment.readColumnsRtl(this.prefs);

	// If this becomes too memory intensive, switch to android.support.v4.app.FragmentStatePagerAdapter.
	final SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager(), this, columnWidth);
	this.viewPager = (SidebarAwareViewPager) findViewById(R.id.pager);
	this.pageSelectionListener = new VisiblePageSelectionListener(columnWidth);
	final MultiplexingOnPageChangeListener onPageChangeListener = new MultiplexingOnPageChangeListener(
			this.pageSelectionListener,
			new NotificationClearingPageSelectionListener(this));
	this.viewPager.setOnPageChangeListener(onPageChangeListener);
	this.viewPager.setAdapter(sectionsPagerAdapter);
	if (!showPageFromIntent(getIntent())) {
		if (this.columnsRtl) {
			gotoPage(0);
		}
		else {
			onPageChangeListener.onPageSelected(this.viewPager.getCurrentItem());
		}
	}

	final ActionBar ab = getActionBar();
	ab.setDisplayShowHomeEnabled(true);
	ab.setHomeButtonEnabled(true);
	ab.setDisplayShowTitleEnabled(false);
	ab.setDisplayShowCustomEnabled(true);

	this.columnTitleStrip = new ColumnTitleStrip(ab.getThemedContext());
	this.columnTitleStrip.setViewPager(this.viewPager);
	this.columnTitleStrip.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	this.columnTitleStrip.setColumnClickListener(new TitleClickListener(this));
	ab.setCustomView(this.columnTitleStrip);

	AlarmReceiver.configureAlarms(this);
	new CheckBackgroundUpdatesRunning(this, this.executorStatus).executeOnExecutor(this.localEs);
}