Ejemplo n.º 1
0
 public TabLayoutOnTabSelectedListener(Context context, ViewPager viewPager, ActionBar actionBar, TabLayout tabLayout)
 {
     this.context   = context;
     this.viewPager = viewPager;
     this.actionBar = actionBar;
     this.tabLayout = tabLayout;
 }
Ejemplo n.º 2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            view          = inflater.Inflate(Resource.Layout.fragment_ingredients, container, false);
            recyclerView  = view.FindViewById <Android.Support.V7.Widget.RecyclerView>(Resource.Id.recyclerView);
            layoutManager = new LinearLayoutManager(Activity);
            recyclerView.SetLayoutManager(layoutManager);
            v4ViewPager = view.FindViewById <V4ViewPager>(Resource.Id.viewpager2);
            LoadIngredients();

            var bt = view.FindViewById <Android.Support.Design.Widget.FloatingActionButton>(Resource.Id.fab);

            bt.ViewAttachedToWindow += (s, e) =>
            {
                Snackbar.Make(bt, "Нажмите на кнопку в углу, после выбора ингридиентов", Snackbar.LengthLong).Show();
            };
            bt.Click += (s, e) =>
            {
                recyclerView.Visibility = ViewStates.Invisible;
                v4ViewPager.Visibility  = ViewStates.Visible;
                SetupViewPager(v4ViewPager);
                var b = mChecked;
            };

            v4ViewPager            = view.FindViewById <V4ViewPager>(Resource.Id.viewpager2);
            v4ViewPager.Visibility = ViewStates.Invisible;

            return(view);
        }
Ejemplo n.º 3
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.ReportsPagerFragment, container, false);

            viewPager = view.FindViewById <ViewPager> (Resource.Id.ReportsViewPager);
            viewPager.PageSelected += OnPageSelected;

            timePeriod     = view.FindViewById <TextView> (Resource.Id.TimePeriodLabel);
            previousPeriod = view.FindViewById(Resource.Id.PreviousFrameLayout);
            nextPeriod     = view.FindViewById(Resource.Id.NextFrameLayout);
            syncErrorBar   = view.FindViewById <FrameLayout> (Resource.Id.ReportsSyncBar);
            syncRetry      = view.FindViewById <ImageButton> (Resource.Id.ReportsSyncRetryButton);

            previousPeriod.Click += (sender, e) => NavigatePage(-1);
            nextPeriod.Click     += (sender, e) => NavigatePage(1);
            syncRetry.Click      += (sender, e) => ReloadCurrent();

            ResetAdapter();
            UpdatePeriod();

            var settings = ServiceContainer.Resolve <SettingsStore> ();

            if (settings.ReportsCurrentItem.HasValue)
            {
                viewPager.CurrentItem = settings.ReportsCurrentItem.Value;
            }

            return(view);
        }
		protected override void OnCreate (Bundle bundle)
		{
			
			base.OnCreate (bundle);
			//prerutas = new IList<string> ();
			SetContentView (Resource.Layout.SliderGaleria);
			this.Window.AddFlags(WindowManagerFlags.Fullscreen);

			paginador = FindViewById<Android.Support.V4.View.ViewPager> (Resource.Id.pager);

			rutas = new List<string> ();
			prerutas = Intent.GetStringArrayListExtra ("rutas");
			posicion = Intent.GetStringExtra ("posicion");

			Log.Debug ("SliderActivity", "La posición del intent es: "+posicion);

			for(int i=0; i<prerutas.Count; i++){
				Log.Debug ("SliderActivity", "Añadiendo: "+prerutas[i]);
				rutas.Add (prerutas [i]);
			}

			Log.Debug ("SliderActivity", "Se crea la galería");
			slidergaleria = new SliderGaleria (this, rutas);

			Log.Debug ("SliderActivity", "se setea el adaptador");
			paginador.Adapter = slidergaleria;

			paginador.SetCurrentItem (Int32.Parse(posicion), false);

			Log.Debug ("SliderActivity", "Acabamos!");
			// Create your application here
		}
Ejemplo n.º 5
0
 public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
 {
     var view = inflater.Inflate (Resource.Layout.TimeTrackingFragment, container, false);
     viewPager = view.FindViewById<ViewPager> (Resource.Id.ViewPager);
     viewPager.PageScrolled += OnViewPagerPageScrolled;
     viewPager.PageSelected += OnViewPagerPageSelected;
     return view;
 }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.rulesSubsectionsFragment, container, false);

            _viewPager = view.FindViewById <Android.Support.V4.View.ViewPager>(Resource.Id.rulesSubsectionsPager);
            SetUpViewPager(_viewPager);
            return(view);
        }
