Permalink
Browse files

Remove ViewPagerIndicator to put in the 4.1-preview branch

  • Loading branch information...
1 parent 2a28edf commit 4d92f4577f8a57eb0ac6905ce8e95eb7a388ae9b @chrisntr chrisntr committed Apr 2, 2012
Showing with 0 additions and 3,750 deletions.
  1. +0 −26 ViewPagerIndicator/README.md
  2. +0 −20 ViewPagerIndicator/ViewPagerIndicator.sln
  3. +0 −84 ViewPagerIndicator/ViewPagerIndicator/ActivityListItem.cs
  4. +0 −19 ViewPagerIndicator/ViewPagerIndicator/Assets/AboutAssets.txt
  5. +0 −63 ViewPagerIndicator/ViewPagerIndicator/BaseSampleActivity.cs
  6. +0 −36 ViewPagerIndicator/ViewPagerIndicator/Circles/SampleCirclesDefault.cs
  7. +0 −39 ViewPagerIndicator/ViewPagerIndicator/Circles/SampleCirclesInitialPage.cs
  8. +0 −37 ViewPagerIndicator/ViewPagerIndicator/Circles/SampleCirclesSnap.cs
  9. +0 −36 ViewPagerIndicator/ViewPagerIndicator/Circles/SampleCirclesStyledLayout.cs
  10. +0 −46 ViewPagerIndicator/ViewPagerIndicator/Circles/SampleCirclesStyledMethods.cs
  11. +0 −36 ViewPagerIndicator/ViewPagerIndicator/Circles/SampleCirclesStyledTheme.cs
  12. +0 −65 ViewPagerIndicator/ViewPagerIndicator/Circles/SampleCirclesWithListener.cs
  13. +0 −544 ViewPagerIndicator/ViewPagerIndicator/Library/CirclePageIndicator.cs
  14. +0 −57 ViewPagerIndicator/ViewPagerIndicator/Library/PageIndicator.cs
  15. +0 −241 ViewPagerIndicator/ViewPagerIndicator/Library/TabPageIndicator.cs
  16. +0 −762 ViewPagerIndicator/ViewPagerIndicator/Library/TitlePageIndicator.cs
  17. +0 −28 ViewPagerIndicator/ViewPagerIndicator/Library/TitleProvider.cs
  18. BIN ViewPagerIndicator/ViewPagerIndicator/Mono.Android.Compatibility.V4.dll
  19. +0 −6 ViewPagerIndicator/ViewPagerIndicator/Properties/AndroidManifest.xml
  20. +0 −28 ViewPagerIndicator/ViewPagerIndicator/Properties/AssemblyInfo.cs
  21. +0 −44 ViewPagerIndicator/ViewPagerIndicator/Resources/AboutResources.txt
  22. +0 −24 ViewPagerIndicator/ViewPagerIndicator/Resources/color/vpi__dark_theme.xml
  23. +0 −26 ViewPagerIndicator/ViewPagerIndicator/Resources/color/vpi__light_theme.xml
  24. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-hdpi/custom_tab_indicator_focused.9.png
  25. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-hdpi/custom_tab_indicator_selected.9.png
  26. BIN ...rIndicator/ViewPagerIndicator/Resources/drawable-hdpi/custom_tab_indicator_selected_pressed.9.png
  27. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-hdpi/custom_tab_indicator_unselected.9.png
  28. BIN ...ndicator/ViewPagerIndicator/Resources/drawable-hdpi/custom_tab_indicator_unselected_focused.9.png
  29. BIN ...ndicator/ViewPagerIndicator/Resources/drawable-hdpi/custom_tab_indicator_unselected_pressed.9.png
  30. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-hdpi/icon.png
  31. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-hdpi/vpi__tab_selected_focused_holo.9.png
  32. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-hdpi/vpi__tab_selected_holo.9.png
  33. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-hdpi/vpi__tab_selected_pressed_holo.9.png
  34. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-hdpi/vpi__tab_unselected_focused_holo.9.png
  35. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-hdpi/vpi__tab_unselected_holo.9.png
  36. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-hdpi/vpi__tab_unselected_pressed_holo.9.png
  37. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-mdpi/custom_tab_indicator_selected.9.png
  38. BIN ...rIndicator/ViewPagerIndicator/Resources/drawable-mdpi/custom_tab_indicator_selected_focused.9.png
  39. BIN ...rIndicator/ViewPagerIndicator/Resources/drawable-mdpi/custom_tab_indicator_selected_pressed.9.png
  40. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-mdpi/custom_tab_indicator_unselected.9.png
  41. BIN ...ndicator/ViewPagerIndicator/Resources/drawable-mdpi/custom_tab_indicator_unselected_focused.9.png
  42. BIN ...ndicator/ViewPagerIndicator/Resources/drawable-mdpi/custom_tab_indicator_unselected_pressed.9.png
  43. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-mdpi/icon.png
  44. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-mdpi/vpi__tab_selected_focused_holo.9.png
  45. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-mdpi/vpi__tab_selected_holo.9.png
  46. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-mdpi/vpi__tab_selected_pressed_holo.9.png
  47. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-mdpi/vpi__tab_unselected_focused_holo.9.png
  48. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-mdpi/vpi__tab_unselected_holo.9.png
  49. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-mdpi/vpi__tab_unselected_pressed_holo.9.png
  50. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-xhdpi/custom_tab_indicator_selected.9.png
  51. BIN ...Indicator/ViewPagerIndicator/Resources/drawable-xhdpi/custom_tab_indicator_selected_focused.9.png
  52. BIN ...Indicator/ViewPagerIndicator/Resources/drawable-xhdpi/custom_tab_indicator_selected_pressed.9.png
  53. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-xhdpi/custom_tab_indicator_unselected.9.png
  54. BIN ...dicator/ViewPagerIndicator/Resources/drawable-xhdpi/custom_tab_indicator_unselected_focused.9.png
  55. BIN ...dicator/ViewPagerIndicator/Resources/drawable-xhdpi/custom_tab_indicator_unselected_pressed.9.png
  56. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-xhdpi/icon.png
  57. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-xhdpi/vpi__tab_selected_focused_holo.9.png
  58. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-xhdpi/vpi__tab_selected_holo.9.png
  59. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-xhdpi/vpi__tab_selected_pressed_holo.9.png
  60. BIN ...PagerIndicator/ViewPagerIndicator/Resources/drawable-xhdpi/vpi__tab_unselected_focused_holo.9.png
  61. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable-xhdpi/vpi__tab_unselected_holo.9.png
  62. BIN ...PagerIndicator/ViewPagerIndicator/Resources/drawable-xhdpi/vpi__tab_unselected_pressed_holo.9.png
  63. BIN ViewPagerIndicator/ViewPagerIndicator/Resources/drawable/Icon.png
  64. +0 −34 ViewPagerIndicator/ViewPagerIndicator/Resources/drawable/custom_tab_indicator.xml
  65. +0 −34 ViewPagerIndicator/ViewPagerIndicator/Resources/drawable/vpi__tab_indicator.xml
  66. +0 −14 ViewPagerIndicator/ViewPagerIndicator/Resources/layout/Main.axml
  67. +0 −35 ViewPagerIndicator/ViewPagerIndicator/Resources/layout/simple_circles.xml
  68. +0 −35 ViewPagerIndicator/ViewPagerIndicator/Resources/layout/simple_circles_vertical.xml
  69. +0 −35 ViewPagerIndicator/ViewPagerIndicator/Resources/layout/simple_tabs.xml
  70. +0 −36 ViewPagerIndicator/ViewPagerIndicator/Resources/layout/simple_titles.xml
  71. +0 −43 ViewPagerIndicator/ViewPagerIndicator/Resources/layout/themed_circles.xml
  72. +0 −45 ViewPagerIndicator/ViewPagerIndicator/Resources/layout/themed_titles.xml
  73. +0 −13 ViewPagerIndicator/ViewPagerIndicator/Resources/layout/vpi__tab.xml
  74. +0 −7 ViewPagerIndicator/ViewPagerIndicator/Resources/menu/menu.xml
  75. +0 −5 ViewPagerIndicator/ViewPagerIndicator/Resources/values/Strings.xml
  76. +0 −51 ViewPagerIndicator/ViewPagerIndicator/Resources/values/styles.xml
  77. +0 −86 ViewPagerIndicator/ViewPagerIndicator/Resources/values/vpi__attrs.xml
  78. +0 −26 ViewPagerIndicator/ViewPagerIndicator/Resources/values/vpi__colors.xml
  79. +0 −40 ViewPagerIndicator/ViewPagerIndicator/Resources/values/vpi__defaults.xml
  80. +0 −73 ViewPagerIndicator/ViewPagerIndicator/Resources/values/vpi__styles.xml
  81. +0 −59 ViewPagerIndicator/ViewPagerIndicator/Tabs/SampleTabsDefault.cs
  82. +0 −59 ViewPagerIndicator/ViewPagerIndicator/Tabs/SampleTabsStyled.cs
  83. +0 −66 ViewPagerIndicator/ViewPagerIndicator/TestFragment.cs
  84. +0 −48 ViewPagerIndicator/ViewPagerIndicator/TestFragmentAdapter.cs
  85. +0 −30 ViewPagerIndicator/ViewPagerIndicator/TestTitleFragmentAdapter.cs
  86. +0 −44 ViewPagerIndicator/ViewPagerIndicator/Titles/SampleTitlesCenterClickListener.cs
  87. +0 −38 ViewPagerIndicator/ViewPagerIndicator/Titles/SampleTitlesDefault.cs
  88. +0 −40 ViewPagerIndicator/ViewPagerIndicator/Titles/SampleTitlesInitialPage.cs
  89. +0 −36 ViewPagerIndicator/ViewPagerIndicator/Titles/SampleTitlesStyledLayout.cs
  90. +0 −47 ViewPagerIndicator/ViewPagerIndicator/Titles/SampleTitlesStyledMethods.cs
  91. +0 −36 ViewPagerIndicator/ViewPagerIndicator/Titles/SampleTitlesStyledTheme.cs
  92. +0 −38 ViewPagerIndicator/ViewPagerIndicator/Titles/SampleTitlesTriangle.cs
  93. +0 −63 ViewPagerIndicator/ViewPagerIndicator/Titles/SampleTitlesWithListener.cs
  94. +0 −109 ViewPagerIndicator/ViewPagerIndicator/ViewPagerIndicator.cs
  95. +0 −158 ViewPagerIndicator/ViewPagerIndicator/ViewPagerIndicator.csproj
  96. BIN ViewPagerIndicator/ViewPagerIndicator/android-support-v4.jar
