android.app.ActionBar#getThemedContext ( )源码实例Demo

下面列出了android.app.ActionBar#getThemedContext ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: AndroidPullMenu   文件: PullMenuAttacher.java
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);
    }
}
 
源代码3 项目: Bitocle   文件: PullToRefreshAttacher.java
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;
        }
    };
}
 
源代码4 项目: Bitocle   文件: PullToRefreshAttacher.java
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;
        }
    };
}
 
源代码5 项目: Bitocle   文件: PullToRefreshAttacher.java
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;
        }
    };
}
 
源代码6 项目: Klyph   文件: PullToRefreshAttacher.java
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;
        }
    };
}
 
源代码7 项目: KlyphMessenger   文件: PullToRefreshAttacher.java
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;
        }
    };
}
 
源代码8 项目: duo-navigation-drawer   文件: DuoDrawerToggle.java
@Override
public Context getActionBarThemedContext() {
    final ActionBar actionBar = mActivity.getActionBar();
    final Context context;
    if (actionBar != null) {
        context = actionBar.getThemedContext();
    } else {
        context = mActivity;
    }
    return context;
}
 
源代码9 项目: duo-navigation-drawer   文件: DuoDrawerToggle.java
@Override
public Context getActionBarThemedContext() {
    final ActionBar actionBar = mActivity.getActionBar();
    final Context context;
    if (actionBar != null) {
        context = actionBar.getThemedContext();
    } else {
        context = mActivity;
    }
    return context;
}
 
源代码10 项目: Overchan-Android   文件: ActionBarDrawerToggle.java
@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;
}
 
源代码11 项目: Overchan-Android   文件: ActionBarDrawerToggle.java
@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;
}
 
源代码13 项目: jus   文件: JToggle.java
@Override
public Context getActionBarThemedContext() {
    final ActionBar actionBar = mActivity.getActionBar();
    final Context context;
    if (actionBar != null) {
        context = actionBar.getThemedContext();
    } else {
        context = mActivity;
    }
    return context;
}
 
源代码14 项目: jus   文件: JToggle.java
@Override
public Context getActionBarThemedContext() {
    final ActionBar actionBar = mActivity.getActionBar();
    final Context context;
    if (actionBar != null) {
        context = actionBar.getThemedContext();
    } else {
        context = mActivity;
    }
    return context;
}
 
源代码15 项目: codeexamples-android   文件: MainActivity.java
@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.
}
 
源代码16 项目: Onosendai   文件: PostActivity.java
@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();
}
 
源代码17 项目: Onosendai   文件: MainActivity.java
@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);
}