Example usage for android.net Uri equals

List of usage examples for android.net Uri equals

Introduction

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

Prototype

public boolean equals(Object o) 

Source Link

Document

Compares this Uri to another object for equality.

Usage

From source file:com.carlrice.reader.activity.HomeActivity.java

private void selectDrawerItem(int position) {
    mCurrentDrawerPos = position;/*from  w ww.j a  v a2s  . c o  m*/

    Uri newUri;
    boolean showFeedInfo = true;

    switch (position) {
    case SEARCH_DRAWER_POSITION:
        newUri = EntryColumns.SEARCH_URI(mEntriesFragment.getCurrentSearch());
        mToolbarPaletteListener.onGenerated(null);
        break;
    case 0:
        newUri = EntryColumns.ALL_ENTRIES_CONTENT_URI;
        mToolbarPaletteListener.onGenerated(null);
        break;
    case 1:
        newUri = EntryColumns.FAVORITES_CONTENT_URI;
        mToolbarPaletteListener.onGenerated(null);
        break;
    default:
        long feedOrGroupId = mDrawerAdapter.getItemId(position);
        if (mDrawerAdapter.isItemAGroup(position)) {
            newUri = EntryColumns.ENTRIES_FOR_GROUP_CONTENT_URI(feedOrGroupId);
            mToolbarPaletteListener.onGenerated(null);
        } else {
            mDrawerAdapter.getItemIconPalette(position, mToolbarPaletteListener);
            newUri = EntryColumns.ENTRIES_FOR_FEED_CONTENT_URI(feedOrGroupId);
            showFeedInfo = false;
        }
        mTitle = mDrawerAdapter.getItemName(position);
        break;
    }

    if (!newUri.equals(mEntriesFragment.getUri())) {
        mEntriesFragment.setData(newUri, showFeedInfo);
    }

    mDrawerList.setItemChecked(position, true);

    // First open => we open the drawer for you
    if (PrefUtils.getBoolean(PrefUtils.FIRST_OPEN, true)) {
        PrefUtils.putBoolean(PrefUtils.FIRST_OPEN, false);
        if (mDrawerLayout != null) {
            mDrawerLayout.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mDrawerLayout.openDrawer(mLeftDrawer);
                }
            }, 500);
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.welcome_title).setItems(new CharSequence[] {
                getString(R.string.google_news_title), getString(R.string.add_custom_feed) },
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        if (which == 1) {
                            startActivity(new Intent(Intent.ACTION_INSERT).setData(FeedColumns.CONTENT_URI));
                        } else {
                            startActivity(new Intent(HomeActivity.this, AddGoogleNewsActivity.class));
                        }
                    }
                });
        builder.show();
    }

    // Set title & icon
    switch (mCurrentDrawerPos) {
    case SEARCH_DRAWER_POSITION:
        getSupportActionBar().setTitle(android.R.string.search_go);
        break;
    case 0:
        getSupportActionBar().setTitle(R.string.all);
        break;
    case 1:
        getSupportActionBar().setTitle(R.string.favorites);
        break;
    default:
        getSupportActionBar().setTitle(mTitle);
        break;
    }

    // Put the good menu
    invalidateOptionsMenu();
}

From source file:com.flym.dennikn.activity.HomeActivity.java