Ejemplo n.º 7
0
        void setupViewPager(Android.Support.V4.View.ViewPager viewPager)
        {
            var adapter = new Adapter(SupportFragmentManager);

            adapter.AddFragment(new CheeseListFragment(), "Category 1");
            adapter.AddFragment(new CheeseListFragment(), "Category 2");
            adapter.AddFragment(new CheeseListFragment(), "Category 3");
            viewPager.Adapter = adapter;
        }
Ejemplo n.º 8
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.TimeTrackingFragment, container, false);

            viewPager = view.FindViewById <ViewPager> (Resource.Id.ViewPager);
            viewPager.PageScrolled += OnViewPagerPageScrolled;
            viewPager.PageSelected += OnViewPagerPageSelected;
            return(view);
        }
Ejemplo n.º 9
0
 public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
 {
     var view = inflater.Inflate(Resource.Layout.fragment_actionbar_tabs, container, false);
     this._viewPager = view.FindViewById<Android.Support.V4.View.ViewPager>(Resource.Id.fragment_actionbar_tabs_viewpager);
     this._viewPager.PageSelected += (object sender, Android.Support.V4.View.ViewPager.PageSelectedEventArgs e) => {
         var actionBar = this.Activity.ActionBar;
         actionBar.SetSelectedNavigationItem(e.P0);
     };
     this._adapter = new DummySectionsPagerAdapter(this.FragmentManager);
     this._viewPager.Adapter = this._adapter;
     return view;
 }
Ejemplo n.º 10
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.ReportsPagerFragment, container, false);

            viewPager = view.FindViewById <ViewPager> (Resource.Id.ReportsViewPager);
            viewPager.PageSelected += OnPageSelected;

            timePeriod           = view.FindViewById <TextView> (Resource.Id.TimePeriodLabel);
            previousPeriod       = view.FindViewById(Resource.Id.PreviousFrameLayout);
            nextPeriod           = view.FindViewById(Resource.Id.NextFrameLayout);
            syncErrorBar         = view.FindViewById <FrameLayout> (Resource.Id.ReportsSyncBar);
            syncRetry            = view.FindViewById <ImageButton> (Resource.Id.ReportsSyncRetryButton);
            reportsContainer     = view.FindViewById <LinearLayout> (Resource.Id.ReportsContainer);
            nouserDisclaimer     = view.FindViewById <LinearLayout> (Resource.Id.NoUserDisclaimer);
            noUserRegisterButton = view.FindViewById <Button> (Resource.Id.ReportsRegisterButton);

            previousPeriod.Click += (sender, e) => NavigatePage(-1);
            nextPeriod.Click     += (sender, e) => NavigatePage(1);
            syncRetry.Click      += async(sender, e) => await ReloadCurrent();

            noUserRegisterButton.Click += OpenRegisterScreen;

            var activity = (MainDrawerActivity)Activity;

            toolbar = activity.MainToolbar;

            HasOptionsMenu = true;
            Activity.InvalidateOptionsMenu();

            ResetAdapter();
            UpdatePeriod();

            var settings = ServiceContainer.Resolve <SettingsStore> ();

            if (settings.ReportsCurrentItem.HasValue)
            {
                viewPager.CurrentItem = settings.ReportsCurrentItem.Value;
            }

            if (ServiceContainer.Resolve <AuthManager> ().OfflineMode)
            {
                nouserDisclaimer.Visibility = ViewStates.Visible;
                reportsContainer.Visibility = ViewStates.Gone;
            }
            else
            {
                nouserDisclaimer.Visibility = ViewStates.Gone;
                reportsContainer.Visibility = ViewStates.Visible;
            }

            return(view);
        }
Ejemplo n.º 11
0
        void setupViewPager(Android.Support.V4.View.ViewPager viewPager)
        {
            var adapter = new Adapter(SupportFragmentManager);

            // adapter.AddFragment(new FacebookLoginFragment(), "FacebookLogin");
            adapter.AddFragment(new CardViewFragment(), "Upcoming Events");
            // adapter.AddFragment(new ListViewFragment(), "Listview");
            adapter.AddFragment(new CardViewFragment3(), "Going");
            adapter.AddFragment(new CardViewFragment2(), "Past Events");
            // adapter.AddFragment(new FormFragment(), "Form");
            // adapter.AddFragment(new CardViewFragment3(), "Going");
            viewPager.Adapter = adapter;
        }
        private void SetUpViewPager(Android.Support.V4.View.ViewPager viewPager)
        {
            var adapter = new RulesSubsectionsViewPagerAdapter(ChildFragmentManager);

            adapter.AddFragment(new RulesOneSubsectionFragment(Rules), Rules.Name);
            var children = Rules.ChildRules.Where(c => c.ChildRules != null && c.ChildRules.Count > 0).ToList();

            foreach (var child in children)
            {
                adapter.AddFragment(new RulesOneSubsectionFragment(child), child.Name);
            }
            viewPager.Adapter = adapter;
        }
