List of usage examples for android.support.v4.app FragmentManager findFragmentByTag
public abstract Fragment findFragmentByTag(String tag);
From source file:com.christophergs.mbientbasic.NavigationActivity.java
public void onSaveButtonPressed(int position) { Log.i(TAG, String.format("SAVE TEST: %d", position)); FragmentManager fragmentManager = getSupportFragmentManager(); BothFragment f1 = (BothFragment) fragmentManager .findFragmentByTag("com.christophergs.mbientbasic.BothFragment"); GyroFragmentNew f2 = (GyroFragmentNew) fragmentManager .findFragmentByTag("com.christophergs.mbientbasic.GyroFragmentNew"); String delete_filename = String.format("METAWEAR.csv"); File path = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), delete_filename);//ww w .j a v a 2 s.co m //delete the csv file if it already exists (will be from older recordings) f1.prep(path); String filename = f1.saveData(false); //f1 is the accelerometer, we keep the header String filename2 = f2.saveData(true); //f2 is the gyro, we remove the header sendFile(); /* if (filename != null) { File dataFile = getFileStreamPath(filename); Uri contentUri = FileProvider.getUriForFile(this, "com.mbientlab.metawear.app.fileprovider", dataFile); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, filename); intent.putExtra(Intent.EXTRA_STREAM, contentUri); startActivity(Intent.createChooser(intent, "Saving Data")); }*/ }
From source file:com.christophergs.mbientbasic.NavigationActivity.java
public void onStartButtonPressed(int position) { //Do something with the position value passed back Log.i(TAG, String.format("FRAG TEST: %d", position)); Log.i(TAG, String.format("CurrentFragment: %s", currentFragment)); FragmentManager fragmentManager = getSupportFragmentManager(); BothFragment f1 = (BothFragment) fragmentManager .findFragmentByTag("com.christophergs.mbientbasic.BothFragment"); GyroFragmentNew f2 = (GyroFragmentNew) fragmentManager .findFragmentByTag("com.christophergs.mbientbasic.GyroFragmentNew"); if (position == 1) { f2.moveViewToLast();//from w ww .j av a2s . co m f1.moveViewToLast(); f2.setup(); f1.setup(); f2.chartHandler.postDelayed(f2.updateChartTask, f2.UPDATE_PERIOD); f1.chartHandler.postDelayed(f1.updateChartTask, f1.UPDATE_PERIOD); } else { f1.chart.setVisibleXRangeMaximum(f1.sampleCount); f2.chart.setVisibleXRangeMaximum(f2.sampleCount); f1.clean(); f2.clean(); if (f1.streamRouteManager != null) { f1.streamRouteManager.remove(); f1.streamRouteManager = null; } if (f2.streamRouteManager != null) { f2.streamRouteManager.remove(); f2.streamRouteManager = null; } f1.chartHandler.removeCallbacks(f1.updateChartTask); f2.chartHandler.removeCallbacks(f2.updateChartTask); } }
From source file:com.dazone.crewchat.libGallery.activity.HomeFragmentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_home_media_chooser); headerBarTitle = (TextView) findViewById(R.id.titleTextViewFromMediaChooserHeaderBar); headerBarCamera = (ImageView) findViewById(R.id.cameraImageViewFromMediaChooserHeaderBar); headerBarBack = (ImageView) findViewById(R.id.backArrowImageViewFromMediaChooserHeaderView); headerBarDone = (TextView) findViewById(R.id.doneTextViewViewFromMediaChooserHeaderView); mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), R.id.realTabcontent); headerBarBack.setOnClickListener(this); headerBarCamera.setOnClickListener(this); headerBarDone.setOnClickListener(this); if (!MediaChooserConstants.showCameraVideo) { headerBarCamera.setVisibility(View.GONE); }/*from ww w.jav a2 s .co m*/ if (getIntent() != null && (getIntent().getBooleanExtra("isFromBucket", false))) { if (getIntent().getBooleanExtra("image", false)) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); Bundle bundle = new Bundle(); bundle.putString("name", getIntent().getStringExtra("name")); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, bundle); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); Bundle bundle = new Bundle(); bundle.putString("name", getIntent().getStringExtra("name")); mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, bundle); } } else { if (MediaChooserConstants.showVideo) { mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, null); } if (MediaChooserConstants.showImage) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, null); } if (MediaChooserConstants.showVideo) { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); } } mTabHost.getTabWidget().getChildAt(0).setVisibility(View.GONE); for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { TextView textView = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); if (textView.getLayoutParams() instanceof RelativeLayout.LayoutParams) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) textView.getLayoutParams(); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_VERTICAL); params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.width = RelativeLayout.LayoutParams.WRAP_CONTENT; textView.setLayoutParams(params); } else if (textView.getLayoutParams() instanceof LinearLayout.LayoutParams) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textView.getLayoutParams(); params.gravity = Gravity.CENTER; textView.setLayoutParams(params); } textView.setTextColor(getResources().getColor(R.color.tabs_title_color)); textView.setTextSize(Utils.convertDipToPixels(this, 10)); } if ((mTabHost.getTabWidget().getChildAt(0) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } if ((mTabHost.getTabWidget().getChildAt(1) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } mTabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1"); VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2"); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (tabId.equalsIgnoreCase("tab1")) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); if (imageFragment != null) { if (videoFragment != null) { fragmentTransaction.hide(videoFragment); } fragmentTransaction.show(imageFragment); } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); if (videoFragment != null) { if (imageFragment != null) { fragmentTransaction.hide(imageFragment); } fragmentTransaction.show(videoFragment); if (videoFragment.getAdapter() != null) { videoFragment.getAdapter().notifyDataSetChanged(); } } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } fragmentTransaction.commit(); } }); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) headerBarCamera.getLayoutParams(); params.height = Utils.convertDipToPixels(this, 40); params.width = Utils.convertDipToPixels(this, 40); headerBarCamera.setLayoutParams(params); headerBarCamera.setScaleType(ScaleType.CENTER_INSIDE); headerBarCamera.setPadding(Utils.convertDipToPixels(this, 15), Utils.convertDipToPixels(this, 15), Utils.convertDipToPixels(this, 15), Utils.convertDipToPixels(this, 15)); }
From source file:com.hippo.scene.StageActivity.java
private void finishScene(String tag, TransitionHelper transitionHelper) { FragmentManager fragmentManager = getSupportFragmentManager(); // Get scene//from w ww . j av a 2 s. c o m Fragment scene = fragmentManager.findFragmentByTag(tag); if (scene == null) { Log.e(TAG, "finishScene: Can't find scene by tag: " + tag); return; } // Get scene index int index = mSceneTagList.indexOf(tag); if (index < 0) { Log.e(TAG, "finishScene: Can't find the tag in tag list: " + tag); return; } if (mSceneTagList.size() == 1) { // It is the last fragment, finish Activity now Log.i(TAG, "finishScene: It is the last scene, finish activity now"); finish(); return; } Fragment next = null; if (index == mSceneTagList.size() - 1) { // It is first fragment, show the next one next = fragmentManager.findFragmentByTag(mSceneTagList.get(index - 1)); } FragmentTransaction transaction = fragmentManager.beginTransaction(); if (next != null) { if (transitionHelper == null || !transitionHelper.onTransition(this, transaction, scene, next)) { // Clear shared item scene.setSharedElementEnterTransition(null); scene.setSharedElementReturnTransition(null); scene.setEnterTransition(null); scene.setExitTransition(null); next.setSharedElementEnterTransition(null); next.setSharedElementReturnTransition(null); next.setEnterTransition(null); next.setExitTransition(null); // Do not show animate if it is not the first fragment transaction.setCustomAnimations(R.anim.scene_close_enter, R.anim.scene_close_exit); } // Attach fragment transaction.attach(next); } transaction.remove(scene); transaction.commitAllowingStateLoss(); // Remove tag mSceneTagList.remove(index); // Return result if (scene instanceof SceneFragment) { ((SceneFragment) scene).returnResult(this); } }
From source file:ca.mudar.parkcatcher.ui.activities.MainActivity.java
@SuppressWarnings("deprecation") @Override/* w ww . jav a2s. c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!Const.IS_DEBUG) { Crittercism.init(getApplicationContext(), Const.CRITTERCISM_APP_ID); } requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); activityHelper = ActivityHelper.createInstance(this); parkingApp = (ParkingApp) getApplicationContext(); parkingApp.updateUiLanguage(); /** * Display the GPLv3 licence */ if (!EulaHelper.hasAcceptedEula(this)) { if (ConnectionHelper.hasConnection(this)) { EulaHelper.showEula(false, this); } else { setContentView(R.layout.activity_no_connection); setSupportProgressBarIndeterminateVisibility(Boolean.FALSE); return; } } hasLoadedData = parkingApp.hasLoadedData(); if (!hasLoadedData) { hasLoadedData = true; // The service runs in the background with no listener Intent intent = new Intent(Intent.ACTION_SYNC, null, getApplicationContext(), SyncService.class); intent.putExtra(Const.INTENT_EXTRA_SERVICE_LOCAL, false); intent.putExtra(Const.INTENT_EXTRA_SERVICE_REMOTE, true); startService(intent); } isPlayservicesOutdated = (GooglePlayServicesUtil .isGooglePlayServicesAvailable(getApplicationContext()) != ConnectionResult.SUCCESS); if (isPlayservicesOutdated) { disableLocationUpdates(); isCenterOnMyLocation = false; setContentView(R.layout.activity_playservices_update); setSupportProgressBarIndeterminateVisibility(Boolean.FALSE); return; } else { setContentView(R.layout.activity_main); setSupportProgressBarIndeterminateVisibility(Boolean.FALSE); } // Set the layout containing the two fragments // Get the fragments FragmentManager fm = getSupportFragmentManager(); mMapFragment = (MapFragment) fm.findFragmentByTag(Const.TAG_FRAGMENT_MAP); mFavoritesFragment = (FavoritesFragment) fm.findFragmentByTag(Const.TAG_FRAGMENT_FAVORITES); // Create the actionbar tabs final ActionBar ab = getSupportActionBar(); ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ab.addTab(ab.newTab().setText(R.string.tab_map).setTabListener(this).setTag(Const.TAG_TABS_MAP)); ab.addTab( ab.newTab().setText(R.string.tab_favorites).setTabListener(this).setTag(Const.TAG_TABS_FAVORITES)); initLocation = null; double latitude = getIntent().getDoubleExtra(Const.INTENT_EXTRA_GEO_LAT, Double.MIN_VALUE); double longitude = getIntent().getDoubleExtra(Const.INTENT_EXTRA_GEO_LNG, Double.MIN_VALUE); if (Double.compare(latitude, Double.MIN_VALUE) != 0 && Double.compare(latitude, Double.MIN_VALUE) != 0) { initLocation = new Location(Const.LOCATION_PROVIDER_INTENT); initLocation.setLatitude(latitude); initLocation.setLongitude(longitude); isCenterOnMyLocation = false; } else { isCenterOnMyLocation = true; // Initialize the displayed values. This is not done when // MainActivity is called from Details activity, to keep the same // Calendar. parkingApp.resetParkingCalendar(); } updateParkingTimeTitle(); updateParkingDateButton(); updateParkingTimeButton(); updateParkingDurationButton(); mFavoritesFragment.refreshList(); mDrawer = (SlidingDrawer) findViewById(R.id.drawer_time); mDrawer.animateOpen(); }
From source file:com.nicolls.ablum.activity.HomeFragmentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_home_media_chooser); pathList = getIntent().getStringArrayListExtra("pathList"); if (pathList == null) { pathList = new ArrayList<>(); }/*ww w .j av a2 s . c om*/ // Toast.makeText(this,pathList.size()+"-@@@--",Toast.LENGTH_SHORT).show(); headerBarTitle = (TextView) findViewById(R.id.titleTextViewFromMediaChooserHeaderBar); headerBarCamera = (ImageView) findViewById(R.id.cameraImageViewFromMediaChooserHeaderBar); headerBarBack = (ImageView) findViewById(R.id.backArrowImageViewFromMediaChooserHeaderView); headerBarDone = (TextView) findViewById(R.id.doneTextViewViewFromMediaChooserHeaderView); mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), R.id.realTabcontent); headerBarBack.setOnClickListener(clickListener); headerBarCamera.setOnClickListener(clickListener); headerBarDone.setOnClickListener(clickListener); headerBarCamera.setVisibility(View.GONE); if (getIntent() != null && (getIntent().getBooleanExtra("isFromBucket", false))) { if (getIntent().getBooleanExtra("image", false)) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); Bundle bundle = new Bundle(); bundle.putString("name", getIntent().getStringExtra("name")); bundle.putStringArrayList("pathList", pathList); // Toast.makeText(this,pathList.size()+"!!!!",Toast.LENGTH_SHORT).show(); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, bundle); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); Bundle bundle = new Bundle(); bundle.putStringArrayList("pathList", pathList); // Toast.makeText(this,pathList.size()+"!!!",Toast.LENGTH_SHORT).show(); bundle.putString("name", getIntent().getStringExtra("name")); mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, bundle); } } else { if (MediaChooserConstants.showVideo) { mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, null); } if (MediaChooserConstants.showImage) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, null); } if (MediaChooserConstants.showVideo) { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); } } for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { TextView textView = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); if (textView.getLayoutParams() instanceof RelativeLayout.LayoutParams) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) textView.getLayoutParams(); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_VERTICAL); params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.width = RelativeLayout.LayoutParams.WRAP_CONTENT; textView.setLayoutParams(params); } else if (textView.getLayoutParams() instanceof LinearLayout.LayoutParams) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textView.getLayoutParams(); params.gravity = Gravity.CENTER; textView.setLayoutParams(params); } textView.setTextColor(getResources().getColor(R.color.tabs_title_color)); textView.setTextSize(convertDipToPixels(10)); } if ((mTabHost.getTabWidget().getChildAt(0) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } if ((mTabHost.getTabWidget().getChildAt(1) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } mTabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1"); VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2"); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (tabId.equalsIgnoreCase("tab1")) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); if (imageFragment != null) { if (videoFragment != null) { fragmentTransaction.hide(videoFragment); } fragmentTransaction.show(imageFragment); } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); if (videoFragment != null) { if (imageFragment != null) { fragmentTransaction.hide(imageFragment); } fragmentTransaction.show(videoFragment); if (videoFragment.getAdapter() != null) { videoFragment.getAdapter().notifyDataSetChanged(); } } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } fragmentTransaction.commit(); } }); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) headerBarCamera.getLayoutParams(); params.height = convertDipToPixels(40); params.width = convertDipToPixels(40); headerBarCamera.setLayoutParams(params); headerBarCamera.setScaleType(ScaleType.CENTER_INSIDE); headerBarCamera.setPadding(convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15)); }
From source file:com.money.manager.ex.reports.IncomeVsExpensesListFragment.java
private void showChartInternal() { // take a adapter and cursor IncomeVsExpensesAdapter adapter = ((IncomeVsExpensesAdapter) getListAdapter()); if (adapter == null) return;/*www.ja v a2s . c o m*/ Cursor cursor = adapter.getCursor(); if (cursor == null) return; // Move to the first record. if (cursor.getCount() <= 0) return; // arrays ArrayList<Double> incomes = new ArrayList<>(); ArrayList<Double> expenses = new ArrayList<>(); ArrayList<String> titles = new ArrayList<>(); // Reset cursor to initial position. cursor.moveToPosition(-1); // cycle cursor while (cursor.moveToNext()) { int month = cursor.getInt(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Month)); // check if not subtotal if (month != IncomeVsExpensesActivity.SUBTOTAL_MONTH) { // incomes and expenses incomes.add(cursor.getDouble(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Income))); expenses.add( Math.abs(cursor.getDouble(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Expenses)))); // titles int year = cursor.getInt(cursor.getColumnIndex(IncomeVsExpenseReportEntity.YEAR)); // format month Calendar calendar = Calendar.getInstance(); calendar.set(year, month - 1, 1); // titles titles.add(Integer.toString(year) + "-" + new SimpleDateFormat("MMM").format(calendar.getTime())); } } //compose bundle for arguments Bundle args = new Bundle(); args.putDoubleArray(IncomeVsExpensesChartFragment.KEY_EXPENSES_VALUES, ArrayUtils.toPrimitive(expenses.toArray(new Double[0]))); args.putDoubleArray(IncomeVsExpensesChartFragment.KEY_INCOME_VALUES, ArrayUtils.toPrimitive(incomes.toArray(new Double[0]))); args.putStringArray(IncomeVsExpensesChartFragment.KEY_XTITLES, titles.toArray(new String[titles.size()])); //get fragment manager FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); if (fragmentManager != null) { IncomeVsExpensesChartFragment fragment; fragment = (IncomeVsExpensesChartFragment) fragmentManager .findFragmentByTag(IncomeVsExpensesChartFragment.class.getSimpleName()); if (fragment == null) { fragment = new IncomeVsExpensesChartFragment(); } fragment.setChartArguments(args); fragment.setDisplayHomeAsUpEnabled(true); if (fragment.isVisible()) fragment.onResume(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (((IncomeVsExpensesActivity) getActivity()).mIsDualPanel) { fragmentTransaction.replace(R.id.fragmentChart, fragment, IncomeVsExpensesChartFragment.class.getSimpleName()); } else { fragmentTransaction.replace(R.id.fragmentMain, fragment, IncomeVsExpensesChartFragment.class.getSimpleName()); fragmentTransaction.addToBackStack(null); } fragmentTransaction.commit(); } }
From source file:com.duy.pascal.ui.editor.BaseEditorActivity.java
private void initFileView() { FragmentManager fragmentManager = getSupportFragmentManager(); mFileExplorer = (FileListPagerFragment) fragmentManager.findFragmentByTag(FileListPagerFragment.TAG); if (mFileExplorer == null) { File path = FileManager.getSrcPath(this); mFileExplorer = (FileListPagerFragment) FileListPagerFragment.newFragment(path); }//from ww w.j ava2 s . c o m FragmentTransaction fm = fragmentManager.beginTransaction(); fm.replace(R.id.file_explorer, mFileExplorer, FileListPagerFragment.TAG).commit(); mFabMenu = findViewById(R.id.fab_menu); mFabMenu.findViewById(R.id.action_new_file).setOnClickListener(this); mFabMenu.findViewById(R.id.action_new_folder).setOnClickListener(this); View menuAnchor = findViewById(R.id.img_file_menus); mFileMenu = new PopupMenu(this, menuAnchor); mFileMenu.setOnMenuItemClickListener(this); Menu menu = mFileMenu.getMenu(); getMenuInflater().inflate(R.menu.explorer_menu, menu); Pref pref = Pref.getInstance(this); menu.findItem(R.id.show_hidden_files_menu).setChecked(pref.isShowHiddenFiles()); MenuItem pasteMenu = menu.findItem(R.id.paste_menu); int sortId; switch (pref.getFileSortType()) { case FileListSorter.SORT_DATE: sortId = R.id.sort_by_datetime_menu; break; case FileListSorter.SORT_SIZE: sortId = R.id.sort_by_size_menu; break; case FileListSorter.SORT_TYPE: sortId = R.id.sort_by_type_menu; break; default: sortId = R.id.sort_by_name_menu; break; } menu.findItem(sortId).setChecked(true); menuAnchor.setOnClickListener(this); findViewById(R.id.img_home_dir).setOnClickListener(this); }
From source file:com.github.hobbe.android.openkarotz.activity.MainActivity.java
private void selectDrawerItem(int position) { Log.v(LOG_TAG, "selectDrawerItem #" + position); // Create a new fragment based on position Fragment fragment = null;/* w w w .j a v a 2 s . c o m*/ boolean allowBack = false; String tag = pageTitles[position]; FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); fragment = fragmentManager.findFragmentByTag(tag); switch (position) { case PAGE_HOME: if (fragment == null) { fragment = getHomeFragment(); } allowBack = true; break; case PAGE_RADIO: if (fragment == null) { fragment = getRadioFragment(); } allowBack = true; break; case PAGE_COLOR: if (fragment == null) { fragment = getColorFragment(); } allowBack = true; break; case PAGE_EARS: if (fragment == null) { fragment = getEarsFragment(); } allowBack = true; break; case PAGE_SYSTEM: if (fragment == null) { fragment = getSystemFragment(); } allowBack = true; break; default: break; } // Insert the fragment by replacing any existing fragment transaction.replace(R.id.content_frame, fragment, tag); // Add transaction to back stack if (allowBack) { transaction.addToBackStack(null); } // Commit transaction.commit(); // Set selected item in drawer updateDrawerSelection(position); // Close the drawer drawerLayout.closeDrawer(drawerList); }
From source file:com.app.blockydemo.ui.fragment.FormulaEditorFragment.java
private void onUserDismiss() { formulaEditorEditText.endEdit();//from w ww .j a v a 2s . c o m currentFormula.prepareToRemove(); FragmentActivity activity = getActivity(); FragmentManager fragmentManager = activity.getSupportFragmentManager(); FragmentTransaction fragTransaction = fragmentManager.beginTransaction(); fragTransaction.hide(this); fragTransaction.show(fragmentManager.findFragmentByTag(ScriptFragment.TAG)); fragTransaction.commit(); resetActionBar(); BottomBar.showBottomBar(activity); BottomBar.showPlayButton(activity); }