private void selectDrawerItem(int position) {
    mCurrentDrawerPos = position;/* w  w  w . jav  a2s .  co m*/
    mIcon = null;

    Uri newUri;
    boolean showFeedInfo = true;

    switch (position) {
    case SEARCH_DRAWER_POSITION:
        newUri = EntryColumns.SEARCH_URI(mEntriesFragment.getCurrentSearch());
        break;
    case 0:
        newUri = EntryColumns.ALL_ENTRIES_CONTENT_URI;
        break;
    case 1:
        newUri = EntryColumns.FAVORITES_CONTENT_URI;
        break;
    default:
        long feedOrGroupId = mDrawerAdapter.getItemId(position);
        if (mDrawerAdapter.isItemAGroup(position)) {
            newUri = EntryColumns.ENTRIES_FOR_GROUP_CONTENT_URI(feedOrGroupId);
        } else {
            byte[] iconBytes = mDrawerAdapter.getItemIcon(position);
            Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24);
            if (bitmap != null) {
                mIcon = new BitmapDrawable(getResources(), bitmap);
            }

            newUri = EntryColumns.ENTRIES_FOR_FEED_CONTENT_URI(feedOrGroupId);
            showFeedInfo = false;
        }
        mTitle = mDrawerAdapter.getItemName(position);
        break;
    }

    if (!newUri.equals(mEntriesFragment.getUri())) {
        mEntriesFragment.setData(newUri, showFeedInfo);
    }

    mDrawerList.setItemChecked(position, true);

    // First open => we open the drawer for you
    if (PrefUtils.getBoolean(PrefUtils.FIRST_OPEN, true)) {
        PrefUtils.putBoolean(PrefUtils.FIRST_OPEN, false);
        if (mDrawerLayout != null) {
            mDrawerLayout.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mDrawerLayout.openDrawer(mLeftDrawer);
                }
            }, 500);
        }

        FeedDataContentProvider.addFeed(this, "https://dennikn.sk/slovensko/feed/", "Slovensko", true);
        FeedDataContentProvider.addFeed(this, "https://dennikn.sk/svet/feed/", "Zahrani?ie", true);
        FeedDataContentProvider.addFeed(this, "https://dennikn.sk/ekonomika/feed/", "Ekonomika", true);
        FeedDataContentProvider.addFeed(this, "https://dennikn.sk/kultura/feed/", "Kultra", true);
        FeedDataContentProvider.addFeed(this, "https://dennikn.sk/komentare/feed/", "Komentre", true);
        FeedDataContentProvider.addFeed(this, "https://dennikn.sk/veda/feed/", "Veda", true);
        FeedDataContentProvider.addFeed(this, "https://dennikn.sk/blog/feed/", "Blogy", true);
        //            FeedDataContentProvider.addFeed(this, "https://dennikn.sk/shooty/feed/", "Shooty", true);

        /*
                  AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.setTitle(R.string.welcome_title)
            .setItems(new CharSequence[]{getString(R.string.google_news_title), getString(R.string.add_custom_feed)}, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    if (which == 1) {
                        startActivity(new Intent(Intent.ACTION_INSERT).setData(FeedColumns.CONTENT_URI));
                    } else {
                        startActivity(new Intent(HomeActivity.this, AddGoogleNewsActivity.class));
                    }
                }
            });
                    builder.show(); */
    }

    // Set title & icon
    switch (mCurrentDrawerPos) {
    case SEARCH_DRAWER_POSITION:
        getSupportActionBar().setTitle(android.R.string.search_go);
        getSupportActionBar().setIcon(R.drawable.action_search);
        break;

    default:
        getSupportActionBar().setTitle(mTitle);
        if (mIcon != null) {
            getSupportActionBar().setIcon(mIcon);
        } else {
            getSupportActionBar().setIcon(null);
        }
        break;
    }

    // Put the good menu
    invalidateOptionsMenu();
}

From source file:net.etuldan.sparss.activity.HomeActivity.java