Ejemplo n.º 13
0
        private void SetupViewPager(Android.Support.V4.View.ViewPager viewPager)
        {
            var adapter     = new Adapter(((AppCompatActivity)Activity).SupportFragmentManager);
            var recipeLinks = new RecipeLinks();
            var newFragment = new RecipeListFragment(recipeLinks.links[0].Item1, LoadType.LoadSearchRecipes, view, mChecked);

            adapter.AddFragment(newFragment, recipeLinks.links[0].Item2);
            viewPager.Adapter = adapter;
            //adapter.AddFragment(new RecipeListFragment(), "Category 1");
            //adapter.AddFragment(new RecipeListFragment(), "Category 3");
            //adapter.AddFragment(new RecipeListFragment(), "Category 3");
            //((AppCompatActivity)Activity).RunOnUiThread(() => viewPager.Adapter = adapter);
        }
Ejemplo n.º 14
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.fragment_actionbar_tabs, container, false);

            this._viewPager = view.FindViewById <Android.Support.V4.View.ViewPager>(Resource.Id.fragment_actionbar_tabs_viewpager);
            this._viewPager.PageSelected += (object sender, Android.Support.V4.View.ViewPager.PageSelectedEventArgs e) => {
                var actionBar = this.Activity.ActionBar;
                actionBar.SetSelectedNavigationItem(e.P0);
            };
            this._adapter           = new DummySectionsPagerAdapter(this.FragmentManager);
            this._viewPager.Adapter = this._adapter;
            return(view);
        }
Ejemplo n.º 15
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            pager = FindViewById <Android.Support.V4.View.ViewPager>(Resource.Id.pager);
            tabs  = FindViewById <PagerSlidingTabStrip>(Resource.Id.tabs);

            adapter       = new MyAdapter(SupportFragmentManager);
            pager.Adapter = adapter;
            tabs.SetViewPager(pager);
            tabs.SetBackgroundColor(Android.Graphics.Color.Argb(255, 0, 149, 164));
        }
Ejemplo n.º 16
0
        private void SetupTabs()
        {
            V4ViewPager      viewPager = FindViewById <V4ViewPager>(Resource.Id.pager);
            ViewPagerAdapter adapter   = new ViewPagerAdapter(SupportFragmentManager);

            // Add Fragments to adapter one by one
            adapter.AddFragment(new RotationFragment(), "Map Rotation");
            adapter.AddFragment(new NewsFragment(), "News");

            viewPager.Adapter = adapter;

            TabLayout tabLayout = FindViewById <TabLayout>(Resource.Id.tabs);

            tabLayout.SetupWithViewPager(viewPager);
        }
Ejemplo n.º 17
0
 private void InitViewPagerScroll()
 {
     try
     {
         Field mField = new ViewPager(Context).Class.GetDeclaredField("mScroller");
         mField.Accessible = true;
         mScroller         = new BannerScroller(viewPager.Context);
         mScroller.SetDuration(scrollTime);
         mField.Set(viewPager, mScroller);
     }
     catch (System.Exception e)
     {
         Log.Error(tag, e.Message);
     }
 }
Ejemplo n.º 18
0
        public override View OnCreateView(LayoutInflater p0, ViewGroup p1, Android.OS.Bundle p2)
        {
            var view = p0.Inflate(Resource.Layout.fragment_pager_tabstrip_tabs, p1, false);
            this._viewPager = view.FindViewById<Android.Support.V4.View.ViewPager>(Resource.Id.fragment_pager_tabstrip_viewpager);
            //this._viewPager.PageSelected += (object sender, Android.Support.V4.View.ViewPager.PageSelectedEventArgs e) => {
                //var actionBar = this.Activity.ActionBar;
                //actionBar.SetSelectedNavigationItem(e.P0);
            //};
            this._adapter = new DummySectionsPagerAdapter(this.FragmentManager);
            this._viewPager.Adapter = this._adapter;

            this._pagerTabStrip = view.FindViewById<Android.Support.V4.View.PagerTabStrip>(Resource.Id.fragment_pagertabstrip_tabstrip);

            return view;
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);
            Android.Support.V4.View.ViewPager viewpager_page = FindViewById <Android.Support.V4.View.ViewPager>(Resource.Id.viewpager_page);
            List <View> viewlist = new List <View>();

            //LayoutInflater.Inflate;
            viewlist.Add(LayoutInflater.Inflate(Resource.Layout.view_one, null, false));
            viewlist.Add(LayoutInflater.Inflate(Resource.Layout.view_Two, null, false));
            MyPagerAdapter mAdapter = new MyPagerAdapter(viewlist);

            viewpager_page.Adapter = mAdapter;
        }
