List of usage examples for android.app FragmentTransaction commit
public abstract int commit();
From source file:com.QuarkLabs.BTCeClient.MainActivity.java
/** * Displays selected fragment/*from www .j a va2s. c o m*/ * * @param position Position at the list (0-based) */ private void displayItem(final int position) { Fragment fragment = null; final FragmentManager fragmentManager = getFragmentManager(); switch (position) { case 0: fragment = mHomeFragment; fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); break; case 1: fragment = new OrdersBookFragment(); break; case 2: fragment = new ActiveOrdersFragment(); break; case 3: fragment = HistoryFragment.newInstance(ListType.Trades); break; case 4: fragment = HistoryFragment.newInstance(ListType.Transactions); break; case 5: fragment = new ChartsFragment(); break; case 6: fragment = new SettingsFragment(); break; case 7: fragment = new NotifiersFragment(); break; case 8: fragment = new HelpFragment(); break; default: break; } final Fragment fr = fragment; if (fr != null) { //delay in msecs int delay = 250; //post delayed for smooth behaviour new Handler().postDelayed(new Runnable() { @Override public void run() { FragmentTransaction transaction = fragmentManager.beginTransaction() .setCustomAnimations(R.animator.fade_in, R.animator.fade_out) .replace(R.id.content_frame, fr); if (position != 0) { transaction.addToBackStack(String.valueOf(position)); //name of fragment = position } transaction.commit(); setTitle(mDrawerListItems[position]); } }, delay); mDrawerList.setItemChecked(position, true); mDrawerList.setSelection(position); if (mDrawerLayout != null) { mDrawerLayout.closeDrawer(mDrawerList); } } }
From source file:com.matthewmitchell.peercoin_android_wallet.ui.AddressBookActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.address_book_content); final ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); final FragmentManager fragmentManager = getFragmentManager(); walletAddressesFragment = (WalletAddressesFragment) fragmentManager.findFragmentByTag(TAG_LEFT); sendingAddressesFragment = (SendingAddressesFragment) fragmentManager.findFragmentByTag(TAG_RIGHT); final FragmentTransaction removal = fragmentManager.beginTransaction(); if (walletAddressesFragment == null) walletAddressesFragment = new WalletAddressesFragment(); else//from w w w.ja v a 2s . co m removal.remove(walletAddressesFragment); if (sendingAddressesFragment == null) sendingAddressesFragment = new SendingAddressesFragment(); else removal.remove(sendingAddressesFragment); if (!removal.isEmpty()) { removal.commit(); fragmentManager.executePendingTransactions(); } final ViewPager pager = (ViewPager) findViewById(R.id.address_book_pager); if (pager != null) { pager.setAdapter( new TwoFragmentAdapter(fragmentManager, walletAddressesFragment, sendingAddressesFragment)); final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.address_book_pager_tabs); pagerTabs.addTabLabels(R.string.address_book_list_receiving_title, R.string.address_book_list_sending_title); pager.setOnPageChangeListener(pagerTabs); final int position = 1; pager.setCurrentItem(position); pager.setPageMargin(2); pager.setPageMarginDrawable(R.color.bg_less_bright); pagerTabs.onPageSelected(position); pagerTabs.onPageScrolled(position, 0, 0); } else { fragmentManager.beginTransaction() .add(R.id.wallet_addresses_fragment, walletAddressesFragment, TAG_LEFT) .add(R.id.sending_addresses_fragment, sendingAddressesFragment, TAG_RIGHT).commit(); } runAfterLoad(new Runnable() { @Override public void run() { updateFragments(); } }); }
From source file:de.lespace.apprtc.CallActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Thread.setDefaultUncaughtExceptionHandler(new UnhandledExceptionHandler(this)); // Set window styles for fullscreen-window size. Needs to be done before // adding content. requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().addFlags(/* ww w . j a v a 2 s . c om*/ LayoutParams.FLAG_FULLSCREEN | LayoutParams.FLAG_KEEP_SCREEN_ON | LayoutParams.FLAG_DISMISS_KEYGUARD | LayoutParams.FLAG_SHOW_WHEN_LOCKED | LayoutParams.FLAG_TURN_SCREEN_ON); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); setContentView(R.layout.activity_call); iceConnected = false; scalingType = ScalingType.SCALE_ASPECT_FILL; callFragment = new CallFragment(); hudFragment = new HudFragment(); // Create UI controls. localRender = (SurfaceViewRenderer) findViewById(R.id.local_video_view); remoteRender = (SurfaceViewRenderer) findViewById(R.id.remote_video_view); screenRender = (SurfaceViewRenderer) findViewById(R.id.remote_screen_view); localRenderLayout = (PercentFrameLayout) findViewById(R.id.local_video_layout); remoteRenderLayout = (PercentFrameLayout) findViewById(R.id.remote_video_layout); screenRenderLayout = (PercentFrameLayout) findViewById(R.id.remote_screen_layout); // Show/hide call control fragment on view click. View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View view) { toggleCallControlFragmentVisibility(); } }; localRender.setOnClickListener(listener); remoteRender.setOnClickListener(listener); screenRender.setOnClickListener(listener); //screensharing // Create video renderers. rootEglBase = EglBase.create(); localRender.init(rootEglBase.getEglBaseContext(), null); remoteRender.init(rootEglBase.getEglBaseContext(), null); screenRender.init(rootEglBase.getEglBaseContext(), null); localRender.setZOrderMediaOverlay(true); screenRender.setZOrderMediaOverlay(true); updateVideoView(); setResult(RESULT_CANCELED); if (!broadcastIsRegistered) { registerReceiver(broadcast_reciever, new IntentFilter("finish_CallActivity")); registerReceiver(broadcast_reciever, new IntentFilter("finish_screensharing")); broadcastIsRegistered = true; } callFragment = new CallFragment(); hudFragment = new HudFragment(); // Send intent arguments to fragments. callFragment.setArguments(getIntent().getExtras()); hudFragment.setArguments(getIntent().getExtras()); // Activate call and HUD fragments and start the call. FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.add(R.id.call_fragment_container, callFragment); ft.add(R.id.hud_fragment_container, hudFragment); ft.commit(); // For command line execution run connection for <runTimeMs> and exit. if (commandLineRun && runTimeMs > 0) { (new Handler()).postDelayed(new Runnable() { @Override public void run() { disconnect(false); } }, runTimeMs); } // Create and audio manager that will take care of audio routing, // audio modes, audio device enumeration etc. audioManager = AppRTCAudioManager.create(this, new Runnable() { // This method will be called each time the audio state (number and // type of devices) has been changed. @Override public void run() { onAudioManagerChangedState(); } }); // Store existing audio settings and change audio mode to // MODE_IN_COMMUNICATION for best possible VoIP performance. Log.d(TAG, "Initializing the audio manager..."); audioManager.init(); peerConnectionClient = PeerConnectionClient.getInstance(true); peerConnectionClient.createPeerConnectionFactory(CallActivity.this, peerConnectionParameters, this); peerConnectionClient.createPeerConnection(rootEglBase.getEglBaseContext(), localRender, remoteRender, screenRender, roomConnectionParameters.initiator); logAndToast("Creating OFFER..."); // Create offer. Offer SDP will be sent to answering client in // PeerConnectionEvents.onLocalDescription event. peerConnectionClient.createOffer(); }
From source file:com.ternup.caddisfly.fragment.ResultFragment.java
private void goBack() { FragmentManager fm = getFragmentManager(); try {/* w w w .j a va 2s . c o m*/ if (fm.getBackStackEntryCount() > 0) { fm.popBackStack(); fm.executePendingTransactions(); } else { Fragment fragment = new HomeFragment(); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.executePendingTransactions(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.replace(R.id.container, fragment, "0"); ft.addToBackStack(null); ft.commit(); fm.executePendingTransactions(); ListView drawerList = (ListView) getActivity().findViewById(R.id.navigation_drawer); drawerList.setItemChecked(0, true); drawerList.setSelection(0); } } catch (Exception e) { e.printStackTrace(); } }
From source file:produvia.com.scanner.DevicesActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mErrorOccurred = false;//from ww w . j a v a 2s.co m mErrorMessage = ""; setContentView(R.layout.activity_devices); listFragment = new DevicesFragment(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.main_fragment, listFragment); transaction.addToBackStack(null); // Commit the transaction transaction.commit(); //Start running the discovery service in the background //any discovered services will be reported on the onTaskUpdate callback: boolean run_discovery = true; Calendar time_now = Calendar.getInstance(); if (mScanCycleCounter > 0 && mLastScanStartedAt != null) { if (time_now.getTimeInMillis() - mLastScanStartedAt.getTimeInMillis() < MINIMUM_TIME_BETWEEN_SCANS_MILLIS) run_discovery = false; } if (run_discovery) { mLastScanStartedAt = time_now; showScanProgress(true); WeaverSdkApi.discoveryService(this, true); } //fetch the services that have already been discovered in previous scans //these services will be returned in the onTaskCompleted callback: WeaverSdkApi.servicesGet(this, null); }
From source file:me.pzheng.conn.MainActivity.java
@Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments FragmentManager fm = getFragmentManager(); FragmentTransaction transaction = fm.beginTransaction(); // debug code // Toast.makeText(this, "Menu item selected -> " + position, Toast.LENGTH_SHORT).show(); Fragment fragment;//w w w. j av a2 s . c o m switch (position) { case 0: //connect fragment = fm.findFragmentByTag(ConnectFragment.TAG); if (fragment == null) { fragment = new ConnectFragment(); } transaction.replace(R.id.container, fragment, ConnectFragment.TAG); transaction.addToBackStack(null); transaction.commit(); break; case 1: //settings /* fragment = getFragmentManager().findFragmentByTag(StatsFragment.TAG); if (fragment == null) { fragment = new StatsFragment(); } getFragmentManager().beginTransaction().replace(R.id.container, fragment, StatsFragment.TAG).commit(); */ fragment = fm.findFragmentByTag(SettingsFragment.TAG); if (fragment == null) { fragment = new SettingsFragment(); } transaction.replace(R.id.container, fragment, SettingsFragment.TAG); transaction.addToBackStack(null); transaction.commit(); break; case 2: //about fragment = fm.findFragmentByTag(AboutFragment.TAG); if (fragment == null) { fragment = new AboutFragment(); } transaction.replace(R.id.container, fragment, AboutFragment.TAG); transaction.addToBackStack(null); transaction.commit(); break; } //transaction.commit(); }
From source file:com.ternup.caddisfly.fragment.DetailsFragment.java
private void goBack() { FragmentManager fm = getFragmentManager(); try {/*from ww w. j a va 2s .com*/ if (fm.getBackStackEntryCount() > 0) { fm.popBackStack(); fm.executePendingTransactions(); } else { Fragment fragment = new HomeFragment(); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.replace(R.id.container, fragment, "0"); ft.addToBackStack(null); ft.commit(); fm.executePendingTransactions(); ListView drawerList = (ListView) getActivity().findViewById(R.id.navigation_drawer); drawerList.setItemChecked(0, true); drawerList.setSelection(0); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.telestax.restcomm_olympus.CallActivity.java
public void onClick(View view) { if (view.getId() == R.id.button_hangup) { if (pendingConnection != null) { // incoming ringing lblStatus.setText("Rejecting Call..."); pendingConnection.reject();/*from w w w .j a v a2 s . c o m*/ pendingConnection = null; } else { if (connection != null) { // incoming established or outgoing any state (pending, connecting, connected) lblStatus.setText("Disconnecting Call..."); connection.disconnect(); connection = null; pendingConnection = null; } else { Log.e(TAG, "Error: not connected/connecting/pending"); } } finish(); } else if (view.getId() == R.id.button_answer) { if (pendingConnection != null) { lblStatus.setText("Answering Call..."); btnAnswer.setVisibility(View.INVISIBLE); btnAnswerAudio.setVisibility(View.INVISIBLE); acceptParams = new HashMap<String, Object>(); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_VIDEO_ENABLED, true); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_LOCAL_VIDEO, findViewById(R.id.local_video_layout)); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_REMOTE_VIDEO, findViewById(R.id.remote_video_layout)); // Check permissions asynchronously and then accept the call handlePermissions(true); } } else if (view.getId() == R.id.button_answer_audio) { if (pendingConnection != null) { lblStatus.setText("Answering Call..."); btnAnswer.setVisibility(View.INVISIBLE); btnAnswerAudio.setVisibility(View.INVISIBLE); acceptParams = new HashMap<String, Object>(); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_VIDEO_ENABLED, false); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_LOCAL_VIDEO, findViewById(R.id.local_video_layout)); acceptParams.put(RCConnection.ParameterKeys.CONNECTION_REMOTE_VIDEO, findViewById(R.id.remote_video_layout)); // Check permissions asynchronously and then accept the call handlePermissions(false); } } else if (view.getId() == R.id.button_keypad) { keypadFragment.setConnection(connection); // show keypad FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.show(keypadFragment); ft.commit(); } else if (view.getId() == R.id.button_mute_audio) { if (connection != null) { if (!muteAudio) { btnMuteAudio.setImageResource(R.drawable.audio_muted_50x50); } else { btnMuteAudio.setImageResource(R.drawable.audio_active_50x50); } muteAudio = !muteAudio; connection.setAudioMuted(muteAudio); } } else if (view.getId() == R.id.button_mute_video) { if (connection != null) { if (!muteVideo) { btnMuteVideo.setImageResource(R.drawable.video_muted_50x50); } else { btnMuteVideo.setImageResource(R.drawable.video_active_50x50); } muteVideo = !muteVideo; connection.setVideoMuted(muteVideo); } } }
From source file:org.yuzhiqiang.itsmine.MainActivity.java
@Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); switch (position) { case 0://from w w w. jav a 2 s. c om fragmentTransaction.replace(R.id.container, new ItemListFragment(), ALL_ITEMS); break; case 1: fragmentTransaction.replace(R.id.container, new ItemListFragment(), TOP_LEVEL_ITEMS); break; case 2: fragmentTransaction.replace(R.id.container, new CategoryFragment()); break; case 3: fragmentTransaction.replace(R.id.container, new SettingsFragment()); break; } fragmentTransaction.commit(); }
From source file:com.vst.functionframework.ui.SupportActivity.java
/** * Fragment?//from ww w .j a v a 2 s. c o m * * @param resView ?? * @param targetFragment ??Fragment */ public void changeFragment(int resView, VstFragment targetFragment) { if (targetFragment.equals(currentKJFragment)) { return; } FragmentTransaction transaction = getFragmentManager().beginTransaction(); if (!targetFragment.isAdded()) { transaction.add(resView, targetFragment, targetFragment.getClass().getName()); } if (targetFragment.isHidden()) { transaction.show(targetFragment); targetFragment.onChange(); } if (currentKJFragment != null && currentKJFragment.isVisible()) { transaction.hide(currentKJFragment); } currentKJFragment = targetFragment; transaction.commit(); }