private void selectDrawerItem(int position) {
    mCurrentDrawerPos = position;/*from  ww  w . j  av a 2 s  .c  o m*/
    mDrawerAdapter.setSelectedItem(position);
    mIcon = null;

    Uri newUri;
    boolean showFeedInfo = true;

    switch (position) {
    case SEARCH_DRAWER_POSITION:
        newUri = EntryColumns.SEARCH_URI(mEntriesFragment.getCurrentSearch());
        break;
    case 0:
        newUri = EntryColumns.ALL_ENTRIES_CONTENT_URI;
        break;
    case 1:
        newUri = EntryColumns.FAVORITES_CONTENT_URI;
        break;
    default:
        long feedOrGroupId = mDrawerAdapter.getItemId(position);
        if (mDrawerAdapter.isItemAGroup(position)) {
            newUri = EntryColumns.ENTRIES_FOR_GROUP_CONTENT_URI(feedOrGroupId);
        } else {
            byte[] iconBytes = mDrawerAdapter.getItemIcon(position);
            Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24);
            if (bitmap != null) {
                mIcon = new BitmapDrawable(getResources(), bitmap);
            }

            newUri = EntryColumns.ENTRIES_FOR_FEED_CONTENT_URI(feedOrGroupId);
            showFeedInfo = false;
        }

        mTitle = mDrawerAdapter.getItemName(position);
        break;
    }

    if (!newUri.equals(mEntriesFragment.getUri())) {
        mEntriesFragment.setData(newUri, showFeedInfo);
    }

    mDrawerList.setItemChecked(position, true);

    // First open => we open the drawer for you
    if (PrefUtils.getBoolean(PrefUtils.FIRST_OPEN, true)) {
        PrefUtils.putBoolean(PrefUtils.FIRST_OPEN, false);
        if (mDrawerLayout != null) {
            mDrawerLayout.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mDrawerLayout.openDrawer(mLeftDrawer);
                }
            }, 500);
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.welcome_title).setItems(new CharSequence[] {
                getString(R.string.google_news_title), getString(R.string.add_custom_feed) },
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        if (which == 1) {
                            startActivity(new Intent(Intent.ACTION_INSERT).setData(FeedColumns.CONTENT_URI));
                        } else {
                            startActivity(new Intent(HomeActivity.this, AddGoogleNewsActivity.class));
                        }
                    }
                });
        builder.show();
    }
    refreshTitle(0);
}

From source file:com.xorcode.andtweet.TweetListActivity.java

/**
 * Prepare query to the ContentProvider (to the database) and load List of Tweets with data
 * @param queryIntent//ww w.ja  va 2 s .  com
 * @param otherThread This method is being accessed from other thread
 * @param loadOneMorePage load one more page of tweets
 */
protected void queryListData(Intent queryIntent, boolean otherThread, boolean loadOneMorePage) {
    // The search query is provided as an "extra" string in the query intent
    // TODO maybe use mQueryString here...
    String queryString = queryIntent.getStringExtra(SearchManager.QUERY);
    Intent intent = getIntent();

    if (MyLog.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "doSearchQuery; queryString=\"" + queryString + "\"; TimelineType=" + mTimelineType);
    }

    Uri contentUri = Tweets.CONTENT_URI;

    SelectionAndArgs sa = new SelectionAndArgs();
    String sortOrder = Tweets.DEFAULT_SORT_ORDER;
    // Id of the last (oldest) tweet to retrieve 
    long lastItemId = -1;

    if (queryString != null && queryString.length() > 0) {
        // Record the query string in the recent queries suggestions
        // provider
        SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                TimelineSearchSuggestionProvider.AUTHORITY, TimelineSearchSuggestionProvider.MODE);
        suggestions.saveRecentQuery(queryString, null);

        contentUri = Tweets.SEARCH_URI;
        contentUri = Uri.withAppendedPath(contentUri, Uri.encode(queryString));
    }
    intent.putExtra(SearchManager.QUERY, queryString);

    if (!contentUri.equals(intent.getData())) {
        intent.setData(contentUri);
    }

    if (sa.nArgs == 0) {
        // In fact this is needed every time you want to load next page of
        // tweets.
        // So we have to duplicate here everything we set in
        // com.xorcode.andtweet.TimelineActivity.onOptionsItemSelected()
        sa.clear();
        sa.addSelection(Tweets.TWEET_TYPE + " IN (?, ?)", new String[] {
                String.valueOf(Tweets.TIMELINE_TYPE_FRIENDS), String.valueOf(Tweets.TIMELINE_TYPE_MENTIONS) });
        if (mTimelineType == Tweets.TIMELINE_TYPE_FAVORITES) {
            sa.addSelection(AndTweetDatabase.Tweets.FAVORITED + " = ?", new String[] { "1" });
        }
        if (mTimelineType == Tweets.TIMELINE_TYPE_MENTIONS) {
            sa.addSelection(Tweets.MESSAGE + " LIKE ?",
                    new String[] { "%@" + TwitterUser.getTwitterUser().getUsername() + "%" });
        }
    }

    if (!positionRestored) {
        // We have to ensure that saved position will be
        // loaded from database into the list
        lastItemId = getSavedPosition(true);
    }

    int nTweets = 0;
    if (mCursor != null && !mCursor.isClosed()) {
        if (positionRestored) {
            // If position is NOT loaded - this cursor is from other
            // timeline/search
            // and we shouldn't care how much rows are there.
            nTweets = mCursor.getCount();
        }
        if (!otherThread) {
            mCursor.close();
        }
    }

    if (lastItemId > 0) {
        if (sa.nArgs == 0) {
            sa.addSelection("AndTweetDatabase.Tweets.TWEET_TYPE" + " IN (?, ?)" + ")",
                    new String[] { String.valueOf(Tweets.TIMELINE_TYPE_FRIENDS),
                            String.valueOf(Tweets.TIMELINE_TYPE_MENTIONS) });
        }
        sa.addSelection(Tweets._ID + " >= ?", new String[] { String.valueOf(lastItemId) });
    } else {
        if (loadOneMorePage) {
            nTweets += PAGE_SIZE;
        } else if (nTweets < PAGE_SIZE) {
            nTweets = PAGE_SIZE;
        }
        sortOrder += " LIMIT 0," + nTweets;
    }

    // This is for testing pruneOldRecords
    //        try {
    //            FriendTimeline fl = new FriendTimeline(TweetListActivity.this,
    //                    AndTweetDatabase.Tweets.TIMELINE_TYPE_FRIENDS);
    //            fl.pruneOldRecords();
    //
    //        } catch (Exception e) {
    //            e.printStackTrace();
    //        }

    mCursor = getContentResolver().query(contentUri, PROJECTION, sa.selection, sa.selectionArgs, sortOrder);
    if (!otherThread) {
        createAdapters();
    }

}