Ejemplo n.º 20
0
        public override View OnCreateView(LayoutInflater p0, ViewGroup p1, Android.OS.Bundle p2)
        {
            var view = p0.Inflate(Resource.Layout.fragment_pager_tabstrip_tabs, p1, false);

            this._viewPager = view.FindViewById <Android.Support.V4.View.ViewPager>(Resource.Id.fragment_pager_tabstrip_viewpager);
            //this._viewPager.PageSelected += (object sender, Android.Support.V4.View.ViewPager.PageSelectedEventArgs e) => {
            //var actionBar = this.Activity.ActionBar;
            //actionBar.SetSelectedNavigationItem(e.P0);
            //};
            this._adapter           = new DummySectionsPagerAdapter(this.FragmentManager);
            this._viewPager.Adapter = this._adapter;

            this._pagerTabStrip = view.FindViewById <Android.Support.V4.View.PagerTabStrip>(Resource.Id.fragment_pagertabstrip_tabstrip);

            return(view);
        }
        public List <PhotoPath> saveUserPhotosAndReturnPaths(String title)
        {
            List <PhotoPath> photoPaths = new List <PhotoPath>();

            Android.Support.V4.View.ViewPager userPhotos = FindViewById <Android.Support.V4.View.ViewPager>(Resource.Id.userPhotos);
            for (int index = 1; index < userPhotos.Adapter.Count; index++)
            {
                userPhotos.SetCurrentItem(index, false);
                UserPhotoFragment userPhotoFragment = (UserPhotoFragment)((UserPhotosAdapter)userPhotos.Adapter).GetItem(index);
                String            imagePath         = saveImageFromImageView(userPhotoFragment.UserPhoto, title + "_" + "image" + index + ".jpg");

                PhotoPath photoPath = new PhotoPath(imagePath);
                photoPaths.Add(photoPath);
            }

            return(photoPaths);
        }
