Example usage for android.net Uri getQueryParameter

List of usage examples for android.net Uri getQueryParameter

Introduction

In this page you can find the example usage for android.net Uri getQueryParameter.

Prototype

@Nullable
public String getQueryParameter(String key) 

Source Link

Document

Searches the query string for the first value with the given key.

Usage

From source file:com.android.mms.ui.MessageUtils.java

private static long getAttachmentSize(Context context) {
    Uri uri = Uri.parse("content://mms/attachment_size");
    ContentValues insertValues = new ContentValues();
    uri = context.getContentResolver().insert(uri, insertValues);
    String size = uri.getQueryParameter("size");
    return Long.parseLong(size);
}

From source file:com.android.mms.ui.MessageUtils.java

private static long getDatabaseSize(Context context) {
    Uri uri = Uri.parse("content://mms-sms/database_size");
    ContentValues insertValues = new ContentValues();
    uri = context.getContentResolver().insert(uri, insertValues);
    String size = uri.getQueryParameter("size");
    return Long.parseLong(size);
}

From source file:com.microsoft.services.msa.AuthorizationRequest.java

/**
 * Called when the end uri is loaded./*w ww  .  j  ava  2  s  .c  o  m*/
 *
 * This method will read the uri's query parameters and fragment, and respond with the
 * appropriate action.
 *
 * @param endUri that was loaded
 */
private void onEndUri(Uri endUri) {
    // If we are on an end uri, the response could either be in
    // the fragment or the query parameters. The response could
    // either be successful or it could contain an error.
    // Check all situations and call the listener's appropriate callback.
    // Callback the listener on the UI/main thread. We could call it right away since
    // we are on the UI/main thread, but it is probably better that we finish up with
    // the WebView code before we callback on the listener.
    boolean hasFragment = endUri.getFragment() != null;
    boolean hasQueryParameters = endUri.getQuery() != null;
    boolean invalidUri = !hasFragment && !hasQueryParameters;
    boolean isHierarchical = endUri.isHierarchical();

    // check for an invalid uri, and leave early
    if (invalidUri) {
        this.onInvalidUri();
        return;
    }

    if (hasFragment) {
        Map<String, String> fragmentParameters = AuthorizationRequest.getFragmentParametersMap(endUri);

        boolean isSuccessfulResponse = fragmentParameters.containsKey(OAuth.ACCESS_TOKEN)
                && fragmentParameters.containsKey(OAuth.TOKEN_TYPE);
        if (isSuccessfulResponse) {

            //                SharedPreferences preferences = activity.getSharedPreferences("csPrivateSpace", Context.MODE_PRIVATE);
            //                SharedPreferences.Editor editor = preferences.edit();
            //                editor.putString("funUserID", fragmentParameters.get("user_id"));
            //                editor.apply();

            this.onAccessTokenResponse(fragmentParameters);
            return;
        }

        String error = fragmentParameters.get(OAuth.ERROR);
        if (error != null) {
            String errorDescription = fragmentParameters.get(OAuth.ERROR_DESCRIPTION);
            String errorUri = fragmentParameters.get(OAuth.ERROR_URI);
            this.onError(error, errorDescription, errorUri);
            return;
        }
    }

    if (hasQueryParameters && isHierarchical) {
        String code = endUri.getQueryParameter(OAuth.CODE);
        if (code != null) {
            this.onAuthorizationResponse(code);
            return;
        }

        String error = endUri.getQueryParameter(OAuth.ERROR);
        if (error != null) {
            String errorDescription = endUri.getQueryParameter(OAuth.ERROR_DESCRIPTION);
            String errorUri = endUri.getQueryParameter(OAuth.ERROR_URI);
            this.onError(error, errorDescription, errorUri);
            return;
        }
    }

    if (hasQueryParameters && !isHierarchical) {
        String[] pairs = endUri.getQuery().split("&|=");
        for (int i = 0; i < pairs.length; i = +2) {
            if (pairs[i].equals(OAuth.CODE)) {
                this.onAuthorizationResponse(pairs[i + 1]);
                return;
            }
        }
    }

    // if the code reaches this point, the uri was invalid
    // because it did not contain either a successful response
    // or an error in either the queryParameter or the fragment
    this.onInvalidUri();
}

From source file:org.getlantern.firetweet.provider.FiretweetDataProvider.java

