List of usage examples for android.support.v4.app DialogFragment show
public int show(FragmentTransaction transaction, String tag)
From source file:com.notepadlite.NoteViewFragment.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override// ww w . j a v a2 s . c o m public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Set values setRetainInstance(true); setHasOptionsMenu(true); // Get filename of saved note filename = getArguments().getString("filename"); // Change window title String title; try { title = listener.loadNoteTitle(filename); } catch (IOException e) { title = getResources().getString(R.string.view_note); } getActivity().setTitle(title); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(title, null, getResources().getColor(R.color.primary)); getActivity().setTaskDescription(taskDescription); } // Show the Up button in the action bar. ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Animate elevation change if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large") && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { LinearLayout noteViewEdit = (LinearLayout) getActivity().findViewById(R.id.noteViewEdit); LinearLayout noteList = (LinearLayout) getActivity().findViewById(R.id.noteList); noteList.animate().z(0f); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) noteViewEdit.animate() .z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation_land)); else noteViewEdit.animate().z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation)); } // Set up content view noteContents = (TextView) getActivity().findViewById(R.id.textView); // Apply theme SharedPreferences pref = getActivity().getSharedPreferences(getActivity().getPackageName() + "_preferences", Context.MODE_PRIVATE); ScrollView scrollView = (ScrollView) getActivity().findViewById(R.id.scrollView); String theme = pref.getString("theme", "light-sans"); if (theme.contains("light")) { noteContents.setTextColor(getResources().getColor(R.color.text_color_primary)); noteContents.setBackgroundColor(getResources().getColor(R.color.window_background)); scrollView.setBackgroundColor(getResources().getColor(R.color.window_background)); } if (theme.contains("dark")) { noteContents.setTextColor(getResources().getColor(R.color.text_color_primary_dark)); noteContents.setBackgroundColor(getResources().getColor(R.color.window_background_dark)); scrollView.setBackgroundColor(getResources().getColor(R.color.window_background_dark)); } if (theme.contains("sans")) noteContents.setTypeface(Typeface.SANS_SERIF); if (theme.contains("serif")) noteContents.setTypeface(Typeface.SERIF); if (theme.contains("monospace")) noteContents.setTypeface(Typeface.MONOSPACE); switch (pref.getString("font_size", "normal")) { case "smallest": noteContents.setTextSize(12); break; case "small": noteContents.setTextSize(14); break; case "normal": noteContents.setTextSize(16); break; case "large": noteContents.setTextSize(18); break; case "largest": noteContents.setTextSize(20); break; } // Load note contents try { contentsOnLoad = listener.loadNote(filename); } catch (IOException e) { showToast(R.string.error_loading_note); // Add NoteListFragment or WelcomeFragment Fragment fragment; if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-normal")) fragment = new NoteListFragment(); else fragment = new WelcomeFragment(); getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteListFragment") .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit(); } // Set TextView contents noteContents.setText(contentsOnLoad); // Show a toast message if this is the user's first time viewing a note final SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); firstLoad = sharedPref.getInt("first-load", 0); if (firstLoad == 0) { // Show dialog with info DialogFragment firstLoad = new FirstViewDialogFragment(); firstLoad.show(getFragmentManager(), "firstloadfragment"); // Set first-load preference to 1; we don't need to show the dialog anymore SharedPreferences.Editor editor = sharedPref.edit(); editor.putInt("first-load", 1); editor.apply(); } // Detect single and double-taps using GestureDetector final GestureDetector detector = new GestureDetector(getActivity(), new GestureDetector.OnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { return false; } @Override public void onShowPress(MotionEvent e) { } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { return false; } @Override public void onLongPress(MotionEvent e) { } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { return false; } @Override public boolean onDown(MotionEvent e) { return false; } }); detector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() { @Override public boolean onDoubleTap(MotionEvent e) { if (sharedPref.getBoolean("show_double_tap_message", true)) { SharedPreferences.Editor editor = sharedPref.edit(); editor.putBoolean("show_double_tap_message", false); editor.apply(); } Bundle bundle = new Bundle(); bundle.putString("filename", filename); Fragment fragment = new NoteEditFragment(); fragment.setArguments(bundle); getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteEditFragment") .commit(); return false; } @Override public boolean onDoubleTapEvent(MotionEvent e) { return false; } @Override public boolean onSingleTapConfirmed(MotionEvent e) { if (sharedPref.getBoolean("show_double_tap_message", true) && showMessage) { showToastLong(R.string.double_tap); showMessage = false; } return false; } }); noteContents.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { detector.onTouchEvent(event); return false; } }); }
From source file:com.nextgis.ngm_clink_monitoring.fragments.ObjectStatusFragment.java
@Override public void onResume() { super.onResume(); if (!mHasAccurateCoordinate) { mHasAccurateCoordinate = true;// ww w . ja va 2 s . co m DialogFragment coordRefiningDialog = new CoordinateRefiningDialog(); coordRefiningDialog.show(getActivity().getSupportFragmentManager(), "CoordinateRefining"); } }
From source file:com.mchp.android.PIC32_BTSK.PIC32_BTSK.java
public void showAbout() { // Get Version Name and Display in About dialog Context context = getApplicationContext(); try {/*w w w.j a va 2s . co m*/ String versionName = context.getPackageManager() .getPackageInfo(getApplicationContext().getPackageName(), 0).versionName; DialogFragment newFragment = new AboutDialogFragment(versionName); newFragment.show(getSupportFragmentManager(), "about"); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:de.schilldroid.carfuelly.Activities.CarDetailsActivity.java
public void initComponents() { // initialize components mViewName = (EditText) findViewById(R.id.car_details_name); mViewDescription = (EditText) findViewById(R.id.car_details_description); mViewManufacturer = (EditText) findViewById(R.id.car_details_manufacturer); mViewModel = (EditText) findViewById(R.id.car_details_model); mViewFirstRegistration = (EditText) findViewById(R.id.car_details_first_registration); mViewPower = (EditText) findViewById(R.id.car_details_power); mViewEngine = (EditText) findViewById(R.id.car_details_engine); mViewConfiguration = (EditText) findViewById(R.id.car_details_configuration); mViewPurchaseDate = (EditText) findViewById(R.id.car_details_purchase_date); mViewPrice = (EditText) findViewById(R.id.car_details_price); mViewLicensePlate = (EditText) findViewById(R.id.car_details_license_plate); mViewConsumptionUrban = (EditText) findViewById(R.id.car_details_consumption_urban); mViewConsumptionExtraUrban = (EditText) findViewById(R.id.car_details_consumption_extraurban); mViewConsumptionCombined = (EditText) findViewById(R.id.car_details_consumption_combined); // add date picker mViewFirstRegistration.setOnClickListener(new View.OnClickListener() { @Override/* w ww. j av a 2 s. co m*/ public void onClick(View v) { DialogFragment datePicker = new CarDetailsDatePickerFragment(); Bundle args = new Bundle(); args.putInt(Consts.CarDetails.DATE_PICKER_CONTEXT, Consts.CarDetails.DATE_PICKER_CONTEXT_FIRST_REGISTRATION); datePicker.setArguments(args); datePicker.show(getSupportFragmentManager(), "datePicker"); } }); mViewPurchaseDate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DialogFragment datePicker = new CarDetailsDatePickerFragment(); Bundle args = new Bundle(); args.putInt(Consts.CarDetails.DATE_PICKER_CONTEXT, Consts.CarDetails.DATE_PICKER_CONTEXT_PURCHASE_DATE); datePicker.setArguments(args); datePicker.show(getSupportFragmentManager(), "datePicker"); } }); // init listview mViewTankList = (ListView) findViewById(R.id.car_details_tank_list); mTankListAdapter = new CarDetailTankListAdapter(this); mViewTankList.setAdapter(mTankListAdapter); // implement add tank button mViewAddTank = (ImageView) findViewById(R.id.car_details_tank_add); mViewAddTank.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mTankListAdapter.addTank(); } }); // setup toolbar mToolbar = (Toolbar) findViewById(R.id.car_details_toolbar); mToolbar.setTitle(mTitle); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); mFAB = (FloatingActionButton) findViewById(R.id.car_details_fab); mFAB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Choose image"), Consts.CarDetails.REQUEST_PICK_IMAGE); } }); mToolbarImage = (ImageView) findViewById(R.id.car_details_toolbar_image); }
From source file:com.google.plus.samples.photohunt.PlusClientFragment.java
private void showProgressDialog() { DialogFragment progressDialog = (DialogFragment) getFragmentManager() .findFragmentByTag(TAG_PROGRESS_DIALOG); if (progressDialog == null) { progressDialog = ProgressDialogFragment.create(); progressDialog.show(getFragmentManager(), TAG_PROGRESS_DIALOG); }/*w w w . jav a2 s .c o m*/ }
From source file:de.vanita5.twittnuker.fragment.support.UserListDetailsFragment.java
@Override public boolean onMenuItemClick(final MenuItem item) { final AsyncTwitterWrapper twitter = getTwitterWrapper(); final ParcelableUserList userList = mUserList; if (twitter == null || userList == null) return false; switch (item.getItemId()) { case MENU_ADD: { if (userList.user_id != userList.account_id) return false; final Intent intent = new Intent(INTENT_ACTION_SELECT_USER); intent.setClass(getActivity(), UserListSelectorActivity.class); intent.putExtra(EXTRA_ACCOUNT_ID, userList.account_id); startActivityForResult(intent, REQUEST_SELECT_USER); break;/*from w w w . j a va2s . com*/ } case MENU_DELETE: { if (userList.user_id != userList.account_id) return false; DestroyUserListDialogFragment.show(getFragmentManager(), userList); break; } case MENU_EDIT: { final Bundle args = new Bundle(); args.putLong(EXTRA_ACCOUNT_ID, userList.account_id); args.putString(EXTRA_LIST_NAME, userList.name); args.putString(EXTRA_DESCRIPTION, userList.description); args.putBoolean(EXTRA_IS_PUBLIC, userList.is_public); args.putLong(EXTRA_LIST_ID, userList.id); final DialogFragment f = new EditUserListDialogFragment(); f.setArguments(args); f.show(getFragmentManager(), "edit_user_list_details"); return true; } case MENU_FOLLOW: { if (userList.is_following) { DestroyUserListSubscriptionDialogFragment.show(getFragmentManager(), userList); } else { twitter.createUserListSubscriptionAsync(userList.account_id, userList.id); } return true; } default: { if (item.getIntent() != null) { try { startActivity(item.getIntent()); } catch (final ActivityNotFoundException e) { if (Utils.isDebugBuild()) Log.w(LOGTAG, e); return false; } } break; } } return true; }
From source file:com.example.signintest.SignInFragment.java
/** * Called when the provider has signed in the user. * Merging users is always handled here. * /* w w w .ja v a 2s. c o m*/ * @param user */ public void onSignedIn(SignInUser user) { if (mUser == null) { // If we have no user, we just take the supplied user. mUser = user; mHandler.sendEmptyMessage(SignInClientFragmentHandler.WHAT_STATUS_CHANGE); resolveUserStates(); } else if (mUser.getId() == user.getId() || user.isNew()) { // If we have a new provider for the same user, just merge. mUser.merge(user); mHandler.sendEmptyMessage(SignInClientFragmentHandler.WHAT_STATUS_CHANGE); } else { mIncomingUser = user; // If not we have two possible states: DialogFragment f; if (mUser.canMerge(user)) { // We can automatically merge, but we should ask the user. f = new MergeOrSwitchDialogFragment(); } else { // The accounts conflict, so tell the user they can only // switch or cancel. f = new SwitchOrCancelDialogFragment(); } f.setTargetFragment(this, TAG_DIALOG_REQ); f.show(getFragmentManager(), TAG_DIALOG); } }
From source file:io.jawg.osmcontributor.ui.activities.MapActivity.java
public void checkFirstStart() { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); if (settings.getBoolean("first_start", true)) { //the app is being launched for first time, do something Log.d("Comments", "First start off the application"); DialogFragment newFragment = new NoticeDialogFragment(); newFragment.show(this.getSupportFragmentManager(), String.valueOf(R.string.setup)); // record the fact that the app has been started at least once settings.edit().putBoolean("first_start", false).commit(); }/*from w ww .j ava 2 s . co m*/ }
From source file:de.tudarmstadt.dvs.myhealthassistant.myhealthhub.MyHealthHubGlassMainActivity.java
private void openSelectDeviceDialog(String sensorType) { BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBluetoothAdapter != null) { BluetoothDevice[] mAllBondedDevices = (BluetoothDevice[]) mBluetoothAdapter.getBondedDevices() .toArray(new BluetoothDevice[0]); int mDeviceIndex = 0; if (mAllBondedDevices.length > 0) { int deviceCount = mAllBondedDevices.length; String[] deviceNames = new String[deviceCount]; int i = 0; for (BluetoothDevice device : mAllBondedDevices) { deviceNames[i++] = device.getName() + "|" + device.getAddress(); }//from www . j a v a2 s.co m DialogFragment deviceDialog = new SelectDeviceDialogFragment(); Bundle args = new Bundle(); args.putString("sensorType", sensorType); args.putStringArray("names", deviceNames); args.putInt("position", mDeviceIndex); args.putBoolean("device", true); deviceDialog.setArguments(args); getFragmentManager().beginTransaction(); deviceDialog.show(getSupportFragmentManager().beginTransaction(), "deviceDialog"); } } }
From source file:com.loloof64.android.chess_position_manager.MainActivity.java
@Override public void onConfirmRemoveElementsDialogPositiveClick(String[] foldersNames, String[] positionsNames) { ArrayList<String> failedFolders = new ArrayList<>(); ArrayList<String> failedPositions = new ArrayList<>(); for (String currentFolderName : foldersNames) { if (!directoryManager.tryToRemoveFileOrFolder(currentFolderName)) { failedFolders.add(currentFolderName); }/* w w w . j a v a 2s . c o m*/ } for (String currentPositionName : positionsNames) { if (!directoryManager.tryToRemoveFileOrFolder(currentPositionName)) { failedPositions.add(currentPositionName); } } boolean allSucceed = failedPositions.isEmpty() && failedFolders.isEmpty(); if (!allSucceed) { Collections.sort(failedFolders); Collections.sort(failedPositions); String[] failedFoldersArray = new String[failedFolders.size()]; String[] failedPositionsArray = new String[failedPositions.size()]; failedFolders.toArray(failedFoldersArray); failedPositions.toArray(failedPositionsArray); DialogFragment newFragment = new RemovingFilesErrorDialogFragment(); Bundle arguments = new Bundle(); arguments.putStringArray(RemovingFilesErrorDialogFragment.FOLDERS_TAG, failedFoldersArray); arguments.putStringArray(RemovingFilesErrorDialogFragment.POSITIONS_TAG, failedPositionsArray); newFragment.setArguments(arguments); newFragment.show(getSupportFragmentManager(), "removingElementsError"); } refreshList(); }