List of usage examples for android.support.v4.app FragmentManager findFragmentByTag
public abstract Fragment findFragmentByTag(String tag);
From source file:ca.mudar.mtlaucasou.BaseMapActivity.java
/** * Save the list isHidden() status. {@inheritDoc} *///from www . java 2 s . c o m @Override public void onSaveInstanceState(Bundle outState) { FragmentManager fm = getSupportFragmentManager(); Fragment fragmentList = fm.findFragmentByTag(Const.TAG_FRAGMENT_LIST); if (fragmentList != null) { /** * For visible/hidden fragments and actionbar icon. */ outState.putBoolean(Const.KEY_INSTANCE_LIST_IS_HIDDEN, fragmentList.isHidden()); } super.onSaveInstanceState(outState); }
From source file:com.money.manager.ex.reports.PayeeReportFragment.java
public void showChart() { PayeeReportAdapter adapter = (PayeeReportAdapter) getListAdapter(); if (adapter == null) return;//from w ww .j a v a2 s . c om Cursor cursor = adapter.getCursor(); if (cursor == null) return; if (!cursor.moveToFirst()) return; ArrayList<ValuePieEntry> arrayList = new ArrayList<ValuePieEntry>(); while (!cursor.isAfterLast()) { ValuePieEntry item = new ValuePieEntry(); // total double total = Math.abs(cursor.getDouble(cursor.getColumnIndex("TOTAL"))); if (!TextUtils.isEmpty(cursor.getString(cursor.getColumnIndex(ViewMobileData.PAYEE)))) { item.setText(cursor.getString(cursor.getColumnIndex(ViewMobileData.PAYEE))); } else { item.setText(getString(R.string.empty_payee)); } item.setValue(total); CurrencyService currencyService = new CurrencyService(getContext()); item.setValueFormatted(currencyService.getBaseCurrencyFormatted(MoneyFactory.fromDouble(total))); // add element arrayList.add(item); // move to next record cursor.moveToNext(); } Bundle args = new Bundle(); args.putSerializable(PieChartFragment.KEY_CATEGORIES_VALUES, arrayList); //get fragment manager FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); if (fragmentManager != null) { PieChartFragment fragment; fragment = (PieChartFragment) fragmentManager .findFragmentByTag(IncomeVsExpensesChartFragment.class.getSimpleName()); if (fragment == null) { fragment = new PieChartFragment(); } fragment.setChartArguments(args); fragment.setDisplayHomeAsUpEnabled(true); if (fragment.isVisible()) fragment.onResume(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (((PayeesReportActivity) getActivity()).mIsDualPanel) { fragmentTransaction.replace(R.id.fragmentChart, fragment, PieChartFragment.class.getSimpleName()); } else { fragmentTransaction.replace(R.id.fragmentMain, fragment, PieChartFragment.class.getSimpleName()); fragmentTransaction.addToBackStack(null); } try { fragmentTransaction.commit(); } catch (IllegalStateException e) { Timber.e(e, "adding fragment"); } } }
From source file:com.barak.pix.NewPostActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_new_post); // find the retained fragment on activity restarts FragmentManager fm = getSupportFragmentManager(); mTaskFragment = (NewPostUploadTaskFragment) fm.findFragmentByTag(TAG_TASK_FRAGMENT); // create the fragment and data the first time if (mTaskFragment == null) { // add the fragment mTaskFragment = new NewPostUploadTaskFragment(); fm.beginTransaction().add(mTaskFragment, TAG_TASK_FRAGMENT).commit(); }/*from w w w . j a va 2 s.c o m*/ mImageView = (ImageView) findViewById(R.id.new_post_picture); mImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showImagePicker(); } }); Bitmap selectedBitmap = mTaskFragment.getSelectedBitmap(); Bitmap thumbnail = mTaskFragment.getThumbnail(); if (selectedBitmap != null) { mImageView.setImageBitmap(selectedBitmap); mResizedBitmap = selectedBitmap; } if (thumbnail != null) { mThumbnail = thumbnail; } final EditText descriptionText = (EditText) findViewById(R.id.new_post_text); mSubmitButton = (Button) findViewById(R.id.new_post_submit); mSubmitButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { if (mResizedBitmap == null) { Toast.makeText(NewPostActivity.this, " !!!", Toast.LENGTH_SHORT).show(); return; } if (mLocation == null) { Toast.makeText(NewPostActivity.this, " ? ?", Toast.LENGTH_SHORT) .show(); return; } String postText = descriptionText.getText().toString(); if (TextUtils.isEmpty(postText)) { descriptionText.setError(getString(R.string.error_required_field)); return; } showProgressDialog(getString(R.string.post_upload_progress_message)); mSubmitButton.setEnabled(false); Long timestamp = System.currentTimeMillis(); String bitmapPath = "https://pictures-e88fc.firebaseio.com" + "/" + FirebaseUtil.getCurrentUserId() + "/full/" + timestamp.toString() + "/"; String thumbnailPath = "https://pictures-e88fc.firebaseio.com" + "/" + FirebaseUtil.getCurrentUserId() + "/thumb/" + timestamp.toString() + "/"; mTaskFragment.uploadPost(mResizedBitmap, bitmapPath, mThumbnail, thumbnailPath, mFileUri.getLastPathSegment(), postText, mLocation.getLatitude(), mLocation.getLongitude()); } }); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationListener = new MyLocationListener(); if (checkPermission(Manifest.permission.ACCESS_COARSE_LOCATION, getApplicationContext(), NewPostActivity.this)) { locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 10, locationListener); } else { requestPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION, 11, getApplicationContext(), this); } }
From source file:com.nextgis.woody.activity.EditActivity.java
private void thirdStep() { currentStep = 3;/* w w w.java 2s. c o m*/ setTitle(getText(R.string.status)); Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar); toolbar.setSubtitle("3/6"); FragmentManager fm = getSupportFragmentManager(); ListViewFragment lvFragment = (ListViewFragment) fm.findFragmentByTag(Constants.FRAGMENT_LISTVIEW); MapBase mapBase = MapBase.getInstance(); NGWLookupTable table = (NGWLookupTable) mapBase.getLayerByName(Constants.KEY_LT_STATE); Map<String, String> data = table.getData(); lvFragment.fill(data, (String) values.get(Constants.KEY_LT_STATE)); }
From source file:com.nextgis.woody.activity.EditActivity.java
private void fourthStep() { currentStep = 4;/*from w w w . j av a2 s. c o m*/ setTitle(getText(R.string.age)); Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar); toolbar.setSubtitle("4/6"); FragmentManager fm = getSupportFragmentManager(); ListViewFragment lvFragment = (ListViewFragment) fm.findFragmentByTag(Constants.FRAGMENT_LISTVIEW); MapBase mapBase = MapBase.getInstance(); NGWLookupTable table = (NGWLookupTable) mapBase.getLayerByName(Constants.KEY_LT_AGE); Map<String, String> data = table.getData(); lvFragment.fill(data, (String) values.get(Constants.KEY_LT_AGE)); }
From source file:com.launcher.silverfish.launcher.appdrawer.TabbedAppDrawerFragment.java
private void removeAppFromTab(int appIndex, String tab_tag) { // Retrieve tab fragment android.support.v4.app.FragmentManager fm = getChildFragmentManager(); AppDrawerTabFragment fragment = (AppDrawerTabFragment) fm.findFragmentByTag(tab_tag); // Remove app and refresh the tab's layout fragment.removeApp(appIndex);//from ww w . ja v a 2 s.c om }
From source file:com.nerderylabs.android.nerdalert.ui.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // set the navigation bar color on Lollipop+ devices if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(ContextCompat.getColor(this, R.color.color_primary_dark)); }/*from www .j a va 2s . com*/ setContentView(R.layout.activity_main); // setup the Google API Client, requesting access to the Nearby Messages API // DO NOT use the application context here, otherwise the Nearby API will fail with the // following error when publishing/subscribing: // Attempting to perform a high-power operation from a non-Activity Context googleApiClient = new GoogleApiClient.Builder(this).addApi(Nearby.MESSAGES_API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); initializeMessageListener(); FragmentManager fm = getSupportFragmentManager(); MainFragment mainFragment = (MainFragment) fm.findFragmentByTag(MAIN_FRAGMENT_TAG); if (mainFragment == null) { mainFragment = new MainFragment(); fm.beginTransaction().add(R.id.container, mainFragment, MAIN_FRAGMENT_TAG).commit(); } }
From source file:com.nextgis.woody.activity.EditActivity.java
private void sixthStep() { currentStep = 6;//from w w w . j ava 2 s .c o m setTitle(getText(R.string.photo)); Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar); toolbar.setSubtitle("6/6"); btRight.setText(R.string.finish); FragmentManager fm = getSupportFragmentManager(); PhotoFragment photoFragment = (PhotoFragment) fm.findFragmentByTag(Constants.FRAGMENT_PHOTO); if (photoFragment == null) photoFragment = new PhotoFragment(); FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.central_frame, photoFragment, Constants.FRAGMENT_PHOTO); ft.commit(); photoFragment.setmFeatureId(mFeatureId); }
From source file:com.nextgis.woody.activity.EditActivity.java
private void firstStep() { currentStep = 1;//from w w w . j a va2s . co m setTitle(getText(R.string.point_on_map)); Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar); toolbar.setSubtitle("1/6"); btLeft.setText(R.string.cancel); FragmentManager fm = getSupportFragmentManager(); MapFragment mapFragment = (MapFragment) fm.findFragmentByTag(Constants.FRAGMENT_MAP); if (mapFragment == null) { mapFragment = new MapFragment(); mapFragment.setSelectedLocationVisible(true); MapBase mapBase = MapBase.getInstance(); NGWVectorLayer vectorLayer = (NGWVectorLayer) mapBase.getLayerByName(Constants.KEY_MAIN); Feature feature = vectorLayer.getFeature(mFeatureId); if (null != feature) { mapFragment.setZoomAndPosition(18, (GeoPoint) feature.getGeometry()); } else { mapFragment.setZoomAndPosition(18, mapCenter); } } FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.central_frame, mapFragment, Constants.FRAGMENT_MAP); ft.commit(); }
From source file:com.nextgis.woody.activity.EditActivity.java
private void saveLookUpValue(String key) { FragmentManager fm = getSupportFragmentManager(); ListViewFragment lvFragment = (ListViewFragment) fm.findFragmentByTag(Constants.FRAGMENT_LISTVIEW); if (key.equals(Constants.KEY_LT_YEAR)) { // Parse string d.M.yyyy to date nd time SimpleDateFormat dateFormat = new SimpleDateFormat("d.M.yyyy"); Date convertedDate;/* w w w . ja va 2 s. c o m*/ try { String sDate = lvFragment.getSelection(); convertedDate = dateFormat.parse(sDate); values.put(Constants.FIELD_PLANT_DT, convertedDate.getTime()); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { values.put(key, lvFragment.getSelection()); } }