@Override
public Cursor query(final Uri uri, final String[] projection, final String selection,
        final String[] selectionArgs, final String sortOrder) {
    try {//from   w  w w.  j ava 2  s.  c  o m
        final int tableId = getTableId(uri);
        final String table = getTableNameById(tableId);
        checkReadPermission(tableId, table, projection);
        switch (tableId) {
        case VIRTUAL_TABLE_ID_DATABASE_READY: {
            if (mDatabaseWrapper.isReady())
                return new MatrixCursor(projection != null ? projection : new String[0]);
            return null;
        }
        case VIRTUAL_TABLE_ID_PERMISSIONS: {
            final MatrixCursor c = new MatrixCursor(FiretweetDataStore.Permissions.MATRIX_COLUMNS);
            final Map<String, String> map = mPermissionsManager.getAll();
            for (final Map.Entry<String, String> item : map.entrySet()) {
                c.addRow(new Object[] { item.getKey(), item.getValue() });
            }
            return c;
        }
        case VIRTUAL_TABLE_ID_ALL_PREFERENCES: {
            return getPreferencesCursor(mPreferences, null);
        }
        case VIRTUAL_TABLE_ID_PREFERENCES: {
            return getPreferencesCursor(mPreferences, uri.getLastPathSegment());
        }
        case VIRTUAL_TABLE_ID_DNS: {
            return getDNSCursor(uri.getLastPathSegment());
        }
        case VIRTUAL_TABLE_ID_CACHED_IMAGES: {
            return getCachedImageCursor(uri.getQueryParameter(QUERY_PARAM_URL));
        }
        case VIRTUAL_TABLE_ID_NOTIFICATIONS: {
            final List<String> segments = uri.getPathSegments();
            if (segments.size() == 2)
                return getNotificationsCursor(ParseUtils.parseInt(segments.get(1), -1));
            else
                return getNotificationsCursor();
        }
        case VIRTUAL_TABLE_ID_UNREAD_COUNTS: {
            final List<String> segments = uri.getPathSegments();
            if (segments.size() == 2)
                return getUnreadCountsCursor(ParseUtils.parseInt(segments.get(1), -1));
            else
                return getUnreadCountsCursor();
        }
        case VIRTUAL_TABLE_ID_UNREAD_COUNTS_BY_TYPE: {
            final List<String> segments = uri.getPathSegments();
            if (segments.size() != 3)
                return null;
            return getUnreadCountsCursorByType(segments.get(2));
        }
        case TABLE_ID_DIRECT_MESSAGES_CONVERSATION: {
            final List<String> segments = uri.getPathSegments();
            if (segments.size() != 4)
                return null;
            final long accountId = ParseUtils.parseLong(segments.get(2));
            final long conversationId = ParseUtils.parseLong(segments.get(3));
            final SQLSelectQuery query = ConversationQueryBuilder.buildByConversationId(projection, accountId,
                    conversationId, selection, sortOrder);
            final Cursor c = mDatabaseWrapper.rawQuery(query.getSQL(), selectionArgs);
            setNotificationUri(c, DirectMessages.CONTENT_URI);
            return c;
        }
        case TABLE_ID_DIRECT_MESSAGES_CONVERSATION_SCREEN_NAME: {
            final List<String> segments = uri.getPathSegments();
            if (segments.size() != 4)
                return null;
            final long accountId = ParseUtils.parseLong(segments.get(2));
            final String screenName = segments.get(3);
            final SQLSelectQuery query = ConversationQueryBuilder.buildByScreenName(projection, accountId,
                    screenName, selection, sortOrder);
            final Cursor c = mDatabaseWrapper.rawQuery(query.getSQL(), selectionArgs);
            setNotificationUri(c, DirectMessages.CONTENT_URI);
            return c;
        }
        case VIRTUAL_TABLE_ID_CACHED_USERS_WITH_RELATIONSHIP: {
            final long accountId = ParseUtils.parseLong(uri.getLastPathSegment(), -1);
            final SQLSelectQuery query = CachedUsersQueryBuilder.withRelationship(projection, selection,
                    sortOrder, accountId);
            final Cursor c = mDatabaseWrapper.rawQuery(query.getSQL(), selectionArgs);
            setNotificationUri(c, CachedUsers.CONTENT_URI);
            return c;
        }
        case VIRTUAL_TABLE_ID_CACHED_USERS_WITH_SCORE: {
            final long accountId = ParseUtils.parseLong(uri.getLastPathSegment(), -1);
            final SQLSelectQuery query = CachedUsersQueryBuilder.withScore(projection, selection, sortOrder,
                    accountId);
            final Cursor c = mDatabaseWrapper.rawQuery(query.getSQL(), selectionArgs);
            setNotificationUri(c, CachedUsers.CONTENT_URI);
            return c;
        }
        case VIRTUAL_TABLE_ID_DRAFTS_UNSENT: {
            final FiretweetApplication app = FiretweetApplication.getInstance(getContext());
            final AsyncTwitterWrapper twitter = app.getTwitterWrapper();
            final RawItemArray sendingIds = new RawItemArray(twitter.getSendingDraftIds());
            final Expression where;
            if (selection != null) {
                where = Expression.and(new Expression(selection),
                        Expression.notIn(new Column(Drafts._ID), sendingIds));
            } else {
                where = Expression.and(Expression.notIn(new Column(Drafts._ID), sendingIds));
            }
            final Cursor c = mDatabaseWrapper.query(Drafts.TABLE_NAME, projection, where.getSQL(),
                    selectionArgs, null, null, sortOrder);
            setNotificationUri(c, getNotificationUri(tableId, uri));
            return c;
        }
        }
        if (table == null)
            return null;
        final Cursor c = mDatabaseWrapper.query(table, projection, selection, selectionArgs, null, null,
                sortOrder);
        setNotificationUri(c, getNotificationUri(tableId, uri));
        return c;
    } catch (final SQLException e) {
        Crashlytics.logException(e);
        throw new IllegalStateException(e);
    }
}