Ejemplo n.º 22
0
        private void TabLayoutViewPager()
        {
            tabLayout            = FindViewById <TabLayout>(Resource.Id.tab_layout);
            tabLayout.TabGravity = TabLayout.GravityFill;
            tabLayout.TabMode    = TabLayout.ModeScrollable;

            // PagerAdapter.FragmentPosition과 순서를 맞출것
            tabLayout.AddTab(tabLayout.NewTab().SetText(Resources.GetString(Resource.String.work_path_fragment)));
            tabLayout.AddTab(tabLayout.NewTab().SetText(Resources.GetString(Resource.String.weld_count_fragment)));
            tabLayout.AddTab(tabLayout.NewTab().SetText(Resources.GetString(Resource.String.weld_condition_fragment)));
            tabLayout.AddTab(tabLayout.NewTab().SetText(Resources.GetString(Resource.String.backup_path_fragment)));

            viewPager         = FindViewById <ViewPager>(Resource.Id.pager);
            pagerAdapter      = new PagerAdapter(SupportFragmentManager, tabLayout.TabCount);
            viewPager.Adapter = pagerAdapter;
            viewPager.AddOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
            tabLayout.SetOnTabSelectedListener(new TabLayoutOnTabSelectedListener(this, viewPager, actionBar, tabLayout));
        }
		public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
		{
			var pager = new ViewPager (inflater.Context) {
				Id = 0x34532,
				Adapter = new MonkeyPageAdapter (ChildFragmentManager),
			};
			pager.PageSelected += async (sender, e) => {
				var map = (SupportMapFragment)FragmentManager.FindFragmentById (Resource.Id.map);
				var monkeyName = ((MonkeyPageAdapter)pager.Adapter).GetMonkeyAtPosition (e.Position);
				var location = await WikipediaApi.FetchHabitatLocation (monkeyName);
				var latLng = new Android.Gms.Maps.Model.LatLng (location.Item1, location.Item2);
				map.Map.AnimateCamera (CameraUpdateFactory.NewLatLng (latLng), 250, null);
				if (existingMarker != null)
					existingMarker.Remove ();
				existingMarker = map.Map.AddMarker (new MarkerOptions ().SetPosition (latLng));
			};

			return pager;
		}
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_add_user_board_game);

            EditText titleEditText   = FindViewById <EditText>(Resource.Id.title);
            Button   downloadFromBGG = FindViewById <Button>(Resource.Id.downloadBGG);

            downloadFromBGG.Click += delegate(object sender, EventArgs e) { searchBoardGameByTitleInBGG(titleEditText.Text); };

            RadioButton categoryRadioButton = FindViewById <RadioButton>(Resource.Id.categoryButton);

            categoryRadioButton.Click += delegate(object sender, EventArgs e) { showBoardGameCategoryPopup(categoryRadioButton.Text); };

            LinearLayout bggRankHeader  = FindViewById <LinearLayout>(Resource.Id.bggRankHeader);
            ImageView    arrowView      = bggRankHeader.FindViewById <ImageView>(Resource.Id.expandArrow);
            LinearLayout bggRankWrapper = FindViewById <LinearLayout>(Resource.Id.bggRankWrapper);

            bggRankHeader.Click += delegate(object sender, EventArgs e) { BggRankWrapperClick(arrowView, bggRankWrapper); };

            ImageView thumbnail = FindViewById <ImageView>(Resource.Id.thumbnail);

            Utils.ImagePicker imagePicker = new Utils.ImagePicker();
            thumbnail.Click += delegate(object sender, EventArgs e) { imagePicker.startImagePickerActivity(this, false); imagePickerThumbnail = true; };

            Android.Support.V4.View.ViewPager      userPhotos = FindViewById <Android.Support.V4.View.ViewPager>(Resource.Id.userPhotos);
            Android.Support.V4.App.FragmentManager fm         = this.SupportFragmentManager;
            userPhotosAdapter = new UserPhotosAdapter(fm);

            UserPhotoFragment addPhotoFragment = new UserPhotoFragment();

            System.Diagnostics.Debug.WriteLine("Garfield test " + "Fragment created");
            addPhotoFragment.PhotoPath        = Android.Net.Uri.Parse("android.resource://" + Application.Context.PackageName + "/" + Resource.Drawable.thumbnail).ToString();
            addPhotoFragment.AddPhotoFragment = true;
            addPhotoFragment.UserPhotoClick   = this;

            userPhotosAdapter.UserPhotosFragments.Add(addPhotoFragment);
            userPhotos.Adapter = userPhotosAdapter;

            Button submitButton = FindViewById <Button>(Resource.Id.submit);

            submitButton.Click += submitButtonClick;
        }
Ejemplo n.º 25
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            firstCreate = true;
            handler     = new Handler();
            prefs       = new PreferenceManager(this);

            circlesFragment = new CirclesFragment();
            statsFragment   = new StatsFragment();

            SetContentView(Resource.Layout.Main);

            pager         = FindViewById <Android.Support.V4.View.ViewPager> (Resource.Id.mainPager);
            pager.Adapter = new StaticFragmentPagerAdapter(SupportFragmentManager, circlesFragment, statsFragment);

            background = new DynamicGradientDrawable(Resources.GetColor(Resource.Color.top_shade_1),
                                                     Resources.GetColor(Resource.Color.bottom_shade_1),
                                                     Resources.GetColor(Resource.Color.top_shade_2),
                                                     Resources.GetColor(Resource.Color.bottom_shade_2));
            pager.SetBackgroundDrawable(background);
            pager.PageScrolled  += HandlePageScrolled;
            pager.OverScrollMode = OverScrollMode.Never;
            if (prefs.FirstTimeAround)
            {
                pager.Touch += DiscardTouchEventHandler;
            }

            circlesTab              = ActionBar.NewTab().SetIcon(Resource.Drawable.ic_tab_circles);
            statsTab                = ActionBar.NewTab().SetIcon(Resource.Drawable.ic_tab_stats);
            circlesTab.TabSelected += (sender, e) => pager.SetCurrentItem(0, true);
            statsTab.TabSelected   += (sender, e) => pager.SetCurrentItem(1, true);
            ActionBar.AddTab(circlesTab);
            ActionBar.AddTab(statsTab);
            pager.PageSelected += (sender, e) => ActionBar.SetSelectedNavigationItem(e.Position);

            circlesFragment.CirclesReady += OnCirclesReady;
        }