From source file:com.slp.rss_api.activity.HomeActivity.java

private void selectDrawerItem(int position) {
    mCurrentDrawerPos = position;/*  w w w .j  av a  2  s.co m*/
    mIcon = null;

    Uri newUri;
    boolean showFeedInfo = true;

    switch (position) {
    case SEARCH_DRAWER_POSITION:
        newUri = EntryColumns.SEARCH_URI(mEntriesFragment.getCurrentSearch());
        break;
    case 0:
        newUri = EntryColumns.ALL_ENTRIES_CONTENT_URI;
        break;
    case 1:
        newUri = EntryColumns.FAVORITES_CONTENT_URI;
        break;
    default:
        long feedOrGroupId = mDrawerAdapter.getItemId(position);
        if (mDrawerAdapter.isItemAGroup(position)) {
            newUri = EntryColumns.ENTRIES_FOR_GROUP_CONTENT_URI(feedOrGroupId);
        } else {
            byte[] iconBytes = mDrawerAdapter.getItemIcon(position);
            Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24);
            if (bitmap != null) {
                mIcon = new BitmapDrawable(getResources(), bitmap);
            }

            newUri = EntryColumns.ENTRIES_FOR_FEED_CONTENT_URI(feedOrGroupId);
            showFeedInfo = false;
        }
        mTitle = mDrawerAdapter.getItemName(position);
        break;
    }

    if (!newUri.equals(mEntriesFragment.getUri())) {
        mEntriesFragment.setData(newUri, showFeedInfo);
    }

    mDrawerList.setItemChecked(position, true);

    // First open => we open the drawer for you
    if (PrefUtils.getBoolean(PrefUtils.FIRST_OPEN, true)) {
        PrefUtils.putBoolean(PrefUtils.FIRST_OPEN, false);
        if (mDrawerLayout != null) {
            mDrawerLayout.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mDrawerLayout.openDrawer(mLeftDrawer);
                }
            }, 500);
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.welcome_title).setItems(new CharSequence[] {
                getString(R.string.google_news_title), getString(R.string.add_custom_feed) },
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        if (which == 1) {
                            startActivity(new Intent(Intent.ACTION_INSERT).setData(FeedColumns.CONTENT_URI));
                        } else {
                            startActivity(new Intent(HomeActivity.this, AddGoogleNewsActivity.class));
                        }
                    }
                });
        builder.show();
    }

    // Set title & icon
    switch (mCurrentDrawerPos) {
    case SEARCH_DRAWER_POSITION:
        getSupportActionBar().setTitle(android.R.string.search_go);
        getSupportActionBar().setIcon(R.drawable.action_search);
        break;
    case 0:
        getSupportActionBar().setTitle(R.string.all);
        getSupportActionBar().setIcon(R.drawable.ic_statusbar_rss);
        break;
    case 1:
        getSupportActionBar().setTitle(R.string.favorites);
        getSupportActionBar().setIcon(R.drawable.rating_important);
        break;
    default:
        getSupportActionBar().setTitle(mTitle);
        if (mIcon != null) {
            getSupportActionBar().setIcon(mIcon);
        } else {
            getSupportActionBar().setIcon(null);
        }
        break;
    }

    // Put the good menu
    invalidateOptionsMenu();
}