From source file:im.vector.receiver.VectorUniversalLinkReceiver.java

/***
 * Tries to parse an universal link./* ww  w.  j ava  2  s .c  om*/
 *
 * @param uri the uri to parse
 * @return the universal link items, null if the universal link is invalid
 */
public static HashMap<String, String> parseUniversalLink(Uri uri) {
    HashMap<String, String> map = null;

    try {
        // sanity check
        if ((null == uri) || TextUtils.isEmpty(uri.getPath())) {
            Log.e(LOG_TAG, "## parseUniversalLink : null");
            return null;
        }

        if (!TextUtils.equals(uri.getHost(), "vector.im") && !TextUtils.equals(uri.getHost(), "riot.im")
                && !TextUtils.equals(uri.getHost(), "matrix.to")) {
            Log.e(LOG_TAG, "## parseUniversalLink : unsupported host " + uri.getHost());
            return null;
        }

        boolean isSupportedHost = TextUtils.equals(uri.getHost(), "vector.im")
                || TextUtils.equals(uri.getHost(), "riot.im");

        // when the uri host is vector.im, it is followed by a dedicated path
        if (isSupportedHost && !mSupportedVectorLinkPaths.contains(uri.getPath())) {
            Log.e(LOG_TAG, "## parseUniversalLink : not supported");
            return null;
        }

        // remove the server part
        String uriFragment;
        if (null != (uriFragment = uri.getFragment())) {
            uriFragment = uriFragment.substring(1); // get rid of first "/"
        } else {
            Log.e(LOG_TAG, "## parseUniversalLink : cannot extract path");
            return null;
        }

        String temp[] = uriFragment.split("/", 3); // limit to 3 for security concerns (stack overflow injection)

        if (!isSupportedHost) {
            ArrayList<String> compliantList = new ArrayList<>(Arrays.asList(temp));
            compliantList.add(0, "room");
            temp = compliantList.toArray(new String[compliantList.size()]);
        }

        if (temp.length < 2) {
            Log.e(LOG_TAG, "## parseUniversalLink : too short");
            return null;
        }

        if (!TextUtils.equals(temp[0], "room") && !TextUtils.equals(temp[0], "user")) {
            Log.e(LOG_TAG, "## parseUniversalLink : not supported " + temp[0]);
            return null;
        }

        map = new HashMap<>();

        String firstParam = temp[1];

        if (MXSession.isUserId(firstParam)) {
            if (temp.length > 2) {
                Log.e(LOG_TAG, "## parseUniversalLink : universal link to member id is too long");
                return null;
            }

            map.put(ULINK_MATRIX_USER_ID_KEY, firstParam);
        } else if (MXSession.isRoomAlias(firstParam) || MXSession.isRoomId(firstParam)) {
            map.put(ULINK_ROOM_ID_OR_ALIAS_KEY, firstParam);
        } else if (MXSession.isGroupId(firstParam)) {
            map.put(ULINK_GROUP_ID_KEY, firstParam);
        }

        // room id only ?
        if (temp.length > 2) {
            String eventId = temp[2];

            if (MXSession.isMessageId(eventId)) {
                map.put(ULINK_EVENT_ID_KEY, temp[2]);
            } else {
                uri = Uri.parse(uri.toString().replace("#/room/", "room/"));

                map.put(ULINK_ROOM_ID_OR_ALIAS_KEY, uri.getLastPathSegment());

                Set<String> names = uri.getQueryParameterNames();

                for (String name : names) {
                    String value = uri.getQueryParameter(name);

                    try {
                        value = URLDecoder.decode(value, "UTF-8");
                    } catch (Exception e) {
                        Log.e(LOG_TAG, "## parseUniversalLink : URLDecoder.decode " + e.getMessage());
                        return null;
                    }

                    map.put(name, value);
                }
            }
        }
    } catch (Exception e) {
        Log.e(LOG_TAG, "## parseUniversalLink : crashes " + e.getLocalizedMessage());
    }

    // check if the parsing succeeds
    if ((null != map) && (map.size() < 1)) {
        Log.e(LOG_TAG, "## parseUniversalLink : empty dictionary");
        return null;
    }

    return map;
}