Ejemplo n.º 26
0
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            ToolBar   = (Android.Support.V7.Widget.Toolbar)FindViewById(Resource.Layout.Toolbar);
            ViewPager = (Android.Support.V4.View.ViewPager)FindViewById(Resource.Layout.Tabbar);

            base.OnCreate(bundle);

            SetUpBottomBar();

            Rg.Plugins.Popup.Popup.Init(this, bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());
            global::Xamarin.Essentials.Platform.Init(this, bundle);
            //if(Device.RuntimePlatform == Device.Android) { var next_activity = new Intent(this, typeof(ActivityB)); this.StartActivity(next_activity); }

            //MessagingCenter.Subscribe<ImageSource>(this, "Share", Share, null);

            App.ScreenHeight = (int)(Resources.DisplayMetrics.HeightPixels / Resources.DisplayMetrics.Density);
            App.ScreenWidth  = (int)(Resources.DisplayMetrics.WidthPixels / Resources.DisplayMetrics.Density);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var pager = new ViewPager(inflater.Context)
            {
                Id      = 0x34532,
                Adapter = new MonkeyPageAdapter(ChildFragmentManager),
            };

            pager.PageSelected += async(sender, e) => {
                var map        = (SupportMapFragment)FragmentManager.FindFragmentById(Resource.Id.map);
                var monkeyName = ((MonkeyPageAdapter)pager.Adapter).GetMonkeyAtPosition(e.Position);
                var location   = await WikipediaApi.FetchHabitatLocation(monkeyName);

                var latLng = new Android.Gms.Maps.Model.LatLng(location.Item1, location.Item2);
                map.Map.AnimateCamera(CameraUpdateFactory.NewLatLng(latLng), 250, null);
                if (existingMarker != null)
                {
                    existingMarker.Remove();
                }
                existingMarker = map.Map.AddMarker(new MarkerOptions().SetPosition(latLng));
            };

            return(pager);
        }
Ejemplo n.º 28
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			firstCreate = true;
			handler = new Handler ();
			prefs = new PreferenceManager (this);

			circlesFragment = new CirclesFragment ();
			statsFragment = new StatsFragment ();

			SetContentView (Resource.Layout.Main);

			pager = FindViewById<Android.Support.V4.View.ViewPager> (Resource.Id.mainPager);
			pager.Adapter = new StaticFragmentPagerAdapter (SupportFragmentManager, circlesFragment, statsFragment);

			background = new DynamicGradientDrawable (Resources.GetColor (Resource.Color.top_shade_1),
			                                          Resources.GetColor (Resource.Color.bottom_shade_1),
			                                          Resources.GetColor (Resource.Color.top_shade_2),
			                                          Resources.GetColor (Resource.Color.bottom_shade_2));
			pager.SetBackgroundDrawable (background);
			pager.PageScrolled += HandlePageScrolled;
			pager.OverScrollMode = OverScrollMode.Never;
			if (prefs.FirstTimeAround)
				pager.Touch += DiscardTouchEventHandler;

			circlesTab = ActionBar.NewTab ().SetIcon (Resource.Drawable.ic_tab_circles);
			statsTab = ActionBar.NewTab ().SetIcon (Resource.Drawable.ic_tab_stats);
			circlesTab.TabSelected += (sender, e) => pager.SetCurrentItem (0, true);
			statsTab.TabSelected += (sender, e) => pager.SetCurrentItem (1, true);
			ActionBar.AddTab (circlesTab);
			ActionBar.AddTab (statsTab);
			pager.PageSelected += (sender, e) => ActionBar.SetSelectedNavigationItem (e.Position);

			circlesFragment.CirclesReady += OnCirclesReady;
		}
Ejemplo n.º 29
0
        private void setupViewPager(ViewPager viewPager)
        {
            var fragments = new List <Android.Support.V4.App.Fragment>();

            //var titles = new List<string>();
            foreach (var item in LiquorNames())
            {
                fragments.Add(new LiquorCategory());
                //titles.Add(item);
            }

            var titles = CharSequence.ArrayFromStringArray(new[]
            {
                "Beer",
                "Whisky",
                "Wine",
                "Champagne",
                "Cognac",
                "Cocktails"
            });
            LiquorCategoryAdapter adapter = new LiquorCategoryAdapter(base.SupportFragmentManager, fragments.ToArray(), titles);

            viewPager.Adapter = adapter;
        }
Ejemplo n.º 30
0
        private void OnViewPagerPageSelected (object sender, ViewPager.PageSelectedEventArgs e)
        {
            if (e.Position != MainPagerAdapter.LogPosition) {
                ((MainPagerAdapter)viewPager.Adapter).LogFragment.CloseActionMode ();
            }

            ToggleTimerDuration ();
        }