From source file:social.news.inrss.activity.HomeActivity.java

private void selectDrawerItem(int position) {
    mCurrentDrawerPos = position;/* w  w  w  .  ja v  a  2  s  .c  o m*/

    if (mDrawerAdapter == null)
        return;

    mDrawerAdapter.setSelectedItem(position);
    mIcon = null;

    Uri newUri;
    boolean showFeedInfo = true;

    switch (position) {
    case SEARCH_DRAWER_POSITION:
        newUri = EntryColumns.SEARCH_URI(mEntriesFragment.getCurrentSearch());
        break;
    case 0:
        newUri = EntryColumns.ALL_ENTRIES_CONTENT_URI;
        break;
    case 1:
        newUri = EntryColumns.FAVORITES_CONTENT_URI;
        break;
    default:
        long feedOrGroupId = mDrawerAdapter.getItemId(position);
        if (mDrawerAdapter.isItemAGroup(position)) {
            newUri = EntryColumns.ENTRIES_FOR_GROUP_CONTENT_URI(feedOrGroupId);
        } else {
            byte[] iconBytes = mDrawerAdapter.getItemIcon(position);
            Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24);
            if (bitmap != null) {
                mIcon = new BitmapDrawable(getResources(), bitmap);
            }

            newUri = EntryColumns.ENTRIES_FOR_FEED_CONTENT_URI(feedOrGroupId);
            showFeedInfo = false;
        }

        mTitle = mDrawerAdapter.getItemName(position);
        break;
    }

    if (!newUri.equals(mEntriesFragment.getUri())) {
        mEntriesFragment.setData(newUri, showFeedInfo);
    }

    mDrawerList.setItemChecked(position, true);

    // First open => we open the drawer for you
    if (PrefUtils.getBoolean(PrefUtils.FIRST_OPEN, true)) {
        PrefUtils.putBoolean(PrefUtils.FIRST_OPEN, false);
        if (mDrawerLayout != null) {
            mDrawerLayout.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mDrawerLayout.openDrawer(mLeftDrawer);
                }
            }, 500);
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.welcome_title).setItems(new CharSequence[] {
                getString(R.string.google_news_title), getString(R.string.add_custom_feed) },
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        if (which == 1) {
                            startActivity(new Intent(Intent.ACTION_INSERT).setData(FeedColumns.CONTENT_URI));
                        } else {
                            startActivity(new Intent(HomeActivity.this, AddGoogleNewsActivity.class));
                        }
                    }
                });
        builder.show();
    }
    refreshTitle(0);
}

From source file:net.news.inrss.activity.HomeActivity.java

