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
08af01f0
Commit
08af01f0
authored
Dec 02, 2016
by
Willard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add dish favorites
parent
cd1ca47a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
72 additions
and
25 deletions
+72
-25
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+2
-0
CanteeneoApiInterface.java
app/src/main/java/com/testapp/CanteeneoApiInterface.java
+20
-10
DishViewActivity.java
app/src/main/java/com/testapp/DishViewActivity.java
+37
-0
StallViewActivity.java
app/src/main/java/com/testapp/StallViewActivity.java
+9
-11
FavoriteInfo.java
app/src/main/java/com/testapp/entities/FavoriteInfo.java
+2
-2
content_dish_view.xml
app/src/main/res/layout/content_dish_view.xml
+2
-2
No files found.
app/src/main/AndroidManifest.xml
View file @
08af01f0
...
@@ -43,6 +43,8 @@
...
@@ -43,6 +43,8 @@
android:theme=
"@style/AppTheme"
/>
android:theme=
"@style/AppTheme"
/>
<activity
android:name=
".RegisterActivity"
>
<activity
android:name=
".RegisterActivity"
>
</activity>
</activity>
<activity
android:name=
".AddStallReviewActivity"
>
</activity>
</application>
</application>
</manifest>
</manifest>
\ No newline at end of file
app/src/main/java/com/testapp/CanteeneoApiInterface.java
View file @
08af01f0
...
@@ -7,7 +7,7 @@ import com.testapp.entities.DishType;
...
@@ -7,7 +7,7 @@ import com.testapp.entities.DishType;
import
com.testapp.entities.Location
;
import
com.testapp.entities.Location
;
import
com.testapp.entities.NewUserResult
;
import
com.testapp.entities.NewUserResult
;
import
com.testapp.entities.Stall
;
import
com.testapp.entities.Stall
;
import
com.testapp.entities.
Stall
FavoriteInfo
;
import
com.testapp.entities.FavoriteInfo
;
import
com.testapp.entities.StallReview
;
import
com.testapp.entities.StallReview
;
import
com.testapp.entities.Token
;
import
com.testapp.entities.Token
;
...
@@ -34,6 +34,10 @@ public interface CanteeneoApiInterface {
...
@@ -34,6 +34,10 @@ public interface CanteeneoApiInterface {
@Query
(
"min_price"
)
int
min_price
,
@Query
(
"min_price"
)
int
min_price
,
@Query
(
"max_price"
)
int
max_price
);
@Query
(
"max_price"
)
int
max_price
);
@FormUrlEncoded
@POST
(
"api/users/new"
)
Call
<
NewUserResult
>
newUser
(
@Field
(
"email"
)
String
email
,
@Field
(
"username"
)
String
username
,
@Field
(
"password"
)
String
password
);
@GET
(
"api/locations"
)
@GET
(
"api/locations"
)
Call
<
List
<
Location
>>
getLocations
();
Call
<
List
<
Location
>>
getLocations
();
...
@@ -43,6 +47,16 @@ public interface CanteeneoApiInterface {
...
@@ -43,6 +47,16 @@ public interface CanteeneoApiInterface {
@GET
(
"api/cuisines"
)
@GET
(
"api/cuisines"
)
Call
<
List
<
Cuisine
>>
getCuisines
();
Call
<
List
<
Cuisine
>>
getCuisines
();
@FormUrlEncoded
@POST
(
"api/dishes/{id}/favorites"
)
Call
<
FavoriteInfo
>
setDishFavorite
(
@Path
(
"id"
)
int
id
,
@Field
(
"favorited"
)
boolean
favorited
);
@GET
(
"api/dishes/{id}/favorites"
)
Call
<
FavoriteInfo
>
getDishFavorite
(
@Path
(
"id"
)
int
id
);
@POST
(
"api/dishes/{id}/reviews"
)
Call
<
ResponseBody
>
newDishReview
(
@Path
(
"id"
)
int
id
,
@Body
DishReview
review
);
@GET
(
"api/dishes/{id}/reviews"
)
@GET
(
"api/dishes/{id}/reviews"
)
Call
<
List
<
DishReview
>>
getDishReviews
(
@Path
(
"id"
)
int
id
);
Call
<
List
<
DishReview
>>
getDishReviews
(
@Path
(
"id"
)
int
id
);
...
@@ -54,21 +68,17 @@ public interface CanteeneoApiInterface {
...
@@ -54,21 +68,17 @@ public interface CanteeneoApiInterface {
@FormUrlEncoded
@FormUrlEncoded
@POST
(
"api/stalls/{id}/favorites"
)
@POST
(
"api/stalls/{id}/favorites"
)
Call
<
Stall
FavoriteInfo
>
setStallFavorite
(
@Path
(
"id"
)
int
id
,
@Field
(
"favorited"
)
boolean
favorited
);
Call
<
FavoriteInfo
>
setStallFavorite
(
@Path
(
"id"
)
int
id
,
@Field
(
"favorited"
)
boolean
favorited
);
@GET
(
"api/stalls/{id}/favorites"
)
@GET
(
"api/stalls/{id}/favorites"
)
Call
<
StallFavoriteInfo
>
getStallFavorite
(
@Path
(
"id"
)
int
id
);
Call
<
FavoriteInfo
>
getStallFavorite
(
@Path
(
"id"
)
int
id
);
@POST
(
"api/stalls/{id}/reviews"
)
Call
<
ResponseBody
>
newStallReview
(
@Path
(
"id"
)
int
id
,
@Body
StallReview
review
);
@GET
(
"api/stalls/{id}/dishes"
)
@GET
(
"api/stalls/{id}/dishes"
)
Call
<
List
<
Dish
>>
getDishesByStall
(
@Path
(
"id"
)
int
id
);
Call
<
List
<
Dish
>>
getDishesByStall
(
@Path
(
"id"
)
int
id
);
@POST
(
"api/dishes/{id}/reviews"
)
Call
<
ResponseBody
>
newDishReview
(
@Path
(
"id"
)
int
id
,
@Body
DishReview
review
);
@FormUrlEncoded
@POST
(
"api/users/new"
)
Call
<
NewUserResult
>
newUser
(
@Field
(
"email"
)
String
email
,
@Field
(
"username"
)
String
username
,
@Field
(
"password"
)
String
password
);
@GET
(
"api/token"
)
@GET
(
"api/token"
)
Call
<
Token
>
getToken
();
Call
<
Token
>
getToken
();
}
}
app/src/main/java/com/testapp/DishViewActivity.java
View file @
08af01f0
...
@@ -7,6 +7,7 @@ import android.support.v7.widget.Toolbar;
...
@@ -7,6 +7,7 @@ import android.support.v7.widget.Toolbar;
import
android.view.MenuItem
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.Button
;
import
android.widget.CheckBox
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.ListView
;
import
android.widget.ListView
;
import
android.widget.TextView
;
import
android.widget.TextView
;
...
@@ -14,6 +15,7 @@ import android.widget.Toast;
...
@@ -14,6 +15,7 @@ import android.widget.Toast;
import
com.squareup.picasso.Picasso
;
import
com.squareup.picasso.Picasso
;
import
com.testapp.entities.DishReview
;
import
com.testapp.entities.DishReview
;
import
com.testapp.entities.FavoriteInfo
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -27,6 +29,7 @@ public class DishViewActivity extends AppCompatActivity {
...
@@ -27,6 +29,7 @@ public class DishViewActivity extends AppCompatActivity {
private
TextView
dishStall
;
private
TextView
dishStall
;
private
ArrayList
<
DishReview
>
reviews
=
new
ArrayList
<>();
private
ArrayList
<
DishReview
>
reviews
=
new
ArrayList
<>();
private
DishReviewAdapter
adapter
;
private
DishReviewAdapter
adapter
;
private
CheckBox
favoriteCheckbox
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
@@ -41,6 +44,7 @@ public class DishViewActivity extends AppCompatActivity {
...
@@ -41,6 +44,7 @@ public class DishViewActivity extends AppCompatActivity {
setTitle
(
"Dish Pls"
);
setTitle
(
"Dish Pls"
);
Intent
i
=
getIntent
();
Intent
i
=
getIntent
();
final
int
id
=
i
.
getIntExtra
(
"ID"
,
0
);
TextView
dishName
=
(
TextView
)
findViewById
(
R
.
id
.
dish_name
);
TextView
dishName
=
(
TextView
)
findViewById
(
R
.
id
.
dish_name
);
dishName
.
setText
(
i
.
getStringExtra
(
"NAME"
));
dishName
.
setText
(
i
.
getStringExtra
(
"NAME"
));
TextView
dishPrice
=
(
TextView
)
findViewById
(
R
.
id
.
dish_price
);
TextView
dishPrice
=
(
TextView
)
findViewById
(
R
.
id
.
dish_price
);
...
@@ -61,6 +65,39 @@ public class DishViewActivity extends AppCompatActivity {
...
@@ -61,6 +65,39 @@ public class DishViewActivity extends AppCompatActivity {
});
});
}
}
favoriteCheckbox
=
(
CheckBox
)
findViewById
(
R
.
id
.
favorite_checkbox
);
favoriteCheckbox
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Call
<
FavoriteInfo
>
favoriteCall
=
AppUtils
.
service
.
setDishFavorite
(
id
,
favoriteCheckbox
.
isChecked
());
favoriteCall
.
enqueue
(
new
Callback
<
FavoriteInfo
>()
{
@Override
public
void
onResponse
(
Call
<
FavoriteInfo
>
call
,
Response
<
FavoriteInfo
>
response
)
{
favoriteCheckbox
.
setText
(
"Favorite ("
+
response
.
body
().
getCount
()
+
")"
);
}
@Override
public
void
onFailure
(
Call
<
FavoriteInfo
>
call
,
Throwable
t
)
{
}
});
}
});
Call
<
FavoriteInfo
>
countCall
=
AppUtils
.
service
.
getDishFavorite
(
id
);
countCall
.
enqueue
(
new
Callback
<
FavoriteInfo
>()
{
@Override
public
void
onResponse
(
Call
<
FavoriteInfo
>
call
,
Response
<
FavoriteInfo
>
response
)
{
favoriteCheckbox
.
setChecked
(
response
.
body
().
isFavorited
());
favoriteCheckbox
.
setText
(
"Favorite ("
+
response
.
body
().
getCount
()
+
")"
);
}
@Override
public
void
onFailure
(
Call
<
FavoriteInfo
>
call
,
Throwable
t
)
{
favoriteCheckbox
.
setText
(
"Favorite (-1)"
);
}
});
Button
addReviewBtn
=
(
Button
)
findViewById
(
R
.
id
.
add_review_button
);
Button
addReviewBtn
=
(
Button
)
findViewById
(
R
.
id
.
add_review_button
);
addReviewBtn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
addReviewBtn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
...
...
app/src/main/java/com/testapp/StallViewActivity.java
View file @
08af01f0
...
@@ -4,7 +4,6 @@ import android.content.Intent;
...
@@ -4,7 +4,6 @@ import android.content.Intent;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.widget.Toolbar
;
import
android.support.v7.widget.Toolbar
;
import
android.util.Log
;
import
android.view.MenuItem
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.AdapterView
;
import
android.widget.AdapterView
;
...
@@ -12,12 +11,11 @@ import android.widget.CheckBox;
...
@@ -12,12 +11,11 @@ import android.widget.CheckBox;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.ListView
;
import
android.widget.ListView
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.squareup.picasso.Picasso
;
import
com.squareup.picasso.Picasso
;
import
com.testapp.entities.Dish
;
import
com.testapp.entities.Dish
;
import
com.testapp.entities.Stall
;
import
com.testapp.entities.Stall
;
import
com.testapp.entities.
Stall
FavoriteInfo
;
import
com.testapp.entities.FavoriteInfo
;
import
com.testapp.entities.StallReview
;
import
com.testapp.entities.StallReview
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -81,31 +79,31 @@ public class StallViewActivity extends AppCompatActivity {
...
@@ -81,31 +79,31 @@ public class StallViewActivity extends AppCompatActivity {
favoriteCheckbox
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
favoriteCheckbox
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
Call
<
Stall
FavoriteInfo
>
favoriteCall
=
AppUtils
.
service
.
setStallFavorite
(
id
,
favoriteCheckbox
.
isChecked
());
Call
<
FavoriteInfo
>
favoriteCall
=
AppUtils
.
service
.
setStallFavorite
(
id
,
favoriteCheckbox
.
isChecked
());
favoriteCall
.
enqueue
(
new
Callback
<
Stall
FavoriteInfo
>()
{
favoriteCall
.
enqueue
(
new
Callback
<
FavoriteInfo
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
StallFavoriteInfo
>
call
,
Response
<
Stall
FavoriteInfo
>
response
)
{
public
void
onResponse
(
Call
<
FavoriteInfo
>
call
,
Response
<
FavoriteInfo
>
response
)
{
favoriteCheckbox
.
setText
(
"Favorite ("
+
response
.
body
().
getCount
()
+
")"
);
favoriteCheckbox
.
setText
(
"Favorite ("
+
response
.
body
().
getCount
()
+
")"
);
}
}
@Override
@Override
public
void
onFailure
(
Call
<
Stall
FavoriteInfo
>
call
,
Throwable
t
)
{
public
void
onFailure
(
Call
<
FavoriteInfo
>
call
,
Throwable
t
)
{
}
}
});
});
}
}
});
});
Call
<
Stall
FavoriteInfo
>
countCall
=
AppUtils
.
service
.
getStallFavorite
(
id
);
Call
<
FavoriteInfo
>
countCall
=
AppUtils
.
service
.
getStallFavorite
(
id
);
countCall
.
enqueue
(
new
Callback
<
Stall
FavoriteInfo
>()
{
countCall
.
enqueue
(
new
Callback
<
FavoriteInfo
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
StallFavoriteInfo
>
call
,
Response
<
Stall
FavoriteInfo
>
response
)
{
public
void
onResponse
(
Call
<
FavoriteInfo
>
call
,
Response
<
FavoriteInfo
>
response
)
{
favoriteCheckbox
.
setChecked
(
response
.
body
().
isFavorited
());
favoriteCheckbox
.
setChecked
(
response
.
body
().
isFavorited
());
favoriteCheckbox
.
setText
(
"Favorite ("
+
response
.
body
().
getCount
()
+
")"
);
favoriteCheckbox
.
setText
(
"Favorite ("
+
response
.
body
().
getCount
()
+
")"
);
}
}
@Override
@Override
public
void
onFailure
(
Call
<
Stall
FavoriteInfo
>
call
,
Throwable
t
)
{
public
void
onFailure
(
Call
<
FavoriteInfo
>
call
,
Throwable
t
)
{
favoriteCheckbox
.
setText
(
"Favorite (-1)"
);
favoriteCheckbox
.
setText
(
"Favorite (-1)"
);
}
}
});
});
...
...
app/src/main/java/com/testapp/entities/
Stall
FavoriteInfo.java
→
app/src/main/java/com/testapp/entities/FavoriteInfo.java
View file @
08af01f0
package
com
.
testapp
.
entities
;
package
com
.
testapp
.
entities
;
public
class
Stall
FavoriteInfo
{
public
class
FavoriteInfo
{
int
count
;
int
count
;
boolean
favorited
;
boolean
favorited
;
public
Stall
FavoriteInfo
(
int
count
,
boolean
favorited
)
{
public
FavoriteInfo
(
int
count
,
boolean
favorited
)
{
this
.
count
=
count
;
this
.
count
=
count
;
this
.
favorited
=
favorited
;
this
.
favorited
=
favorited
;
}
}
...
...
app/src/main/res/layout/content_dish_view.xml
View file @
08af01f0
...
@@ -72,11 +72,11 @@
...
@@ -72,11 +72,11 @@
android:textSize=
"18sp"
android:textSize=
"18sp"
android:textColor=
"?android:attr/textColorLink"
/>
android:textColor=
"?android:attr/textColorLink"
/>
<
Button
<
CheckBox
android:text=
"Favorite"
android:text=
"Favorite"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:id=
"@+id/
dish_favorite
"
android:id=
"@+id/
favorite_checkbox
"
android:layout_marginBottom=
"10dp"
android:layout_marginBottom=
"10dp"
android:layout_weight=
"1"
/>
android:layout_weight=
"1"
/>
...
...
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