Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CS123-CanteeneoAndroid
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Willard Torres
CS123-CanteeneoAndroid
Commits
a168d5e4
Commit
a168d5e4
authored
Nov 23, 2016
by
Willard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make searching use filters
parent
f9f1baee
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
3 deletions
+41
-3
CanteeneoApiInterface.java
app/src/main/java/com/testapp/CanteeneoApiInterface.java
+7
-1
NavDrawerActivity.java
app/src/main/java/com/testapp/NavDrawerActivity.java
+16
-1
SearchActivity.java
app/src/main/java/com/testapp/SearchActivity.java
+18
-1
No files found.
app/src/main/java/com/testapp/CanteeneoApiInterface.java
View file @
a168d5e4
...
@@ -6,6 +6,7 @@ import com.testapp.entities.Dish;
...
@@ -6,6 +6,7 @@ import com.testapp.entities.Dish;
import
com.testapp.entities.DishType
;
import
com.testapp.entities.DishType
;
import
com.testapp.entities.Location
;
import
com.testapp.entities.Location
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
okhttp3.ResponseBody
;
import
okhttp3.ResponseBody
;
...
@@ -27,7 +28,12 @@ public interface CanteeneoApiInterface {
...
@@ -27,7 +28,12 @@ public interface CanteeneoApiInterface {
Call
<
CData
>
getAllBy
(
@Query
(
"date"
)
String
date
);
Call
<
CData
>
getAllBy
(
@Query
(
"date"
)
String
date
);
@GET
(
"api/search/dish"
)
@GET
(
"api/search/dish"
)
Call
<
List
<
Dish
>>
searchByName
(
@Query
(
"name"
)
String
name
);
Call
<
List
<
Dish
>>
searchByName
(
@Query
(
"name"
)
String
name
,
@Query
(
"type_filters"
)
String
types
,
@Query
(
"cuisine_filters"
)
String
cuisines
,
@Query
(
"location_filters"
)
String
location
,
@Query
(
"min_price"
)
int
min_price
,
@Query
(
"max_price"
)
int
max_price
);
@GET
(
"api/locations"
)
@GET
(
"api/locations"
)
Call
<
List
<
Location
>>
getLocations
();
Call
<
List
<
Location
>>
getLocations
();
...
...
app/src/main/java/com/testapp/NavDrawerActivity.java
View file @
a168d5e4
...
@@ -283,8 +283,23 @@ public class NavDrawerActivity extends AppCompatActivity
...
@@ -283,8 +283,23 @@ public class NavDrawerActivity extends AppCompatActivity
return
true
;
return
true
;
}
}
private
String
getChecked
(
int
layoutId
)
{
LinearLayout
checkboxes
=
(
LinearLayout
)
findViewById
(
layoutId
);
String
checked
=
""
;
for
(
int
i
=
0
;
i
<
checkboxes
.
getChildCount
();
i
++)
{
View
v
=
checkboxes
.
getChildAt
(
i
);
if
(
v
instanceof
CheckBox
)
{
CheckBox
c
=
(
CheckBox
)
v
;
if
(
c
.
isChecked
())
{
checked
+=
c
.
getId
();
}
}
}
return
checked
;
}
private
void
searchDish
(
String
name
)
{
private
void
searchDish
(
String
name
)
{
Call
<
List
<
Dish
>>
call
=
service
.
searchByName
(
name
);
Call
<
List
<
Dish
>>
call
=
service
.
searchByName
(
name
,
getChecked
(
R
.
id
.
type_checkboxes
),
getChecked
(
R
.
id
.
cuisine_checkboxes
),
getChecked
(
R
.
id
.
location_checkboxes
),
0
,
1000
);
call
.
enqueue
(
new
Callback
<
List
<
Dish
>>()
{
call
.
enqueue
(
new
Callback
<
List
<
Dish
>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
List
<
Dish
>>
call
,
Response
<
List
<
Dish
>>
response
)
{
public
void
onResponse
(
Call
<
List
<
Dish
>>
call
,
Response
<
List
<
Dish
>>
response
)
{
...
...
app/src/main/java/com/testapp/SearchActivity.java
View file @
a168d5e4
...
@@ -8,6 +8,8 @@ import android.support.v7.app.AppCompatActivity;
...
@@ -8,6 +8,8 @@ import android.support.v7.app.AppCompatActivity;
import
android.support.v7.widget.Toolbar
;
import
android.support.v7.widget.Toolbar
;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.CheckBox
;
import
android.widget.LinearLayout
;
import
android.widget.ListView
;
import
android.widget.ListView
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
...
@@ -97,8 +99,23 @@ public class SearchActivity extends AppCompatActivity {
...
@@ -97,8 +99,23 @@ public class SearchActivity extends AppCompatActivity {
});
});
}
}
private
String
getChecked
(
int
layoutId
)
{
LinearLayout
checkboxes
=
(
LinearLayout
)
findViewById
(
layoutId
);
String
checked
=
""
;
for
(
int
i
=
0
;
i
<
checkboxes
.
getChildCount
();
i
++)
{
View
v
=
checkboxes
.
getChildAt
(
i
);
if
(
v
instanceof
CheckBox
)
{
CheckBox
c
=
(
CheckBox
)
v
;
if
(
c
.
isChecked
())
{
checked
+=
c
.
getId
();
}
}
}
return
checked
;
}
private
void
searchDish
(
String
name
)
{
private
void
searchDish
(
String
name
)
{
Call
<
List
<
Dish
>>
call
=
service
.
searchByName
(
name
);
Call
<
List
<
Dish
>>
call
=
service
.
searchByName
(
name
,
getChecked
(
R
.
id
.
type_checkboxes
),
getChecked
(
R
.
id
.
cuisine_checkboxes
),
getChecked
(
R
.
id
.
location_checkboxes
),
0
,
1000
);
call
.
enqueue
(
new
Callback
<
List
<
Dish
>>()
{
call
.
enqueue
(
new
Callback
<
List
<
Dish
>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
List
<
Dish
>>
call
,
Response
<
List
<
Dish
>>
response
)
{
public
void
onResponse
(
Call
<
List
<
Dish
>>
call
,
Response
<
List
<
Dish
>>
response
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment