List of usage examples for android.net Uri buildUpon
public abstract Builder buildUpon();
From source file:com.appjma.appdeployer.service.Downloader.java
@SuppressWarnings("unused") private String getOneFieldOrNull(Uri uri, String id, String field) { Cursor cursor = mCr.query(uri.buildUpon().appendPath(id).appendQueryParameter("limit", "1").build(), new String[] { field }, null, null, null); try {//from w w w.java 2s .co m if (!cursor.moveToFirst()) { return null; } return cursor.getString(0); } finally { cursor.close(); } }
From source file:com.gumgoose.app.quakebuddy.EarthquakeActivity.java
/** * @param id is the ID of the Loader to be created * @param args are arguments supplied by the caller * @return a new instance of the Loader to the LoaderManager *///from w w w . j a v a2 s . c o m @Override public Loader<List<Quake>> onCreateLoader(int id, Bundle args) { // Loader created, obtain user's shared preferences SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); String timePeriod = sharedPrefs.getString(getString(R.string.settings_time_period_key), getString(R.string.settings_time_period_default)); String orderBy = sharedPrefs.getString(getString(R.string.settings_order_by_key), getString(R.string.settings_order_by_default)); String minMagnitude = sharedPrefs.getString(getString(R.string.settings_min_magnitude_key), getString(R.string.settings_min_magnitude_default)); // Create a URL builder object for querying the server Uri baseUri = Uri.parse(USGS_BASE_URL); Uri.Builder uriBuilder = baseUri.buildUpon(); // Append query parameters to the URL builder uriBuilder.appendQueryParameter("format", "geojson"); uriBuilder.appendQueryParameter("starttime", startDateCalculator(timePeriod)); uriBuilder.appendQueryParameter("limit", getString(R.string.display_in_view_quantity)); uriBuilder.appendQueryParameter("minmagnitude", minMagnitude); uriBuilder.appendQueryParameter("orderby", orderBy); // Hide the empty state View while Loader is running mEmptyStateView.setVisibility(View.INVISIBLE); // Start Loader and pass in the complete query URL String return new EarthquakeLoader(this, uriBuilder.toString()); }
From source file:org.awesomeapp.messenger.ui.ConversationListFragment.java
private void setupRecyclerView(RecyclerView recyclerView) { recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext())); Uri baseUri = Imps.Contacts.CONTENT_URI_CHAT_CONTACTS_BY; Uri.Builder builder = baseUri.buildUpon(); mUri = builder.build();//from w ww. j av a 2s .co m mLoaderManager = getLoaderManager(); mLoaderCallbacks = new MyLoaderCallbacks(); mLoaderManager.initLoader(mLoaderId, null, mLoaderCallbacks); Cursor cursor = null; mAdapter = new ConversationListRecyclerViewAdapter(getActivity(), cursor); // init swipe to dismiss logic ItemTouchHelper swipeToDismissTouchHelper = new ItemTouchHelper( new ItemTouchHelper.SimpleCallback(ItemTouchHelper.RIGHT, ItemTouchHelper.RIGHT) { @Override public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { // callback for drag-n-drop, false to skip this feature return false; } @Override public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { // callback for swipe to dismiss, removing item from data and adapter int position = viewHolder.getAdapterPosition(); //delete / endchat //items.remove(viewHolder.getAdapterPosition()); long itemId = mAdapter.getItemId(position); endConversation(itemId); Snackbar.make(mRecView, getString(R.string.action_archived), Snackbar.LENGTH_LONG).show(); } }); swipeToDismissTouchHelper.attachToRecyclerView(recyclerView); if (mAdapter.getItemCount() == 0) { mRecView.setVisibility(View.GONE); mEmptyView.setVisibility(View.VISIBLE); mEmptyViewImage.setVisibility(View.VISIBLE); } else if (mRecView.getVisibility() == View.GONE) { mRecView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); mEmptyViewImage.setVisibility(View.GONE); } }
From source file:de.janrenz.app.mediathek.HeadlinesFragment.java
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { // query code Uri queryUri = Uri.parse("content://de.janrenz.app.mediathek.cursorloader.data"); Integer timestamp = getArguments().getInt("dateint", 0); queryUri = queryUri.buildUpon().appendQueryParameter("timestamp", timestamp.toString()).build(); //queryUri = queryUri.buildUpon().appendQueryParameter("reload", "1").build(); try {/*from w w w . jav a2 s. c om*/ setListShown(false); } catch (Exception e) { Log.e("ERROR", e.getMessage()); } return new CursorLoader(getActivity(), queryUri, new String[] { "title", "image", "extId", "startTime", "startTimeAsTimestamp", "isLive" }, null, null, null); }
From source file:com.silentcircle.contacts.list.PhoneNumberListAdapter.java
@Override public void configureLoader(CursorLoader loader, long directoryId) { if (directoryId != Directory.DEFAULT) { Log.w(TAG, "PhoneNumberListAdapter is not ready for non-default directory ID (" + "directoryId: " + directoryId + ")"); }/*from w ww . j a v a2 s . c om*/ final Builder builder; if (isSearchMode()) { final Uri baseUri = mUseCallableUri ? Callable.CONTENT_FILTER_URI : Phone.CONTENT_FILTER_URI; builder = baseUri.buildUpon(); final String query = getQueryString(); if (TextUtils.isEmpty(query)) { builder.appendPath(""); } else { builder.appendPath(query); // Builder will encode the query } builder.appendQueryParameter(ScContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(directoryId)); } else { final Uri baseUri = mUseCallableUri ? Callable.CONTENT_URI : Phone.CONTENT_URI; builder = baseUri.buildUpon().appendQueryParameter(ScContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(Directory.DEFAULT)); if (isSectionHeaderDisplayEnabled()) { builder.appendQueryParameter(ScContactsContract.ContactCounts.ADDRESS_BOOK_INDEX_EXTRAS, "true"); } applyFilter(loader, builder, directoryId, getFilter()); } // Remove duplicates when it is possible. builder.appendQueryParameter(ScContactsContract.REMOVE_DUPLICATE_ENTRIES, "true"); loader.setUri(builder.build()); // TODO a projection that includes the search snippet if (getContactNameDisplayOrder() == ScContactsContract.Preferences.DISPLAY_ORDER_PRIMARY) { loader.setProjection(PhoneQuery.PROJECTION_PRIMARY); } else { loader.setProjection(PhoneQuery.PROJECTION_ALTERNATIVE); } if (getSortOrder() == ScContactsContract.Preferences.SORT_ORDER_PRIMARY) { loader.setSortOrder(Phone.SORT_KEY_PRIMARY); } else { loader.setSortOrder(Phone.SORT_KEY_ALTERNATIVE); } }
From source file:org.awesomeapp.messenger.ui.ContactsListFragment.java
private void setupRecyclerView(RecyclerView recyclerView) { recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext())); Uri baseUri = Imps.Contacts.CONTENT_URI; Uri.Builder builder = baseUri.buildUpon(); mUri = builder.build();/*from www. ja va 2 s.c o m*/ mLoaderManager = getLoaderManager(); mLoaderCallbacks = new MyLoaderCallbacks(); mLoaderManager.initLoader(mLoaderId, null, mLoaderCallbacks); Cursor cursor = null; mAdapter = new ContactListRecyclerViewAdapter(getActivity(), cursor); if (mAdapter.getItemCount() == 0) { mRecView.setVisibility(View.GONE); mEmptyView.setVisibility(View.VISIBLE); } else { mRecView.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); } /** // init swipe to dismiss logic ItemTouchHelper swipeToDismissTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback( ItemTouchHelper.RIGHT, ItemTouchHelper.RIGHT) { @Override public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { // callback for drag-n-drop, false to skip this feature return false; } @Override public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { final long itemId = mAdapter.getItemId( viewHolder.getAdapterPosition()); final String address= ((ContactListRecyclerViewAdapter.ViewHolder)viewHolder).mAddress; Snackbar.make(mRecView, "Remove " + address + "?", Snackbar.LENGTH_LONG) .setAction("Yes", new View.OnClickListener() { @Override public void onClick(View v) { //if they click, then cancel timer that will be used to end the chat deleteContact(itemId, address); } }).show(); } }); swipeToDismissTouchHelper.attachToRecyclerView(recyclerView); */ }
From source file:com.owncloud.android.lib.resources.status.GetRemoteCapabilitiesOperation.java
@Override protected RemoteOperationResult run(OwnCloudClient client) { RemoteOperationResult result = null; int status;/* w ww .j a v a2s.c o m*/ GetMethod get = null; try { Uri requestUri = client.getBaseUri(); Uri.Builder uriBuilder = requestUri.buildUpon(); uriBuilder.appendEncodedPath(OCS_ROUTE); // avoid starting "/" in this method uriBuilder.appendQueryParameter(PARAM_FORMAT, VALUE_FORMAT); // Get Method get = new GetMethod(uriBuilder.build().toString()); get.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); status = client.executeMethod(get); if (isSuccess(status)) { String response = get.getResponseBodyAsString(); Log_OC.d(TAG, "Successful response: " + response); // Parse the response JSONObject respJSON = new JSONObject(response); JSONObject respOCS = respJSON.getJSONObject(NODE_OCS); JSONObject respMeta = respOCS.getJSONObject(NODE_META); JSONObject respData = respOCS.getJSONObject(NODE_DATA); // Read meta boolean statusProp = respMeta.getString(PROPERTY_STATUS).equalsIgnoreCase("ok"); int statuscode = respMeta.getInt(PROPERTY_STATUSCODE); String message = respMeta.getString(PROPERTY_MESSAGE); if (statusProp) { ArrayList<Object> data = new ArrayList<Object>(); // For result data OCCapability capability = new OCCapability(); // Add Version if (respData.has(NODE_VERSION)) { JSONObject respVersion = respData.getJSONObject(NODE_VERSION); capability.setVersionMayor(respVersion.getInt(PROPERTY_MAJOR)); capability.setVersionMinor(respVersion.getInt(PROPERTY_MINOR)); capability.setVersionMicro(respVersion.getInt(PROPERTY_MICRO)); capability.setVersionString(respVersion.getString(PROPERTY_STRING)); capability.setVersionEdition(respVersion.getString(PROPERTY_EDITION)); Log_OC.d(TAG, "*** Added " + NODE_VERSION); } // Capabilities Object if (respData.has(NODE_CAPABILITIES)) { JSONObject respCapabilities = respData.getJSONObject(NODE_CAPABILITIES); // Add Core: pollinterval if (respCapabilities.has(NODE_CORE)) { JSONObject respCore = respCapabilities.getJSONObject(NODE_CORE); capability.setCorePollinterval(respCore.getInt(PROPERTY_POLLINTERVAL)); Log_OC.d(TAG, "*** Added " + NODE_CORE); } // Add files_sharing: public, user, resharing if (respCapabilities.has(NODE_FILES_SHARING)) { JSONObject respFilesSharing = respCapabilities.getJSONObject(NODE_FILES_SHARING); if (respFilesSharing.has(PROPERTY_API_ENABLED)) { capability.setFilesSharingApiEnabled(CapabilityBooleanType .fromBooleanValue(respFilesSharing.getBoolean(PROPERTY_API_ENABLED))); } if (respFilesSharing.has(NODE_PUBLIC)) { JSONObject respPublic = respFilesSharing.getJSONObject(NODE_PUBLIC); capability.setFilesSharingPublicEnabled(CapabilityBooleanType .fromBooleanValue(respPublic.getBoolean(PROPERTY_ENABLED))); if (respPublic.has(NODE_PASSWORD)) { capability.setFilesSharingPublicPasswordEnforced( CapabilityBooleanType.fromBooleanValue(respPublic .getJSONObject(NODE_PASSWORD).getBoolean(PROPERTY_ENFORCED))); } if (respPublic.has(NODE_EXPIRE_DATE)) { JSONObject respExpireDate = respPublic.getJSONObject(NODE_EXPIRE_DATE); capability.setFilesSharingPublicExpireDateEnabled(CapabilityBooleanType .fromBooleanValue(respExpireDate.getBoolean(PROPERTY_ENABLED))); if (respExpireDate.has(PROPERTY_DAYS)) { capability.setFilesSharingPublicExpireDateDays( respExpireDate.getInt(PROPERTY_DAYS)); } if (respExpireDate.has(PROPERTY_ENFORCED)) { capability.setFilesSharingPublicExpireDateEnforced(CapabilityBooleanType .fromBooleanValue(respExpireDate.getBoolean(PROPERTY_ENFORCED))); } } if (respPublic.has(PROPERTY_UPLOAD)) { capability.setFilesSharingPublicUpload(CapabilityBooleanType .fromBooleanValue(respPublic.getBoolean(PROPERTY_UPLOAD))); } } if (respFilesSharing.has(NODE_USER)) { JSONObject respUser = respFilesSharing.getJSONObject(NODE_USER); capability.setFilesSharingUserSendMail(CapabilityBooleanType .fromBooleanValue(respUser.getBoolean(PROPERTY_SEND_MAIL))); } capability.setFilesSharingResharing(CapabilityBooleanType .fromBooleanValue(respFilesSharing.getBoolean(PROPERTY_RESHARING))); if (respFilesSharing.has(NODE_FEDERATION)) { JSONObject respFederation = respFilesSharing.getJSONObject(NODE_FEDERATION); capability.setFilesSharingFederationOutgoing(CapabilityBooleanType .fromBooleanValue(respFederation.getBoolean(PROPERTY_OUTGOING))); capability.setFilesSharingFederationIncoming(CapabilityBooleanType .fromBooleanValue(respFederation.getBoolean(PROPERTY_INCOMING))); } Log_OC.d(TAG, "*** Added " + NODE_FILES_SHARING); } if (respCapabilities.has(NODE_FILES)) { JSONObject respFiles = respCapabilities.getJSONObject(NODE_FILES); // Add files capability.setFilesBigFileChuncking(CapabilityBooleanType .fromBooleanValue(respFiles.getBoolean(PROPERTY_BIGFILECHUNKING))); if (respFiles.has(PROPERTY_UNDELETE)) { capability.setFilesUndelete(CapabilityBooleanType .fromBooleanValue(respFiles.getBoolean(PROPERTY_UNDELETE))); } capability.setFilesVersioning(CapabilityBooleanType .fromBooleanValue(respFiles.getBoolean(PROPERTY_VERSIONING))); Log_OC.d(TAG, "*** Added " + NODE_FILES); } } // Result data.add(capability); result = new RemoteOperationResult(true, status, get.getResponseHeaders()); result.setData(data); Log_OC.d(TAG, "*** Get Capabilities completed "); } else { result = new RemoteOperationResult(statusProp, statuscode, null); Log_OC.e(TAG, "Failed response while getting capabilities from the server "); Log_OC.e(TAG, "*** status: " + statusProp + "; message: " + message); } } else { result = new RemoteOperationResult(false, status, get.getResponseHeaders()); String response = get.getResponseBodyAsString(); Log_OC.e(TAG, "Failed response while getting capabilities from the server "); if (response != null) { Log_OC.e(TAG, "*** status code: " + status + "; response message: " + response); } else { Log_OC.e(TAG, "*** status code: " + status); } } } catch (Exception e) { result = new RemoteOperationResult(e); Log_OC.e(TAG, "Exception while getting capabilities", e); } finally { if (get != null) { get.releaseConnection(); } } return result; }
From source file:de.elanev.studip.android.app.frontend.news.NewsListFragment.java
public Loader<Cursor> onCreateLoader(int id, Bundle data) { setLoadingViewVisible(true);//from w w w . j ava2 s . c o m Uri uri = NewsContract.CONTENT_URI; String[] projection = null; switch (id) { case NewsTabsAdapter.NEWS_COURSES: uri = uri.buildUpon().appendPath("courses").build(); projection = NewsQuery.PROJECTION_COURSES; break; case NewsTabsAdapter.NEWS_INSTITUTES: uri = uri.buildUpon().appendPath("institutes").build(); projection = NewsQuery.PROJECTION_INSTITUTES; break; case NewsTabsAdapter.NEWS_GLOBAL: uri = uri.buildUpon().appendPath("global").build(); projection = NewsQuery.PROJECTION_GLOBAL; break; } return new CursorLoader(getActivity(), uri, projection, NewsContract.Columns.NEWS_EXPIRE + " > (strftime('%s','now')-" + NewsContract.Columns.NEWS_DATE + ")", null, NewsContract.DEFAULT_SORT_ORDER); }
From source file:de.janrenz.app.mediathek.LiveFragment.java
@Override public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) { // query codea Uri queryUri = Uri.parse("content://de.janrenz.app.mediathek.cursorloader.data"); queryUri = queryUri.buildUpon().appendQueryParameter("method", "broadcast").build(); return new CursorLoader(getActivity(), queryUri, new String[] { "title", "image", "extId", "startTime", "startTimeAsTimestamp", "isLive", "description", "timeinfo" }, null, null, null); }
From source file:org.mobisocial.corral.ContentCorral.java
private static String getIndexPath(Uri uri) { String seg = uri.getLastPathSegment(); if (seg.endsWith(".html") || seg.endsWith(".htm") || seg.endsWith(".php")) { return uri.getPath(); }//from w w w . j a v a 2 s . c o m return uri.buildUpon().appendPath("index.html").build().getPath(); }