Beispiel #1
0
        private void SetupView(View view)
        {
            mProgressBar = mActivity.FindViewById <ProgressBar>(Resource.Id.search_progressBar);
            mClearButton = mActivity.FindViewById(Resource.Id.search_close_button);
            mSearchView  = mActivity.FindViewById <EditText>(Resource.Id.search_view);

            if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop)
            {
                mProgressBar.IndeterminateDrawable =
                    ContextCompat.GetDrawable(mActivity, Resource.Drawable.progressring);
            }

            mRecyclerView = view.FindViewById <RecyclerView>(Resource.Id.recycler_view);

            // use this setting to improve performance if you know that changes
            // in content do not change the layout size of the RecyclerView
            mRecyclerView.HasFixedSize = true;

            // use a linear layout manager
            mLayoutManager = new LinearLayoutManager(mActivity);
            mRecyclerView.SetLayoutManager(mLayoutManager);

            // specify an adapter (see also next example)
            mAdapter            = new LocationQueryAdapter(new List <LocationQueryViewModel>());
            mAdapter.ItemClick += ClickListener;
            mRecyclerView.SetAdapter(mAdapter);
        }
Beispiel #2
0
        public static void Construct(FragmentActivity activity, Toolbar toolbar)
        {
            _topRatedFragment = new OtherFragment();

            var fragments = new Fragment[]
            {
                new MovieInputFragment(),
                _topRatedFragment
            };
            var titles = CharSequence.ArrayFromStringArray(new[]
            {
                "Search",
                "Top Rated"
            });

            var viewPager = activity.FindViewById <ViewPager>(Resource.Id.viewpager);

            viewPager.Adapter = new TabsFragmentPagerAdapter(activity.SupportFragmentManager, fragments, titles);

            // Give the TabLayout the ViewPager
            var tabLayout = activity.FindViewById <TabLayout>(Resource.Id.sliding_tabs);

            tabLayout.SetupWithViewPager(viewPager);
            tabLayout.TabSelected += async(sender, args) =>
            {
                var tab = args.Tab;
                if (tab.Position == 1)
                {
                    await _topRatedFragment.FetchTopRatedMovies();
                }
            };
            SetToolbar(activity, toolbar);
        }
Beispiel #3
0
        public static void InitPopupMenu(FragmentActivity ctx, int idBelow)
        {
            int layoutWidth  = (ctx.Resources.DisplayMetrics.WidthPixels * 31) / 100;
            int layoutHeight = 4 * ((int)ctx.Resources.GetDimension(Resource.Dimension.main_menu_icon_size) + 2);

            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(layoutWidth, layoutHeight);
            lp.AddRule(LayoutRules.Below, idBelow);
            lp.TopMargin = (int)ctx.Resources.GetDimension(Resource.Dimension.action_bar_height);

            Log.Debug("InitPopupMenu", " before popupMenu=");
            RelativeLayout popupMenu = ctx.FindViewById <RelativeLayout>(Resource.Id.popup_mainmenu_inner);

            Log.Debug("InitPopupMenu", "popupMenu=" + popupMenu);
            popupMenu.LayoutParameters = lp;
            popupMenu.SetBackgroundResource(Resource.Drawable.actionbar_background);

//            MainMenuFragment mainmenupopup_fragment = (MainMenuFragment)ctx.SupportFragmentManager.FindFragmentById(Resource.Id.mainmenupopup_fragment);
//            mainmenupopup_fragment.IsPopupMenu = true;

            Button btnSettings = ctx.FindViewById <Button>(Resource.Id.btnSettingsMain);

            btnSettings.Touch += (object sender, View.TouchEventArgs e) => {
                switch (e.Event.Action & MotionEventActions.Mask)
                {
                case MotionEventActions.Up:
                    popupMenu.Visibility = ViewStates.Gone;
                    SettingsClicked(ctx);
                    break;
                }
            };
        }
Beispiel #4
0
        public static void Construct(FragmentActivity activity, Toolbar toolbar)
        {
            TopMovieFragment topMovieFragment = new TopMovieFragment();
            var fragments = new Fragment[]
            {
                new MovieSearchFragment(),
                topMovieFragment
            };

            var titles = CharSequence.ArrayFromStringArray(new[]
            {
                "Search",
                "Top Rated"
            });

            var viewPager = activity.FindViewById <ViewPager>(Resource.Id.viewpager);

            viewPager.Adapter = new TabsFragmentPageAdapter(activity.SupportFragmentManager, fragments, titles);

            var tabLayout = activity.FindViewById <TabLayout>(Resource.Id.sliding_tabs);

            tabLayout.SetupWithViewPager(viewPager);
            viewPager.PageSelected += (sender, args) =>
            {
                if (args.Position == 1)
                {
                    topMovieFragment.GetTopMovies(activity);
                }
            };
            SetToolbar(activity, toolbar);
        }