From source file:com.android.tv.MainActivity.java

private boolean handleIntent(Intent intent) {
    // Reset the closed caption settings when the activity is 1)created or 2) restarted.
    // And do not reset while TvView is playing.
    if (!mTvView.isPlaying()) {
        mCaptionSettings = new CaptionSettings(this);
    }//w  ww. j av  a 2s .  c  om

    // Handle the passed key press, if any. Note that only the key codes that are currently
    // handled in the TV app will be handled via Intent.
    // TODO: Consider defining a separate intent filter as passing data of mime type
    // vnd.android.cursor.item/channel isn't really necessary here.
    int keyCode = intent.getIntExtra(Utils.EXTRA_KEY_KEYCODE, KeyEvent.KEYCODE_UNKNOWN);
    if (keyCode != KeyEvent.KEYCODE_UNKNOWN) {
        if (DEBUG)
            Log.d(TAG, "Got an intent with keycode: " + keyCode);
        KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, keyCode);
        onKeyUp(keyCode, event);
        return true;
    }
    mShouldTuneToTunerChannel = intent.getBooleanExtra(Utils.EXTRA_KEY_FROM_LAUNCHER, false);
    mInitChannelUri = null;

    String extraAction = intent.getStringExtra(Utils.EXTRA_KEY_ACTION);
    if (!TextUtils.isEmpty(extraAction)) {
        if (DEBUG)
            Log.d(TAG, "Got an extra action: " + extraAction);
        if (Utils.EXTRA_ACTION_SHOW_TV_INPUT.equals(extraAction)) {
            String lastWatchedChannelUri = Utils.getLastWatchedChannelUri(this);
            if (lastWatchedChannelUri != null) {
                mInitChannelUri = Uri.parse(lastWatchedChannelUri);
            }
            mShowSelectInputView = true;
        }
    }

    if (CommonFeatures.DVR.isEnabled(this) && BuildCompat.isAtLeastN()) {
        mRecordingUri = intent.getParcelableExtra(Utils.EXTRA_KEY_RECORDING_URI);
        if (mRecordingUri != null) {
            return true;
        }
    }

    // TODO: remove the checkState once N API is finalized.
    SoftPreconditions
            .checkState(TvInputManager.ACTION_SETUP_INPUTS.equals("android.media.tv.action.SETUP_INPUTS"));
    if (TvInputManager.ACTION_SETUP_INPUTS.equals(intent.getAction())) {
        runAfterAttachedToWindow(new Runnable() {
            @Override
            public void run() {
                mOverlayManager.showSetupFragment();
            }
        });
    } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        Uri uri = intent.getData();
        try {
            mSource = uri.getQueryParameter(Utils.PARAM_SOURCE);
        } catch (UnsupportedOperationException e) {
            // ignore this exception.
        }
        // When the URI points to the programs (directory, not an individual item), go to the
        // program guide. The intention here is to respond to
        // "content://android.media.tv/program", not "content://android.media.tv/program/XXX".
        // Later, we might want to add handling of individual programs too.
        if (Utils.isProgramsUri(uri)) {
            // The given data is a programs URI. Open the Program Guide.
            mShowProgramGuide = true;
            return true;
        }
        // In case the channel is given explicitly, use it.
        mInitChannelUri = uri;
        if (DEBUG)
            Log.d(TAG, "ACTION_VIEW with " + mInitChannelUri);
        if (Channels.CONTENT_URI.equals(mInitChannelUri)) {
            // Tune to default channel.
            mInitChannelUri = null;
            mShouldTuneToTunerChannel = true;
            return true;
        }
        if ((!Utils.isChannelUriForOneChannel(mInitChannelUri)
                && !Utils.isChannelUriForInput(mInitChannelUri))) {
            Log.w(TAG, "Malformed channel uri " + mInitChannelUri + " tuning to default instead");
            mInitChannelUri = null;
            return true;
        }
        mTuneParams = intent.getExtras();
        if (mTuneParams == null) {
            mTuneParams = new Bundle();
        }
        if (Utils.isChannelUriForTunerInput(mInitChannelUri)) {
            long channelId = ContentUris.parseId(mInitChannelUri);
            mTuneParams.putLong(KEY_INIT_CHANNEL_ID, channelId);
        } else if (TvContract.isChannelUriForPassthroughInput(mInitChannelUri)) {
            // If mInitChannelUri is for a passthrough TV input.
            String inputId = mInitChannelUri.getPathSegments().get(1);
            TvInputInfo input = mTvInputManagerHelper.getTvInputInfo(inputId);
            if (input == null) {
                mInitChannelUri = null;
                Toast.makeText(this, R.string.msg_no_specific_input, Toast.LENGTH_SHORT).show();
                return false;
            } else if (!input.isPassthroughInput()) {
                mInitChannelUri = null;
                Toast.makeText(this, R.string.msg_not_passthrough_input, Toast.LENGTH_SHORT).show();
                return false;
            }
        } else if (mInitChannelUri != null) {
            // Handle the URI built by TvContract.buildChannelsUriForInput().
            // TODO: Change hard-coded "input" to TvContract.PARAM_INPUT.
            String inputId = mInitChannelUri.getQueryParameter("input");
            long channelId = Utils.getLastWatchedChannelIdForInput(this, inputId);
            if (channelId == Channel.INVALID_ID) {
                String[] projection = { Channels._ID };
                try (Cursor cursor = getContentResolver().query(uri, projection, null, null, null)) {
                    if (cursor != null && cursor.moveToNext()) {
                        channelId = cursor.getLong(0);
                    }
                }
            }
            if (channelId == Channel.INVALID_ID) {
                // Couldn't find any channel probably because the input hasn't been set up.
                // Try to set it up.
                mInitChannelUri = null;
                mInputToSetUp = mTvInputManagerHelper.getTvInputInfo(inputId);
            } else {
                mInitChannelUri = TvContract.buildChannelUri(channelId);
                mTuneParams.putLong(KEY_INIT_CHANNEL_ID, channelId);
            }
        }
    }
    return true;
}

