Commit 50530e0f authored by Willard's avatar Willard

Add double seek bar for price range filtering

parent e8a07c2a
...@@ -32,4 +32,5 @@ dependencies { ...@@ -32,4 +32,5 @@ dependencies {
compile 'com.squareup.retrofit2:converter-gson:2.1.0' compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile files('libs/picasso-2.5.2.jar') compile files('libs/picasso-2.5.2.jar')
compile 'com.android.support:support-v4:23.2.1' compile 'com.android.support:support-v4:23.2.1'
compile 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'
} }
...@@ -32,6 +32,8 @@ import android.widget.Toast; ...@@ -32,6 +32,8 @@ import android.widget.Toast;
import com.testapp.entities.Dish; import com.testapp.entities.Dish;
import com.testapp.entities.Filter; import com.testapp.entities.Filter;
import org.florescu.android.rangeseekbar.RangeSeekBar;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -257,7 +259,8 @@ public class NavDrawerActivity extends AppCompatActivity implements NavigationVi ...@@ -257,7 +259,8 @@ public class NavDrawerActivity extends AppCompatActivity implements NavigationVi
} }
public void refreshDishes() { public void refreshDishes() {
adapter.filter(query, getChecked(R.id.type_checkboxes), getChecked(R.id.cuisine_checkboxes), getChecked(R.id.location_checkboxes), 0, 1000); RangeSeekBar priceRangeBar = (RangeSeekBar)findViewById(R.id.price_range_bar);
adapter.filter(query, getChecked(R.id.type_checkboxes), getChecked(R.id.cuisine_checkboxes), getChecked(R.id.location_checkboxes), priceRangeBar.getSelectedMinValue().doubleValue(), priceRangeBar.getSelectedMaxValue().doubleValue());
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
System.out.println(adapter.filteredDishes.size()); System.out.println(adapter.filteredDishes.size());
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:rsb="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout" android:id="@+id/drawer_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
...@@ -140,13 +141,13 @@ ...@@ -140,13 +141,13 @@
android:paddingTop="5dp" android:paddingTop="5dp"
android:paddingBottom="5dp"/> android:paddingBottom="5dp"/>
<SeekBar <org.florescu.android.rangeseekbar.RangeSeekBar
android:id="@+id/price_range_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="20dip" rsb:textAboveThumbsColor="#000000"
android:paddingRight="20dip" rsb:absoluteMaxValue="300"
android:max="150" rsb:absoluteMinValue="0"/>
android:progress="1" />
<TextView <TextView
android:typeface="monospace" android:typeface="monospace"
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="RangeSeekBar">
<attr name="absoluteMinValue" format="integer|float"/>
<attr name="absoluteMaxValue" format="integer|float"/>
<attr name="singleThumb" format="boolean"/>
</declare-styleable>
</resources>
\ No newline at end of file
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
<string name="drawer_4">Price Range</string> <string name="drawer_4">Price Range</string>
<string name="drawer_5">Locations</string> <string name="drawer_5">Locations</string>
<string name="apply_filter">Apply Filters</string> <string name="apply_filter">Apply Filters</string>
<string name="min_price">Minimum</string>
<string name="max_price">Maximum</string>
<string name="navigation_drawer_open">Open navigation drawer</string> <string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string> <string name="navigation_drawer_close">Close navigation drawer</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment