From 4b1bcf297ba114b4c690e6a1cb9f8f7f177e738d Mon Sep 17 00:00:00 2001
From: Marcus Terasa <m.terasa@neusta.de>
Date: Thu, 10 Mar 2016 10:54:24 +0100
Subject: [PATCH 01/11] Exposed methods to manually set the selected item

---
 .../java/com/roughike/swipeselector/SwipeAdapter.java     | 15 +++++++++++++++
 .../java/com/roughike/swipeselector/SwipeSelector.java    |  8 ++++++++
 2 files changed, 23 insertions(+)

diff --git a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
index f7a19a8..244ca98 100644
--- a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
+++ b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
@@ -281,6 +281,21 @@ protected SwipeItem getSelectedItem() {
         return mItems.get(mCurrentPosition);
     }
 
+    public void setSelectedItem(int position) {
+        if (position >= 0 && position < mItems.size()) {
+            mViewPager.setCurrentItem(position, true);
+        }
+    }
+
+    public void setSelectedItem(SwipeItem item) {
+        for (int i = 0; i < mItems.size(); i++) {
+            if (mItems.get(i).equals(item)) {
+                mViewPager.setCurrentItem(i, true);
+                break;
+            }
+        }
+    }
+
     protected Bundle onSaveInstanceState() {
         Bundle bundle = new Bundle();
         bundle.putInt(STATE_CURRENT_POSITION, mCurrentPosition);
diff --git a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
index bc43b72..18e6d1a 100644
--- a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
+++ b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
@@ -187,4 +187,12 @@ protected void dispatchSaveInstanceState(SparseArray<Parcelable> container) {
     protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
         dispatchThawSelfOnly(container);
     }
+
+    public void setSelectedItem(int position) {
+        mAdapter.setSelectedItem(position);
+    }
+
+    public void setSelectedItem(SwipeItem item) {
+        mAdapter.setSelectedItem(item);
+    }
 }

From d63fe054d2a6c9744e4313891afebbe5cc12e8c3 Mon Sep 17 00:00:00 2001
From: Marcus Terasa <m.terasa@neusta.de>
Date: Thu, 10 Mar 2016 10:55:11 +0100
Subject: [PATCH 02/11] Hide the description label if description is null