From source file:de.vanita5.twittnuker.activity.support.LinkHandlerActivity.java

private boolean showFragment(final Uri uri) {
    final Intent intent = getIntent();
    intent.setExtrasClassLoader(getClassLoader());
    final Fragment fragment = createFragmentForIntent(this, intent);
    if (uri == null || fragment == null)
        return false;
    switch (matchLinkId(uri)) {
    case LINK_ID_STATUS: {
        setTitle(R.string.status);/*from www .  j  a  va2 s  .  c  o  m*/
        break;
    }
    case LINK_ID_USER: {
        setTitle(R.string.user);
        break;
    }
    case LINK_ID_USER_TIMELINE: {
        setTitle(R.string.statuses);
        break;
    }
    case LINK_ID_USER_FAVORITES: {
        setTitle(R.string.favorites);
        break;
    }
    case LINK_ID_USER_FOLLOWERS: {
        setTitle(R.string.followers);
        break;
    }
    case LINK_ID_USER_FRIENDS: {
        setTitle(R.string.action_following);
        break;
    }
    case LINK_ID_USER_BLOCKS: {
        setTitle(R.string.blocked_users);
        break;
    }
    case LINK_ID_MUTES_USERS: {
        setTitle(R.string.twitter_muted_users);
        break;
    }
    case LINK_ID_DIRECT_MESSAGES_CONVERSATION: {
        setTitle(R.string.direct_messages);
        break;
    }
    case LINK_ID_USER_LIST: {
        setTitle(R.string.user_list);
        break;
    }
    case LINK_ID_USER_LISTS: {
        setTitle(R.string.user_lists);
        break;
    }
    case LINK_ID_USER_LIST_TIMELINE: {
        setTitle(R.string.list_timeline);
        break;
    }
    case LINK_ID_USER_LIST_MEMBERS: {
        setTitle(R.string.list_members);
        break;
    }
    case LINK_ID_USER_LIST_SUBSCRIBERS: {
        setTitle(R.string.list_subscribers);
        break;
    }
    case LINK_ID_USER_LIST_MEMBERSHIPS: {
        setTitle(R.string.lists_following_user);
        break;
    }
    case LINK_ID_SAVED_SEARCHES: {
        setTitle(R.string.saved_searches);
        break;
    }
    case LINK_ID_USER_MENTIONS: {
        setTitle(R.string.user_mentions);
        break;
    }
    case LINK_ID_INCOMING_FRIENDSHIPS: {
        setTitle(R.string.incoming_friendships);
        break;
    }
    case LINK_ID_USERS: {
        setTitle(R.string.users);
        break;
    }
    case LINK_ID_STATUSES: {
        setTitle(R.string.statuses);
        break;
    }
    case LINK_ID_STATUS_RETWEETERS: {
        setTitle(R.string.users_retweeted_this);
        break;
    }
    case LINK_ID_STATUS_FAVORITERS: {
        setTitle(R.string.users_retweeted_this);
        break;
    }
    case LINK_ID_STATUS_REPLIES: {
        setTitle(R.string.view_replies);
        break;
    }
    case LINK_ID_SEARCH: {
        setTitle(android.R.string.search_go);
        setSubtitle(uri.getQueryParameter(QUERY_PARAM_QUERY));
        break;
    }
    default: {
        return false;
    }
    }
    mFinishOnly = Boolean.parseBoolean(uri.getQueryParameter(QUERY_PARAM_FINISH_ONLY));
    final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(android.R.id.content, fragment);
    ft.commit();
    return true;
}

