List of usage examples for android.widget Toast show
public void show()
From source file:com.owncloud.android.ui.activity.FileDisplayActivity.java
/** * Updates the view associated to the activity after the finish of an * operation trying to rename a file./* w ww . ja va2s.c om*/ * * @param operation Renaming operation performed. * @param result Result of the renaming. */ private void onRenameFileOperationFinish(RenameFileOperation operation, RemoteOperationResult result) { dismissDialog(DIALOG_SHORT_WAIT); OCFile renamedFile = operation.getFile(); if (result.isSuccess()) { if (mDualPane) { FileFragment details = getSecondFragment(); if (details != null && details instanceof FileDetailFragment && renamedFile.equals(details.getFile())) { ((FileDetailFragment) details).updateFileDetails(renamedFile, getAccount()); } } if (mStorageManager.getFileById(renamedFile.getParentId()).equals(getCurrentDir())) { refeshListOfFilesFragment(); } } else { if (result.getCode().equals(ResultCode.INVALID_LOCAL_FILE_NAME)) { Toast msg = Toast.makeText(this, R.string.rename_local_fail_msg, Toast.LENGTH_LONG); msg.show(); // TODO throw again the new rename dialog } else { Toast msg = Toast.makeText(this, R.string.rename_server_fail_msg, Toast.LENGTH_LONG); msg.show(); if (result.isSslRecoverableException()) { mLastSslUntrustedServerResult = result; showDialog(DIALOG_SSL_VALIDATOR); } } } }
From source file:cn.kangeqiu.kq.activity.ChatActivity.java
/** * ?uri??//ww w. jav a2 s .c o m * * @param selectedImage */ private void sendPicByUri(Uri selectedImage) { // String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(selectedImage, null, null, null, null); String st8 = getResources().getString(R.string.cant_find_pictures); 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(this, st8, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } sendPicture(picturePath); } else { File file = new File(selectedImage.getPath()); if (!file.exists()) { Toast toast = Toast.makeText(this, st8, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } sendPicture(file.getAbsolutePath()); } }
From source file:com.owncloud.android.ui.activity.FileDisplayActivity.java
private void requestMultipleUpload(Intent data, int resultCode) { String[] filePaths = data.getStringArrayExtra(UploadFilesActivity.EXTRA_CHOSEN_FILES); if (filePaths != null) { String[] remotePaths = new String[filePaths.length]; String remotePathBase = ""; for (int j = mDirectories.getCount() - 2; j >= 0; --j) { remotePathBase += OCFile.PATH_SEPARATOR + mDirectories.getItem(j); }/*from ww w.j a v a 2s.com*/ if (!remotePathBase.endsWith(OCFile.PATH_SEPARATOR)) remotePathBase += OCFile.PATH_SEPARATOR; for (int j = 0; j < remotePaths.length; j++) { remotePaths[j] = remotePathBase + (new File(filePaths[j])).getName(); } Intent i = new Intent(this, FileUploader.class); i.putExtra(FileUploader.KEY_ACCOUNT, getAccount()); i.putExtra(FileUploader.KEY_LOCAL_FILE, filePaths); i.putExtra(FileUploader.KEY_REMOTE_FILE, remotePaths); i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_MULTIPLE_FILES); if (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE) i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE); startService(i); } else { Log_OC.d(TAG, "User clicked on 'Update' with no selection"); Toast t = Toast.makeText(this, getString(R.string.filedisplay_no_file_selected), Toast.LENGTH_LONG); t.show(); return; } }
From source file:cm.aptoide.pt.ApkInfo.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case 0:/*www. j a v a 2 s . com*/ Uri uri = Uri.fromParts("package", viewApk.getApkid(), null); Intent intent = new Intent(Intent.ACTION_DELETE, uri); startActivity(intent); finish(); break; case 1: Intent i = new Intent(); i.setAction(android.content.Intent.ACTION_VIEW); i.setData(Uri.parse("market://details?id=" + viewApk.getApkid())); try { startActivity(i); } catch (ActivityNotFoundException e) { Toast toast = Toast.makeText(context, context.getString(R.string.error_no_market), Toast.LENGTH_SHORT); toast.show(); } break; default: break; } return true; }
From source file:cn.ucai.yizhesale.activity.ChatActivity.java
/** * ?uri??/*from w ww . j a va 2 s . c o m*/ * * @param selectedImage */ private void sendPicByUri(Uri selectedImage) { String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); String st8 = getResources().getString(cn.ucai.yizhesale.R.string.cant_find_pictures); if (cursor != null) { cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String picturePath = cursor.getString(columnIndex); cursor.close(); cursor = null; if (picturePath == null || picturePath.equals("null")) { Toast toast = Toast.makeText(this, st8, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } sendPicture(picturePath); } else { File file = new File(selectedImage.getPath()); if (!file.exists()) { Toast toast = Toast.makeText(this, st8, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } sendPicture(file.getAbsolutePath()); } }
From source file:com.owncloud.android.ui.activity.FileDisplayActivity.java
/** * Updates the view associated to the activity after the finish of an * operation trying create a new folder//from w w w . j a va 2s .c o m * * @param operation Creation operation performed. * @param result Result of the creation. */ private void onCreateFolderOperationFinish(CreateFolderOperation operation, RemoteOperationResult result) { if (result.isSuccess()) { dismissDialog(DIALOG_SHORT_WAIT); refeshListOfFilesFragment(); } else { dismissDialog(DIALOG_SHORT_WAIT); try { Toast msg = Toast.makeText(FileDisplayActivity.this, R.string.create_dir_fail_msg, Toast.LENGTH_LONG); msg.show(); } catch (NotFoundException e) { Log_OC.e(TAG, "Error while trying to show fail message ", e); } } }
From source file:com.owncloud.android.ui.activity.FileDisplayActivity.java
private void requestSimpleUpload(Intent data, int resultCode) { String filepath = null;//from w ww. java 2 s .c om try { Uri selectedImageUri = data.getData(); String filemanagerstring = selectedImageUri.getPath(); String selectedImagePath = getPath(selectedImageUri); if (selectedImagePath != null) filepath = selectedImagePath; else filepath = filemanagerstring; } catch (Exception e) { Log_OC.e(TAG, "Unexpected exception when trying to read the result of Intent.ACTION_GET_CONTENT", e); e.printStackTrace(); } finally { if (filepath == null) { Log_OC.e(TAG, "Couldnt resolve path to file"); Toast t = Toast.makeText(this, getString(R.string.filedisplay_unexpected_bad_get_content), Toast.LENGTH_LONG); t.show(); return; } } Intent i = new Intent(this, FileUploader.class); i.putExtra(FileUploader.KEY_ACCOUNT, getAccount()); String remotepath = new String(); for (int j = mDirectories.getCount() - 2; j >= 0; --j) { remotepath += OCFile.PATH_SEPARATOR + mDirectories.getItem(j); } if (!remotepath.endsWith(OCFile.PATH_SEPARATOR)) remotepath += OCFile.PATH_SEPARATOR; remotepath += new File(filepath).getName(); i.putExtra(FileUploader.KEY_LOCAL_FILE, filepath); i.putExtra(FileUploader.KEY_REMOTE_FILE, remotepath); i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE); if (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE) i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE); startService(i); }
From source file:com.lewa.crazychapter11.MainActivity.java
private void showTost(String content, int tostLength) { Toast mToast; if (mToastReference != null) { mToast = mToastReference.get();// www .j av a 2 s .com if (mToast != null) { mToast.cancel(); mToastReference = null; } } mToast = Toast.makeText(MainActivity.this, content, tostLength); mToastReference = new WeakReference<Toast>(mToast); mToast.show(); }
From source file:cmu.cconfs.instantMessage.activities.ChatActivity.java
/** * ?uri??/*w w w. j av a2 s . c om*/ * * @param selectedImage */ private void sendPicByUri(Uri selectedImage) { String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); String st8 = getResources().getString(R.string.cant_find_pictures); if (cursor != null) { cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String picturePath = cursor.getString(columnIndex); cursor.close(); cursor = null; if (picturePath == null || picturePath.equals("null")) { Toast toast = Toast.makeText(this, st8, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } sendPicture(picturePath); } else { File file = new File(selectedImage.getPath()); if (!file.exists()) { Toast toast = Toast.makeText(this, st8, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } sendPicture(file.getAbsolutePath()); } }
From source file:cn.gen.superwechat.activity.ChatActivity.java
/** * ?uri??//from www . ja v a 2 s . co m * * @param selectedImage */ private void sendPicByUri(Uri selectedImage) { String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); String st8 = getResources().getString(cn.gen.superwechat.R.string.cant_find_pictures); if (cursor != null) { cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String picturePath = cursor.getString(columnIndex); cursor.close(); cursor = null; if (picturePath == null || picturePath.equals("null")) { Toast toast = Toast.makeText(this, st8, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } sendPicture(picturePath); } else { File file = new File(selectedImage.getPath()); if (!file.exists()) { Toast toast = Toast.makeText(this, st8, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } sendPicture(file.getAbsolutePath()); } }