private void selectDrawerItem(int position) {
    mCurrentDrawerPos = position;/*w w w .  ja  va 2 s .  co  m*/

    if (mDrawerAdapter == null)
        return;

    mDrawerAdapter.setSelectedItem(position);
    mIcon = null;

    Uri newUri;
    boolean showFeedInfo = true;

    switch (position) {
    case SEARCH_DRAWER_POSITION:
        newUri = EntryColumns.SEARCH_URI(mEntriesFragment.getCurrentSearch());
        break;
    case 0:
        newUri = EntryColumns.ALL_ENTRIES_CONTENT_URI;
        break;
    case 1:
        newUri = EntryColumns.FAVORITES_CONTENT_URI;
        break;
    default:
        long feedOrGroupId = mDrawerAdapter.getItemId(position);
        if (mDrawerAdapter.isItemAGroup(position)) {
            newUri = EntryColumns.ENTRIES_FOR_GROUP_CONTENT_URI(feedOrGroupId);
        } else {
            byte[] iconBytes = mDrawerAdapter.getItemIcon(position);
            Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24);
            if (bitmap != null) {
                mIcon = new BitmapDrawable(getResources(), bitmap);
            }

            newUri = EntryColumns.ENTRIES_FOR_FEED_CONTENT_URI(feedOrGroupId);
            showFeedInfo = false;
        }

        mTitle = mDrawerAdapter.getItemName(position);
        break;
    }

    if (!newUri.equals(mEntriesFragment.getUri())) {
        mEntriesFragment.setData(newUri, showFeedInfo);
    }

    mDrawerList.setItemChecked(position, true);

    // First open => we open the drawer for you
    if (PrefUtils.getBoolean(PrefUtils.FIRST_OPEN, true)) {
        PrefUtils.putBoolean(PrefUtils.FIRST_OPEN, false);
        if (mDrawerLayout != null) {
            mDrawerLayout.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mDrawerLayout.openDrawer(mLeftDrawer);
                }
            }, 500);
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(
                Html.fromHtml("<font color='#FF7F27'>Welcome to inRSS. Would you like to add one feed?</font>"))
                .setItems(new CharSequence[] { getString(R.string.google_news_title),
                        getString(R.string.add_custom_feed) }, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                if (which == 1) {
                                    startActivity(
                                            new Intent(Intent.ACTION_INSERT).setData(FeedColumns.CONTENT_URI));
                                } else {
                                    startActivity(new Intent(HomeActivity.this, AddGoogleNewsActivity.class));
                                }
                            }
                        });
        builder.show();
    }
    refreshTitle(0);
}

From source file:com.technoxist.activity.HomeActivity.java

private void selectDrawerItem(int position) {
    mCurrentDrawerPos = position;//from   w  w  w . ja v a 2s .c  om
    mIcon = null;

    Uri newUri;
    boolean showFeedInfo = true;

    if (position == 0) {
        newUri = EntryColumns.ALL_ENTRIES_CONTENT_URI;
    }

    else if (position == N + 1) {
        newUri = EntryColumns.FAVORITES_CONTENT_URI;
    } else if (position == N + 2) {
        newUri = EntryColumns.SEARCH_URI(mEntriesFragment.getCurrentSearch());
    } else if (position == N + 3) {
        startActivity(new Intent(this, GeneralPrefsActivity.class));
        newUri = EntryColumns.ALL_ENTRIES_CONTENT_URI;
        position = 0;
        mCurrentDrawerPos = 0;
    } else {
        long feedOrGroupId = mDrawerAdapter.getItemId(position);
        if (mDrawerAdapter.isItemAGroup(position)) {
            newUri = EntryColumns.ENTRIES_FOR_GROUP_CONTENT_URI(feedOrGroupId);
        } else {
            byte[] iconBytes = mDrawerAdapter.getItemIcon(position);
            Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24);
            if (bitmap != null) {
                mIcon = new BitmapDrawable(getResources(), bitmap);
            }

            newUri = EntryColumns.ENTRIES_FOR_FEED_CONTENT_URI(feedOrGroupId);
            showFeedInfo = false;
        }
        mTitle = mDrawerAdapter.getItemName(position);
    }

    if (!newUri.equals(mEntriesFragment.getUri())) {
        mEntriesFragment.setData(newUri, showFeedInfo);
    }

    mDrawerList.setItemChecked(position, true);

    // First open => we open the drawer for you
    if (PrefUtils.getBoolean(PrefUtils.FIRST_OPEN, true)) {
        PrefUtils.putBoolean(PrefUtils.FIRST_OPEN, false);
        mDrawerLayout.postDelayed(new Runnable() {
            @Override
            public void run() {
                mDrawerLayout.openDrawer(mDrawerList);
            }
        }, 500);
    }
}