From source file:gc.david.dfm.ui.MainActivity.java

/**
 * Handles a send intent with position data.
 *
 * @param intent Input intent with position data.
 *///from  ww  w .ja va  2s.c om
private void handleViewPositionIntent(final Intent intent) throws Exception {
    Mint.leaveBreadcrumb("MainActivity::handleViewPositionIntent");
    final Uri uri = intent.getData();
    Mint.addExtraData("queryParameter", uri.toString());

    final String uriScheme = uri.getScheme();
    if (uriScheme.equals("geo")) {
        final String schemeSpecificPart = uri.getSchemeSpecificPart();
        final Matcher matcher = getMatcherForUri(schemeSpecificPart);
        if (matcher.find()) {
            if (matcher.group(1).equals("0") && matcher.group(2).equals("0")) {
                if (matcher.find()) { // Manage geo:0,0?q=lat,lng(label)
                    setDestinationPosition(matcher);
                } else { // Manage geo:0,0?q=my+street+address
                    String destination = Uri.decode(uri.getQuery()).replace('+', ' ');
                    destination = destination.replace("q=", "");

                    // TODO check this ugly workaround
                    new SearchPositionByName().execute(destination);
                    mustShowPositionWhenComingFromOutside = true;
                }
            } else { // Manage geo:latitude,longitude or geo:latitude,longitude?z=zoom
                setDestinationPosition(matcher);
            }
        } else {
            final NoSuchFieldException noSuchFieldException = new NoSuchFieldException(
                    "Error al obtener las coordenadas. Matcher = " + matcher.toString());
            Mint.logException(noSuchFieldException);
            throw noSuchFieldException;
        }
    } else if ((uriScheme.equals("http") || uriScheme.equals("https"))
            && (uri.getHost().equals("maps.google.com"))) { // Manage maps.google.com?q=latitude,longitude

        final String queryParameter = uri.getQueryParameter("q");
        if (queryParameter != null) {
            final Matcher matcher = getMatcherForUri(queryParameter);
            if (matcher.find()) {
                setDestinationPosition(matcher);
            } else {
                final NoSuchFieldException noSuchFieldException = new NoSuchFieldException(
                        "Error al obtener las coordenadas. Matcher = " + matcher.toString());
                Mint.logException(noSuchFieldException);
                throw noSuchFieldException;
            }
        } else {
            final NoSuchFieldException noSuchFieldException = new NoSuchFieldException(
                    "Query sin parmetro q.");
            Mint.logException(noSuchFieldException);
            throw noSuchFieldException;
        }
    } else {
        final Exception exception = new Exception("Imposible tratar la query " + uri.toString());
        Mint.logException(exception);
        throw exception;
    }
}

