List of usage examples for android.app FragmentManager beginTransaction
public abstract FragmentTransaction beginTransaction();
From source file:com.hit.jj.mapshow.RoutingActivity.java
/** * ?/*from w w w . j av a 2 s .c om*/ */ private void setListener() { /** * On single clicking the directions label, start a ListActivity to show * the list of all directions for this route. Selecting one of those * items will return to the map and highlight that segment. * */ directionsLabel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (mPaths == null) return; isStart = true; for (int i = 0; i < mPaths.size(); i++) { final Path path = mPaths.get(i);//? final int finalI = i; new Handler().postDelayed(new Runnable() { @Override public void run() { switch (path.getNextDirection()) { case 1: speak("?"); break; case 0: speak(""); break; case 2: speak("??"); break; } clearAll(); pathfingding(mPaths, finalI); } }, 10000); } } }); img_cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { clearAll(); } }); img_currLocation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.e("mLocation", mLocation.getX() + " " + mLocation.getY()); Point p = (Point) GeometryEngine.project(mLocation, egs, wm); map.zoomToResolution(p, 20.0); } }); img_getDirections.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); RoutingDialogFragment frag_dialog = new RoutingDialogFragment(); ft.add(frag_dialog, "Dialog"); ft.commit(); } }); img_speak.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); SpeakDialogFragment frag_dialog = new SpeakDialogFragment(); ft.add(frag_dialog, "SpeakDialog"); ft.commit(); } }); /** * On single tapping the map, query for a route segment and highlight * the segment and show direction summary in the label if a segment is * found. */ map.setOnSingleTapListener(new OnSingleTapListener() { private static final long serialVersionUID = 1L; public void onSingleTap(float x, float y) { // Get all the graphics within 20 pixels the click int[] indexes = hiddenSegmentsLayer.getGraphicIDs(x, y, 20); // Hide the currently selected segment hiddenSegmentsLayer.updateGraphic(selectedSegmentID, segmentHider); if (indexes.length < 1) { // If no segments were found but there is currently a route, // zoom to the extent of the full route if (curRoute != null) { map.setExtent(curRoute.getEnvelope(), 250); directionsLabel.setText(routeSummary); } return; } // Otherwise update our currently selected segment selectedSegmentID = indexes[0]; Graphic selected = hiddenSegmentsLayer.getGraphic(selectedSegmentID); // Highlight it on the map hiddenSegmentsLayer.updateGraphic(selectedSegmentID, segmentShower); String direction = ((String) selected.getAttributeValue("text")); double time = ((Double) selected.getAttributeValue("time")).doubleValue(); double length = ((Double) selected.getAttributeValue("length")).doubleValue(); // Update the label with this direction's information String label = String.format("%s%n%.1f minutes (%.1f miles)", direction, time, length); directionsLabel.setText(label); // Zoom to the extent of that segment map.setExtent(selected.getGeometry(), 50); } }); /** * On long pressing the map view, route from our current location to the * pressed location. * */ map.setOnLongPressListener(new OnLongPressListener() { private static final long serialVersionUID = 1L; public boolean onLongPress(final float x, final float y) { final Point loc = map.toMapPoint(x, y); // Point s1= new Point(26.0734997,119.3150024); Point s1 = new Point(26.1023006, 119.2789993); Point s2 = new Point(mLocation.getY(), mLocation.getX()); Point sp = new Point(loc.getY(), loc.getX()); pathfind(s2, sp);// // pathfind(s1,sp);// return true; } }); }
From source file:fbla.hhs.eclat.Camera.Camera2BasicFragment.java
/** * Switch Fragments/*w ww. j a v a 2s. c o m*/ */ private void switchFrag() { ImagePreview fragment = new ImagePreview(); fragment.setImage(mFile, this, cameraType); FragmentManager fragmentManager = getActivity().getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.container, fragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); }
From source file:com.luke.lukef.lukeapp.MainActivity.java
/** * Switches the <code>fragment_container</code> RelativeLayout from <code>activity_main.xml</code> to the * fragment which is chosen.// w ww.ja va2 s. co m * * @param fragmentToChange Constants enum type defined for each fragment * @param bundleToSend Optional bundle to send along with the transaction */ public void fragmentSwitcher(Constants.fragmentTypes fragmentToChange, Bundle bundleToSend) { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Fragment fragment = null; String tag = "default"; // cases are enumerations, create new fragment corresponding with the enum given switch (fragmentToChange) { case FRAGMENT_LEADERBOARD: fragment = new LeaderboardFragment(); tag = "leader"; break; case FRAGMENT_NEW_SUBMISSION: fragment = new NewSubmissionFragment(); tag = "newSub"; break; case FRAGMENT_PROFILE: fragment = new ProfileFragment(); tag = "profile"; break; case FRAGMENT_MAP: fragment = new MapViewFragment(); tag = "map"; break; default: fragment = null; break; } //replace the fragment if (bundleToSend != null && fragment != null) { fragment.setArguments(bundleToSend); } if (fragment != null) { fragmentTransaction.replace(R.id.fragment_container, fragment, tag).addToBackStack(tag).commit(); } }
From source file:com.ultimate.camera.activities.MainActivity.java
@Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments FragmentManager fragmentManager = getFragmentManager(); BaseFragment targetFragment = null;/*from ww w.j a v a2 s.c o m*/ // Populate the fragment switch (position) { case SIMPLE_CAMERA_INTENT_FRAGMENT: { targetFragment = SimpleCameraIntentFragment.newInstance(position + 1); break; } case SIMPLE_PHOTO_GALLERY_FRAGMENT: { targetFragment = SimplePhotoGalleryListFragment.newInstance(position + 1); break; } case SIMPLE_PHOTO_PICKER_FRAGMENT: { targetFragment = SimpleAndroidImagePickerFragment.newInstance(position + 1); break; } case NATIVE_CAMERA_FRAGMENT: { targetFragment = NativeCameraFragment.newInstance(position + 1); break; } case HORIZONTAL_GALLERY_FRAGMENT: { targetFragment = HorizontalPhotoGalleryFragment.newInstance(position + 1); break; } default: break; } // Select the fragment. fragmentManager.beginTransaction().replace(R.id.container, targetFragment).commit(); }
From source file:org.nypl.simplified.app.MainSettingsAccountActivity.java
@Override protected void onCreate(final @Nullable Bundle state) { super.onCreate(state); final Bundle extras = getIntent().getExtras(); if (extras != null) { this.account = new AccountsRegistry(this).getAccount(extras.getInt("selected_account")); } else {//from ww w .j av a 2 s. c om this.account = Simplified.getCurrentAccount(); } final ActionBar bar = this.getActionBar(); if (android.os.Build.VERSION.SDK_INT < 21) { bar.setDisplayHomeAsUpEnabled(false); bar.setHomeButtonEnabled(true); bar.setIcon(R.drawable.ic_arrow_back); } else { bar.setHomeAsUpIndicator(R.drawable.ic_arrow_back); bar.setDisplayHomeAsUpEnabled(true); bar.setHomeButtonEnabled(false); } final DocumentStoreType docs = Simplified.getDocumentStore(this.account, getResources()); final LayoutInflater inflater = NullCheck.notNull(this.getLayoutInflater()); final FrameLayout content_area = this.getContentFrame(); final ViewGroup layout = NullCheck .notNull((ViewGroup) inflater.inflate(R.layout.settings_account, content_area, false)); content_area.addView(layout); content_area.requestLayout(); final TextView in_barcode_label = NullCheck.notNull(this.findViewById(R.id.settings_barcode_label)); final TextView in_barcode_text = NullCheck.notNull(this.findViewById(R.id.settings_barcode_text)); final TextView in_pin_label = NullCheck.notNull(this.findViewById(R.id.settings_pin_label)); final ImageView in_barcode_image = NullCheck.notNull(this.findViewById(R.id.settings_barcode_image)); final TextView in_barcode_image_toggle = NullCheck .notNull(this.findViewById(R.id.settings_barcode_toggle_barcode)); final TextView in_pin_text = NullCheck.notNull(this.findViewById(R.id.settings_pin_text)); final CheckBox in_pin_reveal = NullCheck.notNull(this.findViewById(R.id.settings_reveal_password)); if (!this.account.pinRequired()) { in_pin_label.setVisibility(View.INVISIBLE); in_pin_text.setVisibility(View.INVISIBLE); in_pin_reveal.setVisibility(View.INVISIBLE); } final Button in_login = NullCheck.notNull(this.findViewById(R.id.settings_login)); final Button in_signup = NullCheck.notNull(this.findViewById(R.id.settings_signup)); this.sync_switch = findViewById(R.id.sync_switch); this.sync_table_row = findViewById(R.id.sync_table_row); this.sync_table_row.setVisibility(View.GONE); this.advanced_table_row = findViewById(R.id.link_advanced); this.advanced_table_row.setVisibility(View.GONE); this.advanced_table_row.setOnClickListener(view -> { final FragmentManager mgr = getFragmentManager(); final FragmentTransaction transaction = mgr.beginTransaction(); final SettingsAccountAdvancedFragment fragment = new SettingsAccountAdvancedFragment(); transaction.add(R.id.settings_account_container, fragment).addToBackStack("advanced").commit(); }); final TableRow in_privacy = findViewById(R.id.link_privacy); final TableRow in_license = findViewById(R.id.link_license); final TextView account_name = NullCheck.notNull(this.findViewById(android.R.id.text1)); final TextView account_subtitle = NullCheck.notNull(this.findViewById(android.R.id.text2)); final ImageView in_account_icon = NullCheck.notNull(this.findViewById(R.id.account_icon)); in_pin_text.setTransformationMethod(PasswordTransformationMethod.getInstance()); if (android.os.Build.VERSION.SDK_INT >= 21) { this.handle_pin_reveal(in_pin_text, in_pin_reveal); } else { in_pin_reveal.setVisibility(View.GONE); } final TableRow in_report_issue = findViewById(R.id.report_issue); if (this.account.getSupportEmail() == null) { in_report_issue.setVisibility(View.GONE); } else { in_report_issue.setVisibility(View.VISIBLE); in_report_issue.setOnClickListener(view -> { final Intent intent = new Intent(this, ReportIssueActivity.class); final Bundle b = new Bundle(); b.putInt("selected_account", this.account.getId()); intent.putExtras(b); startActivity(intent); }); } final TableRow in_support_center = findViewById(R.id.support_center); if (this.account.supportsHelpCenter()) { in_support_center.setVisibility(View.VISIBLE); in_support_center.setOnClickListener(view -> { final HSHelpStack stack = HSHelpStack.getInstance(this); final HSDeskGear gear = new HSDeskGear("https://nypl.desk.com/", "4GBRmMv8ZKG8fGehhA", null); stack.setGear(gear); stack.showHelp(this); }); } else { in_support_center.setVisibility(View.GONE); } //Get labels from the current authentication document. final AuthenticationDocumentType auth_doc = docs.getAuthenticationDocument(); in_barcode_label.setText(auth_doc.getLabelLoginUserID()); in_pin_label.setText(auth_doc.getLabelLoginPassword()); final TableLayout in_table_with_code = NullCheck .notNull(this.findViewById(R.id.settings_login_table_with_code)); in_table_with_code.setVisibility(View.GONE); final TableLayout in_table_signup = NullCheck.notNull(this.findViewById(R.id.settings_signup_table)); // boolean locationpermission = false; // if (ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { // locationpermission = true; // } // else // { // ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1); // } if (this.account.supportsCardCreator() || this.account.getCardCreatorUrl() != null) { in_table_signup.setVisibility(View.VISIBLE); } else { in_table_signup.setVisibility(View.GONE); } in_login.setOnClickListener(v -> this.onLoginWithBarcode()); final CheckBox in_age13_checkbox = NullCheck.notNull(this.findViewById(R.id.age13_checkbox)); if (Simplified.getSharedPrefs().contains("age13")) { in_age13_checkbox.setChecked(Simplified.getSharedPrefs().getBoolean("age13")); } else if (account.getId() == 2) { showAgeGateOptionsDialog(in_age13_checkbox); } in_age13_checkbox.setOnCheckedChangeListener(this::showAgeChangeConfirmation); if (this.account.needsAuth()) { in_login.setVisibility(View.VISIBLE); in_age13_checkbox.setVisibility(View.GONE); } else { in_login.setVisibility(View.GONE); in_age13_checkbox.setVisibility(View.VISIBLE); } if (this.account.supportsCardCreator()) { in_signup.setOnClickListener(v -> { final Intent cardcreator = new Intent(this, CardCreatorActivity.class); startActivity(cardcreator); }); in_signup.setText(R.string.need_card_button); } else if (this.account.getCardCreatorUrl() != null) { in_signup.setOnClickListener(v -> { final Intent e_card = new Intent(Intent.ACTION_VIEW); e_card.setData(Uri.parse(this.account.getCardCreatorUrl())); startActivity(e_card); }); in_signup.setText(R.string.need_card_button); } final boolean permission = Simplified.getSharedPrefs().getBoolean("syncPermissionGranted", this.account.getId()); this.sync_switch.setChecked(permission); /* If switching on, disable user interaction until server has responded. If switching off, disable applicable network requests by updating shared prefs flags. */ this.sync_switch.setOnCheckedChangeListener((buttonView, isChecked) -> { if (isChecked) { buttonView.setEnabled(false); annotationsManager.updateServerSyncPermissionStatus(true, (success) -> { if (success) { Simplified.getSharedPrefs().putBoolean("syncPermissionGranted", this.account.getId(), true); this.sync_switch.setChecked(true); } else { Simplified.getSharedPrefs().putBoolean("syncPermissionGranted", this.account.getId(), false); this.sync_switch.setChecked(false); } this.sync_switch.setEnabled(true); return kotlin.Unit.INSTANCE; }); } else { Simplified.getSharedPrefs().putBoolean("syncPermissionGranted", this.account.getId(), false); this.sync_switch.setChecked(false); } }); if (this.account.getPrivacyPolicy() != null) { in_privacy.setVisibility(View.VISIBLE); } else { in_privacy.setVisibility(View.GONE); } if (this.account.getContentLicense() != null) { in_license.setVisibility(View.VISIBLE); } else { in_license.setVisibility(View.GONE); } in_license.setOnClickListener(view -> { final Intent intent = new Intent(this, WebViewActivity.class); final Bundle b = new Bundle(); WebViewActivity.setActivityArguments(b, this.account.getContentLicense(), "Content Licenses", SimplifiedPart.PART_SETTINGS); intent.putExtras(b); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); }); in_privacy.setOnClickListener(view -> { final Intent intent = new Intent(this, WebViewActivity.class); final Bundle b = new Bundle(); WebViewActivity.setActivityArguments(b, this.account.getPrivacyPolicy(), "Privacy Policy", SimplifiedPart.PART_SETTINGS); intent.putExtras(b); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); }); this.navigationDrawerSetActionBarTitle(); this.account_name_text = account_name; this.account_subtitle_text = account_subtitle; this.account_icon = in_account_icon; this.barcode_text = in_barcode_text; this.pin_text = in_pin_text; this.barcode_image_toggle = in_barcode_image_toggle; this.barcode_image = in_barcode_image; this.login = in_login; this.table_with_code = in_table_with_code; this.table_signup = in_table_signup; final CheckBox in_eula_checkbox = NullCheck.notNull(this.findViewById(R.id.eula_checkbox)); final OptionType<EULAType> eula_opt = docs.getEULA(); if (eula_opt.isSome()) { final Some<EULAType> some_eula = (Some<EULAType>) eula_opt; final EULAType eula = some_eula.get(); in_eula_checkbox.setChecked(eula.eulaHasAgreed()); in_eula_checkbox.setEnabled(true); in_eula_checkbox.setOnCheckedChangeListener((button, checked) -> eula.eulaSetHasAgreed(checked)); if (eula.eulaHasAgreed()) { LOG.debug("EULA: agreed"); } else { LOG.debug("EULA: not agreed"); } } else { LOG.debug("EULA: unavailable"); } this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); }
From source file:com.example.android.navigationdrawerexample.Controller.PilihanController.java
private void selectItem(int position) { // update the main content by replacing fragments /*Fragment fragment = new PlanetFragment();*/ fragment = null;/*ww w .j a v a2 s.com*/ Bundle args = new Bundle(); switch (position) { case 0: fragment = new Fragment() { @Override public void onResume() { super.onResume(); new GetAllJadwalTask(PilihanController.this).execute(username); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); View view = inflater.inflate(R.layout.list_jadwal, container, false); GetAllJadwalListView = (ExpandableListView) view.findViewById(R.id.GetAllJadwalListView); ImageView buat = (ImageView) view.findViewById(R.id.button); //Button pilihan = (Button) view.findViewById(R.id.button9); if (role == 0) buat.setVisibility(View.GONE); else buat.setVisibility(View.VISIBLE); new GetAllJadwalTask(PilihanController.this).execute(username); GetAllJadwalListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { GetAllJadwalListView.expandGroup(groupPosition); return true; } }); GetAllJadwalListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { try { //Toast.makeText(getApplicationContext(), listDataChild2.get(listDataHeader2.get(groupPosition)).get(childPosition).toString(), Toast.LENGTH_LONG).show(); int jadwalp = listDataChild2.get(listDataHeader2.get(groupPosition)) .get(childPosition).getInt("Id"); int kelasp = listDataChild2.get(listDataHeader2.get(groupPosition)) .get(childPosition).getInt("Id_kelas"); //// JSONObject mahasiswaClicked = jsonArray.getJSONObject(groupPosition+childPosition); //// int jadwalp = mahasiswaClicked.getInt("Id"); //// int kelasp = mahasiswaClicked.getInt("Id_kelas"); Intent showDetails = new Intent(getActivity(), JadwalController.class); showDetails.putExtra("JadwalID", jadwalp); showDetails.putExtra("KelasID", kelasp); showDetails.putExtra("Username", username); showDetails.putExtra("View", "detailJadwal"); startActivity(showDetails); } catch (JSONException e) { e.printStackTrace(); //Toast.makeText(getApplicationContext(), "lala masuk ex", Toast.LENGTH_LONG).show(); } return false; } }); buat.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent showDetails = new Intent(getActivity(), JadwalController.class); //asumsi username gak null showDetails.putExtra("Username", username); showDetails.putExtra("View", "createJadwal"); startActivity(showDetails); } }); return view; } }; args.putString(FragmentOne.ITEM_NAME, dataList.get(position).getItemName()); args.putInt(FragmentOne.IMAGE_RESOURCE_ID, dataList.get(position).getImgResID()); args.putInt("role", 2); break; case 1: fragment = new RoleFragment(); args.putInt("role", 1); break; case 2: fragment = new Fragment() { @Override public void onResume() { super.onResume(); new GetAllEnrollTask(PilihanController.this).execute(username); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); view = inflater.inflate(R.layout.list_enroll, container, false); //GetAllEnrollListView = (ListView) view.findViewById(R.id.GetAllJadwalListView); ImageView enroll = (ImageView) view.findViewById(R.id.button); expListView = (ExpandableListView) view.findViewById(R.id.lvExp); new GetAllEnrollTask(PilihanController.this).execute(username); expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { //asumsikan kalo dipencet bisa ngeluarin infromasi asistennya //viewnya di view_profile_personal //kelasnya inten, nah loh pake controller mana nih?? //asumsikan gue punya kelas ProfileAsdos.java String userAsdos = listDataChild.get(listDataHeader.get(groupPosition)) .get(childPosition); Intent showDetails = new Intent(getActivity(), MenjabatController.class); showDetails.putExtra("Username", userAsdos); startActivity(showDetails); return false; } }); enroll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent showDetails = new Intent(getActivity(), EnrollController.class); showDetails.putExtra("Username", username); startActivity(showDetails); } }); return view; } }; args.putInt("role", 0); break; case 3: fragment = new Fragment() { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); View view = inflater.inflate(R.layout.choose_forum, container, false); Button buttonForumReply = (Button) view.findViewById(R.id.choose_forum_1); Button buttonForumForum = (Button) view.findViewById(R.id.choose_forum_2); Button buttonForumPolling = (Button) view.findViewById(R.id.choose_forum_3); buttonForumReply.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), ForumQA.class); intent.putExtra("Username", username); startActivity(intent); } }); buttonForumForum.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), ForumRequest.class); intent.putExtra("Username", username); startActivity(intent); } }); buttonForumPolling.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), ForumPolling.class); intent.putExtra("Username", username); startActivity(intent); } }); return view; } }; args.putInt("role", 3); break; case 4: //ProfileController profileController2 = new ProfileController(username); if (role == 2) { fragment = new Fragment() { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); view = inflater.inflate(R.layout.admin, container, false); //GetAllEnrollListView = (ListView) view.findViewById(R.id.GetAllJadwalListView); Button kelas = (Button) view.findViewById(R.id.button9); Button role = (Button) view.findViewById(R.id.button10); Button database = (Button) view.findViewById(R.id.button11); Button forum = (Button) view.findViewById(R.id.button12); kelas.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent showDetails = new Intent(getActivity(), KelasController.class); //asumsi username gak null showDetails.putExtra("Username", username); showDetails.putExtra("View", "listKelas"); startActivity(showDetails); } }); role.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent showDetails = new Intent(getActivity(), RoleController.class); //asumsi username gak null showDetails.putExtra("Username", username); startActivity(showDetails); } }); database.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent showDetails = new Intent(getActivity(), Database.class); startActivity(showDetails); } }); forum.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent showDetails = new Intent(getActivity(), AdminThread.class); startActivity(showDetails); } }); return view; } }; } else { fragment = new FragmentOne(); Toast.makeText(getApplicationContext(), "Hei Anda Bukan Admin", Toast.LENGTH_LONG).show(); } args.putInt("role", 4); break; case 5: session.logoutUser(); finish(); return; } /*args.putInt(PlanetFragment.ARG_PLANET_NUMBER, position);*/ fragment.setArguments(args); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mPlanetTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:org.proninyaroslav.libretorrent.fragments.MainFragment.java
private void showBlankFragment() { if (Utils.isTablet(activity.getApplicationContext())) { FragmentManager fm = getFragmentManager(); BlankFragment blank = BlankFragment.newInstance(); fm.beginTransaction().replace(R.id.detail_torrent_fragmentContainer, blank) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE).commitAllowingStateLoss(); }//from w w w .ja va 2s . co m }
From source file:com.geecko.QuickLyric.MainActivity.java
private LyricsViewFragment init(FragmentManager fragmentManager, boolean startEmpty) { LyricsViewFragment lyricsViewFragment = (LyricsViewFragment) fragmentManager .findFragmentByTag(LYRICS_FRAGMENT_TAG); if (lyricsViewFragment == null || lyricsViewFragment.isDetached()) lyricsViewFragment = new LyricsViewFragment(); lyricsViewFragment.startEmpty(startEmpty); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.setCustomAnimations(R.animator.slide_in_end, R.animator.slide_out_start, R.animator.slide_in_start, R.animator.slide_out_end); if (!lyricsViewFragment.isAdded()) { fragmentTransaction.add(id.main_fragment_container, lyricsViewFragment, LYRICS_FRAGMENT_TAG); }//from ww w. j a v a2s.co m Fragment[] activeFragments = getActiveFragments(); displayedFragment = getDisplayedFragment(activeFragments); for (Fragment fragment : activeFragments) if (fragment != null) { if (fragment != displayedFragment && !fragment.isHidden()) { fragmentTransaction.hide(fragment); fragment.onHiddenChanged(true); } else if (fragment == displayedFragment) fragmentTransaction.show(fragment); } fragmentTransaction.commit(); return lyricsViewFragment; }
From source file:com.example.search.car.pools.welcome.java
private void set_fragment(Fragment fragment) { // TODO Auto-generated method stub FragmentManager fm = getFragmentManager(); FragmentTransaction fragmentTransaction = fm.beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment, frag_tag); fragmentTransaction.commit();// w w w. j a v a2 s. com }
From source file:com.example.search.car.pools.welcome.java
public void onBackPressed() { if (canExit) { super.onBackPressed(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);/*from w w w .java2 s. co m*/ } else { // Fragment fm = getFragmentManager().findFragmentByTag("Search"); if (frag_tag != "Search") { svg_search = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.search1); iv_search.setImageDrawable(svg_search.createPictureDrawable()); rlSearch.setBackgroundColor(Color.parseColor("#00ca98")); l_search.setBackground(getResources().getDrawable(R.drawable.white_circle_side_menu)); svg_dashboard = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.dashboard); iv_dashboard.setImageDrawable(svg_dashboard.createPictureDrawable()); rlDashboard.setBackgroundColor(Color.parseColor("#2C3E50")); l_dashboard.setBackground(getResources().getDrawable(R.drawable.search_blue)); svg_cities = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.city); iv_cities.setImageDrawable(svg_cities.createPictureDrawable()); rlCities.setBackgroundColor(Color.parseColor("#2C3E50")); l_cities.setBackground(getResources().getDrawable(R.drawable.search_blue)); FragmentManager fm = getFragmentManager(); FragmentTransaction fragmentTransaction = fm.beginTransaction(); fragmentTransaction.replace(R.id.content_frame, new Search()); fragmentTransaction.commit(); frag_tag = "Search"; } else { canExit = true; Toast.makeText(getApplicationContext(), "Press again to exit", Toast.LENGTH_SHORT).show(); } } mHandler.sendEmptyMessageDelayed(1, 2000/* time interval to next press in milli second */);// if not // pressed // within // 2 // seconds // then // will // be // setted(canExit) // as // false }