From 7aabe4ff6ae1fb3f3f29e73ec8d08a0ac5f0e40c Mon Sep 17 00:00:00 2001 From: EHila Date: Wed, 27 Jul 2016 18:49:51 -0400 Subject: [PATCH 1/3] Added feature to allow progress style Library object now needs to be instantiated setIsProgressStyle to control progress --- .gitignore | 1 + .idea/.name | 1 - .idea/compiler.xml | 22 --------- .idea/copyright/profiles_settings.xml | 3 -- .idea/encodings.xml | 6 --- .idea/gradle.xml | 26 ----------- .idea/misc.xml | 46 ------------------- .idea/modules.xml | 12 ----- .idea/runConfigurations.xml | 12 ----- .idea/vcs.xml | 6 --- .../MainActivity.java | 8 ++-- app/src/main/res/layout/activity_main.xml | 2 +- .../pagerindicatorbinder/IndicatorBinder.java | 38 +++++++++++---- 13 files changed, 37 insertions(+), 146 deletions(-) delete mode 100644 .idea/.name delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/copyright/profiles_settings.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/gradle.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/runConfigurations.xml delete mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index c6cbe56..f65954e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.iml .gradle +.idea/ /local.properties /.idea/workspace.xml /.idea/libraries diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index d256b34..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -IndicatorBinderExample \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 96cc43e..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 97626ba..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index 7ceadaf..0000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 5d19981..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 015bc70..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/java/com/avontell/pagerindicatorbinderexample/MainActivity.java b/app/src/main/java/com/avontell/pagerindicatorbinderexample/MainActivity.java index 01c8b77..cb44c0d 100644 --- a/app/src/main/java/com/avontell/pagerindicatorbinderexample/MainActivity.java +++ b/app/src/main/java/com/avontell/pagerindicatorbinderexample/MainActivity.java @@ -37,11 +37,13 @@ protected void onCreate(Bundle savedInstanceState) { int unselectedImage = R.drawable.indicator_unselected; // Bind the view pager to the indicatorContainer - IndicatorBinder.bind(this, + IndicatorBinder sample = new IndicatorBinder().bind(this, viewPager, indicatorContainer, selectedImage, unselectedImage); + // Set whether you want a progress style + sample.setProgressStyle(true); // EXAMPLE WITH TABS ----------------------------------------------------------------------- @@ -56,7 +58,7 @@ protected void onCreate(Bundle savedInstanceState) { tabViews.get(1).setText("Tab 2"); tabViews.get(2).setText("Tab 3"); tabViews.get(3).setText("Tab 4"); - tabViews.get(4).setText("Tab 6"); + tabViews.get(4).setText("Tab 5"); // Set the requested colors int selectedBackgroundColor = R.color.tabBackgroundSelected; @@ -67,7 +69,7 @@ protected void onCreate(Bundle savedInstanceState) { // Grab the LinearLayout LinearLayout tabContainer = (LinearLayout) findViewById(R.id.tab_container); - IndicatorBinder.bindTextTabs(this, + new IndicatorBinder().bindTextTabs(this, viewPager, tabContainer, tabViews, diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 70de161..1660d38 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -11,7 +11,7 @@ android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="30dp" - android:id="@+id/tab_container"> + android:id="@+id/tab_container"/> Date: Wed, 27 Jul 2016 19:36:06 -0400 Subject: [PATCH 2/3] Replaced depriated resource methods with ContextCompat --- .../pagerindicatorbinder/IndicatorBinder.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/indicatorbinder/src/main/java/com/avontell/pagerindicatorbinder/IndicatorBinder.java b/indicatorbinder/src/main/java/com/avontell/pagerindicatorbinder/IndicatorBinder.java index 3ba4d23..e970b76 100644 --- a/indicatorbinder/src/main/java/com/avontell/pagerindicatorbinder/IndicatorBinder.java +++ b/indicatorbinder/src/main/java/com/avontell/pagerindicatorbinder/IndicatorBinder.java @@ -5,6 +5,7 @@ import android.support.annotation.ColorRes; import android.support.annotation.DrawableRes; import android.support.annotation.NonNull; +import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.view.Gravity; import android.view.View; @@ -66,8 +67,8 @@ public IndicatorBinder bind(@NonNull final Context context, @DrawableRes final int indicatorOffResource) { // Load the indicator drawables - final Drawable selected = context.getResources().getDrawable(indicatorOnResource); - final Drawable unselected = context.getResources().getDrawable(indicatorOffResource); + final Drawable selected = ContextCompat.getDrawable(context, indicatorOnResource); + final Drawable unselected = ContextCompat.getDrawable(context, indicatorOffResource); // Load the container with indicators final int numItems = viewPager.getAdapter().getCount(); @@ -154,11 +155,11 @@ public IndicatorBinder bindTextTabs( // Set colors of the TextView if(i == viewPager.getCurrentItem()) { - tab.setBackgroundColor(context.getResources().getColor(backgroundSelectedColor)); - tab.setTextColor(context.getResources().getColor(textSelectedColor)); + tab.setBackgroundColor(ContextCompat.getColor(context, backgroundSelectedColor)); + tab.setTextColor(ContextCompat.getColor(context, textSelectedColor)); } else { - tab.setBackgroundColor(context.getResources().getColor(backgroundUnselectedColor)); - tab.setTextColor(context.getResources().getColor(textUnselectedColor)); + tab.setBackgroundColor(ContextCompat.getColor(context, backgroundUnselectedColor)); + tab.setTextColor(ContextCompat.getColor(context, textUnselectedColor)); } // Set Click Listeners of the tabs @@ -186,11 +187,11 @@ public void onPageSelected(int position) { for(int i = 0; i < tabViews.size(); i++){ TextView tab = (TextView) tabContainer.getChildAt(i); if(i == position) { - tab.setBackgroundColor(context.getResources().getColor(backgroundSelectedColor)); - tab.setTextColor(context.getResources().getColor(textSelectedColor)); + tab.setBackgroundColor(ContextCompat.getColor(context, backgroundSelectedColor)); + tab.setTextColor(ContextCompat.getColor(context, textSelectedColor)); } else { - tab.setBackgroundColor(context.getResources().getColor(backgroundUnselectedColor)); - tab.setTextColor(context.getResources().getColor(textUnselectedColor)); + tab.setBackgroundColor(ContextCompat.getColor(context, backgroundUnselectedColor)); + tab.setTextColor(ContextCompat.getColor(context, textUnselectedColor)); } } } From 0e4413dff4799d43ce358b1eecb6246d1e2249bc Mon Sep 17 00:00:00 2001 From: vontell Date: Wed, 27 Jul 2016 21:15:16 -0400 Subject: [PATCH 3/3] Added example of default indicators --- .../MainActivity.java | 16 ++++++++++++++++ app/src/main/res/layout/activity_main.xml | 18 +++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/avontell/pagerindicatorbinderexample/MainActivity.java b/app/src/main/java/com/avontell/pagerindicatorbinderexample/MainActivity.java index cb44c0d..f4211c7 100644 --- a/app/src/main/java/com/avontell/pagerindicatorbinderexample/MainActivity.java +++ b/app/src/main/java/com/avontell/pagerindicatorbinderexample/MainActivity.java @@ -20,6 +20,7 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_main); // EXAMPLE WITH BASIC DRAWABLE RESOURCES --------------------------------------------------- + // INCLUDES PROGRESS STYLE ----------------------------------------------------------------- // Grab the views ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager_one); @@ -42,9 +43,24 @@ protected void onCreate(Bundle savedInstanceState) { indicatorContainer, selectedImage, unselectedImage); + // Set whether you want a progress style sample.setProgressStyle(true); + // EXAMPLE WITHOUT PROGRESS STYLE ---------------------------------------------------------- + + LinearLayout indicatorContainerDefault = (LinearLayout) findViewById(R.id.indicator_default); + + // Bind the view pager to the indicatorContainer + IndicatorBinder defaultInd = new IndicatorBinder().bind(this, + viewPager, + indicatorContainerDefault, + selectedImage, + unselectedImage); + + // Set whether you want a progress style + defaultInd.setProgressStyle(false); + // EXAMPLE WITH TABS ----------------------------------------------------------------------- // Create each tab TextView diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 1660d38..47aa5af 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -27,13 +27,25 @@ android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="30dp" - android:layout_below="@+id/view_pager_one" - android:layout_centerHorizontal="true" android:layout_marginTop="8dp" android:gravity="center_horizontal" - android:id="@+id/indicator_cont"> + android:id="@+id/indicator_cont" + android:layout_below="@+id/indicator_default" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true"> + +