From source file:org.getlantern.firetweet.activity.support.LinkHandlerActivity.java

private boolean showFragment(final int linkId, final Uri uri) {
    final Intent intent = getIntent();
    intent.setExtrasClassLoader(getClassLoader());
    final Fragment fragment = createFragmentForIntent(this, linkId, intent);
    if (uri == null || fragment == null)
        return false;
    switch (linkId) {
    case LINK_ID_STATUS: {
        setTitle(R.string.status);/*  ww  w.j  ava 2 s.co  m*/
        break;
    }
    case LINK_ID_USER: {
        setTitle(R.string.user);
        break;
    }
    case LINK_ID_USER_TIMELINE: {
        setTitle(R.string.statuses);
        break;
    }
    case LINK_ID_USER_FAVORITES: {
        setTitle(R.string.favorites);
        break;
    }
    case LINK_ID_USER_FOLLOWERS: {
        setTitle(R.string.followers);
        break;
    }
    case LINK_ID_USER_FRIENDS: {
        setTitle(R.string.following);
        break;
    }
    case LINK_ID_USER_BLOCKS: {
        setTitle(R.string.blocked_users);
        break;
    }
    case LINK_ID_MUTES_USERS: {
        setTitle(R.string.twitter_muted_users);
        break;
    }
    case LINK_ID_DIRECT_MESSAGES_CONVERSATION: {
        setTitle(R.string.direct_messages);
        break;
    }
    case LINK_ID_USER_LIST: {
        setTitle(R.string.user_list);
        break;
    }
    case LINK_ID_USER_LISTS: {
        setTitle(R.string.user_lists);
        break;
    }
    case LINK_ID_USER_LIST_TIMELINE: {
        setTitle(R.string.list_timeline);
        break;
    }
    case LINK_ID_USER_LIST_MEMBERS: {
        setTitle(R.string.list_members);
        break;
    }
    case LINK_ID_USER_LIST_SUBSCRIBERS: {
        setTitle(R.string.list_subscribers);
        break;
    }
    case LINK_ID_USER_LIST_MEMBERSHIPS: {
        setTitle(R.string.lists_following_user);
        break;
    }
    case LINK_ID_SAVED_SEARCHES: {
        setTitle(R.string.saved_searches);
        break;
    }
    case LINK_ID_USER_MENTIONS: {
        setTitle(R.string.user_mentions);
        break;
    }
    case LINK_ID_INCOMING_FRIENDSHIPS: {
        setTitle(R.string.incoming_friendships);
        break;
    }
    case LINK_ID_USERS: {
        setTitle(R.string.users);
        break;
    }
    case LINK_ID_STATUSES: {
        setTitle(R.string.statuses);
        break;
    }
    case LINK_ID_USER_MEDIA_TIMELINE: {
        setTitle(R.string.media);
        break;
    }
    case LINK_ID_STATUS_RETWEETERS: {
        setTitle(R.string.users_retweeted_this);
        break;
    }
    case LINK_ID_STATUS_FAVORITERS: {
        setTitle(R.string.users_retweeted_this);
        break;
    }
    case LINK_ID_STATUS_REPLIES: {
        setTitle(R.string.view_replies);
        break;
    }
    case LINK_ID_SEARCH: {
        setTitle(android.R.string.search_go);
        setSubtitle(uri.getQueryParameter(QUERY_PARAM_QUERY));
        break;
    }
    }
    mFinishOnly = Boolean.parseBoolean(uri.getQueryParameter(QUERY_PARAM_FINISH_ONLY));
    final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.main_content, fragment);
    ft.commit();
    return true;
}