Ejemplo n.º 31
0
		private void TabLayoutViewPager()
		{
			tabLayout = FindViewById<TabLayout>(Resource.Id.tab_layout);
			tabLayout.TabGravity = TabLayout.GravityFill;
			tabLayout.TabMode = TabLayout.ModeScrollable;

			// PagerAdapter.FragmentPosition과 순서를 맞출것
			tabLayout.AddTab(tabLayout.NewTab().SetText(Resources.GetString(Resource.String.work_path_fragment)));
			tabLayout.AddTab(tabLayout.NewTab().SetText(Resources.GetString(Resource.String.weld_count_fragment)));
			tabLayout.AddTab(tabLayout.NewTab().SetText(Resources.GetString(Resource.String.weld_condition_fragment)));
			tabLayout.AddTab(tabLayout.NewTab().SetText(Resources.GetString(Resource.String.backup_path_fragment)));

			viewPager = FindViewById<ViewPager>(Resource.Id.pager);
			pagerAdapter = new PagerAdapter(SupportFragmentManager, tabLayout.TabCount);
			viewPager.Adapter = pagerAdapter;
			viewPager.AddOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
			tabLayout.SetOnTabSelectedListener(new TabLayoutOnTabSelectedListener(this, viewPager, actionBar, tabLayout));
		}
Ejemplo n.º 32
0
			public TabLayoutOnTabSelectedListener(Context context, ViewPager viewPager, ActionBar actionBar, TabLayout tabLayout)
			{
				this.context = context;
				this.viewPager = viewPager;
				this.actionBar = actionBar;
				this.tabLayout = tabLayout;
			}
Ejemplo n.º 33
0
        private void OnPageSelected (object sender, ViewPager.PageSelectedEventArgs e)
        {
            var adapter = (MainPagerAdapter)viewPager.Adapter;

            var frag = (ReportsFragment)adapter.GetItem (e.Position);
            if (frag.IsError) {
                frag.ReloadData();
            }
            frag.UserVisibleHint = true;
            backDate = e.Position - StartPage;
            UpdatePeriod ();
        }
Ejemplo n.º 34
0
        public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate (Resource.Layout.ReportsPagerFragment, container, false);
            viewPager = view.FindViewById<ViewPager> (Resource.Id.ReportsViewPager);
            viewPager.PageSelected += OnPageSelected;

            timePeriod = view.FindViewById<TextView> (Resource.Id.TimePeriodLabel);
            previousPeriod = view.FindViewById (Resource.Id.PreviousFrameLayout);
            nextPeriod = view.FindViewById (Resource.Id.NextFrameLayout);
            syncErrorBar = view.FindViewById<FrameLayout> (Resource.Id.ReportsSyncBar);
            syncRetry = view.FindViewById<ImageButton> (Resource.Id.ReportsSyncRetryButton);

            previousPeriod.Click += (sender, e) => NavigatePage (-1);
            nextPeriod.Click += (sender, e) => NavigatePage (1);
            syncRetry.Click += (sender, e) => ReloadCurrent();

            ResetAdapter ();
            UpdatePeriod ();

            var settings = ServiceContainer.Resolve<SettingsStore> ();
            if (settings.ReportsCurrentItem.HasValue) {
                viewPager.CurrentItem = settings.ReportsCurrentItem.Value;
            }

            return view;
        }
Ejemplo n.º 35
0
        public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate (Resource.Layout.ReportsPagerFragment, container, false);
            viewPager = view.FindViewById<ViewPager> (Resource.Id.ReportsViewPager);
            viewPager.PageSelected += OnPageSelected;

            timePeriod = view.FindViewById<TextView> (Resource.Id.TimePeriodLabel);
            previousPeriod = view.FindViewById (Resource.Id.PreviousFrameLayout);
            nextPeriod = view.FindViewById (Resource.Id.NextFrameLayout);
            syncErrorBar = view.FindViewById<FrameLayout> (Resource.Id.ReportsSyncBar);
            syncRetry = view.FindViewById<ImageButton> (Resource.Id.ReportsSyncRetryButton);
            reportsContainer = view.FindViewById<LinearLayout> (Resource.Id.ReportsContainer);
            nouserDisclaimer = view.FindViewById<LinearLayout> (Resource.Id.NoUserDisclaimer);
            noUserRegisterButton = view.FindViewById<Button> (Resource.Id.ReportsRegisterButton);

            previousPeriod.Click += (sender, e) => NavigatePage (-1);
            nextPeriod.Click += (sender, e) => NavigatePage (1);
            syncRetry.Click += async (sender, e) => await ReloadCurrent ();
            noUserRegisterButton.Click += OpenRegisterScreen;

            var activity = (MainDrawerActivity)Activity;
            toolbar = activity.MainToolbar;

            HasOptionsMenu = true;
            Activity.InvalidateOptionsMenu ();

            ResetAdapter ();
            UpdatePeriod ();

            var settings = ServiceContainer.Resolve<SettingsStore> ();
            if (settings.ReportsCurrentItem.HasValue) {
                viewPager.CurrentItem = settings.ReportsCurrentItem.Value;
            }

            if (ServiceContainer.Resolve<AuthManager> ().OfflineMode) {
                nouserDisclaimer.Visibility = ViewStates.Visible;
                reportsContainer.Visibility = ViewStates.Gone;
            } else {
                nouserDisclaimer.Visibility = ViewStates.Gone;
                reportsContainer.Visibility = ViewStates.Visible;
            }

            return view;
        }
