Search in sources :

Example 1 with Icicle

use of icepick.Icicle in project wh-app-android by WhiteHouse.

the class DrawerFragment method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mMenu = new MenuBuilder(getActivity());
    bindSubscription(AndroidObservable.bindFragment(this, FeedCategoryManager.get().getFeedCategoryConfig().first().subscribeOn(Schedulers.newThread())).subscribe(feedCategoryConfig -> {
        List<FeedCategoryItem> items = feedCategoryConfig.feeds();
        int i = 0;
        int group = 0;
        for (FeedCategoryItem c : items) {
            switch(c.viewType()) {
                case FeedCategoryItem.VIEW_TYPE_ARTICLE_LIST:
                    group = GROUP_ARTICLES;
                    break;
                case FeedCategoryItem.VIEW_TYPE_PHOTO_GALLERY:
                    group = GROUP_PHOTOS;
                    break;
                case FeedCategoryItem.VIEW_TYPE_VIDEO_GALLERY:
                    group = GROUP_VIDEOS;
                    break;
                case FeedCategoryItem.VIEW_TYPE_LIVE:
                    mLivePosition = i + 1;
                    group = GROUP_LIVE;
                    break;
            }
            mMenu.add(group, Menu.NONE, i++, c.title()).setIntent(new Intent().setData(Uri.parse(c.feedUrl())));
        }
        mMenu.add(GROUP_FAVORITES, Menu.NONE, i++, R.string.title_favorites);
        getAdapter().addHeader(new Object());
        getAdapter().fillWith(getMenuItems());
        getAdapter().selectOnly(mCheckedPosition);
        getProgressBar().setVisibility(View.GONE);
        getRecyclerView().setVisibility(View.VISIBLE);
        if (mDrawerCallbacks != null) {
            if (icicle == null) {
                mDrawerCallbacks.onRestoreSelectedItem(getAdapter().getItem(mCheckedPosition));
            }
            updateTitle();
        }
    }));
}
Also used : MenuBuilder(android.support.v7.internal.view.menu.MenuBuilder) Bundle(android.os.Bundle) Uri(android.net.Uri) Intent(android.content.Intent) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) BaseListFragment(gov.whitehouse.app.BaseListFragment) AndroidObservable(rx.android.observables.AndroidObservable) BaseAdapter(gov.whitehouse.widget.BaseAdapter) Menu(android.view.Menu) Schedulers(rx.schedulers.Schedulers) View(android.view.View) FeedCategoryManager(gov.whitehouse.core.manager.FeedCategoryManager) Icicle(icepick.Icicle) LayoutInflater(android.view.LayoutInflater) Collection(java.util.Collection) ViewGroup(android.view.ViewGroup) List(java.util.List) TextView(android.widget.TextView) Toolbar(android.support.v7.widget.Toolbar) FeedCategoryItem(gov.whitehouse.data.model.FeedCategoryItem) Nullable(android.support.annotation.Nullable) Activity(android.app.Activity) R(gov.whitehouse.R) DrawerItemAdapter(gov.whitehouse.widget.wh.DrawerItemAdapter) ArrayList(java.util.ArrayList) List(java.util.List) Intent(android.content.Intent) MenuBuilder(android.support.v7.internal.view.menu.MenuBuilder) FeedCategoryItem(gov.whitehouse.data.model.FeedCategoryItem)

Aggregations

Activity (android.app.Activity)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 Nullable (android.support.annotation.Nullable)1 MenuBuilder (android.support.v7.internal.view.menu.MenuBuilder)1 Toolbar (android.support.v7.widget.Toolbar)1 LayoutInflater (android.view.LayoutInflater)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 TextView (android.widget.TextView)1 R (gov.whitehouse.R)1 BaseListFragment (gov.whitehouse.app.BaseListFragment)1 FeedCategoryManager (gov.whitehouse.core.manager.FeedCategoryManager)1 FeedCategoryItem (gov.whitehouse.data.model.FeedCategoryItem)1 BaseAdapter (gov.whitehouse.widget.BaseAdapter)1 DrawerItemAdapter (gov.whitehouse.widget.wh.DrawerItemAdapter)1 Icicle (icepick.Icicle)1