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

The following examples show how to use android.support.v7.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: TaskListFragment.java    From mvp-helpers with MIT License 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.task_list_menu, menu);

    final MenuItem item = menu.findItem(R.id.action_search);
    final ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();

    if (null != actionBar) {
        final SearchView searchView = new SearchView(actionBar.getThemedContext());

        MenuItemCompat.setActionView(item, searchView);

        searchView.setOnQueryTextListener(this);
        searchView.setIconifiedByDefault(false);

        searchView.setOnSearchClickListener(v -> newTaskButton.hide());
        searchView.setOnCloseListener(this::onClose);

        MenuItemCompat.setOnActionExpandListener(item, this);
    }

    if (isPresenterAvailable()) {
        Long count = getPresenter().getTasksCount();

        menu.findItem(R.id.action_delete_all).setEnabled(count != 0);
        menu.findItem(R.id.action_delete_all).setVisible(count != 0);
    }

    super.onCreateOptionsMenu(menu, inflater);
}
 
Example 2
Source File: DropdownProxy.java    From actionbarextras with MIT License 5 votes vote down vote up
@Override
public void handleCreationDict(KrollDict options) {
	
	final ActionBar actionBar = ((AppCompatActivity)getActivity()).getSupportActionBar();
	final boolean keepTitle;
	
	if (options.containsKey("keepTitle")) {
		keepTitle = options.getBoolean("keepTitle");
	}else{
		keepTitle = false;
	}
	
	add(keepTitle);
    
    if (options.containsKey("titles")) {
    	final String[] dropdownValues = options.getStringArray("titles");
    	
        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);

        actionBar.setListNavigationCallbacks(adapter, navigationListener);
	}
    
    if (options.containsKey("index")) {
    	int activeItem = options.getInt("index");
    	setActiveItem(activeItem);
    }

	super.handleCreationDict(options);
}
 
Example 3
Source File: ReviewsActivity.java    From StreamHub-Android-SDK with MIT License 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void buildToolBar() {
    toolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(toolbar);
    //disable title on toolbar
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    ImageView homeIcon = (ImageView) findViewById(R.id.activityIcon);
    homeIcon.setBackgroundResource(R.mipmap.livefyreflame);
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);

    Spinner mSpinner = (Spinner) findViewById(R.id.activityTitleSpinner);
    String[] items = getResources().getStringArray(R.array.helpful_categories);
    mSpinner.setVisibility(View.VISIBLE);
    activityTitle.setVisibility(View.GONE);
    List<String> spinnerItems = new ArrayList<String>();

    for (int i = 0; i < items.length; i++) {
        spinnerItems.add(items[i]);
    }

    SpinnerAdapter adapter = new SpinnerAdapter(actionBar.getThemedContext(), spinnerItems);
    mSpinner.setAdapter(adapter);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        mSpinner.setDropDownVerticalOffset(-116);
    }

}