List of usage examples for android.app FragmentManager findFragmentById
public abstract Fragment findFragmentById(int id);
From source file:org.proninyaroslav.libretorrent.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getIntent().getAction() != null && getIntent().getAction().equals(TAG_ACTION_SHUTDOWN)) { finish();/*from ww w. ja v a2 s . com*/ return; } if (savedInstanceState != null) { permDialogIsShow = savedInstanceState.getBoolean(TAG_PERM_DIALOG_IS_SHOW); } verifyStoragePermissions(this); SettingsManager.initPreferences(getApplicationContext()); startService(new Intent(this, TorrentTaskService.class)); setContentView(R.layout.activity_main); Utils.showColoredStatusBar_KitKat(this); FragmentManager fm = getFragmentManager(); mainFragment = (MainFragment) fm.findFragmentById(R.id.main_fragmentContainer); }
From source file:com.artitk.licensefragment.example.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FragmentManager fragmentManager = getFragmentManager(); mNavigationDrawerFragment = (NavigationDrawerFragment) fragmentManager .findFragmentById(R.id.navigation_drawer); if (savedInstanceState == null) mTitle = getTitle();/*from w w w.ja va 2s . co m*/ // Set up the drawer. mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); // ScrollViewLicenseFragment scrollViewLicenseFragment = (ScrollViewLicenseFragment) fragmentManager.findFragmentById(R.id.fragment); // scrollViewLicenseFragment.setLog(true); // scrollViewLicenseFragment.addLicense(new int[]{LicenseID.PICASSO, LicenseID.STATED_FRAGMENT, LicenseID.GSON}); // ListViewLicenseFragment listViewLicenseFragment = (ListViewLicenseFragment) fragmentManager.findFragmentById(R.id.fragment); // // listViewLicenseFragment.setLog(true); // listViewLicenseFragment.addLicense(new int[]{LicenseID.PICASSO, LicenseID.STATED_FRAGMENT, LicenseID.GSON}); // listViewLicenseFragment.withLicenseChain(false); // // ArrayList<License> licenses = new ArrayList<>(); // licenses.add(new License(this, "Title", LicenseType.BSD_3_CLAUSE, "YEAR", "OWNER")); // listViewLicenseFragment.addCustomLicense(licenses); // RecyclerViewLicenseFragment recyclerViewLicenseFragment = (RecyclerViewLicenseFragment) fragmentManager.findFragmentById(R.id.fragment); // // recyclerViewLicenseFragment.setLog(true); // recyclerViewLicenseFragment.addLicense(new int[]{LicenseID.PICASSO, LicenseID.STATED_FRAGMENT, LicenseID.GSON}); // recyclerViewLicenseFragment.withLicenseChain(false); // // ArrayList<License> licenses = new ArrayList<>(); // licenses.add(new License(this, "Title", LicenseType.BSD_3_CLAUSE, "YEAR", "OWNER")); // recyclerViewLicenseFragment.addCustomLicense(licenses); // recyclerViewLicenseFragment.setCustomUI(new CustomUI().setTitleBackgroundColor(Color.RED)); }
From source file:mx.itchetumal.sensado_urbano.MainMapas.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public void setUpMap() { int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext()); if (status != ConnectionResult.SUCCESS) { int requestCode = 10; Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode); dialog.show();//w w w . j a v a 2 s . co m } else { if (map == null) { map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); if (map != null) { map.setMapType(GoogleMap.MAP_TYPE_NORMAL); map.setMyLocationEnabled(true); } } lo = (LocationManager) getSystemService(LOCATION_SERVICE); Criteria criteria = new Criteria(); String provider = lo.getBestProvider(criteria, true); myLoc = lo.getLastKnownLocation(provider); if (myLoc != null) { onLocationChanged(myLoc); } lo.requestLocationUpdates(provider, 20000, 0, this); FragmentManager myfrag = getFragmentManager(); MapFragment myFragment = (MapFragment) myfrag.findFragmentById(R.id.map); map = myFragment.getMap(); map.setMapType(GoogleMap.MAP_TYPE_NORMAL); map.setMyLocationEnabled(true); // map.animateCamera(CameraUpdateFactory.newLatLng(new LatLng(myLoc.getLatitude(), myLoc.getLongitude()))); map.setOnMapClickListener(this); map.setOnMapLongClickListener(this); map.setOnMarkerClickListener(this); marketClicked = false; } }
From source file:net.exclaimindustries.geohashdroid.activities.CentralMapExtraActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getLayoutResource()); // Grab the fragment. We know it's there, it's right there in the // layout./* w w w.j a va2 s . com*/ FragmentManager manager = getFragmentManager(); mFrag = (CentralMapExtraFragment) manager.findFragmentById(getFragmentResource()); // We'd BETTER have an Intent. Intent intent = getIntent(); // And that intent BETTER have an Info. mInfo = intent.getParcelableExtra(INFO); // Since the fragment's part of the layout, we can't set an argument // anymore. So, just update the Info. mFrag.setCloseListener(this); mFrag.setInfo(mInfo); // Let's get the client fired up, since CentralMap won't be around to // handle updating the location. mGoogleClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(LocationServices.API).build(); }
From source file:org.jorge.lolin1.ui.activities.DrawerLayoutFragmentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(savedInstanceState.getInt(ACTIVITY_LAYOUT)); if (navigatedItemsStack.isEmpty()) { navigatedItemsStack.add(0);//from ww w . ja va 2 s. c o m } FragmentManager fragmentManager = getFragmentManager(); NavigationDrawerFragment mNavigationDrawerFragment = (NavigationDrawerFragment) fragmentManager .findFragmentById(R.id.navigation_drawer); mNavigationDrawerFragment.setHasOptionsMenu(Boolean.TRUE); // if (TextUtils.isEmpty(mTitle)) mTitle = getTitle(); logString("debug", "onCreate: mTitle = " + mTitle); // Set up the drawer. mNavigationDrawerFragment.setUp(R.id.navigation_drawer, drawerLayout = (FixedDrawerLayout) findViewById(R.id.drawer_layout)); }
From source file:jsettlers.main.android.JsettlersActivity.java
@Override public void onBackPressed() { FragmentManager manager = getFragmentManager(); Fragment last = manager.findFragmentById(R.id.base_menu); if (last instanceof JsettlersFragment) { if (((JsettlersFragment) last).onBackButtonPressed()) { return; }// w w w . j a v a 2s . c om } super.onBackPressed(); }
From source file:cz.zcu.kiv.eeg.mobile.base.ws.asynctask.RemoveReservation.java
/** * If reservation was removed, attempt to update reservation fragment or at least inform user, that he should do that manually. * * @param success true if reservation is removed *//*from w w w.ja v a 2 s . c om*/ @Override protected void onPostExecute(Boolean success) { if (success) { if (activity instanceof NavigationActivity) { FragmentManager fm = activity.getFragmentManager(); ReservationFragment fragment = (ReservationFragment) fm.findFragmentByTag(ReservationFragment.TAG); if (fragment == null) fragment = (ReservationFragment) fm.findFragmentById(fragmentId); if (fragment != null) { fragment.updateData(); Toast.makeText(activity, activity.getString(R.string.reser_removed), Toast.LENGTH_SHORT).show(); } else { Log.e(TAG, "Agenda fragment not found!"); Toast.makeText(activity, activity.getString(R.string.reser_removed_update), Toast.LENGTH_LONG) .show(); } } } }
From source file:my.madet.uniteninfo.MainHome.java
@Override public void onDestroy() { super.onDestroy(); FragmentManager fragmentManager = getFragmentManager(); Fragment fragment = fragmentManager.findFragmentById(R.id.frame_container); if (fragment != null) { fragment.onDestroy();/*from www. j a v a 2s . co m*/ } }
From source file:my.madet.uniteninfo.MainHome.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d("onActivityResult", "onActivityResult in main Home " + requestCode); Log.d("onActivityResult", "onActivityResult in main Home " + data.getIntExtra("RESPONSE_CODE", 0)); super.onActivityResult(requestCode, resultCode, data); FragmentManager fragmentManager = getFragmentManager(); Fragment fragment = fragmentManager.findFragmentById(R.id.frame_container); if (fragment != null) { fragment.onActivityResult(requestCode, resultCode, data); }//from w w w.jav a2 s . co m }
From source file:com.cloudbees.gasp.activity.GaspRESTLoaderActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set main content view for Gasp! Reviews setContentView(R.layout.gasp_review_activity); // Use the Fragments API to display review data FragmentManager fm = getFragmentManager(); ListFragment list = (ListFragment) fm.findFragmentById(R.id.gasp_review_content); if (list == null) { list = new ListFragment(); FragmentTransaction ft = fm.beginTransaction(); ft.add(R.id.gasp_review_content, list); ft.commit();/*from ww w. j a v a 2s. c o m*/ } // Array adapter provides access to the review list data mAdapter = new ArrayAdapter<String>(this, R.layout.gasp_review_list); list.setListAdapter(mAdapter); // Load shared preferences from res/xml/preferences.xml (first time only) // Subsequent activations will use the saved shared preferences from the device PreferenceManager.setDefaultValues(this, R.xml.preferences, false); SharedPreferences gaspSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); Log.i(TAG, "Using Gasp Server URI: " + gaspSharedPreferences.getString("gasp_endpoint_uri", "")); Uri gaspReviewsUri = Uri.parse(gaspSharedPreferences.getString("gasp_endpoint_uri", "")); // Loader arguments: LoaderManager will maintain the state of our Loaders // and reload if necessary. Bundle args = new Bundle(); Bundle params = new Bundle(); args.putParcelable(ARGS_URI, gaspReviewsUri); args.putParcelable(ARGS_PARAMS, params); // Initialize the Loader. getLoaderManager().initLoader(LOADER_GASP_REVIEWS, args, this); // Use gasp-mongo REST service new ReviewsRequest().execute(); try { LocationsRequest locations = new LocationsRequest( new SpatialQuery(new Location(-122.1139858, 37.3774655), 0.005)); List<GeoLocation> locationList = locations.execute().get(); for (GeoLocation geoLocation : locationList) { Log.i(TAG, geoLocation.getName()); Log.i(TAG, " " + geoLocation.getFormattedAddress()); Log.i(TAG, " " + String.valueOf(geoLocation.getLocation().getLng())); Log.i(TAG, " " + String.valueOf(geoLocation.getLocation().getLat())); } } catch (Exception e) { Log.e(TAG, e.getLocalizedMessage()); } }