List of usage examples for android.net Uri buildUpon
public abstract Builder buildUpon();
From source file:com.cerema.cloud2.lib.resources.shares.UpdateRemoteShareOperation.java
@Override protected RemoteOperationResult run(OwnCloudClient client) { RemoteOperationResult result = null; int status = -1; /// prepare array of parameters to update List<Pair<String, String>> parametersToUpdate = new ArrayList<Pair<String, String>>(); if (mPassword != null) { parametersToUpdate.add(new Pair<String, String>(PARAM_PASSWORD, mPassword)); }//from w ww .j av a 2 s. c o m if (mExpirationDateInMillis < 0) { // clear expiration date parametersToUpdate.add(new Pair(PARAM_EXPIRATION_DATE, "")); } else if (mExpirationDateInMillis > 0) { // set expiration date DateFormat dateFormat = new SimpleDateFormat(FORMAT_EXPIRATION_DATE); Calendar expirationDate = Calendar.getInstance(); expirationDate.setTimeInMillis(mExpirationDateInMillis); String formattedExpirationDate = dateFormat.format(expirationDate.getTime()); parametersToUpdate.add(new Pair(PARAM_EXPIRATION_DATE, formattedExpirationDate)); } // else, ignore - no update if (mPermissions > 0) { // set permissions parametersToUpdate.add(new Pair(PARAM_PERMISSIONS, Integer.toString(mPermissions))); } if (mPublicUpload != null) { parametersToUpdate.add(new Pair(PARAM_PUBLIC_UPLOAD, Boolean.toString(mPublicUpload))); } /// perform required PUT requests PutMethod put = null; String uriString = null; try { Uri requestUri = client.getBaseUri(); Uri.Builder uriBuilder = requestUri.buildUpon(); uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH.substring(1)); uriBuilder.appendEncodedPath(Long.toString(mRemoteId)); uriString = uriBuilder.build().toString(); for (Pair<String, String> parameter : parametersToUpdate) { if (put != null) { put.releaseConnection(); } put = new PutMethod(uriString); put.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); put.setRequestEntity(new StringRequestEntity(parameter.first + "=" + parameter.second, ENTITY_CONTENT_TYPE, ENTITY_CHARSET)); status = client.executeMethod(put); if (status == HttpStatus.SC_OK) { String response = put.getResponseBodyAsString(); // Parse xml response ShareToRemoteOperationResultParser parser = new ShareToRemoteOperationResultParser( new ShareXMLParser()); parser.setOwnCloudVersion(client.getOwnCloudVersion()); parser.setServerBaseUri(client.getBaseUri()); result = parser.parse(response); } else { result = new RemoteOperationResult(false, status, put.getResponseHeaders()); } } } catch (Exception e) { result = new RemoteOperationResult(e); Log_OC.e(TAG, "Exception while updating remote share ", e); if (put != null) { put.releaseConnection(); } } finally { if (put != null) { put.releaseConnection(); } } return result; }
From source file:de.janrenz.app.mediathek.SearchActivity.java
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { // query code Uri queryUri = Uri.parse("content://de.janrenz.app.mediathek.cursorloader.data"); queryUri = queryUri.buildUpon().appendQueryParameter("method", "search") .appendQueryParameter("query", mQuery).build(); try {//w w w .j a v a2 s . com //setListShown(false); } catch (Exception e) { Log.e("ERROR_____", e.getMessage()); } return new CursorLoader(this, queryUri, new String[] { "title", "image", "extId", "startTime", "startTimeAsTimestamp", "isLive" }, null, null, null); }
From source file:com.android.julia.todolist.ui.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); Stetho.initializeWithDefaults(this); // Get DBHelper to read from database final TaskDbHelper helper = TaskDbHelper.getInstance(this); mDatabase = helper.getReadableDatabase(); // Initialize the adapter and attach it to the RecyclerView mAdapter = new TodoCursorAdapter(this, new TaskClickListener() { @Override/*from w ww. j a v a 2 s. c om*/ public void onTaskClick(View v, int position, String description, int priority) { showEditTaskDialog(position, description, priority); } }); mRecyclerView.setAdapter(mAdapter); /* Add a touch helper to the RecyclerView to recognize when a user swipes to delete an item. An ItemTouchHelper enables touch behavior (like swipe and move) on each ViewHolder, and uses callbacks to signal when a user is performing these actions. */ new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) { @Override public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { return false; } // Called when a user swipes left or right on a ViewHolder @Override public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) { // Construct the URI for the item to delete. // Use getTag (from the adapter code) to get the id of the swiped item // Retrieve the id of the task to delete int id = (int) viewHolder.itemView.getTag(); // Build appropriate uri with String row id appended String stringId = Integer.toString(id); Uri uri = TaskContract.TaskEntry.CONTENT_URI; uri = uri.buildUpon().appendPath(stringId).build(); // Delete a single row of data using a ContentResolver getContentResolver().delete(uri, null, null); // Restart the loader to re-query for all tasks after a deletion getSupportLoaderManager().restartLoader(TASK_LOADER_ID, null, MainActivity.this); } }).attachToRecyclerView(mRecyclerView); /* Ensure a loader is initialized and active. If the loader doesn't already exist, one is created, otherwise the last created loader is re-used. */ getSupportLoaderManager().initLoader(TASK_LOADER_ID, null, this); // A gray divider line at the bottom of each task mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); }
From source file:com.tapchatapp.android.app.activity.MainActivity.java
public void showBuffer(int type, long connectionId, long bufferId, boolean isArchived) { boolean isTablet = (findViewById(R.id.content1) != null); if (isTablet) { Fragment fragment = BufferFragment.create(type, connectionId, bufferId); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.content1, fragment, "buffer"); transaction.commit();/* w ww . j a v a 2 s. co m*/ } else { Intent intent = new Intent(this, BuffersActivity.class); Uri data = Uri.parse(String.format("tapchat://%s/%s", connectionId, bufferId)); if (isArchived) { data = data.buildUpon().appendQueryParameter("display", "archived").build(); } intent.setData(data); startActivity(intent); } }
From source file:jp.mixi.android.sdk.MixiDialog.java
private WebView setUpWebView(WebView webView) { Log.v(TAG, "setwebview"); webView.getSettings().setUserAgentString(Constants.USER_AGENT); webView.setVerticalScrollBarEnabled(false); webView.setHorizontalScrollBarEnabled(false); webView.setWebViewClient(new MixiWebviewClient()); webView.getSettings().setJavaScriptEnabled(true); webView.addJavascriptInterface(new JsHandler(), "mixi"); String token = mParams.get("oauth_token"); int sdkInt = Integer.valueOf(Build.VERSION.SDK); // android2.1 if (sdkInt < Constants.SUPPORTED_SDK_VERSION) { Uri uri = Uri.parse(mUrl); if (token != null) { Builder builder = uri.buildUpon(); builder.appendQueryParameter("oauth_token", token); uri = builder.build();/*from w ww . j a v a 2 s .c o m*/ } webView.loadUrl(uri.toString()); } else { HashMap<String, String> extraHeaders = new HashMap<String, String>(); if (token != null) { extraHeaders.put("Authorization", "OAuth " + token); } webView.loadUrl(mUrl, extraHeaders); } return webView; }
From source file:co.codecrunch.musicplayerlite.childfragment.ChildFragmentGenres.java
private Cursor getGenersCursor(AsyncQueryHandler async, String filter) { String[] cols = new String[] { MediaStore.Audio.Genres._ID, MediaStore.Audio.Genres.NAME }; Uri uri = MediaStore.Audio.Genres.EXTERNAL_CONTENT_URI; if (!TextUtils.isEmpty(filter)) { uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build(); }//from w w w . j a va 2s.co m Cursor ret = null; if (async != null) { async.startQuery(0, null, uri, cols, null, null, null); } else { ret = MusicPlayerUtility.query(getActivity(), uri, cols, null, null, null); } return ret; }
From source file:com.dmplayer.childfragment.ChildFragmentGenres.java
private Cursor getGenersCursor(AsyncQueryHandler async, String filter) { String[] cols = new String[] { MediaStore.Audio.Genres._ID, MediaStore.Audio.Genres.NAME }; Uri uri = MediaStore.Audio.Genres.EXTERNAL_CONTENT_URI; if (!TextUtils.isEmpty(filter)) { uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build(); }/* w w w. j a v a2s. com*/ Cursor ret = null; if (async != null) { async.startQuery(0, null, uri, cols, null, null, null); } else { ret = DMPlayerUtility.query(getActivity(), uri, cols, null, null, null); } return ret; }
From source file:in.risysnetworks.shplayer.fragments.childfragment.ChildFragmentGenres.java
private Cursor getGenersCursor(AsyncQueryHandler async, String filter) { String[] cols = new String[] { MediaStore.Audio.Genres._ID, MediaStore.Audio.Genres.NAME }; Uri uri = MediaStore.Audio.Genres.EXTERNAL_CONTENT_URI; if (!TextUtils.isEmpty(filter)) { uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build(); }/* w ww . java 2s .c o m*/ Cursor ret = null; if (async != null) { async.startQuery(0, null, uri, cols, null, null, null); } else { ret = SHPlayerUtility.query(getActivity(), uri, cols, null, null, null); } return ret; }
From source file:co.codecrunch.musicplayerlite.childfragment.ChildFragmentAlbum.java
private Cursor getAlbumCursor(AsyncQueryHandler async, String filter) { String[] cols = new String[] { MediaStore.Audio.Albums._ID, MediaStore.Audio.Albums.ARTIST, MediaStore.Audio.Albums.ALBUM, MediaStore.Audio.Albums.ALBUM_ART }; Cursor ret = null;// w ww . j av a 2 s . c om Uri uri = MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI; if (!TextUtils.isEmpty(filter)) { uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build(); } if (async != null) { async.startQuery(0, null, uri, cols, null, null, MediaStore.Audio.Albums.DEFAULT_SORT_ORDER); } else { ret = MusicPlayerUtility.query(getActivity(), uri, cols, null, null, MediaStore.Audio.Albums.DEFAULT_SORT_ORDER); } return ret; }
From source file:com.dmplayer.childfragment.ChildFragmentAlbum.java
private Cursor getAlbumCursor(AsyncQueryHandler async, String filter) { String[] cols = new String[] { MediaStore.Audio.Albums._ID, MediaStore.Audio.Albums.ARTIST, MediaStore.Audio.Albums.ALBUM, MediaStore.Audio.Albums.ALBUM_ART }; Cursor ret = null;/* w w w . ja va 2 s . c o m*/ Uri uri = MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI; if (!TextUtils.isEmpty(filter)) { uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build(); } if (async != null) { async.startQuery(0, null, uri, cols, null, null, MediaStore.Audio.Albums.DEFAULT_SORT_ORDER); } else { ret = DMPlayerUtility.query(getActivity(), uri, cols, null, null, MediaStore.Audio.Albums.DEFAULT_SORT_ORDER); } return ret; }