List of usage examples for android.app Fragment setArguments
public void setArguments(Bundle args)
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
public void showMap(boolean popBackStack) { if (popBackStack) { popBackStackFull();/* www. j a va 2s .c o m*/ } FragmentTransaction ft; ft = fm.beginTransaction(); Fragment f = new RMBTMapFragment(); Bundle bundle = new Bundle(); bundle.putBoolean(RMBTMapFragment.OPTION_ENABLE_ALL_GESTURES, true); bundle.putBoolean(RMBTMapFragment.OPTION_SHOW_INFO_TOAST, true); bundle.putBoolean(RMBTMapFragment.OPTION_ENABLE_CONTROL_BUTTONS, true); f.setArguments(bundle); ft.replace(R.id.fragment_content, f, AppConstants.PAGE_TITLE_MAP); ft.addToBackStack(AppConstants.PAGE_TITLE_MAP); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commit(); refreshActionBar(AppConstants.PAGE_TITLE_MAP); }
From source file:pace.cs389.team2.quickfitness.MainActivity.java
public void selectItem(int position) { Fragment fragment = null; Bundle args = new Bundle(); switch (position) { case 0://from w w w . j a v a 2 s. co m fragment = new FragmentOne(); args.putString(FragmentOne.ITEM_NAME, mDataList.get(position).getmNameItem()); args.putInt(FragmentOne.IMAGE_RESOURCE_ID, mDataList.get(position).getmIconRes()); break; case 1: fragment = new FragmentOne(); args.putString(FragmentOne.ITEM_NAME, mDataList.get(position).getmNameItem()); args.putInt(FragmentOne.IMAGE_RESOURCE_ID, mDataList.get(position).getmIconRes()); break; case 2: fragment = new FragmentOne(); args.putString(FragmentOne.ITEM_NAME, mDataList.get(position).getmNameItem()); args.putInt(FragmentOne.IMAGE_RESOURCE_ID, mDataList.get(position).getmIconRes()); break; case 3: fragment = new FragmentOne(); args.putString(FragmentOne.ITEM_NAME, mDataList.get(position).getmNameItem()); args.putInt(FragmentOne.IMAGE_RESOURCE_ID, mDataList.get(position).getmIconRes()); break; case 4: fragment = new FragmentOne(); args.putString(FragmentOne.ITEM_NAME, mDataList.get(position).getmNameItem()); args.putInt(FragmentOne.IMAGE_RESOURCE_ID, mDataList.get(position).getmIconRes()); break; case 5: fragment = new FragmentOne(); args.putString(FragmentOne.ITEM_NAME, mDataList.get(position).getmNameItem()); args.putInt(FragmentOne.IMAGE_RESOURCE_ID, mDataList.get(position).getmIconRes()); break; case 6: fragment = new FragmentOne(); args.putString(FragmentOne.ITEM_NAME, mDataList.get(position).getmNameItem()); args.putInt(FragmentOne.IMAGE_RESOURCE_ID, mDataList.get(position).getmIconRes()); break; default: break; } fragment.setArguments(args); FragmentManager frgManager = getFragmentManager(); frgManager.beginTransaction().replace(R.id.content_place_holder, fragment).commit(); mDrawerList.setItemChecked(position, true); setTitle(mDataList.get(position).getmNameItem()); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:me.isassist.isa.MainActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override/*w w w . j a va 2 s . c om*/ public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); Fragment fragment = new ListFragment(); Bundle args = new Bundle(); if (mLastLocation == null) { Toast.makeText(this, "Waiting for the location...", Toast.LENGTH_LONG).show(); return false; } switch (id) { case R.id.nav_atms: { args.putSerializable("API_TYPE", Bihapi.CASH_MACHINES); mListType = Bihapi.CASH_MACHINES; break; } case R.id.nav_bikes: { args.putSerializable("API_TYPE", Bihapi.VETURILO); mListType = Bihapi.VETURILO; break; } case R.id.nav_city_offices: { args.putSerializable("API_TYPE", Bihapi.CITY_OFFICES); mListType = Bihapi.CITY_OFFICES; break; } case R.id.nav_dormitories: { args.putSerializable("API_TYPE", Bihapi.DORMITORIES); mListType = Bihapi.DORMITORIES; break; } case R.id.nav_hotels: { args.putSerializable("API_TYPE", Bihapi.HOTELS); mListType = Bihapi.HOTELS; break; } case R.id.nav_pharmacies: { args.putSerializable("API_TYPE", Bihapi.PHARMACIES); mListType = Bihapi.PHARMACIES; break; } case R.id.nav_sport_fields: { args.putSerializable("API_TYPE", Bihapi.SPORT_FIELDS); mListType = Bihapi.SPORT_FIELDS; break; } case R.id.nav_swimming: { args.putSerializable("API_TYPE", Bihapi.SWIMMING_POOLS); mListType = Bihapi.SWIMMING_POOLS; break; } case R.id.nav_police_offices: { args.putSerializable("API_TYPE", Bihapi.POLICE_OFFICES); mListType = Bihapi.POLICE_OFFICES; break; } case R.id.nav_theaters: { args.putSerializable("API_TYPE", Bihapi.THEATRES); mListType = Bihapi.THEATRES; break; } } fragment.setArguments(args); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.fragment_container, fragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:co.taqat.call.CallActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); instance = this; if (getResources().getBoolean(R.bool.orientation_portrait_only)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }/* ww w . j a va 2 s .c om*/ getWindow().addFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); setContentView(R.layout.call); isTransferAllowed = getApplicationContext().getResources().getBoolean(R.bool.allow_transfers); if (!BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) { BluetoothManager.getInstance().initBluetooth(); } cameraNumber = AndroidCameraConfiguration.retrieveCameras().length; try { // Yeah, this is hidden field. field = PowerManager.class.getClass().getField("PROXIMITY_SCREEN_OFF_WAKE_LOCK").getInt(null); } catch (Throwable ignored) { } powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = powerManager.newWakeLock(field, getLocalClassName()); mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mProximity = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); mListener = new LinphoneCoreListenerBase() { @Override public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) { displayMissedChats(); } @Override public void callState(LinphoneCore lc, final LinphoneCall call, LinphoneCall.State state, String message) { if (LinphoneManager.getLc().getCallsNb() == 0) { finish(); return; } if (state == State.IncomingReceived) { startIncomingCallActivity(); return; } else if (state == State.Paused || state == State.PausedByRemote || state == State.Pausing) { if (LinphoneManager.getLc().getCurrentCall() != null) { enabledVideoButton(false); } if (isVideoEnabled(call)) { showAudioView(); } } else if (state == State.Resuming) { if (LinphonePreferences.instance().isVideoEnabled()) { status.refreshStatusItems(call, isVideoEnabled(call)); if (call.getCurrentParamsCopy().getVideoEnabled()) { showVideoView(); } } if (LinphoneManager.getLc().getCurrentCall() != null) { enabledVideoButton(true); } } else if (state == State.StreamsRunning) { switchVideo(isVideoEnabled(call)); enableAndRefreshInCallActions(); if (status != null) { videoProgress.setVisibility(View.GONE); status.refreshStatusItems(call, isVideoEnabled(call)); } } else if (state == State.CallUpdatedByRemote) { // If the correspondent proposes video while audio call boolean videoEnabled = LinphonePreferences.instance().isVideoEnabled(); if (!videoEnabled) { acceptCallUpdate(false); } boolean remoteVideo = call.getRemoteParams().getVideoEnabled(); boolean localVideo = call.getCurrentParamsCopy().getVideoEnabled(); boolean autoAcceptCameraPolicy = true;//LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests(); if (remoteVideo && !localVideo && !autoAcceptCameraPolicy && !LinphoneManager.getLc().isInConference()) { showAcceptCallUpdateDialog(); timer = new CountDownTimer(SECONDS_BEFORE_DENYING_CALL_UPDATE, 1000) { public void onTick(long millisUntilFinished) { } public void onFinish() { //TODO dismiss dialog acceptCallUpdate(false); } }.start(); /*showAcceptCallUpdateDialog(); timer = new CountDownTimer(SECONDS_BEFORE_DENYING_CALL_UPDATE, 1000) { public void onTick(long millisUntilFinished) { } public void onFinish() { //TODO dismiss dialog } }.start();*/ } // else if (remoteVideo && !LinphoneManager.getLc().isInConference() && autoAcceptCameraPolicy) { // mHandler.post(new Runnable() { // @Override // public void run() { // acceptCallUpdate(true); // } // }); // } } refreshIncallUi(); transfer.setEnabled(LinphoneManager.getLc().getCurrentCall() != null); } @Override public void callEncryptionChanged(LinphoneCore lc, final LinphoneCall call, boolean encrypted, String authenticationToken) { if (status != null) { if (call.getCurrentParamsCopy().getMediaEncryption().equals(LinphoneCore.MediaEncryption.ZRTP) && !call.isAuthenticationTokenVerified()) { status.showZRTPDialog(call); } status.refreshStatusItems(call, call.getCurrentParamsCopy().getVideoEnabled()); } } }; if (findViewById(R.id.fragmentContainer) != null) { initUI(); if (LinphoneManager.getLc().getCallsNb() > 0) { LinphoneCall call = LinphoneManager.getLc().getCalls()[0]; if (LinphoneUtils.isCallEstablished(call)) { enableAndRefreshInCallActions(); } } if (savedInstanceState != null) { // Fragment already created, no need to create it again (else it will generate a memory leak with duplicated fragments) isSpeakerEnabled = savedInstanceState.getBoolean("Speaker"); isMicMuted = savedInstanceState.getBoolean("Mic"); isVideoCallPaused = savedInstanceState.getBoolean("VideoCallPaused"); refreshInCallActions(); return; } else { isSpeakerEnabled = LinphoneManager.getLc().isSpeakerEnabled(); isMicMuted = LinphoneManager.getLc().isMicMuted(); } Fragment callFragment; if (isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) { callFragment = new CallVideoFragment(); videoCallFragment = (CallVideoFragment) callFragment; displayVideoCall(false); LinphoneManager.getInstance().routeAudioToSpeaker(); isSpeakerEnabled = true; } else { callFragment = new CallAudioFragment(); audioCallFragment = (CallAudioFragment) callFragment; } if (BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) { BluetoothManager.getInstance().routeAudioToBluetooth(); } callFragment.setArguments(getIntent().getExtras()); getFragmentManager().beginTransaction().add(R.id.fragmentContainer, callFragment) .commitAllowingStateLoss(); } }
From source file:org.linphone.CallActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); instance = this; if (getResources().getBoolean(R.bool.orientation_portrait_only)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }//from w ww. j a va 2 s.c o m getWindow().addFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); setContentView(R.layout.call); isTransferAllowed = getApplicationContext().getResources().getBoolean(R.bool.allow_transfers); cameraNumber = AndroidCameraConfiguration.retrieveCameras().length; mEncoderTexts = new HashMap<String, String>(); mDecoderTexts = new HashMap<String, String>(); mListener = new LinphoneCoreListenerBase() { @Override public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) { displayMissedChats(); } @Override public void callState(LinphoneCore lc, final LinphoneCall call, LinphoneCall.State state, String message) { if (LinphoneManager.getLc().getCallsNb() == 0) { finish(); return; } if (state == State.IncomingReceived) { startIncomingCallActivity(); return; } else if (state == State.Paused || state == State.PausedByRemote || state == State.Pausing) { if (LinphoneManager.getLc().getCurrentCall() != null) { enabledVideoButton(false); } if (isVideoEnabled(call)) { showAudioView(); } } else if (state == State.Resuming) { if (LinphonePreferences.instance().isVideoEnabled()) { status.refreshStatusItems(call, isVideoEnabled(call)); if (call.getCurrentParams().getVideoEnabled()) { showVideoView(); } } if (LinphoneManager.getLc().getCurrentCall() != null) { enabledVideoButton(true); } } else if (state == State.StreamsRunning) { switchVideo(isVideoEnabled(call)); enableAndRefreshInCallActions(); if (status != null) { videoProgress.setVisibility(View.GONE); status.refreshStatusItems(call, isVideoEnabled(call)); } } else if (state == State.CallUpdatedByRemote) { // If the correspondent proposes video while audio call boolean videoEnabled = LinphonePreferences.instance().isVideoEnabled(); if (!videoEnabled) { acceptCallUpdate(false); } boolean remoteVideo = call.getRemoteParams().getVideoEnabled(); boolean localVideo = call.getCurrentParams().getVideoEnabled(); boolean autoAcceptCameraPolicy = LinphonePreferences.instance() .shouldAutomaticallyAcceptVideoRequests(); if (remoteVideo && !localVideo && !autoAcceptCameraPolicy && !LinphoneManager.getLc().isInConference()) { showAcceptCallUpdateDialog(); createTimerForDialog(SECONDS_BEFORE_DENYING_CALL_UPDATE); } // else if (remoteVideo && !LinphoneManager.getLc().isInConference() && autoAcceptCameraPolicy) { // mHandler.post(new Runnable() { // @Override // public void run() { // acceptCallUpdate(true); // } // }); // } } refreshIncallUi(); transfer.setEnabled(LinphoneManager.getLc().getCurrentCall() != null); } @Override public void callEncryptionChanged(LinphoneCore lc, final LinphoneCall call, boolean encrypted, String authenticationToken) { if (status != null) { if (call.getCurrentParams().getMediaEncryption().equals(LinphoneCore.MediaEncryption.ZRTP) && !call.isAuthenticationTokenVerified()) { status.showZRTPDialog(call); } status.refreshStatusItems(call, call.getCurrentParams().getVideoEnabled()); } } }; if (findViewById(R.id.fragmentContainer) != null) { initUI(); if (LinphoneManager.getLc().getCallsNb() > 0) { LinphoneCall call = LinphoneManager.getLc().getCalls()[0]; if (LinphoneUtils.isCallEstablished(call)) { enableAndRefreshInCallActions(); } } if (savedInstanceState != null) { // Fragment already created, no need to create it again (else it will generate a memory leak with duplicated fragments) isSpeakerEnabled = savedInstanceState.getBoolean("Speaker"); isMicMuted = savedInstanceState.getBoolean("Mic"); isVideoCallPaused = savedInstanceState.getBoolean("VideoCallPaused"); if (savedInstanceState.getBoolean("AskingVideo")) { showAcceptCallUpdateDialog(); TimeRemind = savedInstanceState.getLong("TimeRemind"); createTimerForDialog(TimeRemind); } refreshInCallActions(); return; } else { isSpeakerEnabled = LinphoneManager.getLc().isSpeakerEnabled(); isMicMuted = LinphoneManager.getLc().isMicMuted(); } Fragment callFragment; if (isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) { callFragment = new CallVideoFragment(); videoCallFragment = (CallVideoFragment) callFragment; displayVideoCall(false); LinphoneManager.getInstance().routeAudioToSpeaker(); isSpeakerEnabled = true; } else { callFragment = new CallAudioFragment(); audioCallFragment = (CallAudioFragment) callFragment; } if (BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) { BluetoothManager.getInstance().routeAudioToBluetooth(); } callFragment.setArguments(getIntent().getExtras()); getFragmentManager().beginTransaction().add(R.id.fragmentContainer, callFragment) .commitAllowingStateLoss(); } }
From source file:com.mariogrip.octodroid.mainActivity.java
private void selectItem(int position) { pos = position;/*from w ww. j a va 2 s .c o m*/ Fragment fragment = new main_card(); if (betamode) { fragment = new main_card_BETA(); switch (position) { case 0: fragment = new main_card_BETA(); break; case 6: fragment = new main_card_BETA(); pos = 0; position = 0; Intent i = new Intent(this, settings.class); startActivityForResult(i, RESULT_SETTINGS); break; case 1: fragment = new temp_card(); break; case 2: fragment = new cont_card(); break; case 3: fragment = new file_card(); break; case 4: fragment = new con_card(); break; case 5: fragment = new custom_card(); break; default: break; } } else { fragment = new main_card(); switch (position) { case 0: fragment = new main_card(); break; case 6: fragment = new main_card(); pos = 0; position = 0; Intent i = new Intent(this, settings.class); startActivityForResult(i, RESULT_SETTINGS); break; case 1: fragment = new temp_card(); break; case 2: fragment = new cont_card(); break; case 3: fragment = new file_card(); break; case 4: fragment = new con_card(); break; case 5: fragment = new custom_card(); break; default: break; } } Bundle args = new Bundle(); 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 nawList.setItemChecked(position, true); setTitle(nawTitle[position]); nawlay.closeDrawer(nawList); }
From source file:hu.zelena.guide.MainActivity.java
public void selectDrawerItem(MenuItem menuItem) { Fragment fragment = null; Bundle bundle = new Bundle(); switch (menuItem.getItemId()) { case R.id.alcatel_frag: fragment = new PhonesFragment(); brand = "Alcatel"; analyticINFO = brand;/*from ww w.j a v a 2 s.co m*/ break; case R.id.apple_frag: fragment = new PhonesFragment(); brand = "Apple"; analyticINFO = brand; break; case R.id.balckberry_frag: fragment = new PhonesFragment(); brand = "BlackBerry"; analyticINFO = brand; break; case R.id.cat_frag: fragment = new PhonesFragment(); brand = "CAT"; analyticINFO = brand; break; case R.id.honor_frag: fragment = new PhonesFragment(); brand = "Honor"; analyticINFO = brand; break; case R.id.HTC_frag: fragment = new PhonesFragment(); brand = "HTC"; analyticINFO = brand; break; case R.id.huawei_frag: fragment = new PhonesFragment(); brand = "Huawei"; analyticINFO = brand; break; case R.id.lenovo_frag: fragment = new PhonesFragment(); brand = "Lenovo"; analyticINFO = brand; break; case R.id.lg_frag: fragment = new PhonesFragment(); brand = "LG"; analyticINFO = brand; break; case R.id.samsung_frag: fragment = new PhonesFragment(); brand = "Samsung"; analyticINFO = brand; break; case R.id.sony_frag: fragment = new PhonesFragment(); brand = "Sony"; analyticINFO = brand; break; case R.id.watch_frag: fragment = new WatchFragment(); analyticINFO = "Watch"; break; case R.id.tablet_frag: fragment = new TabletFragment(); analyticINFO = "Tablet"; break; case R.id.postpaid_frag: fragment = new PostPaidFragment(); analyticINFO = "PostPaid"; break; case R.id.prepaid_frag: fragment = new PrePaidFragment(); analyticINFO = "PrePaid"; break; case R.id.net_frag: fragment = new InternetFragment(); analyticINFO = "Net"; break; case R.id.magicbook_frag: fragment = new MagicbookFragment(); analyticINFO = "MagicBook"; break; case R.id.others_frag: fragment = new OthersFragment(); analyticINFO = "Others"; break; default: break; } if (fragment != null) { mTracker.send(new HitBuilders.EventBuilder().setCategory("Action") .setAction(analyticINFO + " drawer select").build()); firstFrag = false; bundle.putString("brand", brand); fragment.setArguments(bundle); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit(); } else { Intent i = new Intent(this, ErrorActivity.class); i.putExtra("error", "Nem sikerlt a FRAGMENT betltse. [Null object]"); startActivity(i); Log.e("MainActivity", "Error in creating fragment"); } // Kivlasztott kijellse menuItem.setChecked(true); // Cm bellts setTitle(menuItem.getTitle()); // Drawer bezrsa mDrawer.closeDrawers(); }