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
8bd0b903
Commit
8bd0b903
authored
Nov 24, 2016
by
lumisce
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add dish review, remove dish location
parent
1dadb1d9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
147 additions
and
10 deletions
+147
-10
CanteeneoApiInterface.java
app/src/main/java/com/testapp/CanteeneoApiInterface.java
+11
-0
DishReviewAdapter.java
app/src/main/java/com/testapp/DishReviewAdapter.java
+55
-0
DishViewActivity.java
app/src/main/java/com/testapp/DishViewActivity.java
+34
-2
content_dish_view.xml
app/src/main/res/layout/content_dish_view.xml
+0
-8
dish_review_row.xml
app/src/main/res/layout/dish_review_row.xml
+47
-0
No files found.
app/src/main/java/com/testapp/CanteeneoApiInterface.java
View file @
8bd0b903
...
...
@@ -2,13 +2,18 @@ package com.testapp;
import
com.testapp.entities.Cuisine
;
import
com.testapp.entities.Dish
;
import
com.testapp.entities.DishReview
;
import
com.testapp.entities.DishType
;
import
com.testapp.entities.Location
;
import
com.testapp.entities.StallReview
;
import
java.util.List
;
import
okhttp3.ResponseBody
;
import
retrofit2.Call
;
import
retrofit2.http.GET
;
import
retrofit2.http.Path
;
import
retrofit2.http.Query
;
public
interface
CanteeneoApiInterface
{
...
...
@@ -29,4 +34,10 @@ public interface CanteeneoApiInterface {
@GET
(
"api/cuisines"
)
Call
<
List
<
Cuisine
>>
getCuisines
();
@GET
(
"api/dishes/{id}/reviews"
)
Call
<
List
<
DishReview
>>
getDishReviews
(
@Path
(
"id"
)
int
id
);
@GET
(
"api/stalls/{id}/reviews"
)
Call
<
List
<
StallReview
>>
getStallReviews
(
@Path
(
"id"
)
int
id
);
}
app/src/main/java/com/testapp/DishReviewAdapter.java
0 → 100644
View file @
8bd0b903
package
com
.
testapp
;
import
android.app.Activity
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.BaseAdapter
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
com.squareup.picasso.Picasso
;
import
com.testapp.entities.Dish
;
import
com.testapp.entities.DishReview
;
import
java.util.ArrayList
;
public
class
DishReviewAdapter
extends
BaseAdapter
{
private
Activity
context
;
ArrayList
<
DishReview
>
dishReviews
;
public
DishReviewAdapter
(
Activity
context
,
ArrayList
<
DishReview
>
dishReviews
)
{
this
.
context
=
context
;
this
.
dishReviews
=
dishReviews
;
}
@Override
public
int
getCount
()
{
return
dishReviews
.
size
();
}
@Override
public
DishReview
getItem
(
int
position
)
{
return
dishReviews
.
get
(
position
);
}
@Override
public
long
getItemId
(
int
position
)
{
return
position
;
}
@Override
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
View
v
=
context
.
getLayoutInflater
().
inflate
(
R
.
layout
.
dish_review_row
,
null
);
TextView
title
=
(
TextView
)
v
.
findViewById
(
R
.
id
.
drv_title
);
TextView
rating
=
(
TextView
)
v
.
findViewById
(
R
.
id
.
drv_rating
);
TextView
body
=
(
TextView
)
v
.
findViewById
(
R
.
id
.
drv_body
);
TextView
username
=
(
TextView
)
v
.
findViewById
(
R
.
id
.
drv_username
);
DishReview
dr
=
dishReviews
.
get
(
position
);
title
.
setText
(
dr
.
getTitle
());
rating
.
setText
(
dr
.
getRating
());
body
.
setText
(
dr
.
getBody
());
// TODO set username
return
v
;
}
}
app/src/main/java/com/testapp/DishViewActivity.java
View file @
8bd0b903
...
...
@@ -6,11 +6,23 @@ import android.support.v7.app.AppCompatActivity;
import
android.support.v7.widget.Toolbar
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.widget.ListView
;
import
android.widget.TextView
;
import
com.testapp.entities.DishReview
;
import
java.util.ArrayList
;
import
java.util.List
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
public
class
DishViewActivity
extends
AppCompatActivity
{
private
TextView
dishStall
;
private
ArrayList
<
DishReview
>
reviews
=
new
ArrayList
<>();
private
DishReviewAdapter
adapter
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -31,8 +43,6 @@ public class DishViewActivity extends AppCompatActivity {
dishPrice
.
setText
(
i
.
getStringExtra
(
"PRICE"
));
TextView
dishDesc
=
(
TextView
)
findViewById
(
R
.
id
.
dish_desc
);
dishDesc
.
setText
(
i
.
getStringExtra
(
"DESCRIPTION"
));
TextView
dishLocation
=
(
TextView
)
findViewById
(
R
.
id
.
dish_location
);
// TODO setDishLocation
dishStall
=
(
TextView
)
findViewById
(
R
.
id
.
dish_stall
);
dishStall
.
setText
(
i
.
getStringExtra
(
"STALLNAME"
));
...
...
@@ -44,6 +54,10 @@ public class DishViewActivity extends AppCompatActivity {
}
});
}
ListView
lv
=
(
ListView
)
findViewById
(
R
.
id
.
dish_reviews
);
adapter
=
new
DishReviewAdapter
(
this
,
reviews
);
lv
.
setAdapter
(
adapter
);
}
public
void
visitStall
()
{
...
...
@@ -64,4 +78,22 @@ public class DishViewActivity extends AppCompatActivity {
}
}
private
void
getDishReviews
(
int
id
)
{
Call
<
List
<
DishReview
>>
call
=
AppUtils
.
service
.
getDishReviews
(
id
);
call
.
enqueue
(
new
Callback
<
List
<
DishReview
>>()
{
@Override
public
void
onResponse
(
Call
<
List
<
DishReview
>>
call
,
Response
<
List
<
DishReview
>>
response
)
{
List
<
DishReview
>
newDishes
=
response
.
body
();
reviews
.
clear
();
reviews
.
addAll
(
newDishes
);
adapter
.
notifyDataSetChanged
();
}
@Override
public
void
onFailure
(
Call
<
List
<
DishReview
>>
call
,
Throwable
t
)
{
}
});
}
}
app/src/main/res/layout/content_dish_view.xml
View file @
8bd0b903
...
...
@@ -69,14 +69,6 @@
android:clickable=
"true"
android:onClick=
"visitStall"
/>
<TextView
android:text=
"Location"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:id=
"@+id/dish_location"
android:paddingTop=
"5dp"
android:layout_weight=
"1"
/>
<Button
android:text=
"Favorite"
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/dish_review_row.xml
0 → 100644
View file @
8bd0b903
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:padding=
"@dimen/activity_horizontal_margin"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textAppearance=
"?android:attr/textAppearanceLarge"
android:text=
"Title"
android:id=
"@+id/drv_title"
android:layout_alignParentTop=
"true"
android:layout_alignParentLeft=
"true"
android:layout_alignParentStart=
"true"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textAppearance=
"?android:attr/textAppearanceLarge"
android:text=
"Rating"
android:id=
"@+id/drv_rating"
android:layout_alignParentTop=
"true"
android:layout_alignParentRight=
"true"
android:layout_alignParentEnd=
"true"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"New Text"
android:id=
"@+id/drv_body"
android:layout_below=
"@+id/drv_title"
android:layout_alignParentLeft=
"true"
android:layout_alignParentStart=
"true"
android:layout_alignParentRight=
"true"
android:layout_alignParentEnd=
"true"
android:inputType=
"textMultiLine"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"username"
android:id=
"@+id/drv_username"
android:layout_below=
"@+id/drv_body"
android:layout_alignParentRight=
"true"
android:layout_alignParentEnd=
"true"
/>
</RelativeLayout>
\ No newline at end of file
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