View
26 ViewPagerIndicator/README.md
@@ -1,26 +0,0 @@
-ViewPagerIndicator
-==================
-
-This is a port of the wonderful [ViewPagerIndicator library by JakeWharton][1]
-
-License
-=======
-
- Copyright 2011 Patrik Åkerfeldt
- Copyright 2011 Francisco Figueiredo Jr.
- Copyright 2011 Jake Wharton
- Copyright 2012 Xamarin Inc
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-[1]: https://github.com/JakeWharton/Android-ViewPagerIndicator
View
20 ViewPagerIndicator/ViewPagerIndicator.sln
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ViewPagerIndicator", "ViewPagerIndicator\ViewPagerIndicator.csproj", "{10BE6857-6A09-448A-A52E-C0AC31CAFD9D}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {10BE6857-6A09-448A-A52E-C0AC31CAFD9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {10BE6857-6A09-448A-A52E-C0AC31CAFD9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {10BE6857-6A09-448A-A52E-C0AC31CAFD9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {10BE6857-6A09-448A-A52E-C0AC31CAFD9D}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(MonoDevelopProperties) = preSolution
- StartupItem = ViewPagerIndicator\ViewPagerIndicator.csproj
- EndGlobalSection
-EndGlobal
View
84 ViewPagerIndicator/ViewPagerIndicator/ActivityListItem.cs
@@ -1,84 +0,0 @@
-//
-// Copyright (C) 2007 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-using System;
-using System.Collections.Generic;
-
-namespace ViewPagerIndicator
-{
- class ActivityListItem : Java.Lang.Object
- {
- public string LaunchData { get; set; }
- public string Path { get; set; }
- public string Prefix { get; set; }
-
- public ActivityListItem (string prefix, string path, string launchData)
- {
- Prefix = prefix;
- Path = path;
- LaunchData = launchData;
- }
-
- public string Component {
- get { return LaunchData.Split (':')[1]; }
- }
-
- public bool IsMenuItem { get { return !IsSubMenu; } }
- public bool IsSubMenu { get { return NoPrefixPath.Contains ("/"); } }
-
- public string Name {
- get {
- if (IsMenuItem)
- return NoPrefixPath;
-
- return NoPrefixPath.Split ('/')[0];
- }
- }
-
- public string NoPrefixPath {
- get { return Path.Substring (Prefix.Length).TrimStart ('/'); }
- }
-
- public string Package {
- get { return LaunchData.Split (':')[0]; }
- }
-
- public bool IsInPrefix (string prefix)
- {
- return Path.StartsWith (prefix, StringComparison.InvariantCultureIgnoreCase);
- }
-
- public override string ToString ()
- {
- return Name;
- }
-
- public class NameComparer : IEqualityComparer<ActivityListItem>
- {
- #region IEqualityComparer<ActivityListItem> Members
- public bool Equals (ActivityListItem x, ActivityListItem y)
- {
- return string.Compare (x.Name, y.Name) == 0;
- }
-
- public int GetHashCode (ActivityListItem obj)
- {
- return obj.Name.GetHashCode ();
- }
- #endregion
- }
- }
-}
View
19 ViewPagerIndicator/ViewPagerIndicator/Assets/AboutAssets.txt
@@ -1,19 +0,0 @@
-Any raw assets you want to be deployed with your application can be placed in
-this directory (and child directories) and given a Build Action of "AndroidAsset".
-
-These files will be deployed with you package and will be accessible using Android's
-AssetManager, like this:
-
-public class ReadAsset : Activity
-{
- protected override void OnCreate (Bundle bundle)
- {
- base.OnCreate (bundle);
-
- InputStream input = Assets.Open ("my_asset.txt");
- }
-}
-
-Additionally, some Android functions will automatically load asset files:
-
-Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
View
63 ViewPagerIndicator/ViewPagerIndicator/BaseSampleActivity.cs
@@ -1,63 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Android.App;
-using Android.Content;
-using Android.OS;
-using Android.Runtime;
-using Android.Views;
-using Android.Widget;
-using Android.Support.V4.App;
-using Android.Support.V4.View;
-
-namespace ViewPagerIndicator
-{
- [Activity (Label = "BaseSampleActivity")]
- public class BaseSampleActivity : FragmentActivity
- {
- private Random RANDOM = new Random();
-
- public TestFragmentAdapter mAdapter;
- public ViewPager mPager;
- public PageIndicator mIndicator;
-
- public override bool OnCreateOptionsMenu (IMenu menu)
- {
- MenuInflater.Inflate(Resource.Menu.menu, menu);
- return true;
- }
-
- public override bool OnOptionsItemSelected (IMenuItem item)
- {
- switch (item.ItemId)
- {
- case Resource.Id.random:
- int page = RANDOM.Next(mAdapter.Count);
- Toast.MakeText(this, "Changing to page " + page, ToastLength.Short);
- mPager.CurrentItem = page;
- return true;
-
- case Resource.Id.add_page:
- Console.WriteLine ("Adapter count " + mAdapter.Count);
- if (mAdapter.Count < 10) {
- mAdapter.SetCount(mAdapter.Count + 1);
- mIndicator.NotifyDataSetChanged();
- }
- return true;
-
- case Resource.Id.remove_page:
-
- Console.WriteLine ("Remove page " + mAdapter.Count);
- if (mAdapter.Count > 1) {
- mAdapter.SetCount(mAdapter.Count - 1);
- mIndicator.NotifyDataSetChanged();
- }
- return true;
- }
- return base.OnOptionsItemSelected(item);
- }
- }
-}
-
View
36 ViewPagerIndicator/ViewPagerIndicator/Circles/SampleCirclesDefault.cs
@@ -1,36 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Android.App;
-using Android.Content;
-using Android.OS;
-using Android.Runtime;
-using Android.Views;
-using Android.Widget;
-using Android.Support.V4.View;
-
-namespace ViewPagerIndicator
-{
- [Activity (Label = "Circles/Default", Theme = "@style/StyledIndicators")]
- [IntentFilter (new[]{Intent.ActionMain}, Categories = new[]{ "mono.viewpagerindicator.sample" })]
- public class SampleCirclesDefault : BaseSampleActivity
- {
- protected override void OnCreate (Bundle bundle)
- {
- base.OnCreate (bundle);
-
- SetContentView(Resource.Layout.simple_circles);
-
- mAdapter = new TestFragmentAdapter(SupportFragmentManager);
-
- mPager = FindViewById<ViewPager>(Resource.Id.pager);
- mPager.Adapter = mAdapter;
-
- mIndicator = FindViewById<CirclePageIndicator>(Resource.Id.indicator);
- mIndicator.SetViewPager(mPager);
- }
- }
-}
-
View
39 ViewPagerIndicator/ViewPagerIndicator/Circles/SampleCirclesInitialPage.cs
@@ -1,39 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Android.App;
-using Android.Content;
-using Android.OS;
-using Android.Runtime;
-using Android.Views;
-using Android.Widget;
-using Android.Support.V4.View;
-
-namespace ViewPagerIndicator
-{
- [Activity (Label = "Circles/Initial Page")]
- [IntentFilter (new[]{Intent.ActionMain}, Categories = new[]{ "mono.viewpagerindicator.sample" })]
- public class SampleCirclesInitialPage : BaseSampleActivity
- {
- protected override void OnCreate (Bundle bundle)
- {
- base.OnCreate (bundle);
-
- SetContentView(Resource.Layout.simple_circles);
-
- mAdapter = new TestFragmentAdapter(SupportFragmentManager);
-
- mPager = FindViewById<ViewPager>(Resource.Id.pager);
- mPager.Adapter = mAdapter;
-
- mIndicator = FindViewById<CirclePageIndicator>(Resource.Id.indicator);
- mIndicator.SetViewPager(mPager);
- mIndicator.SetCurrentItem(mAdapter.Count - 1);
-
- //You can also do: indicator.SetViewPager(pager, initialPage);
- }
- }
-}
-
View
37 ViewPagerIndicator/ViewPagerIndicator/Circles/SampleCirclesSnap.cs
@@ -1,37 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Android.App;
-using Android.Content;
-using Android.OS;
-using Android.Runtime;
-using Android.Views;
-using Android.Widget;
-using Android.Support.V4.View;
-
-namespace ViewPagerIndicator
-{
- [Activity (Label = "Circles/Snap")]
- [IntentFilter (new[]{Intent.ActionMain}, Categories = new[]{ "mono.viewpagerindicator.sample" })]
- public class SampleCirclesSnap : BaseSampleActivity
- {
- protected override void OnCreate (Bundle bundle)
- {
- base.OnCreate (bundle);
-
- SetContentView(Resource.Layout.simple_circles);
-
- mAdapter = new TestFragmentAdapter(SupportFragmentManager);
-
- mPager = FindViewById<ViewPager>(Resource.Id.pager);
- mPager.Adapter = mAdapter;
- var indicator = FindViewById<CirclePageIndicator>(Resource.Id.indicator);
- mIndicator = indicator;
- indicator.SetViewPager(mPager);
- indicator.SetSnap(true);
- }
- }
-}
-
View
36 ViewPagerIndicator/ViewPagerIndicator/Circles/SampleCirclesStyledLayout.cs
@@ -1,36 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Android.App;
-using Android.Content;
-using Android.OS;
-using Android.Runtime;
-using Android.Views;
-using Android.Widget;
-using Android.Support.V4.View;
-
-namespace ViewPagerIndicator
-{
- [Activity (Label = "Circles/Styled (via layout)", Theme = "@android:style/Theme.Light")]
- [IntentFilter (new[]{Intent.ActionMain}, Categories = new[]{ "mono.viewpagerindicator.sample" })]
- public class SampleCirclesStyledLayout : BaseSampleActivity
- {
- protected override void OnCreate (Bundle bundle)
- {
- base.OnCreate (bundle);
-
- SetContentView(Resource.Layout.themed_circles);
-
- mAdapter = new TestFragmentAdapter(SupportFragmentManager);
-
- mPager = FindViewById<ViewPager>(Resource.Id.pager);
- mPager.Adapter = mAdapter;
-
- mIndicator = FindViewById<CirclePageIndicator>(Resource.Id.indicator);
- mIndicator.SetViewPager(mPager);
- }
- }
-}
-
View
46 ViewPagerIndicator/ViewPagerIndicator/Circles/SampleCirclesStyledMethods.cs
@@ -1,46 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Android.App;
-using Android.Content;
-using Android.OS;
-using Android.Runtime;
-using Android.Views;
-using Android.Widget;
-using Android.Support.V4.View;
-using Android.Graphics;
-
-namespace ViewPagerIndicator
-{
- [Activity (Label = "Circles/Styled (via methods)", Theme = "@android:style/Theme.Light")]
- [IntentFilter (new[]{Intent.ActionMain}, Categories = new[]{ "mono.viewpagerindicator.sample" })]
- public class SampleCirclesStyledMethods : BaseSampleActivity
- {
- protected override void OnCreate (Bundle bundle)
- {
- base.OnCreate (bundle);
-
- SetContentView(Resource.Layout.themed_circles);
-
- mAdapter = new TestFragmentAdapter(SupportFragmentManager);
-
- mPager = FindViewById<ViewPager>(Resource.Id.pager);
- mPager.Adapter = mAdapter;
-
- var indicator = FindViewById<CirclePageIndicator>(Resource.Id.indicator);
- mIndicator = indicator;
- indicator.SetViewPager(mPager);
-
- float density = Resources.DisplayMetrics.Density;
- indicator.SetBackgroundColor(Color.ParseColor("#FFCCCCCC"));
- indicator.SetRadius(10 * density);
- indicator.SetPageColor(Color.ParseColor("#880000FF"));
- indicator.SetFillColor(Color.ParseColor("#FF888888"));
- indicator.SetStrokeColor(Color.ParseColor("#FF000000"));
- indicator.SetStrokeWidth(2 * density);
- }
- }
-}
-
View
36 ViewPagerIndicator/ViewPagerIndicator/Circles/SampleCirclesStyledTheme.cs
@@ -1,36 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Android.App;
-using Android.Content;
-using Android.OS;
-using Android.Runtime;
-using Android.Views;
-using Android.Widget;
-using Android.Support.V4.View;
-
-namespace ViewPagerIndicator
-{
- [Activity (Label = "Circles/Styled (via theme)", Theme = "@style/StyledIndicators")]
- [IntentFilter (new[]{Intent.ActionMain}, Categories = new[]{ "mono.viewpagerindicator.sample" })]
- public class SampleCirclesStyledTheme : BaseSampleActivity
- {
- protected override void OnCreate (Bundle bundle)
- {
- base.OnCreate (bundle);
-
- SetContentView(Resource.Layout.simple_circles);
-
- mAdapter = new TestFragmentAdapter(SupportFragmentManager);
-
- mPager = FindViewById<ViewPager>(Resource.Id.pager);
- mPager.Adapter = mAdapter;
-
- mIndicator = FindViewById<CirclePageIndicator>(Resource.Id.indicator);
- mIndicator.SetViewPager(mPager);
- }
- }
-}
-
View
65 ViewPagerIndicator/ViewPagerIndicator/Circles/SampleCirclesWithListener.cs
@@ -1,65 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Android.App;
-using Android.Content;
-using Android.OS;
-using Android.Runtime;
-using Android.Views;
-using Android.Widget;
-using Android.Support.V4.View;
-
-namespace ViewPagerIndicator
-{
- [Activity (Label = "Circles/With Listener")]
- [IntentFilter (new[]{Intent.ActionMain}, Categories = new[]{ "mono.viewpagerindicator.sample" })]
- public class SampleCirclesWithListener : BaseSampleActivity
- {
- protected override void OnCreate (Bundle bundle)
- {
- base.OnCreate (bundle);
-
- SetContentView(Resource.Layout.simple_circles);
-
- mAdapter = new TestFragmentAdapter(SupportFragmentManager);
-
- mPager = FindViewById<ViewPager>(Resource.Id.pager);
- mPager.Adapter = mAdapter;
-
- mIndicator = FindViewById<CirclePageIndicator>(Resource.Id.indicator);
- mIndicator.SetViewPager(mPager);
-
- mIndicator.SetOnPageChangeListener(new MyPageChangeListener(this));
-
- }
-
- public class MyPageChangeListener : Java.Lang.Object, ViewPager.IOnPageChangeListener
- {
- Context _context;
-
- public MyPageChangeListener(Context context)
- {
- _context = context;
- }
-
- #region IOnPageChangeListener implementation
- public void OnPageScrollStateChanged (int p0)
- {
- }
-
- public void OnPageScrolled (int p0, float p1, int p2)
- {
- }
-
- public void OnPageSelected (int position)
- {
- Toast.MakeText(_context, "Changed to page " + position, ToastLength.Short).Show();
- }
- #endregion
- }
-
- }
-}
-
View
544 ViewPagerIndicator/ViewPagerIndicator/Library/CirclePageIndicator.cs
@@ -1,544 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Android.App;
-using Android.Content;
-using Android.OS;
-using Android.Runtime;
-using Android.Views;
-using Android.Widget;
-using Android.Graphics;
-using Android.Support.V4.View;
-using Android.Util;
-using Java.Lang;
-
-namespace ViewPagerIndicator
-{
- public class CirclePageIndicator : View, PageIndicator
- {
- const int HORIZONTAL = 0;
- const int VERTICAL = 1;
-
- private float mRadius;
- private Paint mPaintPageFill;
- private Paint mPaintStroke;
- private Paint mPaintFill;
- private ViewPager mViewPager;
- private ViewPager.IOnPageChangeListener mListener;
- private int mCurrentPage;
- private int mSnapPage;
- private int mCurrentOffset;
- private int mScrollState;
- private int mPageSize;
- private int mOrientation;
- private bool mCentered;
- private bool mSnap;
-
- private const int INVALID_POINTER = -1;
-
- private int mTouchSlop;
- private float mLastMotionX = -1;
- private int mActivePointerId = INVALID_POINTER;
- private bool mIsDragging;
-
- public CirclePageIndicator(Context context) : this(context, null)
- {
- }
-
- public CirclePageIndicator(Context context, IAttributeSet attrs) : this (context, attrs, Resource.Attribute.vpiCirclePageIndicatorStyle)
- {
- }
-
- public CirclePageIndicator(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
- {
- //Load defaults from resources
- var res = Resources;
- int defaultPageColor = res.GetColor(Resource.Color.default_circle_indicator_page_color);
- int defaultFillColor = res.GetColor(Resource.Color.default_circle_indicator_fill_color);
- int defaultOrientation = res.GetInteger(Resource.Integer.default_circle_indicator_orientation);
- int defaultStrokeColor = res.GetColor(Resource.Color.default_circle_indicator_stroke_color);
- float defaultStrokeWidth = res.GetDimension(Resource.Dimension.default_circle_indicator_stroke_width);
- float defaultRadius = res.GetDimension(Resource.Dimension.default_circle_indicator_radius);
- bool defaultCentered = res.GetBoolean(Resource.Boolean.default_circle_indicator_centered);
- bool defaultSnap = res.GetBoolean(Resource.Boolean.default_circle_indicator_snap);
-
- //Retrieve styles attributes
- var a = context.ObtainStyledAttributes(attrs, Resource.Styleable.CirclePageIndicator, defStyle, Resource.Style.Widget_CirclePageIndicator);
-
- mCentered = a.GetBoolean(Resource.Styleable.CirclePageIndicator_centered, defaultCentered);
- mOrientation = a.GetInt(Resource.Styleable.CirclePageIndicator_orientation, defaultOrientation);
- mPaintPageFill = new Paint(PaintFlags.AntiAlias);
- mPaintPageFill.SetStyle(Paint.Style.Fill);
- mPaintPageFill.Color = a.GetColor(Resource.Styleable.CirclePageIndicator_pageColor, defaultPageColor);
- mPaintStroke = new Paint(PaintFlags.AntiAlias);
- mPaintStroke.SetStyle(Paint.Style.Stroke);
- mPaintStroke.Color = a.GetColor(Resource.Styleable.CirclePageIndicator_strokeColor, defaultStrokeColor);
- mPaintStroke.StrokeWidth = a.GetDimension(Resource.Styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth);
- mPaintFill = new Paint(PaintFlags.AntiAlias);
- mPaintFill.SetStyle(Paint.Style.Fill);
- mPaintFill.Color = a.GetColor(Resource.Styleable.CirclePageIndicator_fillColor, defaultFillColor);
- mRadius = a.GetDimension(Resource.Styleable.CirclePageIndicator_radius, defaultRadius);
- mSnap = a.GetBoolean(Resource.Styleable.CirclePageIndicator_snap, defaultSnap);
-
- a.Recycle();
-
- var configuration = ViewConfiguration.Get(context);
- mTouchSlop = ViewConfigurationCompat.GetScaledPagingTouchSlop(configuration);
-
- }
-
- public void SetCentered(bool centered) {
- mCentered = centered;
- Invalidate();
- }
-
- public bool IsCentered() {
- return mCentered;
- }
-
- public void SetPageColor(int pageColor) {
- mPaintPageFill.Color = pageColor;
- Invalidate();
- }
-
- public int GetPageColor() {
- return mPaintPageFill.Color;
- }
-
- public void SetFillColor(int fillColor) {
- mPaintFill.Color = fillColor;
- Invalidate();
- }
-
- public int GetFillColor() {
- return mPaintFill.Color;
- }
-
- public void setOrientation(int orientation) {
- switch (orientation) {
- case HORIZONTAL:
- case VERTICAL:
- mOrientation = orientation;
- UpdatePageSize();
- RequestLayout();
- break;
-
- default:
- throw new IllegalArgumentException("Orientation must be either HORIZONTAL or VERTICAL.");
- }
- }
-
- public int GetOrientation() {
- return mOrientation;
- }
-
- public void SetStrokeColor(int strokeColor) {
- mPaintStroke.Color = strokeColor;
- Invalidate();
- }
-
- public int GetStrokeColor() {
- return mPaintStroke.Color;
- }
-
- public void SetStrokeWidth(float strokeWidth) {
- mPaintStroke.StrokeWidth = strokeWidth;
- Invalidate();
- }
-
- public float GetStrokeWidth() {
- return mPaintStroke.StrokeWidth;
- }
-
- public void SetRadius(float radius) {
- mRadius = radius;
- Invalidate();
- }
-
- public float GetRadius() {
- return mRadius;
- }
-
- public void SetSnap(bool snap) {
- mSnap = snap;
- Invalidate();
- }
-
- public bool IsSnap() {
- return mSnap;
- }
-
- protected override void OnDraw (Canvas canvas)
- {
- base.OnDraw (canvas);
-
- if (mViewPager == null) {
- return;
- }
- int count = mViewPager.Adapter.Count;
- if (count == 0) {
- return;
- }
-
- if (mCurrentPage >= count) {
- SetCurrentItem(count - 1);
- return;
- }
-
- int longSize;
- int longPaddingBefore;
- int longPaddingAfter;
- int shortPaddingBefore;
- if (mOrientation == HORIZONTAL) {
- longSize = Width;
- longPaddingBefore = PaddingLeft;
- longPaddingAfter = PaddingRight;
- shortPaddingBefore = PaddingTop;
- } else {
- longSize = Height;
- longPaddingBefore = PaddingTop;
- longPaddingAfter = PaddingBottom;
- shortPaddingBefore = PaddingLeft;
- }
-
- float threeRadius = mRadius * 3;
- float shortOffset = shortPaddingBefore + mRadius;
- float longOffset = longPaddingBefore + mRadius;
- if (mCentered) {
- longOffset += ((longSize - longPaddingBefore - longPaddingAfter) / 2.0f) - ((count * threeRadius) / 2.0f);
- }
-
- float dX;
- float dY;
-
- float pageFillRadius = mRadius;
- if (mPaintStroke.StrokeWidth > 0) {
- pageFillRadius -= mPaintStroke.StrokeWidth / 2.0f;
- }
-
- //Draw stroked circles
- for (int iLoop = 0; iLoop < count; iLoop++) {
- float drawLong = longOffset + (iLoop * threeRadius);
- if (mOrientation == HORIZONTAL) {
- dX = drawLong;
- dY = shortOffset;
- } else {
- dX = shortOffset;
- dY = drawLong;
- }
- // Only paint fill if not completely transparent
- if (mPaintPageFill.Alpha > 0) {
- canvas.DrawCircle(dX, dY, pageFillRadius, mPaintPageFill);
- }
-
- // Only paint stroke if a stroke width was non-zero
- if (pageFillRadius != mRadius) {
- canvas.DrawCircle(dX, dY, mRadius, mPaintStroke);
- }
- }
-
- //Draw the filled circle according to the current scroll
- float cx = (mSnap ? mSnapPage : mCurrentPage) * threeRadius;
- if (!mSnap && (mPageSize != 0)) {
- cx += (mCurrentOffset * 1.0f / mPageSize) * threeRadius;
- }
- if (mOrientation == HORIZONTAL) {
- dX = longOffset + cx;
- dY = shortOffset;
- } else {
- dX = shortOffset;
- dY = longOffset + cx;
- }
- canvas.DrawCircle(dX, dY, mRadius, mPaintFill);
- }
-
- public override bool OnTouchEvent(MotionEvent ev) {
-
- if(base.OnTouchEvent(ev))
- {
- return true;
- }
- if ((mViewPager == null) || (mViewPager.Adapter.Count == 0)) {
- return false;
- }
-
- var action = ev.Action;
-
- switch ((int) action & MotionEventCompat.ActionMask) {
- case (int) MotionEventActions.Down:
- mActivePointerId = MotionEventCompat.GetPointerId(ev, 0);
- mLastMotionX = ev.GetX();
- break;
-
- case (int)MotionEventActions.Move: {
- int activePointerIndex = MotionEventCompat.FindPointerIndex(ev, mActivePointerId);
- float x = MotionEventCompat.GetX(ev, activePointerIndex);
- float deltaX = x - mLastMotionX;
-
- if (!mIsDragging) {
- if (Java.Lang.Math.Abs(deltaX) > mTouchSlop) {
- mIsDragging = true;
- }
- }
-
- if (mIsDragging) {
- if (!mViewPager.IsFakeDragging) {
- mViewPager.BeginFakeDrag();
- }
-
- mLastMotionX = x;
-
- mViewPager.FakeDragBy(deltaX);
- }
-
- break;
- }
-
- case (int)MotionEventActions.Cancel:
- case (int)MotionEventActions.Up:
- if (!mIsDragging) {
- int count = mViewPager.Adapter.Count;
- int width = Width;
- float halfWidth = width / 2f;
- float sixthWidth = width / 6f;
-
- if ((mCurrentPage > 0) && (ev.GetX() < halfWidth - sixthWidth)) {
- mViewPager.CurrentItem = mCurrentPage - 1;
- return true;
- } else if ((mCurrentPage < count - 1) && (ev.GetX() > halfWidth + sixthWidth)) {
- mViewPager.CurrentItem = mCurrentPage + 1;
- return true;
- }
- }
-
- mIsDragging = false;
- mActivePointerId = INVALID_POINTER;
- if (mViewPager.IsFakeDragging) mViewPager.EndFakeDrag();
- break;
-
- case MotionEventCompat.ActionPointerDown: {
- int index = MotionEventCompat.GetActionIndex(ev);
- float x = MotionEventCompat.GetX(ev, index);
- mLastMotionX = x;
- mActivePointerId = MotionEventCompat.GetPointerId(ev, index);
- break;
- }
-
- case MotionEventCompat.ActionPointerUp:
- int pointerIndex = MotionEventCompat.GetActionIndex(ev);
- int pointerId = MotionEventCompat.GetPointerId(ev, pointerIndex);
- if (pointerId == mActivePointerId) {
- int newPointerIndex = pointerIndex == 0 ? 1 : 0;
- mActivePointerId = MotionEventCompat.GetPointerId(ev, newPointerIndex);
- }
- mLastMotionX = MotionEventCompat.GetX(ev, MotionEventCompat.FindPointerIndex(ev, mActivePointerId));
- break;
- }
-
- return true;
- }
-
- public void SetViewPager (ViewPager view)
- {
- if (view.Adapter == null) {
- throw new IllegalStateException("ViewPager does not have adapter instance.");
- }
- mViewPager = view;
- mViewPager.SetOnPageChangeListener(this);
- UpdatePageSize();
- Invalidate();
- }
-
- private void UpdatePageSize() {
- if (mViewPager != null) {
- mPageSize = (mOrientation == HORIZONTAL) ? mViewPager.Width : mViewPager.Height;
- }
- }
-
- public void SetViewPager (ViewPager view, int initialPosition)
- {
- SetViewPager(view);
- SetCurrentItem(initialPosition);
- }
-
- public void SetCurrentItem (int item)
- {
- if (mViewPager == null) {
- throw new IllegalStateException("ViewPager has not been bound.");
- }
- mViewPager.CurrentItem = item;
- mCurrentPage = item;
- Invalidate();
- }
-
- public void NotifyDataSetChanged ()
- {
- Invalidate();
- }
-
- public void OnPageScrollStateChanged (int state)
- {
- mScrollState = state;
-
- if (mListener != null) {
- mListener.OnPageScrollStateChanged(state);
- }
- }
-
- public void OnPageScrolled (int position, float positionOffset, int positionOffsetPixels)
- {
- mCurrentPage = position;
- mCurrentOffset = positionOffsetPixels;
- UpdatePageSize();
- Invalidate();
-
- if (mListener != null) {
- mListener.OnPageScrolled(position, positionOffset, positionOffsetPixels);
- }
- }
-
- public void OnPageSelected (int position)
- {
- if (mSnap || mScrollState == ViewPager.ScrollStateIdle) {
- mCurrentPage = position;
- mSnapPage = position;
- Invalidate();
- }
-
- if (mListener != null) {
- mListener.OnPageSelected(position);
- }
- }
-
- public void SetOnPageChangeListener (ViewPager.IOnPageChangeListener listener)
- {
- mListener = listener;
- }
-
- protected override void OnMeasure (int widthMeasureSpec, int heightMeasureSpec)
- {
- if (mOrientation == HORIZONTAL) {
- SetMeasuredDimension(MeasureLong(widthMeasureSpec), MeasureShort(heightMeasureSpec));
- } else {
- SetMeasuredDimension(MeasureShort(widthMeasureSpec), MeasureLong(heightMeasureSpec));
- }
- }
-
- /**
- * Determines the width of this view
- *
- * @param measureSpec
- * A measureSpec packed into an int
- * @return The width of the view, honoring constraints from measureSpec
- */
- private int MeasureLong(int measureSpec) {
- int result = 0;
- var specMode = MeasureSpec.GetMode(measureSpec);
- var specSize = MeasureSpec.GetSize(measureSpec);
-
- if ((specMode == MeasureSpecMode.Exactly) || (mViewPager == null)) {
- //We were told how big to be
- result = specSize;
- } else {
- //Calculate the width according the views count
- int count = mViewPager.Adapter.Count;
- result = (int)(PaddingLeft + PaddingRight
- + (count * 2 * mRadius) + (count - 1) * mRadius + 1);
- //Respect AT_MOST value if that was what is called for by measureSpec
- if (specMode == MeasureSpecMode.AtMost) {
- result = Java.Lang.Math.Min(result, specSize);
- }
- }
- return result;
- }
-
- /**
- * Determines the height of this view
- *
- * @param measureSpec
- * A measureSpec packed into an int
- * @return The height of the view, honoring constraints from measureSpec
- */
- private int MeasureShort(int measureSpec) {
- int result = 0;
- var specMode = MeasureSpec.GetMode(measureSpec);
- var specSize = MeasureSpec.GetSize(measureSpec);
-
- if (specMode == MeasureSpecMode.Exactly) {
- //We were told how big to be
- result = specSize;
- } else {
- //Measure the height
- result = (int)(2 * mRadius + PaddingTop + PaddingBottom + 1);
- //Respect AT_MOST value if that was what is called for by measureSpec
- if (specMode == MeasureSpecMode.AtMost) {
- result = Java.Lang.Math.Min(result, specSize);
- }
- }
- return result;
- }
-
- protected override void OnRestoreInstanceState (IParcelable state)
- {
-
- try
- {
- SavedState savedState = (SavedState)state;
- base.OnRestoreInstanceState(savedState.SuperState);
- mCurrentPage = savedState.CurrentPage;
- mSnapPage = savedState.CurrentPage;
- }
- catch
- {
- base.OnRestoreInstanceState(state);
- // Ignore, this needs to support IParcelable...
- }
- RequestLayout();
- }
-
-// protected override IParcelable OnSaveInstanceState ()
-// {
-// Parcelable superState = super.onSaveInstanceState();
-// SavedState savedState = new SavedState(superState);
-// savedState.currentPage = mCurrentPage;
-// return savedState;
-// }
-
- public class SavedState : BaseSavedState {
- public int CurrentPage {get; set;}
-
- public SavedState(IParcelable superState) : base(superState)
- {
- }
-
- private SavedState(Parcel parcel) : base(parcel)
- {
- CurrentPage = parcel.ReadInt();
- }
-
- public override void WriteToParcel (Parcel dest, int flags)
- {
- base.WriteToParcel(dest, flags);
- dest.WriteInt(CurrentPage);
- }
-
- // NO idea how to conver this to C#
-
-// public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() {
-// @Override
-// public SavedState createFromParcel(Parcel in) {
-// return new SavedState(in);
-// }
-//
-// @Override
-// public SavedState[] newArray(int size) {
-// return new SavedState[size];
-// }
-// };
- }
-
- }
-}
-
View
57 ViewPagerIndicator/ViewPagerIndicator/Library/PageIndicator.cs
@@ -1,57 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Android.App;
-using Android.Content;
-using Android.OS;
-using Android.Runtime;
-using Android.Views;
-using Android.Widget;
-using Android.Support.V4.View;
-
-namespace ViewPagerIndicator
-{
- public interface PageIndicator : ViewPager.IOnPageChangeListener
- {
- /**
- * Bind the indicator to a ViewPager.
- *
- * @param view
- */
- void SetViewPager(ViewPager view);
-
- /**
- * Bind the indicator to a ViewPager.
- *
- * @param view
- * @param initialPosition
- */
- void SetViewPager(ViewPager view, int initialPosition);
-
- /**
- * <p>Set the current page of both the ViewPager and indicator.</p>
- *
- * <p>This <strong>must</strong> be used if you need to set the page before
- * the views are drawn on screen (e.g., default start page).</p>
- *
- * @param item
- */
- void SetCurrentItem(int item);
-
- /**
- * Set a page change listener which will receive forwarded events.
- *
- * @param listener
- */
- void SetOnPageChangeListener(ViewPager.IOnPageChangeListener listener);
-
- /**
- * Notify the indicator that the fragment list has changed.
- */
- void NotifyDataSetChanged();
- }
-
-}
-
View
241 ViewPagerIndicator/ViewPagerIndicator/Library/TabPageIndicator.cs
@@ -1,241 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Android.App;
-using Android.Content;
-using Android.OS;
-using Android.Runtime;
-using Android.Views;
-using Android.Widget;
-using Android.Support.V4.View;
-using Java.Lang;
-using Android.Util;
-
-namespace ViewPagerIndicator
-{
- class TabPageIndicator : HorizontalScrollView, PageIndicator
- {
- private LinearLayout mTabLayout;
- private ViewPager mViewPager;
- private ViewPager.IOnPageChangeListener mListener;
-
- private LayoutInflater mInflater;
-
- int mMaxTabWidth;
- private int mSelectedTabIndex;
-
- public TabPageIndicator(Context context) : base(context, null)
- {
- }
-
- public TabPageIndicator(Context context, IAttributeSet attrs) : base(context, attrs)
- {
- HorizontalScrollBarEnabled = false;
-
- mInflater = LayoutInflater.From(context);
-
- mTabLayout = new LinearLayout(Context);
- AddView(mTabLayout, new ViewGroup.LayoutParams (ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.FillParent));
- }
-
- protected override void OnMeasure (int widthMeasureSpec, int heightMeasureSpec)
- {
- var widthMode = MeasureSpec.GetMode(widthMeasureSpec);
- var lockedExpanded = widthMode == MeasureSpecMode.Exactly;
- FillViewport = lockedExpanded;
-
- int childCount = mTabLayout.ChildCount;
- if (childCount > 1 && (widthMode == MeasureSpecMode.Exactly || widthMode == MeasureSpecMode.AtMost)) {
- if (childCount > 2) {
- mMaxTabWidth = (int)(MeasureSpec.GetSize(widthMeasureSpec) * 0.4f);
- } else {
- mMaxTabWidth = MeasureSpec.GetSize(widthMeasureSpec) / 2;
- }
- } else {
- mMaxTabWidth = -1;
- }
-
- int oldWidth = MeasuredWidth;
- base.OnMeasure(widthMeasureSpec, heightMeasureSpec);
- int newWidth = MeasuredWidth;
-
- if (lockedExpanded && oldWidth != newWidth) {
- // Recenter the tab display if we're at a new (scrollable) size.
- SetCurrentItem(mSelectedTabIndex);
- }
- }
-
- private void AnimateToTab(int position) {
- var tabView = mTabLayout.GetChildAt(position);
-
- // Do we not have any call backs because we're handling this with Post?
- /*if (mTabSelector != null) {
- RemoveCallbacks(mTabSelector);
- }*/
-
- Post(() => {
- var scrollPos = tabView.Left - (Width - tabView.Width) / 2;
- SmoothScrollTo(scrollPos, 0);
- });
- }
-
-
-
- public void SetCurrentItem (int item)
- {
- if (mViewPager == null) {
- throw new IllegalStateException("ViewPager has not been bound.");
- }
- mSelectedTabIndex = item;
- var tabCount = mTabLayout.ChildCount;
- for (int i = 0; i < tabCount; i++) {
- var child = mTabLayout.GetChildAt(i);
- var isSelected = (i == item);
- child.Selected = isSelected;
- if (isSelected) {
- AnimateToTab(item);
- }
- }
- }
-
- protected override void OnAttachedToWindow ()
- {
- base.OnAttachedToWindow ();
-
- Console.WriteLine ("OnAttachedToWindow");
- /*
- *
- * super.onAttachedToWindow();
- if (mTabSelector != null) {
- // Re-post the selector we saved
- post(mTabSelector);
- }
-*/
- }
-
- protected override void OnDetachedFromWindow ()
- {
- base.OnDetachedFromWindow ();
-
- Console.WriteLine ("OnDetachedFromWindow...");
-// super.onDetachedFromWindow();
-// if (mTabSelector != null) {
-// removeCallbacks(mTabSelector);
-// }
- }
-
- private void AddTab(string text, int index) {
- //Workaround for not being able to pass a defStyle on pre-3.0
- var tabView = (TabView)mInflater.Inflate(Resource.Layout.vpi__tab, null);
- tabView.Init(this, text, index);
- tabView.Focusable = true;
- tabView.Click += delegate(object sender, EventArgs e) {
- var tView = (TabView) sender;
-
- mViewPager.CurrentItem = tView.GetIndex();
- };
-
- mTabLayout.AddView(tabView, new LinearLayout.LayoutParams(0, LayoutParams.FillParent, 1));
- }
-
- public void OnPageScrollStateChanged (int p0)
- {
- if (mListener != null) {
- mListener.OnPageScrollStateChanged(p0);
- }
- }
-
- public void OnPageScrolled (int p0, float p1, int p2)
- {
- if (mListener != null) {
- mListener.OnPageScrolled(p0, p1, p2);
- }
- }
-
- public void OnPageSelected (int p0)
- {
- SetCurrentItem(p0);
- if (mListener != null) {
- mListener.OnPageSelected(p0);
- }
- }
-
- public void SetViewPager (ViewPager view)
- {
- var adapter = view.Adapter;
- if (adapter == null) {
- throw new IllegalStateException("ViewPager does not have adapter instance.");
- }
- if (!(adapter is TitleProvider)) {
- throw new IllegalStateException("ViewPager adapter must implement TitleProvider to be used with TitlePageIndicator.");
- }
- mViewPager = view;
- view.SetOnPageChangeListener(this);
- NotifyDataSetChanged();
- }
-
- public void NotifyDataSetChanged() {
- mTabLayout.RemoveAllViews();
- TitleProvider adapter = (TitleProvider)mViewPager.Adapter;
- int count = ((PagerAdapter)adapter).Count;
- for (int i = 0; i < count; i++) {
- AddTab(adapter.GetTitle(i), i);
- }
- if (mSelectedTabIndex > count) {
- mSelectedTabIndex = count - 1;
- }
- SetCurrentItem(mSelectedTabIndex);
- RequestLayout();
- }
-
- public void SetViewPager (ViewPager view, int initialPosition)
- {
- SetViewPager(view);
- SetCurrentItem(initialPosition);
- }
-
- public void SetOnPageChangeListener (ViewPager.IOnPageChangeListener listener)
- {
- mListener = listener;
- }
-
- public class TabView : LinearLayout
- {
- private TabPageIndicator mParent;
- private int mIndex;
-
- public TabView (Context context, IAttributeSet attrs) : base(context, attrs)
- {
- }
-
- public void Init(TabPageIndicator parent, string text, int index) {
- mParent = parent;
- mIndex = index;
-
- TextView textView = FindViewById<TextView>(Android.Resource.Id.Text1);
- textView.Text = text;
- }
-
-
- protected override void OnMeasure (int widthMeasureSpec, int heightMeasureSpec)
- {
- base.OnMeasure (widthMeasureSpec, heightMeasureSpec);
-
- // Re-measure if we went beyond our maximum size.
- if (mParent.mMaxTabWidth > 0 && MeasuredWidth > mParent.mMaxTabWidth) {
- base.OnMeasure(MeasureSpec.MakeMeasureSpec(mParent.mMaxTabWidth, MeasureSpecMode.Exactly), heightMeasureSpec);
- }
-
- }
-
- public int GetIndex() {
- return mIndex;
- }
- }
-
-
- }
-}
-
View
762 ViewPagerIndicator/ViewPagerIndicator/Library/TitlePageIndicator.cs
@@ -1,762 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Android.App;
-using Android.Content;
-using Android.OS;
-using Android.Runtime;
-using Android.Views;
-using Android.Widget;
-using Android.Graphics;
-using Android.Support.V4.View;
-using Android.Util;
-using Java.Lang;
-
-namespace ViewPagerIndicator
-{
- public enum IndicatorStyle {
- None = 0,
- Triangle = 1,
- Underline = 2
- }
-
- public class TitlePageIndicator : View, PageIndicator
- {
- /**
- * Percentage indicating what percentage of the screen width away from
- * center should the underline be fully faded. A value of 0.25 means that
- * halfway between the center of the screen and an edge.
- */
- const float SELECTION_FADE_PERCENTAGE = 0.25f;
-
- /**
- * Percentage indicating what percentage of the screen width away from
- * center should the selected text bold turn off. A value of 0.05 means
- * that 10% between the center and an edge.
- */
- const float BOLD_FADE_PERCENTAGE = 0.05f;
-
- /**
- * Interface for a callback when the center item has been clicked.
- */
- public interface OnCenterItemClickListener
- {
- /**
- * Callback when the center item has been clicked.
- *
- * @param position Position of the current center item.
- */
- void OnCenterItemClick(int position);
- }
-
- private ViewPager mViewPager;
- private ViewPager.IOnPageChangeListener mListener;
- private TitleProvider mTitleProvider;
- private int mCurrentPage;
- private int mCurrentOffset;
- private int mScrollState;
- private Paint mPaintText = new Paint();
- private bool mBoldText;
- private int mColorText;
- private int mColorSelected;
- private Path mPath;
- private Paint mPaintFooterLine = new Paint();
- private IndicatorStyle mFooterIndicatorStyle;
- private Paint mPaintFooterIndicator = new Paint();
- private float mFooterIndicatorHeight;
- private float mFooterIndicatorUnderlinePadding;
- private float mFooterPadding;
- private float mTitlePadding;
- private float mTopPadding;
- /** Left and right side padding for not active view titles. */
- private float mClipPadding;
- private float mFooterLineHeight;
-
- private const int INVALID_POINTER = -1;
-
- private int mTouchSlop;
- private float mLastMotionX = -1;
- private int mActivePointerId = INVALID_POINTER;
- private bool mIsDragging;
-
- private OnCenterItemClickListener mCenterItemClickListener;
-
-
- public TitlePageIndicator(Context context) : this(context, null)
- {
- }
-
- public TitlePageIndicator(Context context, IAttributeSet attrs) : this (context, attrs, Resource.Attribute.vpiTitlePageIndicatorStyle)
- {
- }
-
- public TitlePageIndicator(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
- {
- //Load defaults from resources
- var res = Resources;
- int defaultFooterColor = res.GetColor(Resource.Color.default_title_indicator_footer_color);
- float defaultFooterLineHeight = res.GetDimension(Resource.Dimension.default_title_indicator_footer_line_height);
- int defaultFooterIndicatorStyle = res.GetInteger(Resource.Integer.default_title_indicator_footer_indicator_style);
- float defaultFooterIndicatorHeight = res.GetDimension(Resource.Dimension.default_title_indicator_footer_indicator_height);
- float defaultFooterIndicatorUnderlinePadding = res.GetDimension(Resource.Dimension.default_title_indicator_footer_indicator_underline_padding);
- float defaultFooterPadding = res.GetDimension(Resource.Dimension.default_title_indicator_footer_padding);
- int defaultSelectedColor = res.GetColor(Resource.Color.default_title_indicator_selected_color);
- bool defaultSelectedBold = res.GetBoolean(Resource.Boolean.default_title_indicator_selected_bold);
- int defaultTextColor = res.GetColor(Resource.Color.default_title_indicator_text_color);
- float defaultTextSize = res.GetDimension(Resource.Dimension.default_title_indicator_text_size);
- float defaultTitlePadding = res.GetDimension(Resource.Dimension.default_title_indicator_title_padding);
- float defaultClipPadding = res.GetDimension(Resource.Dimension.default_title_indicator_clip_padding);
- float defaultTopPadding = res.GetDimension(Resource.Dimension.default_title_indicator_top_padding);
-
- //Retrieve styles attributes
- var a = context.ObtainStyledAttributes(attrs, Resource.Styleable.TitlePageIndicator, defStyle, Resource.Style.Widget_TitlePageIndicator);
-
- //Retrieve the colors to be used for this view and apply them.
- mFooterLineHeight = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerLineHeight, defaultFooterLineHeight);
- mFooterIndicatorStyle = (IndicatorStyle) a.GetInteger(Resource.Styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle);
- mFooterIndicatorHeight = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerIndicatorHeight, defaultFooterIndicatorHeight);
- mFooterIndicatorUnderlinePadding = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, defaultFooterIndicatorUnderlinePadding);
- mFooterPadding = a.GetDimension(Resource.Styleable.TitlePageIndicator_footerPadding, defaultFooterPadding);
- mTopPadding = a.GetDimension(Resource.Styleable.TitlePageIndicator_topPadding, defaultTopPadding);
- mTitlePadding = a.GetDimension(Resource.Styleable.TitlePageIndicator_titlePadding, defaultTitlePadding);
- mClipPadding = a.GetDimension(Resource.Styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
- mColorSelected = a.GetColor(Resource.Styleable.TitlePageIndicator_selectedColor, defaultSelectedColor);
- mColorText = a.GetColor(Resource.Styleable.TitlePageIndicator_textColor, defaultTextColor);
- mBoldText = a.GetBoolean(Resource.Styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);
-
- float textSize = a.GetDimension(Resource.Styleable.TitlePageIndicator_textSize, defaultTextSize);
- int footerColor = a.GetColor(Resource.Styleable.TitlePageIndicator_footerColor, defaultFooterColor);
- mPaintText.TextSize = textSize;
- mPaintText.AntiAlias = true;
- mPaintFooterLine.SetStyle(Android.Graphics.Paint.Style.FillAndStroke);
- mPaintFooterLine.StrokeWidth = mFooterLineHeight;
- mPaintFooterLine.Color = footerColor;
- mPaintFooterIndicator.SetStyle(Android.Graphics.Paint.Style.FillAndStroke);
- mPaintFooterIndicator.Color = footerColor;
-
- a.Recycle();
-
- var configuration = ViewConfiguration.Get(context);
- mTouchSlop = ViewConfigurationCompat.GetScaledPagingTouchSlop(configuration);
-
- }
-
- public int GetFooterColor() {
- return mPaintFooterLine.Color;
- }
-
- public void SetFooterColor(int footerColor) {
- mPaintFooterLine.Color = footerColor;
- mPaintFooterIndicator.Color = footerColor;
- Invalidate();
- }
-
- public float GetFooterLineHeight() {
- return mFooterLineHeight;
- }
-
- public void SetFooterLineHeight(float footerLineHeight) {
- mFooterLineHeight = footerLineHeight;
- mPaintFooterLine.StrokeWidth = mFooterLineHeight;
- Invalidate();
- }
-
- public float GetFooterIndicatorHeight() {
- return mFooterIndicatorHeight;
- }
-
- public void SetFooterIndicatorHeight(float footerTriangleHeight) {
- mFooterIndicatorHeight = footerTriangleHeight;
- Invalidate();
- }
-
- public float GetFooterIndicatorPadding() {
- return mFooterPadding;
- }
-
- public void SetFooterIndicatorPadding(float footerIndicatorPadding) {
- mFooterPadding = footerIndicatorPadding;
- Invalidate();
- }
-
- public IndicatorStyle GetFooterIndicatorStyle() {
- return mFooterIndicatorStyle;
- }
-
- public void SetFooterIndicatorStyle(IndicatorStyle indicatorStyle) {
- mFooterIndicatorStyle = indicatorStyle;
- Invalidate();
- }
-
- public int GetSelectedColor() {
- return mColorSelected;
- }
-
- public void SetSelectedColor(int selectedColor) {
- mColorSelected = selectedColor;
- Invalidate();
- }
-
- public bool IsSelectedBold() {
- return mBoldText;
- }
-
- public void SetSelectedBold(bool selectedBold) {
- mBoldText = selectedBold;
- Invalidate();
- }
-
- public int GetTextColor() {
- return mColorText;
- }
-
- public void SetTextColor(int textColor) {
- mPaintText.Color = textColor;
- mColorText = textColor;
- Invalidate();
- }
-
- public float GetTextSize() {
- return mPaintText.TextSize;
- }
-
- public void SetTextSize(float textSize) {
- mPaintText.TextSize = textSize;
- Invalidate();
- }
-
- public float GetTitlePadding() {
- return this.mTitlePadding;
- }
-
- public void SetTitlePadding(float titlePadding) {
- mTitlePadding = titlePadding;
- Invalidate();
- }
-
- public float GetTopPadding() {
- return this.mTopPadding;
- }
-
- public void SetTopPadding(float topPadding) {
- mTopPadding = topPadding;
- Invalidate();
- }
-
- public float GetClipPadding() {
- return this.mClipPadding;
- }
-
- public void SetClipPadding(float clipPadding) {
- mClipPadding = clipPadding;
- Invalidate();
- }
-
- public void SetTypeface(Typeface typeface) {
- mPaintText.SetTypeface(typeface);
- Invalidate();
- }
-
- public Typeface GetTypeface() {
- return mPaintText.Typeface;
- }
-
- protected override void OnDraw (Canvas canvas)
- {
- base.OnDraw (canvas);
-
- if (mViewPager == null) {
- return;
- }
- int count = mViewPager.Adapter.Count;
- if (count == 0) {
- return;
- }
-
- //Calculate views bounds
- var bounds = CalculateAllBounds(mPaintText);
- int boundsSize = bounds.Count;
-
- //Make sure we're on a page that still exists
- if (mCurrentPage >= boundsSize) {
- SetCurrentItem(boundsSize - 1);
- return;
- }
-
- int countMinusOne = count - 1;
- float halfWidth = Width / 2f;
- int left = Left;
- float leftClip = left + mClipPadding;
- int width = Width;
- int height = Height;
- int right = left + width;
- float rightClip = right - mClipPadding;
-
- int page = mCurrentPage;
- float offsetPercent;
- if (mCurrentOffset <= halfWidth) {
- offsetPercent = 1.0f * mCurrentOffset / width;
- } else {
- page += 1;
- offsetPercent = 1.0f * (width - mCurrentOffset) / width;
- }
- bool currentSelected = (offsetPercent <= SELECTION_FADE_PERCENTAGE);
- bool currentBold = (offsetPercent <= BOLD_FADE_PERCENTAGE);
- float selectedPercent = (SELECTION_FADE_PERCENTAGE - offsetPercent) / SELECTION_FADE_PERCENTAGE;
-
- //Verify if the current view must be clipped to the screen
- RectF curPageBound = bounds[mCurrentPage];
- float curPageWidth = curPageBound.Right - curPageBound.Left;
- if (curPageBound.Left < leftClip) {
- //Try to clip to the screen (left side)
- ClipViewOnTheLeft(curPageBound, curPageWidth, left);
- }
- if (curPageBound.Right > rightClip) {
- //Try to clip to the screen (right side)
- ClipViewOnTheRight(curPageBound, curPageWidth, right);
- }
-
- //Left views starting from the current position
- if (mCurrentPage > 0) {
- for (int i = mCurrentPage - 1; i >= 0; i--) {
- RectF bound = bounds[i];
- //Is left side is outside the screen
- if (bound.Left < leftClip) {
- float w = bound.Right - bound.Left;
- //Try to clip to the screen (left side)
- ClipViewOnTheLeft(bound, w, left);
- //Except if there's an intersection with the right view
- RectF rightBound = bounds[i + 1];
- //Intersection
- if (bound.Right + mTitlePadding > rightBound.Left) {
- bound.Left = rightBound.Left - w - mTitlePadding;
- bound.Right = bound.Left + w;
- }
- }
- }
- }
- //Right views starting from the current position
- if (mCurrentPage < countMinusOne) {
- for (int i = mCurrentPage + 1 ; i < count; i++) {
- RectF bound = bounds[i];
- //If right side is outside the screen
- if (bound.Right > rightClip) {
- float w = bound.Right - bound.Left;
- //Try to clip to the screen (right side)
- ClipViewOnTheRight(bound, w, right);
- //Except if there's an intersection with the left view
- RectF leftBound = bounds[i - 1];
- //Intersection
- if (bound.Left - mTitlePadding < leftBound.Right) {
- bound.Left = leftBound.Right + mTitlePadding;
- bound.Right = bound.Left + w;
- }
- }
- }
- }
-
- //Now draw views
- //int colorTextAlpha = mColorText >>> 24;
- int colorTextAlpha = mColorText >> 24;
- for (int i = 0; i < count; i++) {
- //Get the title
- RectF bound = bounds[i];
- //Only if one side is visible
- if ((bound.Left > left && bound.Left < right) || (bound.Right > left && bound.Right < right)) {
- bool currentPage = (i == page);
- //Only set bold if we are within bounds
- mPaintText.FakeBoldText = (currentPage && currentBold && mBoldText);
-
- //Draw text as unselected
- mPaintText.Color = (mColorText);
- if(currentPage && currentSelected) {
- //Fade out/in unselected text as the selected text fades in/out
- mPaintText.Alpha = (colorTextAlpha - (int)(colorTextAlpha * selectedPercent));
- }
- canvas.DrawText(mTitleProvider.GetTitle(i), bound.Left, bound.Bottom + mTopPadding, mPaintText);
-
- //If we are within the selected bounds draw the selected text
- if (currentPage && currentSelected) {
- mPaintText.Color = mColorSelected;
- mPaintText.Alpha = ((int)((mColorSelected >> 24) * selectedPercent));
- canvas.DrawText(mTitleProvider.GetTitle(i), bound.Left, bound.Bottom + mTopPadding, mPaintText);
- }
- }
- }
-
- //Draw the footer line
- mPath = new Path();
- mPath.MoveTo(0, height - mFooterLineHeight / 2f);
- mPath.LineTo(width, height - mFooterLineHeight / 2f);
- mPath.Close();
- canvas.DrawPath(mPath, mPaintFooterLine);
-
- switch (mFooterIndicatorStyle) {
- case IndicatorStyle.Triangle:
- mPath = new Path();
- mPath.MoveTo(halfWidth, height - mFooterLineHeight - mFooterIndicatorHeight);
- mPath.LineTo(halfWidth + mFooterIndicatorHeight, height - mFooterLineHeight);
- mPath.LineTo(halfWidth - mFooterIndicatorHeight, height - mFooterLineHeight);
- mPath.Close();
- canvas.DrawPath(mPath, mPaintFooterIndicator);
- break;
-
- case IndicatorStyle.Underline:
- if (!currentSelected || page >= boundsSize) {
- break;
- }
-
- RectF underlineBounds = bounds[page];
- mPath = new Path();
- mPath.MoveTo(underlineBounds.Left - mFooterIndicatorUnderlinePadding, height - mFooterLineHeight);
- mPath.LineTo(underlineBounds.Right + mFooterIndicatorUnderlinePadding, height - mFooterLineHeight);
- mPath.LineTo(underlineBounds.Right + mFooterIndicatorUnderlinePadding, height - mFooterLineHeight - mFooterIndicatorHeight);
- mPath.LineTo(underlineBounds.Left - mFooterIndicatorUnderlinePadding, height - mFooterLineHeight - mFooterIndicatorHeight);
- mPath.Close();
-
- mPaintFooterIndicator.Alpha = ((int)(0xFF * selectedPercent));
- canvas.DrawPath(mPath, mPaintFooterIndicator);
- mPaintFooterIndicator.Alpha = (0xFF);
- break;
- }
- }
-
- public override bool OnTouchEvent(MotionEvent ev) {
-
- if(base.OnTouchEvent(ev))
- {
- return true;
- }
- if ((mViewPager == null) || (mViewPager.Adapter.Count == 0)) {
- return false;
- }
-
- var action = ev.Action;
-
- switch ((int) action & MotionEventCompat.ActionMask) {
- case (int) MotionEventActions.Down:
- mActivePointerId = MotionEventCompat.GetPointerId(ev, 0);
- mLastMotionX = ev.GetX();
- break;
-
- case (int)MotionEventActions.Move: {
- int activePointerIndex = MotionEventCompat.FindPointerIndex(ev, mActivePointerId);
- float x = MotionEventCompat.GetX(ev, activePointerIndex);
- float deltaX = x - mLastMotionX;
-
- if (!mIsDragging) {
- if (Java.Lang.Math.Abs(deltaX) > mTouchSlop) {
- mIsDragging = true;
- }
- }
-
- if (mIsDragging) {
- if (!mViewPager.IsFakeDragging) {
- mViewPager.BeginFakeDrag();
- }
-
- mLastMotionX = x;
-
- mViewPager.FakeDragBy(deltaX);
- }
-
- break;
- }
-
- case (int)MotionEventActions.Cancel:
- case (int)MotionEventActions.Up:
- if (!mIsDragging) {
- int count = mViewPager.Adapter.Count;
- int width = Width;
- float halfWidth = width / 2f;
- float sixthWidth = width / 6f;
- float leftThird = halfWidth - sixthWidth;
- float rightThird = halfWidth + sixthWidth;
- float eventX = ev.GetX();
-
- if (eventX < leftThird) {
- if (mCurrentPage > 0) {
- mViewPager.CurrentItem = mCurrentPage - 1;
- return true;
- }
- } else if (eventX > rightThird) {
- if (mCurrentPage < count - 1) {
- mViewPager.CurrentItem = mCurrentPage + 1;
- return true;
- }
- } else {
- //Middle third
- if (mCenterItemClickListener != null) {
- mCenterItemClickListener.OnCenterItemClick(mCurrentPage);
- }
- }
- }
-
-
- mIsDragging = false;
- mActivePointerId = INVALID_POINTER;
- if (mViewPager.IsFakeDragging) mViewPager.EndFakeDrag();
- break;
-
- case MotionEventCompat.ActionPointerDown: {
- int index = MotionEventCompat.GetActionIndex(ev);
- float x = MotionEventCompat.GetX(ev, index);
- mLastMotionX = x;
- mActivePointerId = MotionEventCompat.GetPointerId(ev, index);
- break;
- }
-
- case MotionEventCompat.ActionPointerUp:
- int pointerIndex = MotionEventCompat.GetActionIndex(ev);
- int pointerId = MotionEventCompat.GetPointerId(ev, pointerIndex);
- if (pointerId == mActivePointerId) {
- int newPointerIndex = pointerIndex == 0 ? 1 : 0;
- mActivePointerId = MotionEventCompat.GetPointerId(ev, newPointerIndex);
- }
- mLastMotionX = MotionEventCompat.GetX(ev, MotionEventCompat.FindPointerIndex(ev, mActivePointerId));
- break;
- }
-
- return true;
- }
-
- /**
- * Set bounds for the right textView including clip padding.
- *
- * @param curViewBound
- * current bounds.
- * @param curViewWidth
- * width of the view.
- */
- private void ClipViewOnTheRight(RectF curViewBound, float curViewWidth, int right) {
- curViewBound.Right = right - mClipPadding;
- curViewBound.Left = curViewBound.Right - curViewWidth;
- }
-
- /**
- * Set bounds for the left textView including clip padding.
- *
- * @param curViewBound
- * current bounds.
- * @param curViewWidth
- * width of the view.
- */
- private void ClipViewOnTheLeft(RectF curViewBound, float curViewWidth, int left) {
- curViewBound.Left = left + mClipPadding;
- curViewBound.Right = mClipPadding + curViewWidth;
- }
-
- /**
- * Calculate views bounds and scroll them according to the current index
- *
- * @param paint
- * @param currentIndex
- * @return
- */
- private List<RectF> CalculateAllBounds(Paint paint) {
- var list = new List<RectF>();
- //For each views (If no values then add a fake one)
- int count = mViewPager.Adapter.Count;
- int width = Width;
- int halfWidth = width / 2;
-
- for (int i = 0; i < count; i++) {
- RectF bounds = CalcBounds(i, paint);
- float w = (bounds.Right - bounds.Left);
- float h = (bounds.Bottom - bounds.Top);
- bounds.Left = (halfWidth) - (w / 2) - mCurrentOffset + ((i - mCurrentPage) * width);
- bounds.Right = bounds.Left + w;
- bounds.Top = 0;
- bounds.Bottom = h;
- list.Add(bounds);
- }
-
- return list;
- }
-
- /**
- * Calculate the bounds for a view's title
- *
- * @param index
- * @param paint
- * @return
- */
- private RectF CalcBounds(int index, Paint paint) {
- //Calculate the text bounds
- RectF bounds = new RectF();
- bounds.Right = paint.MeasureText(mTitleProvider.GetTitle(index));
- bounds.Bottom = paint.Descent() - paint.Ascent();
- return bounds;
- }
-
- public void SetViewPager (ViewPager view)
- {
- var adapter = view.Adapter;
- if (adapter == null) {
- throw new IllegalStateException("ViewPager does not have adapter instance.");
- }
- if (!(adapter is TitleProvider)) {
- throw new IllegalStateException("ViewPager adapter must implement TitleProvider to be used with TitlePageIndicator.");
- }
- mViewPager = view;
- mViewPager.SetOnPageChangeListener(this);
- mTitleProvider = (TitleProvider)adapter;
- Invalidate();
- }
-
- public void SetViewPager (ViewPager view, int initialPosition)
- {
- SetViewPager(view);
- SetCurrentItem(initialPosition);
- }
-
- public void NotifyDataSetChanged ()
- {
- Invalidate();
- }
-
- /**
- * Set a callback listener for the center item click.
- *
- * @param listener Callback instance.
- */
- public void SetOnCenterItemClickListener(OnCenterItemClickListener listener) {
- mCenterItemClickListener = listener;
- }
-
- public void SetCurrentItem (int item)
- {
- if (mViewPager == null) {
- throw new IllegalStateException("ViewPager has not been bound.");
- }
- mViewPager.CurrentItem = item;
- mCurrentPage = item;
- Invalidate();
- }
-
-
-
- public void OnPageScrollStateChanged (int state)
- {
- mScrollState = state;
-
- if (mListener != null) {
- mListener.OnPageScrollStateChanged(state);
- }
- }
-
- public void OnPageScrolled (int position, float positionOffset, int positionOffsetPixels)
- {
- mCurrentPage = position;
- mCurrentOffset = positionOffsetPixels;
- Invalidate();
-
- if (mListener != null) {
- mListener.OnPageScrolled(position, positionOffset, positionOffsetPixels);
- }
- }
-
- public void OnPageSelected (int position)
- {
- if (mScrollState == ViewPager.ScrollStateIdle) {
- mCurrentPage = position;
- Invalidate();
- }
-
- if (mListener != null) {
- mListener.OnPageSelected(position);
- }
- }
-
- public void SetOnPageChangeListener (ViewPager.IOnPageChangeListener listener)
- {
- mListener = listener;
- }
-
- protected override void OnMeasure (int widthMeasureSpec, int heightMeasureSpec)
- {
- //Measure our width in whatever mode specified
- int measuredWidth = MeasureSpec.GetSize(widthMeasureSpec);
-
- //Determine our height
- float height = 0;
- var heightSpecMode = MeasureSpec.GetMode(heightMeasureSpec);
- if (heightSpecMode == MeasureSpecMode.Exactly) {
- //We were told how big to be
- height = MeasureSpec.GetSize(heightMeasureSpec);
- } else {
- //Calculate the text bounds
- RectF bounds = new RectF();
- bounds.Bottom = mPaintText.Descent()-mPaintText.Ascent();
- height = bounds.Bottom - bounds.Top + mFooterLineHeight + mFooterPadding + mTopPadding;
- if (mFooterIndicatorStyle != IndicatorStyle.None) {
- height += mFooterIndicatorHeight;
- }
- }
- int measuredHeight = (int)height;
-
- SetMeasuredDimension(measuredWidth, measuredHeight);
- }
-
- protected override void OnRestoreInstanceState (IParcelable state)
- {
- try
- {
- SavedState savedState = (SavedState)state;
- base.OnRestoreInstanceState(savedState.SuperState);
- mCurrentPage = savedState.CurrentPage;
- }
- catch
- {
- base.OnRestoreInstanceState(state);
- // Ignore, this needs to support IParcelable...
- }
- RequestLayout();
- }
-
-// protected override IParcelable OnSaveInstanceState ()
-// {
-// Parcelable superState = super.onSaveInstanceState();
-// SavedState savedState = new SavedState(superState);
-// savedState.currentPage = mCurrentPage;
-// return savedState;
-// }
-
-
- public class SavedState : BaseSavedState {
- public int CurrentPage {get; set;}
-
- public SavedState(IParcelable superState) : base(superState)
- {
- }
-
- private SavedState(Parcel parcel) : base(parcel)
- {
- CurrentPage = parcel.ReadInt();
- }
-
- public override void WriteToParcel (Parcel dest, int flags)
- {
- base.WriteToParcel(dest, flags);
- dest.WriteInt(CurrentPage);
- }
-
- // Need an update to support Creator with Parcelable.
-
-// public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() {
-// @Override
-// public SavedState createFromParcel(Parcel in) {
-// return new SavedState(in);
-// }
-//
-// @Override
-// public SavedState[] newArray(int size) {
-// return new SavedState[size];
-// }
-// };
- }
- }
-}
-
View
28 ViewPagerIndicator/ViewPagerIndicator/Library/TitleProvider.cs
@@ -1,28 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Android.App;
-using Android.Content;
-using Android.OS;
-using Android.Runtime;
-using Android.Views;
-using Android.Widget;
-
-namespace ViewPagerIndicator
-{
- /**
- * A TitleProvider provides the title to display according to a view.
- */
- public interface TitleProvider
- {
- /**
- * Returns the title of the view at position
- * @param position
- * @return
- */
- String GetTitle(int position);
- }
-}
-
View
BIN ViewPagerIndicator/ViewPagerIndicator/Mono.Android.Compatibility.V4.dll
Binary file not shown.
View
6 ViewPagerIndicator/ViewPagerIndicator/Properties/AndroidManifest.xml
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="ViewPagerIndicator.ViewPagerIndicator">
- <application android:label="MfA ViewPager Indicator" android:icon="@drawable/icon">
- </application>
- <uses-sdk android:targetSdkVersion="14" android:minSdkVersion="4" />
-</manifest>
View
28 ViewPagerIndicator/ViewPagerIndicator/Properties/AssemblyInfo.cs
@@ -1,28 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using Android.App;
-
-// Information about this assembly is defined by the following attributes.
-// Change them to the values specific to your project.
-
-[assembly: AssemblyTitle("ViewPagerIndicator")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("chrishardy")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
-// The form "{Major}.{Minor}.*" will automatically update the build and revision,
-// and "{Major}.{Minor}.{Build}.*" will update just the revision.
-
-[assembly: AssemblyVersion("1.0.0")]
-
-// The following attributes are used to specify the signing key for the assembly,
-// if desired. See the Mono documentation for more information about signing.
-
-//[assembly: AssemblyDelaySign(false)]
-//[assembly: AssemblyKeyFile("")]
-
View
44 ViewPagerIndicator/ViewPagerIndicator/Resources/AboutResources.txt
@@ -1,44 +0,0 @@
-Images, layout descriptions, binary blobs and string dictionaries can be included
-in your application as resource files. Various Android APIs are designed to
-operate on the resource IDs instead of dealing with images, strings or binary blobs
-directly.
-
-For example, a sample Android app that contains a user interface layout (main.axml),
-an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
-would keep its resources in the "Resources" directory of the application:
-
-Resources/
- drawable/
- icon.png
-
- layout/
- main.axml
-
- values/
- strings.xml
-
-In order to get the build system to recognize Android resources, set the build action to
-"AndroidResource". The native Android APIs do not operate directly with filenames, but
-instead operate on resource IDs. When you compile an Android application that uses resources,
-the build system will package the resources for distribution and generate a class called "R"
-(this is an Android convention) that contains the tokens for each one of the resources
-included. For example, for the above Resources layout, this is what the R class would expose:
-
-public class R {
- public class drawable {
- public const int icon = 0x123;
- }
-
- public class layout {
- public const int main = 0x456;
- }
-
- public class strings {
- public const int first_string = 0xabc;
- public const int second_string = 0xbcd;
- }
-}
-
-You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
-to reference the layout/main.axml file, or R.strings.first_string to reference the first
-string in the dictionary file values/strings.xml.
View
24 ViewPagerIndicator/ViewPagerIndicator/Resources/color/vpi__dark_theme.xml
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_enabled="false" android:color="@color/vpi__bright_foreground_disabled_holo_dark"/>
- <item android:state_window_focused="false" android:color="@color/vpi__bright_foreground_holo_dark"/>
- <item android:state_pressed="true" android:color="@color/vpi__bright_foreground_holo_dark"/>
- <item android:state_selected="true" android:color="@color/vpi__bright_foreground_holo_dark"/>
- <!--item android:state_activated="true" android:color="@color/vpi__bright_foreground_holo_dark"/-->
- <item android:color="@color/vpi__bright_foreground_holo_dark"/> <!-- not selected -->
-</selector>
View
26 ViewPagerIndicator/ViewPagerIndicator/Resources/color/vpi__light_theme.xml
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_enabled="false" android:color="@color/vpi__bright_foreground_disabled_holo_light"/>
- <item android:state_window_focused="false" android:color="@color/vpi__bright_foreground_holo_light"/>
- <item android:state_pressed="true" android:color="@color/vpi__bright_foreground_holo_light"/>
- <item android:state_selected="true" android:color="@color/vpi__bright_foreground_holo_light"/>
- <!--item android:state_activated="true" android:color="@color/vpi__bright_foreground_holo_light"/-->
- <item android:color="@color/vpi__bright_foreground_holo_light"/> <!-- not selected -->
-
-</selector>
-
View
BIN ...erIndicator/ViewPagerIndicator/Resources/drawable-hdpi/custom_tab_indicator_focused.9.png
Deleted file not rendered
View
BIN ...rIndicator/ViewPagerIndicator/Resources/drawable-hdpi/custom_tab_indicator_selected.9.png
Deleted file not rendered
View
BIN ...or/ViewPagerIndicator/Resources/drawable-hdpi/custom_tab_indicator_selected_pressed.9.png
Deleted file not rendered
View
BIN ...ndicator/ViewPagerIndicator/Resources/drawable-hdpi/custom_tab_indicator_unselected.9.png
Deleted file not rendered
View
BIN