List of usage examples for android.net Uri EMPTY
Uri EMPTY
To view the source code for android.net Uri EMPTY.
Click Source Link
From source file:com.chen.mail.ui.AbstractActivityController.java
@Override public void changeAccount(Account account) { LogUtils.d(LOG_TAG, "AAC.changeAccount(%s)", account); // Is the account or account settings different from the existing account? final boolean firstLoad = mAccount == null; final boolean accountChanged = firstLoad || !account.uri.equals(mAccount.uri); // If nothing has changed, return early without wasting any more time. if (!accountChanged && !account.settingsDiffer(mAccount)) { return;/*from w ww.j ava 2s.c om*/ } // We also don't want to do anything if the new account is null if (account == null) { LogUtils.e(LOG_TAG, "AAC.changeAccount(null) called."); return; } final String emailAddress = account.getEmailAddress(); mHandler.post(new Runnable() { @Override public void run() { MailActivity.setNfcMessage(emailAddress); } }); if (accountChanged) { commitDestructiveActions(false); } Analytics.getInstance().setCustomDimension(Analytics.CD_INDEX_ACCOUNT_TYPE, AnalyticsUtils.getAccountTypeForAccount(emailAddress)); // Change the account here setAccount(account); // And carry out associated actions. cancelRefreshTask(); if (accountChanged) { loadAccountInbox(); } // Check if we need to force setting up an account before proceeding. if (mAccount != null && !Uri.EMPTY.equals(mAccount.settings.setupIntentUri)) { // Launch the intent! final Intent intent = new Intent(Intent.ACTION_EDIT); intent.setData(mAccount.settings.setupIntentUri); mActivity.startActivity(intent); } }
From source file:org.secu3.android.ParamActivity.java
public void onItemChange(int itemId) { Secu3Packet packet = null;//from w w w.java 2s .c o m BaseParamItem item = paramAdapter.findItemByNameId(itemId); if (item != null) { if (item.getPageId() == R.string.choke_control_title) { packet = new Secu3Packet(Skeletons.get(R.string.choke_control_title)); switch (itemId) { case R.string.choke_manual_step_down_title: ((ProtoFieldInteger) packet.findField(R.string.choke_steps_title)).setValue(-127); break; case R.string.choke_manual_step_up_title: ((ProtoFieldInteger) packet.findField(R.string.choke_steps_title)).setValue(127); break; case R.string.choke_testing_title: ((ProtoFieldInteger) packet.findField(R.string.choke_testing_title)) .setValue(((ParamItemToggleButton) item).getValue() ? 1 : 0); break; default: break; } startService(new Intent(Secu3Service.ACTION_SECU3_SERVICE_SEND_PACKET, Uri.EMPTY, this, Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_SEND_PACKET_PARAM_PACKET, packet)); } else if (item.getNameId() == R.string.secur_par_apply_bluetooth_title) { Secu3Packet sourcePacket = packetUtils.buildPacket(Skeletons.get(R.string.secur_par_title), paramAdapter, R.string.secur_par_title); if (sourcePacket != null) { int flags = ((ProtoFieldInteger) sourcePacket.findField(R.string.secur_par_flags_title)) .getValue(); packet = new Secu3Packet(Skeletons.get(R.string.secur_par_title)); flags |= Secu3Packet.SECUR_SET_BTBR_FLAG; ((ProtoFieldInteger) packet.findField(R.string.secur_par_flags_title)).setValue(flags); String name = ((ParamItemString) paramAdapter .findItemByNameId(R.string.secur_par_bluetooth_name_title)).getValue(); String pass = ((ParamItemString) paramAdapter .findItemByNameId(R.string.secur_par_bluetooth_pass_title)).getValue(); if ((name != null) && (pass != null)) { ((ProtoFieldInteger) packet.findField(R.string.secur_par_name_length_title)) .setValue(name.length()); ((ProtoFieldString) packet.findField(R.string.secur_par_bluetooth_name_title)) .setValue(name); ((ProtoFieldInteger) packet.findField(R.string.secur_par_name_length_title)) .setValue(pass.length()); ((ProtoFieldString) packet.findField(R.string.secur_par_bluetooth_pass_title)) .setValue(pass); startService(new Intent(Secu3Service.ACTION_SECU3_SERVICE_SEND_PACKET, Uri.EMPTY, this, Secu3Service.class).putExtra( Secu3Service.ACTION_SECU3_SERVICE_SEND_PACKET_PARAM_PACKET, packet)); } } } else if ((item.getNameId() == R.string.secur_par_bluetooth_name_title) || (item.getNameId() == R.string.secur_par_bluetooth_pass_title)) { paramAdapter.setStringItem(bluetoothSecurityFlags, bluetoothSecurityValue); String name = ((ParamItemString) paramAdapter .findItemByNameId(R.string.secur_par_bluetooth_name_title)).getValue(); String pass = ((ParamItemString) paramAdapter .findItemByNameId(R.string.secur_par_bluetooth_pass_title)).getValue(); paramAdapter.findItemByNameId(R.string.secur_par_apply_bluetooth_title).setEnabled((name != null) && (pass != null) && (!TextUtils.isEmpty(name)) && (!TextUtils.isEmpty(pass))); adapter.notifyDataSetChanged(); } else if (uploadImmediatelly) { startService(new Intent(Secu3Service.ACTION_SECU3_SERVICE_SEND_PACKET, Uri.EMPTY, this, Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_SEND_PACKET_PARAM_PACKET, packetUtils.buildPacket(Skeletons.get(item.getPageId()), paramAdapter, item.getPageId()))); } } }
From source file:com.maskyn.fileeditorpro.activity.MainActivity.java
void newFileToOpen(final GreatUri newUri, final String newFileText) { if (fileOpened && mEditor != null && mEditor.canSaveFile() && greatUri != null && pageSystem != null && currentEncoding != null) { new SaveFileDialog(greatUri, pageSystem.getAllText(mEditor.getText().toString()), currentEncoding, true, newUri).show(getFragmentManager(), "dialog"); return;//from w w w . jav a 2s . c o m } new AsyncTask<Void, Void, Void>() { String message = ""; String fileText = ""; String fileName = ""; String encoding = "UTF-16"; boolean isRootRequired = false; ProgressDialog progressDialog; @Override protected void onPreExecute() { super.onPreExecute(); // Close the drawer mDrawerLayout.closeDrawer(Gravity.START); progressDialog = new ProgressDialog(MainActivity.this); progressDialog.setMessage(getString(R.string.please_wait)); progressDialog.show(); } @Override protected Void doInBackground(Void... params) { try { // if no new uri if (newUri == null || newUri.getUri() == null || newUri.getUri() == Uri.EMPTY) { fileExtension = "txt"; fileText = newFileText; } else { String filePath = newUri.getFilePath(); // if the uri has no path if (TextUtils.isEmpty(filePath)) { fileName = newUri.getFileName(); fileExtension = FilenameUtils.getExtension(fileName).toLowerCase(); readUri(newUri.getUri(), filePath, false); } // if the uri has a path else { fileName = FilenameUtils.getName(filePath); fileExtension = FilenameUtils.getExtension(fileName).toLowerCase(); isRootRequired = !newUri.isReadable(); // if we cannot read the file, root permission required if (isRootRequired) { readUri(newUri.getUri(), filePath, true); } // if we can read the file associated with the uri else { readUri(newUri.getUri(), filePath, false); } } } greatUri = newUri; } catch (Exception e) { message = e.getMessage(); fileText = ""; } while (mDrawerLayout.isDrawerOpen(Gravity.START)) { try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } } return null; } private void readUri(Uri uri, String path, boolean asRoot) throws IOException { BufferedReader buffer = null; StringBuilder stringBuilder = new StringBuilder(); String line; if (asRoot) { encoding = "UTF-8"; // Connect the shared connection if (RootFW.connect()) { FileReader reader = RootFW.getFileReader(path); buffer = new BufferedReader(reader); } } else { boolean autoencoding = PreferenceHelper.getAutoEncoding(MainActivity.this); if (autoencoding) { encoding = FileUtils.getDetectedEncoding(getContentResolver().openInputStream(uri)); if (encoding.isEmpty()) { encoding = PreferenceHelper.getEncoding(MainActivity.this); } } else { encoding = PreferenceHelper.getEncoding(MainActivity.this); } InputStream inputStream = getContentResolver().openInputStream(uri); if (inputStream != null) { buffer = new BufferedReader(new InputStreamReader(inputStream, encoding)); } } if (buffer != null) { while ((line = buffer.readLine()) != null) { stringBuilder.append(line); stringBuilder.append("\n"); } buffer.close(); fileText = stringBuilder.toString(); } if (isRootRequired) RootFW.disconnect(); } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); progressDialog.hide(); if (!TextUtils.isEmpty(message)) { Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show(); cannotOpenFile(); } else { pageSystem = new PageSystem(MainActivity.this, MainActivity.this, fileText); currentEncoding = encoding; aFileWasSelected(greatUri); showTextEditor(); if (fileName.isEmpty()) getSupportActionBar().setTitle(R.string.new_file); else getSupportActionBar().setTitle(fileName); if (greatUri != null) { refreshList(greatUri, true, false); } } } }.execute(); }
From source file:com.android.mail.ui.AbstractActivityController.java
public void changeAccount(Account account) { LogUtils.d(LOG_TAG, "AAC.changeAccount(%s)", account); // Is the account or account settings different from the existing account? final boolean firstLoad = mAccount == null; final boolean accountChanged = firstLoad || !account.uri.equals(mAccount.uri); // If nothing has changed, return early without wasting any more time. if (!accountChanged && !account.settingsDiffer(mAccount)) { return;//from w w w. jav a 2s .co m } // We also don't want to do anything if the new account is null if (account == null) { LogUtils.e(LOG_TAG, "AAC.changeAccount(null) called."); return; } final String emailAddress = account.getEmailAddress(); mHandler.post(new Runnable() { @Override public void run() { MailActivity.setNfcMessage(emailAddress); } }); if (accountChanged) { commitDestructiveActions(false); } // Change the account here setAccount(account); // And carry out associated actions. cancelRefreshTask(); if (accountChanged) { loadAccountInbox(); } // Check if we need to force setting up an account before proceeding. if (mAccount != null && !Uri.EMPTY.equals(mAccount.settings.setupIntentUri)) { // Launch the intent! final Intent intent = new Intent(Intent.ACTION_EDIT); intent.setPackage(mContext.getPackageName()); intent.setData(mAccount.settings.setupIntentUri); mActivity.startActivity(intent); } }
From source file:br.com.viniciuscr.notification2android.mediaPlayer.MusicUtils.java
static void activateTab(Activity a, int id) { Intent intent = new Intent(Intent.ACTION_PICK); switch (id) { case R.id.artisttab: intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/artistalbum"); break;/*from w ww.j av a 2 s. co m*/ case R.id.albumtab: intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/album"); break; case R.id.songtab: intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track"); break; case R.id.playlisttab: intent.setDataAndType(Uri.EMPTY, MediaStore.Audio.Playlists.CONTENT_TYPE); break; case R.id.nowplaying: // intent = new Intent(a, MediaPlaybackActivity.class); // a.startActivity(intent); // fall through and return default: return; } intent.putExtra("withtabs", true); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); a.startActivity(intent); a.finish(); a.overridePendingTransition(0, 0); }
From source file:com.chen.mail.ui.AbstractActivityController.java
@Override public void onFolderChanged(Folder folder, final boolean force) { /** If the folder doesn't exist, or its parent URI is empty, * this is not a child folder */ final boolean isTopLevel = (folder == null) || (folder.parent == Uri.EMPTY); final int mode = mViewMode.getMode(); mDrawerToggle.setDrawerIndicatorEnabled(getShouldShowDrawerIndicator(mode, isTopLevel)); mDrawerContainer.setDrawerLockMode(getShouldAllowDrawerPull(mode) ? DrawerLayout.LOCK_MODE_UNLOCKED : DrawerLayout.LOCK_MODE_LOCKED_CLOSED); mDrawerContainer.closeDrawers();/*from ww w . j a v a2s . c om*/ if (mFolder == null || !mFolder.equals(folder)) { // We are actually changing the folder, so exit cab mode exitCabMode(); } final String query; if (folder != null && folder.isType(FolderType.SEARCH)) { query = mConvListContext.searchQuery; } else { query = null; } changeFolder(folder, query, force); }
From source file:org.secu3.android.ParamActivity.java
void update(Intent intent) { if (Secu3Service.EVENT_SECU3_SERVICE_STATUS_ONLINE.equals(intent.getAction())) { boolean isOnline = intent.getBooleanExtra(Secu3Service.EVENT_SECU3_SERVICE_STATUS, false); if (isOnline && !this.isOnline) { this.isOnline = true; paramsRead();// w w w .java2 s. co m } if (!isOnline) { isValid = false; } String s = isOnline ? getString(R.string.status_online) : getString(R.string.status_offline); textViewStatus.setText(s); } else if (Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PACKET.equals(intent.getAction())) { Secu3Packet packet = intent.getParcelableExtra(Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PARAM_PACKET); if (packet != null) { if (packet.getNameId() == R.string.op_comp_nc_title) { if (((ProtoFieldInteger) packet.getField(R.string.op_comp_nc_operation_title)) .getValue() == Secu3Packet.OPCODE_EEPROM_PARAM_SAVE) { progressBar.setVisibility(ProgressBar.GONE); Toast.makeText(this, String.format(getString(R.string.params_saved_error_code), ((ProtoFieldInteger) packet.getField(R.string.op_comp_nc_operation_code_title)) .getValue()), Toast.LENGTH_LONG).show(); } } else { packetUtils.setParamFromPacket(paramAdapter, packet); } } } else if (Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_SKELETON_PACKET.equals(intent.getAction())) { Secu3Packet packet = intent .getParcelableExtra(Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PARAM_SKELETON_PACKET); if (packet != null) { Skeletons.put(packet.getNameId(), packet); } } else if (Secu3Service.EVENT_SECU3_SERVICE_PROGRESS.equals(intent.getAction())) { int current = intent.getIntExtra(Secu3Service.EVENT_SECU3_SERVICE_PROGRESS_CURRENT, 0); int total = intent.getIntExtra(Secu3Service.EVENT_SECU3_SERVICE_PROGRESS_TOTAL, 0); progressBar.setIndeterminate(current == 0); progressBar.setMax(total); progressBar.setProgress(current); if (current == total) { startService(new Intent(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PARAMETER, Uri.EMPTY, this, Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PARAMETER_ID, Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PARAMETER_FUNSET_NAMES)); } } else if (Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PARAMETER.equals(intent.getAction())) { String funsetNames[] = intent .getStringArrayExtra(Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PARAMETER_FUNSET_NAMES); if (funsetNames != null) { progressBar.setVisibility(ProgressBar.GONE); PacketUtils.setFunsetNames(paramAdapter, funsetNames); paramAdapter.notifyDataSetChanged(); isValid = true; } } }
From source file:com.maskyn.fileeditorpro.activity.MainActivity.java
void closedTheFile() { arrayAdapter.selectPosition(new GreatUri(Uri.EMPTY, "", "")); }
From source file:com.tct.mail.ui.AbstractActivityController.java
public void changeAccount(Account account) { LogUtils.d(LOG_TAG, "AAC.changeAccount(%s)", account); // Is the account or account settings different from the existing account? final boolean firstLoad = mAccount == null; final boolean accountChanged = firstLoad || !account.uri.equals(mAccount.uri); // If nothing has changed, return early without wasting any more time. if (!accountChanged && !account.settingsDiffer(mAccount)) { return;/* w w w. ja va2 s . c om*/ } // We also don't want to do anything if the new account is null if (account == null) { LogUtils.e(LOG_TAG, "AAC.changeAccount(null) called."); return; } final String emailAddress = account.getEmailAddress(); mHandler.post(new Runnable() { @Override public void run() { MailActivity.setNfcMessage(emailAddress); } }); if (accountChanged) { commitDestructiveActions(false); } Analytics.getInstance().setCustomDimension(Analytics.CD_INDEX_ACCOUNT_TYPE, AnalyticsUtils.getAccountTypeForAccount(emailAddress)); // Change the account here setAccount(account); // And carry out associated actions. cancelRefreshTask(); if (accountChanged) { loadAccountInbox(); } // Check if we need to force setting up an account before proceeding. if (mAccount != null && !Uri.EMPTY.equals(mAccount.settings.setupIntentUri)) { // Launch the intent! final Intent intent = new Intent(Intent.ACTION_EDIT); intent.setPackage(mContext.getPackageName()); intent.setData(mAccount.settings.setupIntentUri); mActivity.startActivity(intent); } }
From source file:com.maskyn.fileeditorpro.activity.MainActivity.java
public void CreateFile(View view) { if (Device.hasKitKatApi() && PreferenceHelper.getUseStorageAccessFramework(this)) { Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.setType("*/*"); //intent.putExtra(Intent.EXTRA_TITLE, ".txt"); startActivityForResult(intent, CREATE_REQUEST_CODE); } else {/*from w w w . ja v a 2 s . com*/ newFileToOpen(new GreatUri(Uri.EMPTY, "", ""), ""); } }