---
 .../main/java/com/roughike/swipeselector/SwipeAdapter.java |  7 ++++++-
 .../src/main/res/layout/swipeselector_content_item.xml     | 14 +++++++++-----
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
index 244ca98..dc72015 100644
--- a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
+++ b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
@@ -318,7 +318,12 @@ public Object instantiateItem(ViewGroup container, int position) {
 
         SwipeItem slideItem = mItems.get(position);
         title.setText(slideItem.title);
-        description.setText(slideItem.description);
+        if (slideItem.description == null) {
+            description.setVisibility(View.GONE);
+        } else {
+            description.setVisibility(View.VISIBLE);
+            description.setText(slideItem.description);
+        }
 
         // We shouldn't get here if the typeface didn't exist.
         // But just in case, because we're paranoid.
diff --git a/swipe-selector/src/main/res/layout/swipeselector_content_item.xml b/swipe-selector/src/main/res/layout/swipeselector_content_item.xml
index 8acce52..1e4da67 100644
--- a/swipe-selector/src/main/res/layout/swipeselector_content_item.xml
+++ b/swipe-selector/src/main/res/layout/swipeselector_content_item.xml
@@ -1,23 +1,27 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
-    android:orientation="vertical"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:gravity="center_horizontal"
-    xmlns:android="http://schemas.android.com/apk/res/android">
+        android:orientation="vertical"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center"
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:tools="http://schemas.android.com/tools">
 
     <TextView
         android:id="@+id/swipeselector_content_title"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
+        tools:text="Title"
         android:textAppearance="@style/TextAppearance.AppCompat.Body2"/>
 
+
     <TextView
         android:id="@+id/swipeselector_content_description"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="center_horizontal"
         android:layout_marginTop="4dp"
+        tools:text="Description"
         android:textAppearance="@style/TextAppearance.AppCompat.Caption"/>
 
 </LinearLayout>
\ No newline at end of file

From 4dd7d1905088fe5a2dd76bf0406b122003628fdc Mon Sep 17 00:00:00 2001
From: Iiro <iiro.krankka@gmail.com>
Date: Thu, 10 Mar 2016 15:09:14 +0200
Subject: [PATCH 03/11] Added some space and removed
 setVisibility(View.VISIBLE), as the description is visible by default.

---
 .../src/main/java/com/roughike/swipeselector/SwipeAdapter.java          | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
index dc72015..7e5f40d 100644
--- a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
+++ b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
@@ -318,10 +318,10 @@ public Object instantiateItem(ViewGroup container, int position) {
 
         SwipeItem slideItem = mItems.get(position);
         title.setText(slideItem.title);
+
         if (slideItem.description == null) {
             description.setVisibility(View.GONE);
         } else {
-            description.setVisibility(View.VISIBLE);
             description.setText(slideItem.description);
         }
 

From c615f660c8b610268f08d266d9109a153dba8568 Mon Sep 17 00:00:00 2001
From: Iiro <iiro.krankka@gmail.com>
Date: Thu, 10 Mar 2016 15:12:19 +0200
Subject: [PATCH 04/11] Realized I made a horrible mistake, because as the
 views are reused, a description text that was previously invisible could stay
 that way when reusing that layout.

---
 .../src/main/java/com/roughike/swipeselector/SwipeAdapter.java           | 1 +
 1 file changed, 1 insertion(+)

diff --git a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
index 7e5f40d..984599e 100644
--- a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
+++ b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
@@ -322,6 +322,7 @@ public Object instantiateItem(ViewGroup container, int position) {
         if (slideItem.description == null) {
             description.setVisibility(View.GONE);
         } else {
+            description.setVisibility(View.VISIBLE);
             description.setText(slideItem.description);
         }
 

From aa49b9c7f76cb800ad24fba3e0ab33a201ee49a2 Mon Sep 17 00:00:00 2001
From: Iiro <iiro.krankka@gmail.com>
Date: Thu, 10 Mar 2016 15:15:44 +0200
Subject: [PATCH 05/11] Added choice for setting the items with or without
 animation.

---
 .../src/main/java/com/roughike/swipeselector/SwipeAdapter.java      | 4 ++--
 .../src/main/java/com/roughike/swipeselector/SwipeSelector.java     | 6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
index 984599e..393422e 100644
--- a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
+++ b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
@@ -281,9 +281,9 @@ protected SwipeItem getSelectedItem() {
         return mItems.get(mCurrentPosition);
     }
 
-    public void setSelectedItem(int position) {
+    public void setSelectedItem(int position, boolean animate) {
         if (position >= 0 && position < mItems.size()) {
-            mViewPager.setCurrentItem(position, true);
+            mViewPager.setCurrentItem(position, animate);
         }
     }
 
diff --git a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
index e81a609..1d82128 100644
--- a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
+++ b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
@@ -188,7 +188,11 @@ protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
     }
 
     public void setSelectedItem(int position) {
-        mAdapter.setSelectedItem(position);
+        setSelectedItem(position, true);
+    }
+
+    public void setSelectedItem(int position, boolean animate) {
+        mAdapter.setSelectedItem(position, animate);
     }
 
     public void setSelectedItem(SwipeItem item) {

From 0f45b5576bfb2620622dbc5c53780e59dad24ea7 Mon Sep 17 00:00:00 2001
From: Iiro <iiro.krankka@gmail.com>
Date: Thu, 10 Mar 2016 15:18:48 +0200
Subject: [PATCH 06/11] Added choice for setting the items with or without
 animation.

---
 .../src/main/java/com/roughike/swipeselector/SwipeAdapter.java    | 6 +++---
 .../src/main/java/com/roughike/swipeselector/SwipeSelector.java   | 8 ++++++--
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
index 393422e..2a6ef1e 100644
--- a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
+++ b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
@@ -287,10 +287,10 @@ public void setSelectedItem(int position, boolean animate) {
         }
     }
 
-    public void setSelectedItem(SwipeItem item) {
+    public void setSelectedItem(Object value, boolean animate) {
         for (int i = 0; i < mItems.size(); i++) {
-            if (mItems.get(i).equals(item)) {
-                mViewPager.setCurrentItem(i, true);
+            if (mItems.get(i).value.equals(value)) {
+                mViewPager.setCurrentItem(i, animate);
                 break;
             }
         }
diff --git a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
index 1d82128..af0eb10 100644
--- a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
+++ b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
@@ -195,7 +195,11 @@ public void setSelectedItem(int position, boolean animate) {
         mAdapter.setSelectedItem(position, animate);
     }
 
-    public void setSelectedItem(SwipeItem item) {
-        mAdapter.setSelectedItem(item);
+    public void setSelectedItem(Object value) {
+        setSelectedItem(value, true);
+    }
+
+    public void setSelectedItem(Object value, boolean animate) {
+        mAdapter.setSelectedItem(value, animate);
     }
 }

From df4708e468c43b0a99210229174a715f08dcceee Mon Sep 17 00:00:00 2001
From: Iiro <iiro.krankka@gmail.com>
Date: Thu, 10 Mar 2016 15:21:33 +0200
Subject: [PATCH 07/11] Refractored method names.

---
 .../java/com/roughike/swipeselector/SwipeAdapter.java    |  4 ++--
 .../java/com/roughike/swipeselector/SwipeSelector.java   | 16 ++++++++--------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
index 2a6ef1e..cf22419 100644
--- a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
+++ b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
@@ -281,13 +281,13 @@ protected SwipeItem getSelectedItem() {
         return mItems.get(mCurrentPosition);
     }
 
-    public void setSelectedItem(int position, boolean animate) {
+    public void selectItemAt(int position, boolean animate) {
         if (position >= 0 && position < mItems.size()) {
             mViewPager.setCurrentItem(position, animate);
         }
     }
 
-    public void setSelectedItem(Object value, boolean animate) {
+    public void selectItemWithValue(Object value, boolean animate) {
         for (int i = 0; i < mItems.size(); i++) {
             if (mItems.get(i).value.equals(value)) {
                 mViewPager.setCurrentItem(i, animate);
diff --git a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
index af0eb10..8c72b9e 100644
--- a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
+++ b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
@@ -187,19 +187,19 @@ protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
         dispatchThawSelfOnly(container);
     }
 
-    public void setSelectedItem(int position) {
-        setSelectedItem(position, true);
+    public void selectItemAt(int position) {
+        selectItemAt(position, true);
     }
 
-    public void setSelectedItem(int position, boolean animate) {
-        mAdapter.setSelectedItem(position, animate);
+    public void selectItemAt(int position, boolean animate) {
+        mAdapter.selectItemAt(position, animate);
     }
 
-    public void setSelectedItem(Object value) {
-        setSelectedItem(value, true);
+    public void selectItemWithValue(Object value) {
+        selectItemWithValue(value, true);
     }
 
-    public void setSelectedItem(Object value, boolean animate) {
-        mAdapter.setSelectedItem(value, animate);
+    public void selectItemWithValue(Object value, boolean animate) {
+        mAdapter.selectItemWithValue(value, animate);
     }
 }

From 12d1658d5d8bd9efc1d75eaf567d88ef446b9118 Mon Sep 17 00:00:00 2001
From: Iiro <iiro.krankka@gmail.com>
Date: Thu, 10 Mar 2016 15:34:46 +0200
Subject: [PATCH 08/11] Added commenting.

---
 .../com/roughike/swipeselector/SwipeSelector.java  | 50 ++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
index 8c72b9e..de247d1 100644
--- a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
+++ b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
@@ -187,18 +187,68 @@ protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
         dispatchThawSelfOnly(container);
     }
 
+    /**
+     * Select an item at the specified position and animate the change.
+     *
+     * @param position the position to select.
+     */
     public void selectItemAt(int position) {
         selectItemAt(position, true);
     }
 
+    /**
+     * Select an item at the specified position.
+     *
+     * @param position the position to select.
+     * @param animate should the change be animated or not.
+     */
     public void selectItemAt(int position, boolean animate) {
         mAdapter.selectItemAt(position, animate);
     }
 
+    /**
+     * Select an item that has the specified value. The value was given
+     * to the {@link SwipeItem} when constructing it.
+     *
+     * For example, an item constructed like this:
+     *
+     * {@code
+     * new SwipeItem(1, "Example title", "Example description");
+     * }
+     *
+     * would have the value "1" (without the quote marks). Then you would
+     * select that item by using something like this:
+     *
+     * {@code
+     * swipeSelector.selectItemWithValue(1);
+     * }
+     *
+     * @param value the value of the item to select.
+     */
     public void selectItemWithValue(Object value) {
         selectItemWithValue(value, true);
     }
 
+    /**
+     * Select an item that has the specified value. The value was given
+     * to the {@link SwipeItem} when constructing it.
+     *
+     * For example, an item constructed like this:
+     *
+     * {@code
+     * new SwipeItem(1, "Example title", "Example description");
+     * }
+     *
+     * would have the value "1" (without the quote marks). Then you would
+     * select that item by using something like this:
+     *
+     * {@code
+     * swipeSelector.selectItemWithValue(1, true);
+     * }
+     *
+     * @param value the value of the item to select.
+     * @param animate should the change be animated or not.
+     */
     public void selectItemWithValue(Object value, boolean animate) {
         mAdapter.selectItemWithValue(value, animate);
     }

From 1abe8f5e1bfa0183e16027a2482a12e23b3e7dd3 Mon Sep 17 00:00:00 2001
From: Iiro <iiro.krankka@gmail.com>
Date: Thu, 10 Mar 2016 15:35:47 +0200
Subject: [PATCH 09/11] Moved the public method to the top, just because.

---
 .../com/roughike/swipeselector/SwipeSelector.java  | 54 +++++++++++-----------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
index de247d1..d7f2b89 100644
--- a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
+++ b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeSelector.java
@@ -160,33 +160,6 @@ public SwipeItem getSelectedItem() {
         return mAdapter.getSelectedItem();
     }
 
-    @Override
-    public Parcelable onSaveInstanceState() {
-        Bundle bundle = mAdapter.onSaveInstanceState();
-        bundle.putParcelable(STATE_SELECTOR, super.onSaveInstanceState());
-        return bundle;
-    }
-
-    @Override
-    public void onRestoreInstanceState(Parcelable state) {
-        if (state instanceof Bundle) {//Shouldn't be needed, just in case
-            Bundle bundle = (Bundle) state;
-            mAdapter.onRestoreInstanceState(bundle);
-            state = bundle.getParcelable(STATE_SELECTOR);
-        }
-        super.onRestoreInstanceState(state);
-    }
-
-    @Override
-    protected void dispatchSaveInstanceState(SparseArray<Parcelable> container) {
-        dispatchFreezeSelfOnly(container);
-    }
-
-    @Override
-    protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
-        dispatchThawSelfOnly(container);
-    }
-
     /**
      * Select an item at the specified position and animate the change.
      *
@@ -252,4 +225,31 @@ public void selectItemWithValue(Object value) {
     public void selectItemWithValue(Object value, boolean animate) {
         mAdapter.selectItemWithValue(value, animate);
     }
+
+    @Override
+    public Parcelable onSaveInstanceState() {
+        Bundle bundle = mAdapter.onSaveInstanceState();
+        bundle.putParcelable(STATE_SELECTOR, super.onSaveInstanceState());
+        return bundle;
+    }
+
+    @Override
+    public void onRestoreInstanceState(Parcelable state) {
+        if (state instanceof Bundle) {//Shouldn't be needed, just in case
+            Bundle bundle = (Bundle) state;
+            mAdapter.onRestoreInstanceState(bundle);
+            state = bundle.getParcelable(STATE_SELECTOR);
+        }
+        super.onRestoreInstanceState(state);
+    }
+
+    @Override
+    protected void dispatchSaveInstanceState(SparseArray<Parcelable> container) {
+        dispatchFreezeSelfOnly(container);
+    }
+
+    @Override
+    protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
+        dispatchThawSelfOnly(container);
+    }
 }

From 0b0e152d3eac20b34c1bd53183e56dda44415aec Mon Sep 17 00:00:00 2001
From: Iiro <iiro.krankka@gmail.com>
Date: Thu, 10 Mar 2016 15:36:42 +0200
Subject: [PATCH 10/11] Fixed formatting.

---
 .../main/res/layout/swipeselector_content_item.xml   | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/swipe-selector/src/main/res/layout/swipeselector_content_item.xml b/swipe-selector/src/main/res/layout/swipeselector_content_item.xml
index 1e4da67..eb6b069 100644
--- a/swipe-selector/src/main/res/layout/swipeselector_content_item.xml
+++ b/swipe-selector/src/main/res/layout/swipeselector_content_item.xml
@@ -1,18 +1,18 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
-        android:orientation="vertical"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:gravity="center"
-        xmlns:android="http://schemas.android.com/apk/res/android"
-        xmlns:tools="http://schemas.android.com/tools">
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:gravity="center"
+    android:orientation="vertical">
 
     <TextView
         android:id="@+id/swipeselector_content_title"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        tools:text="Title"
-        android:textAppearance="@style/TextAppearance.AppCompat.Body2"/>
+        android:textAppearance="@style/TextAppearance.AppCompat.Body2"
+        tools:text="Title" />
 
 
     <TextView
@@ -21,7 +21,7 @@
         android:layout_height="wrap_content"
         android:layout_gravity="center_horizontal"
         android:layout_marginTop="4dp"
-        tools:text="Description"
-        android:textAppearance="@style/TextAppearance.AppCompat.Caption"/>
+        android:textAppearance="@style/TextAppearance.AppCompat.Caption"
+        tools:text="Description" />
 
 </LinearLayout>
\ No newline at end of file

From 889f5a83ede7b616a0e490f7c2b37fcd77842059 Mon Sep 17 00:00:00 2001
From: Iiro <iiro.krankka@gmail.com>
Date: Thu, 10 Mar 2016 15:50:28 +0200
Subject: [PATCH 11/11] Now throwing exceptions if the item selection fails,
 just because exceptions are fun.

---
 .../java/com/roughike/swipeselector/SwipeAdapter.java    | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
index cf22419..9886e2c 100644
--- a/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
+++ b/swipe-selector/src/main/java/com/roughike/swipeselector/SwipeAdapter.java
@@ -282,18 +282,30 @@ protected SwipeItem getSelectedItem() {
     }
 
     public void selectItemAt(int position, boolean animate) {
-        if (position >= 0 && position < mItems.size()) {
-            mViewPager.setCurrentItem(position, animate);
+        if (position < 0 || position >= mItems.size()) {
+            throw new IndexOutOfBoundsException("This SwipeSelector does " +
+                    "not have an item at position " + position + ".");
         }
+
+        mViewPager.setCurrentItem(position, animate);
     }
 
     public void selectItemWithValue(Object value, boolean animate) {
+        boolean itemExists = false;
+
         for (int i = 0; i < mItems.size(); i++) {
             if (mItems.get(i).value.equals(value)) {
                 mViewPager.setCurrentItem(i, animate);
+                itemExists = true;
                 break;
             }
         }
+
+        if (!itemExists) {
+            throw new IllegalArgumentException("This SwipeSelector " +
+                    "does not have an item with the given value "
+                    + value.toString() + ".");
+        }
     }
 
     protected Bundle onSaveInstanceState() {