Ejemplo n.º 36
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            FrameLayout MainLayout = new FrameLayout(this);

            SetContentView(MainLayout);
            base.CombineWith(MainLayout, Resource.Layout.History, ActivityIs.History);

            MainToolbar = FindViewById <SupportToolBar>(Resource.Id.toolbar);
            TabLayout   = FindViewById <SupportTabLayout>(Resource.Id.tabLayout);
            ViewPager   = FindViewById <SupportViewPager>(Resource.Id.viewPager);

            MainToolbar.Title = "History";
            String LastHistoryItemDate = String.Empty;

            ProgressDialog progressDialog = ProgressDialog.Show(this, "", "Loading list of users, please wait.", true);

            if (NetworkStatus.State != NetworkState.Disconnected)
            {
                UsersDatabase db = new UsersDatabase();

                ISharedPreferences info = Application.Context.GetSharedPreferences(Application.Context.GetString(Resource.String.ApplicationInfo), FileCreationMode.Private);
                String             Date = info.GetString(Application.Context.GetString(Resource.String.ModifyDate), String.Empty);
                LastHistoryItemDate = info.GetString(Application.Context.GetString(Resource.String.HistoryLoadedDate), "0");

                List <UserListItem> tmp = await MeritMoneyBrain.GetListOfUsers(modifyAfter : Date);

                if (db.IsExist())
                {
                    db.Update(tmp);
                }
                else
                {
                    db.CreateDatabase();
                    db.Insert(tmp);
                }
            }
            else
            {
                StartActivity(new Intent(this, typeof(NoInternetActivity)));
            }

            progressDialog.Dismiss();

            var db2   = new UsersDatabase();
            var Users = db2.GetUsers();

            ViewPagerAdapter = new ViewPagerAdapter(SupportFragmentManager);
            ViewPagerAdapter.AddFragments(new HistoryFragment(HistoryType.Personal,
                                                              LastHistoryItemDate,
                                                              NetworkStatus,
                                                              Users),
                                          new Java.Lang.String("Personal"));
            ViewPagerAdapter.AddFragments(new HistoryFragment(HistoryType.Company,
                                                              LastHistoryItemDate,
                                                              NetworkStatus,
                                                              Users),
                                          new Java.Lang.String("Company"));
            ViewPager.Adapter = ViewPagerAdapter;

            TabLayout.SetupWithViewPager(ViewPager);
        }
Ejemplo n.º 37
0
        private void OnViewPagerPageScrolled (object sender, ViewPager.PageScrolledEventArgs e)
        {
            var current = viewPager.CurrentItem;
            var pos = e.Position + e.PositionOffset;
            int idx;
            if (pos + 0.05f < current) {
                // Moving to the left
                idx = (int)Math.Floor (pos);
            } else if (pos - 0.05f > current) {
                // Moving to the right
                idx = (int)Math.Ceiling (pos);
            } else {
                return;
            }

            // Make sure the fragment knows that it's about to become visible
            var adapter = (MainPagerAdapter)viewPager.Adapter;
            if (adapter != null) {
                var frag = adapter.GetItem (idx);
                frag.UserVisibleHint = true;
            }
        }
 public void SetViewPager (Android.Support.V4.View.ViewPager view)
 {
     if (view.Adapter == null) {
         throw new Java.Lang.IllegalStateException ("ViewPager does not have adapter instance.");
     }
     _viewPager = view;
     _viewPager.AddOnPageChangeListener(this);
     UpdatePageSize ();
     Invalidate ();
 }