From source file:org.mariotaku.twidere.activity.support.LinkHandlerActivity.java

private boolean showFragment(final int linkId, final Uri uri) {
    final Intent intent = getIntent();
    intent.setExtrasClassLoader(getClassLoader());
    final Fragment fragment = createFragmentForIntent(this, linkId, intent);
    if (uri == null || fragment == null)
        return false;
    setSubtitle(null);/*from   ww w .j av  a  2s.  com*/
    switch (linkId) {
    case LINK_ID_STATUS: {
        setTitle(R.string.status);
        break;
    }
    case LINK_ID_USER: {
        setTitle(R.string.user);
        break;
    }
    case LINK_ID_USER_TIMELINE: {
        setTitle(R.string.statuses);
        break;
    }
    case LINK_ID_USER_FAVORITES: {
        setTitle(R.string.favorites);
        break;
    }
    case LINK_ID_USER_FOLLOWERS: {
        setTitle(R.string.followers);
        break;
    }
    case LINK_ID_USER_FRIENDS: {
        setTitle(R.string.following);
        break;
    }
    case LINK_ID_USER_BLOCKS: {
        setTitle(R.string.blocked_users);
        break;
    }
    case LINK_ID_MUTES_USERS: {
        setTitle(R.string.twitter_muted_users);
        break;
    }
    case LINK_ID_DIRECT_MESSAGES_CONVERSATION: {
        setTitle(R.string.direct_messages);
        break;
    }
    case LINK_ID_USER_LIST: {
        setTitle(R.string.user_list);
        break;
    }
    case LINK_ID_USER_LISTS: {
        setTitle(R.string.user_lists);
        break;
    }
    case LINK_ID_USER_LIST_TIMELINE: {
        setTitle(R.string.list_timeline);
        break;
    }
    case LINK_ID_USER_LIST_MEMBERS: {
        setTitle(R.string.list_members);
        break;
    }
    case LINK_ID_USER_LIST_SUBSCRIBERS: {
        setTitle(R.string.list_subscribers);
        break;
    }
    case LINK_ID_USER_LIST_MEMBERSHIPS: {
        setTitle(R.string.lists_following_user);
        break;
    }
    case LINK_ID_SAVED_SEARCHES: {
        setTitle(R.string.saved_searches);
        break;
    }
    case LINK_ID_USER_MENTIONS: {
        setTitle(R.string.user_mentions);
        break;
    }
    case LINK_ID_INCOMING_FRIENDSHIPS: {
        setTitle(R.string.incoming_friendships);
        break;
    }
    case LINK_ID_USERS: {
        setTitle(R.string.users);
        break;
    }
    case LINK_ID_STATUSES: {
        setTitle(R.string.statuses);
        break;
    }
    case LINK_ID_USER_MEDIA_TIMELINE: {
        setTitle(R.string.media);
        break;
    }
    case LINK_ID_STATUS_RETWEETERS: {
        setTitle(R.string.users_retweeted_this);
        break;
    }
    case LINK_ID_STATUS_FAVORITERS: {
        setTitle(R.string.users_retweeted_this);
        break;
    }
    case LINK_ID_STATUS_REPLIES: {
        setTitle(R.string.view_replies);
        break;
    }
    case LINK_ID_SEARCH: {
        setTitle(android.R.string.search_go);
        setSubtitle(uri.getQueryParameter(QUERY_PARAM_QUERY));
        break;
    }
    case LINK_ID_ACCOUNTS: {
        setTitle(R.string.accounts);
        break;
    }
    case LINK_ID_DRAFTS: {
        setTitle(R.string.drafts);
        break;
    }
    case LINK_ID_FILTERS: {
        setTitle(R.string.filters);
        break;
    }
    case LINK_ID_MAP: {
        setTitle(R.string.view_map);
        break;
    }
    case LINK_ID_PROFILE_EDITOR: {
        setTitle(R.string.edit_profile);
        break;
    }
    default: {
        setTitle(getString(R.string.app_name));
        break;
    }
    }
    mFinishOnly = Boolean.parseBoolean(uri.getQueryParameter(QUERY_PARAM_FINISH_ONLY));
    final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.content_fragment, fragment);
    ft.commit();
    return true;
}