下面列出了android.app.ActionBar#getThemedContext ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
};
}
@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);
}
}
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;
}
};
}
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;
}
};
}
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;
}
};
}
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;
}
};
}
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;
}
};
}
@Override
public Context getActionBarThemedContext() {
final ActionBar actionBar = mActivity.getActionBar();
final Context context;
if (actionBar != null) {
context = actionBar.getThemedContext();
} else {
context = mActivity;
}
return context;
}
@Override
public Context getActionBarThemedContext() {
final ActionBar actionBar = mActivity.getActionBar();
final Context context;
if (actionBar != null) {
context = actionBar.getThemedContext();
} else {
context = mActivity;
}
return context;
}
@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;
}
@Override
public Context getActionBarThemedContext() {
final ActionBar actionBar = mActivity.getActionBar();
final Context context;
if (actionBar != null) {
context = actionBar.getThemedContext();
} else {
context = mActivity;
}
return context;
}
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;
}
@Override
public Context getActionBarThemedContext() {
final ActionBar actionBar = mActivity.getActionBar();
final Context context;
if (actionBar != null) {
context = actionBar.getThemedContext();
} else {
context = mActivity;
}
return context;
}
@Override
public Context getActionBarThemedContext() {
final ActionBar actionBar = mActivity.getActionBar();
final Context context;
if (actionBar != null) {
context = actionBar.getThemedContext();
} else {
context = mActivity;
}
return context;
}
@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.
}
@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();
}
@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);
}