From source file:net.fred.feedex.activity.HomeActivity.java

private void selectDrawerItem(int position) {
    mCurrentDrawerPos = position;//  ww w .j av a  2s.c o  m
    mIcon = null;

    Uri newUri;
    boolean showFeedInfo = true;

    switch (position) {
    case 0:
        newUri = EntryColumns.ALL_ENTRIES_CONTENT_URI;
        break;
    case 1:
        newUri = EntryColumns.FAVORITES_CONTENT_URI;
        break;
    case 2:
        newUri = EntryColumns.SEARCH_URI(mEntriesFragment.getCurrentSearch());
        break;
    default:
        long feedOrGroupId = mDrawerAdapter.getItemId(position);
        if (mDrawerAdapter.isItemAGroup(position)) {
            newUri = EntryColumns.ENTRIES_FOR_GROUP_CONTENT_URI(feedOrGroupId);
        } else {
            byte[] iconBytes = mDrawerAdapter.getItemIcon(position);
            Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24);
            if (bitmap != null) {
                mIcon = new BitmapDrawable(getResources(), bitmap);
            }

            newUri = EntryColumns.ENTRIES_FOR_FEED_CONTENT_URI(feedOrGroupId);
            showFeedInfo = false;
        }
        mTitle = mDrawerAdapter.getItemName(position);
        break;
    }

    if (!newUri.equals(mEntriesFragment.getUri())) {
        mEntriesFragment.setData(newUri, showFeedInfo);
    }

    mDrawerList.setItemChecked(position, true);

    // First open => we open the drawer for you
    /* if (PrefUtils.getBoolean(PrefUtils.FIRST_OPEN, true)) {
    PrefUtils.putBoolean(PrefUtils.FIRST_OPEN, false);
    mDrawerLayout.postDelayed(new Runnable() {
        @Override
        public void run() {
            mDrawerLayout.openDrawer(mDrawerList);
        }
    }, 500);
            
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.welcome_title)
            .setItems(new CharSequence[]{getString(R.string.google_news_title), getString(R.string.add_custom_feed)}, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    if (which == 1) {
                        startActivity(new Intent(Intent.ACTION_INSERT).setData(FeedColumns.CONTENT_URI));
                    } else {
                        startActivity(new Intent(HomeActivity.this, AddGoogleNewsActivity.class));
                    }
                }
            });
    builder.show();
      }*/
}

From source file:uk.org.ngo.squeezer.service.SqueezeService.java

@TargetApi(Build.VERSION_CODES.GINGERBREAD)
private void downloadSong(@NonNull Uri url, String title, @NonNull Uri serverUrl) {
    if (url.equals(Uri.EMPTY)) {
        return;//from  ww w  .jav a 2  s.  c  o m
    }

    // If running on Gingerbread or greater use the Download Manager
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
        DownloadDatabase downloadDatabase = new DownloadDatabase(this);
        String localPath = getLocalFile(serverUrl);
        String tempFile = UUID.randomUUID().toString();
        String credentials = mUsername + ":" + mPassword;
        String base64EncodedCredentials = Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
        DownloadManager.Request request = new DownloadManager.Request(url).setTitle(title)
                .setDestinationInExternalFilesDir(this, Environment.DIRECTORY_MUSIC, tempFile)
                .setVisibleInDownloadsUi(false)
                .addRequestHeader("Authorization", "Basic " + base64EncodedCredentials);
        long downloadId = downloadManager.enqueue(request);

        Crashlytics.log("Registering new download");
        Crashlytics.log("downloadId: " + downloadId);
        Crashlytics.log("tempFile: " + tempFile);
        Crashlytics.log("localPath: " + localPath);

        if (!downloadDatabase.registerDownload(downloadId, tempFile, localPath)) {
            Crashlytics.log(Log.WARN, TAG, "Could not register download entry for: " + downloadId);
            downloadManager.remove(downloadId);
        }
    }
}