List of usage examples for android.widget Toast show
public void show()
From source file:com.synox.android.ui.activity.FileActivity.java
private void onCreateShareViaLinkOperationFinish(CreateShareViaLinkOperation operation, RemoteOperationResult result) {/* www . jav a2 s . c om*/ if (result.isSuccess()) { updateFileFromDB(); Intent sendIntent = operation.getSendIntentWithSubject(this); if (sendIntent != null) { startActivity(sendIntent); } } else { // Detect Failure (403) --> needs Password if (result.getCode() == ResultCode.SHARE_FORBIDDEN) { String password = operation.getPassword(); if ((password == null || password.length() == 0) && getCapabilities().getFilesSharingPublicEnabled().isUnknown()) { // Was tried without password, but not sure that it's optional. Try with password. // Try with password before giving up. // See also ShareFileFragment#OnShareViaLinkListener SharePasswordDialogFragment dialog = SharePasswordDialogFragment .newInstance(new OCFile(operation.getPath()), true); dialog.show(getSupportFragmentManager(), DIALOG_SHARE_PASSWORD); } else { Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), Toast.LENGTH_LONG); t.show(); } } else { Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), Toast.LENGTH_LONG); t.show(); } } }
From source file:com.synox.android.ui.activity.FileActivity.java
/** * @param operation Removal operation performed. * @param result Result of the removal. *//* w ww. j a v a 2 s. c om*/ @Override public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) { Log_OC.d(TAG, "Received result of operation in FileActivity - common behaviour for all the " + "FileActivities "); mFileOperationsHelper.setOpIdWaitingFor(Long.MAX_VALUE); dismissLoadingDialog(); if (!result.isSuccess() && (result.getCode() == ResultCode.UNAUTHORIZED || result.isIdPRedirection() || (result.isException() && result.getException() instanceof AuthenticatorException))) { requestCredentialsUpdate(this); if (result.getCode() == ResultCode.UNAUTHORIZED) { dismissLoadingDialog(); Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), Toast.LENGTH_LONG); t.show(); } } else if (operation == null || operation instanceof CreateShareWithShareeOperation || operation instanceof UnshareOperation || operation instanceof SynchronizeFolderOperation || operation instanceof UpdateShareViaLinkOperation || operation instanceof UpdateSharePermissionsOperation) { if (result.isSuccess()) { updateFileFromDB(); } else if (result.getCode() != ResultCode.CANCELLED) { Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), Toast.LENGTH_LONG); t.show(); } } else if (operation instanceof CreateShareViaLinkOperation) { onCreateShareViaLinkOperationFinish((CreateShareViaLinkOperation) operation, result); } else if (operation instanceof SynchronizeFileOperation) { onSynchronizeFileOperationFinish((SynchronizeFileOperation) operation, result); } else if (operation instanceof GetSharesForFileOperation) { if (result.isSuccess() || result.getCode() == ResultCode.SHARE_NOT_FOUND) { updateFileFromDB(); } else { Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), Toast.LENGTH_LONG); t.show(); } } }
From source file:com.lofland.housebot.BotController.java
public void queueCommandToRobot(Command commandToSend, int valueToSend) { if (!myRobot.isConnectedToNXT()) { // Don't queue commands when not connected Context context = getApplicationContext(); Toast robotMessageToast = Toast.makeText(context, "Not Connected!", Toast.LENGTH_SHORT); // Display the toast robotMessageToast.show(); } else if (nextCommand == Command.EMPTY) { // If "buffer" is empty, fill it with this nextCommand = commandToSend;/*from www . j av a 2 s . co m*/ nextValueToSend = valueToSend; /* * The toast is too slow and gets way behind. Context context = getApplicationContext(); Toast robotMessageToast = Toast.makeText(context, commandToSend.toString(), * Toast.LENGTH_SHORT); // Display the toast robotMessageToast.show(); */ } else if (commandToSend == Command.STOP) { // Let STOP override other commands! nextCommand = commandToSend; nextValueToSend = valueToSend; Context context = getApplicationContext(); Toast robotMessageToast = Toast.makeText(context, "OVERRIDE!", Toast.LENGTH_SHORT); // Display the toast robotMessageToast.show(); } else { // Otherwise consider buffer full and system is "BUSY" // Essentially command is discarded Context context = getApplicationContext(); Toast robotMessageToast = Toast.makeText(context, "BUSY!", Toast.LENGTH_SHORT); // Display the toast robotMessageToast.show(); } }
From source file:com.ccxt.whl.activity.SettingsFragment.java
/** * ?uri?/*from w w w . j a va 2 s .c o m*/ * * @param selectedImage */ private String getpathfromUri(Uri selectedImage) { // String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getActivity().getContentResolver().query(selectedImage, null, null, null, null); if (cursor != null) { cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex("_data"); String picturePath = cursor.getString(columnIndex); cursor.close(); cursor = null; if (picturePath == null || picturePath.equals("null")) { Toast toast = Toast.makeText(getActivity(), "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return null; } return picturePath; //sendPicture(picturePath); } else { File file = new File(selectedImage.getPath()); if (!file.exists()) { Toast toast = Toast.makeText(getActivity(), "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return null; } return file.getAbsolutePath(); } }
From source file:com.ccxt.whl.activity.SettingsFragment.java
/** * ?uri??//from w ww. j a v a 2s.c om * * @param selectedImage */ private File Uritofile(Uri selectedImage) { File file = null; Cursor cursor = getActivity().getContentResolver().query(selectedImage, null, null, null, null); if (cursor != null) { cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex("_data"); String picturePath = cursor.getString(columnIndex); cursor.close(); cursor = null; if (picturePath == null || picturePath.equals("null")) { Toast toast = Toast.makeText(getActivity(), "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return null; } file = new File(picturePath); //sendPicture(picturePath); } else { file = new File(selectedImage.getPath()); if (!file.exists()) { Toast toast = Toast.makeText(getActivity(), "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return null; } } return file; }
From source file:com.ccxt.whl.activity.SettingsFragment.java
/** * ?uri?/*from w w w . j a va2 s. c o m*/ * * @param selectedImage */ private void sendPicByUri(Uri selectedImage) { // String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getActivity().getContentResolver().query(selectedImage, null, null, null, null); if (cursor != null) { cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex("_data"); String picturePath = cursor.getString(columnIndex); cursor.close(); cursor = null; if (picturePath == null || picturePath.equals("null")) { Toast toast = Toast.makeText(getActivity(), "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } //copyFile(picturePath,imageUri.getPath()); cropImageUri(selectedImage, 200, 200, USERPIC_REQUEST_CODE_CUT); //sendPicture(picturePath); } else { File file = new File(selectedImage.getPath()); if (!file.exists()) { Toast toast = Toast.makeText(getActivity(), "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } //copyFile(selectedImage.getPath(),imageUri.getPath()); cropImageUri(selectedImage, 200, 200, USERPIC_REQUEST_CODE_CUT); //sendPicture(file.getAbsolutePath()); } }
From source file:com.moonpi.tapunlock.MainActivity.java
@Override protected Dialog onCreateDialog(int id) { // Scan NFC Tag dialog, inflate image LayoutInflater factory = LayoutInflater.from(MainActivity.this); final View view = factory.inflate(R.layout.scan_tag_image, null); // Ask for tagTitle (tagName) in dialog final EditText tagTitle = new EditText(this); tagTitle.setHint(getResources().getString(R.string.set_tag_name_dialog_hint)); tagTitle.setSingleLine(true);//from ww w. j av a 2s . com tagTitle.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); // Set tagTitle maxLength int maxLength = 50; InputFilter[] array = new InputFilter[1]; array[0] = new InputFilter.LengthFilter(maxLength); tagTitle.setFilters(array); final LinearLayout l = new LinearLayout(this); l.setOrientation(LinearLayout.VERTICAL); l.addView(tagTitle); // Dialog that shows scan tag image if (id == DIALOG_READ) { return new AlertDialog.Builder(this).setTitle(R.string.scan_tag_dialog_title).setView(view) .setCancelable(false) .setNeutralButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialogCancelled = true; killForegroundDispatch(); dialog.cancel(); } }).create(); } // Dialog that asks for tagName and stores it after 'Ok' pressed else if (id == DIALOG_SET_TAGNAME) { tagTitle.requestFocus(); return new AlertDialog.Builder(this).setTitle(R.string.set_tag_name_dialog_title).setView(l) .setCancelable(false) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { JSONObject newTag = new JSONObject(); try { newTag.put("tagName", tagTitle.getText()); newTag.put("tagID", tagID); } catch (JSONException e) { e.printStackTrace(); } tags.put(newTag); writeToJSON(); adapter.notifyDataSetChanged(); updateListViewHeight(listView); if (tags.length() == 0) noTags.setVisibility(View.VISIBLE); else noTags.setVisibility(View.INVISIBLE); Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_tag_added, Toast.LENGTH_SHORT); toast.show(); imm.hideSoftInputFromWindow(tagTitle.getWindowToken(), 0); tagID = ""; tagTitle.setText(""); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { tagID = ""; tagTitle.setText(""); imm.hideSoftInputFromWindow(tagTitle.getWindowToken(), 0); dialog.cancel(); } }).create(); } return null; }
From source file:ca.nehil.rter.streamingapp2.StreamingActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Orientation listenever implementation myOrientationEventListener = new OrientationEventListener(this, SensorManager.SENSOR_DELAY_NORMAL) { @Override/*ww w . ja v a2s. c o m*/ public void onOrientationChanged(int orientation) { int rotation = getWindowManager().getDefaultDisplay().getRotation(); if (rotation == Surface.ROTATION_270) { flipVideo = true; } else { flipVideo = false; } } }; myOrientationEventListener.enable(); // stopService(new Intent(StreamingActivity.this, // BackgroundService.class)); Log.e(TAG, "onCreate"); AndroidId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID); frameInfo = new FrameInfo(); // openGL overlay overlay = new OverlayController(this); // orientation mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mAcc = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mMag = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setContentView(R.layout.activity_streaming); // Find the total number of cameras available numberOfCameras = Camera.getNumberOfCameras(); cookies = getSharedPreferences("RterUserCreds", MODE_PRIVATE); prefEditor = cookies.edit(); setUsername = cookies.getString("Username", "not-set"); setRterCredentials = cookies.getString("RterCreds", "not-set"); if (setRterCredentials.equalsIgnoreCase("not-set") || setRterCredentials == null) { Log.e("PREFS", "Login Not successful, please restart"); } Log.d("PREFS", "Prefs ==> rter_Creds:" + setRterCredentials); // Get the location manager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // Define the criteria how to select the location provider -> use // default if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { Log.e(TAG, "GPS not available"); } Criteria criteria = new Criteria(); provider = locationManager.getBestProvider(criteria, true); Log.d(TAG, "Requesting location"); locationManager.requestLocationUpdates(provider, 0, 1, this); // register the overlay control for location updates as well, so we get // the geomagnetic field locationManager.requestLocationUpdates(provider, 0, 1000, overlay); if (provider != null) { Location location = locationManager.getLastKnownLocation(provider); // Initialize the location fields if (location != null) { System.out.println("Provider " + provider + " has been selected. and location " + location); onLocationChanged(location); } else { Toast toast = Toast.makeText(this, "Location not available", Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP, 0, 0); toast.show(); lati = (float) (45.505958f); longi = (float) (-73.576254f); Log.d(TAG, "Location not available"); } } // power manager PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, CLASS_LABEL); mWakeLock.acquire(); // test, set desired orienation to north overlay.letFreeRoam(false); overlay.setDesiredOrientation(0.0f); // CharSequence text = "Tap to start.."; // int duration = Toast.LENGTH_SHORT; // // Toast toast = Toast.makeText(this, text, duration); // toast.setGravity(Gravity.TOP|Gravity.RIGHT, 0, 0); // toast.show(); }
From source file:ca.nehil.rter.streamingapp.StreamingActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_streaming); poilist = new ArrayList<POI>(); /* Retrieve server URL from stored app values */ storedValues = getSharedPreferences(getString(R.string.sharedPreferences_filename), MODE_PRIVATE); server_url = storedValues.getString("server_url", "not-set"); /* Orientation listenever implementation to orient video */ myOrientationEventListener = new OrientationEventListener(this, SensorManager.SENSOR_DELAY_NORMAL) { @Override/*from w w w .jav a 2 s . c om*/ public void onOrientationChanged(int orientation) { int rotation = getWindowManager().getDefaultDisplay().getRotation(); if (rotation == Surface.ROTATION_270) { flipVideo = true; } else { flipVideo = false; } } }; myOrientationEventListener.enable(); /* Retrieve user auth data from cookie */ cookies = getSharedPreferences("RterUserCreds", MODE_PRIVATE); cookieEditor = cookies.edit(); setUsername = cookies.getString("Username", "not-set"); setRterCredentials = cookies.getString("RterCreds", "not-set"); if (setRterCredentials.equalsIgnoreCase("not-set") || setRterCredentials == null) { Log.e("PREFS", "Login Not successful, please restart"); } Log.d("PREFS", "Prefs ==> rter_Creds:" + setRterCredentials); URL serverURL = null; try { serverURL = new URL(server_url); CookieStore myCookieStore = new BasicCookieStore(); client.setCookieStore(myCookieStore); String[] credentials = setRterCredentials.split("=", 2); BasicClientCookie newCookie = new BasicClientCookie(credentials[0], credentials[1]); newCookie.setDomain(serverURL.getHost()); newCookie.setPath("/"); myCookieStore.addCookie(newCookie); mSensorSource = SensorSource.getInstance(this, GET_LOCATION_FROM_SERVER, serverURL, setRterCredentials, setUsername); POIs = new POIList(this, serverURL, setRterCredentials, mSensorSource); } catch (MalformedURLException e) { e.printStackTrace(); } overlay = new OverlayController(this, POIs, mSensorSource); // OpenGL overlay /* Get location */ Location location = mSensorSource.getLocation(); if (location != null) { lati = (float) (location.getLatitude()); longi = (float) (location.getLongitude()); } else { Toast toast = Toast.makeText(this, "Location not available", Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP, 0, 0); toast.show(); lati = (float) (45.505958f); // Hard coded location for testing purposes. longi = (float) (-73.576254f); } PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, CLASS_LABEL); mWakeLock.acquire(); /* Test, set desired orienation to north */ overlay.setDesiredOrientation(0.0f); }
From source file:flex.android.magiccube.activity.ActivityBattleMode.java
public void LeaveOnError(String msg) { Toast toast = Toast.makeText(this, msg, Toast.LENGTH_LONG); toast.setGravity(Gravity.BOTTOM, 0, height / 11); toast.show(); State = OnStateListener.LEAVING_ON_ERROR; finish();/*from w ww. ja v a 2 s. co m*/ }