use of android.app.ActionBar in project GTFSOffline by wbrenna.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Set up the action bar.
final ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
}
mProgress = (ProgressBar) findViewById(R.id.progress);
// read in the preferences
mPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
Set<String> emptyString = new HashSet<String>();
emptyString.clear();
Set<String> initial_preferences = mPrefs.getStringSet(getString(R.string.pref_dbs), emptyString);
mDBListPrefsOld = initial_preferences;
// this is the list of currently checked databases
String[] tmpDBActive = initial_preferences.toArray(new String[initial_preferences.size()]);
// we have to be careful to exclude databases that aren't in our directory
dbHelper = new DatabaseHelper(this);
dbHelper.gatherFiles();
mDBList = dbHelper.GetListofDB();
List<String> workingDBList = new ArrayList<String>();
for (int i = 0; i < tmpDBActive.length; i++) {
if (mDBList.contains(tmpDBActive[i])) {
workingDBList.add(tmpDBActive[i]);
} else {
initial_preferences.remove(tmpDBActive[i]);
}
}
if (workingDBList.size() == 0) {
mDBActive = null;
} else {
mDBActive = workingDBList.toArray(new String[workingDBList.size()]);
}
Editor prefsDBEditor = mPrefs.edit();
prefsDBEditor.putStringSet(getString(R.string.pref_dbs), initial_preferences);
prefsDBEditor.commit();
// Set up the location management
mLocationHelper = new LocationHelper(this);
mLocation = mLocationHelper.startLocationManager();
// Define a listener that responds to location updates
locationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
if (mLocationHelper.isBetterLocation(location, mLocation)) {
mLocation = location;
if (mLocation != null) {
// new ProcessBusStops().execute();
mSectionsPagerAdapter.notifyDataSetChanged();
} else {
Toast.makeText(getBaseContext(), R.string.last_location_fix, Toast.LENGTH_LONG).show();
// Log.e(TAG, "No more location fixes ");
}
}
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
};
// TODO: eventually add automated downloading of databases...
// Create the adapter that will return a fragment for each of the
// primary sections of the app.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
});
// For each of the sections in the app, add a tab to the action bar.
for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
}
}
use of android.app.ActionBar in project android_packages_apps_Settings by crdroidandroid.
the class RunningServices method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
ActionBar actionBar = getActivity().getActionBar();
switch(item.getItemId()) {
case SHOW_RUNNING_SERVICES:
mRunningProcessesView.mAdapter.setShowBackground(false);
actionBar.setTitle(R.string.runningservices_settings_title);
break;
case SHOW_BACKGROUND_PROCESSES:
mRunningProcessesView.mAdapter.setShowBackground(true);
actionBar.setTitle(R.string.background_processes_settings_title);
break;
default:
return false;
}
updateOptionsMenu();
return true;
}
use of android.app.ActionBar in project android_packages_apps_Settings by crdroidandroid.
the class EntityHeaderControllerTest method styleActionBar_setElevationAndBackground.
@Test
public void styleActionBar_setElevationAndBackground() {
final ActionBar actionBar = mActivity.getActionBar();
mController = EntityHeaderController.newInstance(mActivity, mFragment, null);
mController.styleActionBar(mActivity);
verify(actionBar).setElevation(0);
// Enforce a color drawable as background here, as image based drawables might not be
// wide enough to cover entire action bar.
verify(actionBar).setBackgroundDrawable(any(ColorDrawable.class));
}
use of android.app.ActionBar in project android_packages_apps_Settings by SudaMod.
the class EntityHeaderController method styleActionBar.
public EntityHeaderController styleActionBar(Activity activity) {
if (activity == null) {
Log.w(TAG, "No activity, cannot style actionbar.");
return this;
}
final ActionBar actionBar = activity.getActionBar();
if (actionBar == null) {
Log.w(TAG, "No actionbar, cannot style actionbar.");
return this;
}
actionBar.setBackgroundDrawable(new ColorDrawable(Utils.getColorAttr(activity, android.R.attr.colorSecondary)));
actionBar.setElevation(0);
if (mRecyclerView != null && mLifecycle != null) {
ActionBarShadowController.attachToRecyclerView(mActivity, mLifecycle, mRecyclerView);
}
return this;
}
use of android.app.ActionBar in project android_packages_apps_Settings by SudaMod.
the class UserDictionarySettings method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Show the language as a subtitle of the action bar
final ActionBar actionBar = getActivity().getActionBar();
if (actionBar != null) {
actionBar.setTitle(R.string.user_dict_settings_title);
actionBar.setSubtitle(UserDictionarySettingsUtils.getLocaleDisplayName(getActivity(), mLocale));
}
return inflater.inflate(com.android.internal.R.layout.preference_list_fragment, container, false);
}
Aggregations