Beispiel #5
0
        public static void SetButtonsColor(FragmentActivity context, int id)
        {
            foreach (var item in _buttons)
            {
                var element = context.FindViewById <ImageView>(item);
                element.SetBackgroundResource(Resource.Drawable.uncheckedButton);
            }

            var indexer = context.FindViewById <ImageView>(_buttons[id]);

            indexer.SetBackgroundResource(Resource.Drawable.checkedButton);
        }
        public static void Construct(FragmentActivity activity, Toolbar toolbar)
        {
            MovieDbFactory.RegisterSettings(new MovieDbSettings());
            _topRatedHelper = new MovieHelper();
            _searchHelper   = new MovieHelper();
            _movieApi       = MovieDbFactory.Create <IApiMovieRequest>().Value;

            _topRatedFragment = new TopRatedMoviesFragment(_topRatedHelper, _movieApi);

            var fragments = new Fragment[]
            {
                new MovieSearchFragment(_searchHelper, _movieApi),
                _topRatedFragment
            };
            var titles = CharSequence.ArrayFromStringArray(new[]
            {
                activity.GetString(Resource.String.SearchTab),
                activity.GetString(Resource.String.TopRatedTab)
            });

            var viewPager = activity.FindViewById <ViewPager>(Resource.Id.viewpager);

            viewPager.Adapter = new TabsFragmentPagerAdapter(activity.SupportFragmentManager, fragments, titles);

            // Give the TabLayout the ViewPager
            var tabLayout = activity.FindViewById <TabLayout>(Resource.Id.sliding_tabs);

            tabLayout.SetupWithViewPager(viewPager);

            tabLayout.TabSelected += async(sender, args) =>
            {
                var tab = args.Tab;
                if (tab.Position == 1)
                {
                    viewPager.SetCurrentItem(tab.Position, true);
                    var manager = (InputMethodManager)activity.GetSystemService(Context.InputMethodService);
                    manager.HideSoftInputFromWindow(activity.CurrentFocus.WindowToken, 0);
                    await _topRatedFragment.GetMovies();
                }
                else
                {
                    viewPager.SetCurrentItem(tab.Position, true);
                }
            };

            SetToolbar(activity, toolbar);
        }
Beispiel #7
0
        public static void Construct(FragmentActivity activity, Toolbar toolbar)
        {
            var _otherFragment = new OtherFragment();
            var fragments      = new Fragment[]
            {
                new MovieInputFragment(),
                _otherFragment
            };
            var titles = CharSequence.ArrayFromStringArray(new[]
            {
                "Movies",
                "Top Rated"
            });

            var viewPager = activity.FindViewById <ViewPager>(Resource.Id.viewpager);

            viewPager.Adapter = new TabsFragmentPagerAdapter(activity.SupportFragmentManager, fragments, titles);

            // Give the TabLayout the ViewPager
            var tabLayout = activity.FindViewById <TabLayout>(Resource.Id.sliding_tabs);

            tabLayout.SetupWithViewPager(viewPager);

            tabLayout.TabSelected += async(sender, args) =>
            {
                viewPager.Enabled = false;

                var tab = args.Tab;
                if (tab.Position == 1)
                {
                    var manager = (InputMethodManager)activity.GetSystemService(Context.InputMethodService);
                    manager.HideSoftInputFromWindow(tabLayout.WindowToken, 0);

                    _otherFragment.enableSpinner();
                    await _otherFragment.FetchTopRatedMovies();
                }

                viewPager.Enabled = true;
            };

            SetToolbar(activity, toolbar);
        }
Beispiel #8
0
        public static void Construct(FragmentActivity activity, Toolbar toolbar)
        {
            var fragments = new Fragment[]
            {
                new NameInputFragment(),
                new OtherFragment()
            };
            var titles = CharSequence.ArrayFromStringArray(new[]
            {
                "People",
                "Other"
            });

            var viewPager = activity.FindViewById <ViewPager>(Resource.Id.viewpager);

            viewPager.Adapter = new TabsFragmentPagerAdapter(activity.SupportFragmentManager, fragments, titles);

            // Give the TabLayout the ViewPager
            var tabLayout = activity.FindViewById <TabLayout>(Resource.Id.sliding_tabs);

            tabLayout.SetupWithViewPager(viewPager);

            SetToolbar(activity, toolbar);
        }
Beispiel #9
0
        static void SettingsClicked(FragmentActivity ctx)
        {
            if (Common.isTabletDevice(ctx))
            {
                ctx.FindViewById <FrameLayout>(Resource.Id.details_fragment).Visibility = ViewStates.Gone;
                var ft = ctx.SupportFragmentManager.BeginTransaction();
                ft.Replace(Resource.Id.detailInfo_fragment, new SettingsFragment());

                ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade);
                ft.Commit();
            }
            else
            {
                var intent = new Android.Content.Intent();
                intent.SetClass(ctx, typeof(SettingsFragmentActivity));
                ctx.StartActivity(intent);
            }
        }