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
387625c9
Commit
387625c9
authored
Nov 25, 2016
by
Willard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add features fix bugs
parent
36e3c324
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
130 additions
and
96 deletions
+130
-96
AddDishReviewActivity.java
app/src/main/java/com/testapp/AddDishReviewActivity.java
+2
-1
AppUtils.java
app/src/main/java/com/testapp/AppUtils.java
+24
-0
CanteeneoApiInterface.java
app/src/main/java/com/testapp/CanteeneoApiInterface.java
+6
-2
DishViewActivity.java
app/src/main/java/com/testapp/DishViewActivity.java
+0
-1
LoginActivity.java
app/src/main/java/com/testapp/LoginActivity.java
+30
-46
StallViewActivity.java
app/src/main/java/com/testapp/StallViewActivity.java
+27
-25
Token.java
app/src/main/java/com/testapp/entities/Token.java
+17
-0
activity_login.xml
app/src/main/res/layout/activity_login.xml
+3
-3
content_stall_view.xml
app/src/main/res/layout/content_stall_view.xml
+10
-5
dish_row.xml
app/src/main/res/layout/dish_row.xml
+11
-13
No files found.
app/src/main/java/com/testapp/AddDishReviewActivity.java
View file @
387625c9
...
@@ -60,7 +60,8 @@ public class AddDishReviewActivity extends AppCompatActivity {
...
@@ -60,7 +60,8 @@ public class AddDishReviewActivity extends AppCompatActivity {
call
.
enqueue
(
new
Callback
<
ResponseBody
>()
{
call
.
enqueue
(
new
Callback
<
ResponseBody
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
ResponseBody
>
call
,
Response
<
ResponseBody
>
response
)
{
public
void
onResponse
(
Call
<
ResponseBody
>
call
,
Response
<
ResponseBody
>
response
)
{
finish
();
Toast
.
makeText
(
getApplicationContext
(),
"Review posted!"
,
Toast
.
LENGTH_SHORT
);
//finish();
}
}
@Override
@Override
...
...
app/src/main/java/com/testapp/AppUtils.java
View file @
387625c9
...
@@ -3,6 +3,7 @@ package com.testapp;
...
@@ -3,6 +3,7 @@ package com.testapp;
import
android.content.Context
;
import
android.content.Context
;
import
android.net.ConnectivityManager
;
import
android.net.ConnectivityManager
;
import
android.net.NetworkInfo
;
import
android.net.NetworkInfo
;
import
android.util.Base64
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
com.google.gson.GsonBuilder
;
import
com.google.gson.GsonBuilder
;
...
@@ -13,12 +14,17 @@ import java.io.IOException;
...
@@ -13,12 +14,17 @@ import java.io.IOException;
import
okhttp3.Cache
;
import
okhttp3.Cache
;
import
okhttp3.Interceptor
;
import
okhttp3.Interceptor
;
import
okhttp3.OkHttpClient
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.Response
;
import
okhttp3.internal.http.RequestException
;
import
retrofit2.Retrofit
;
import
retrofit2.Retrofit
;
import
retrofit2.converter.gson.GsonConverterFactory
;
import
retrofit2.converter.gson.GsonConverterFactory
;
public
class
AppUtils
{
public
class
AppUtils
{
public
static
CanteeneoApiInterface
service
;
public
static
CanteeneoApiInterface
service
;
private
static
Context
c
;
private
static
Context
c
;
public
static
String
username
=
""
;
public
static
String
password
=
""
;
public
static
boolean
isNetworkAvailable
(
Context
c
)
{
public
static
boolean
isNetworkAvailable
(
Context
c
)
{
ConnectivityManager
connectivity
=(
ConnectivityManager
)
c
.
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
);
ConnectivityManager
connectivity
=(
ConnectivityManager
)
c
.
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
);
...
@@ -47,6 +53,7 @@ public class AppUtils {
...
@@ -47,6 +53,7 @@ public class AppUtils {
OkHttpClient
client
=
new
OkHttpClient
().
newBuilder
()
OkHttpClient
client
=
new
OkHttpClient
().
newBuilder
()
.
addNetworkInterceptor
(
REWRITE_CACHE_CONTROL_INTERCEPTOR
)
.
addNetworkInterceptor
(
REWRITE_CACHE_CONTROL_INTERCEPTOR
)
.
cache
(
cache
)
.
cache
(
cache
)
.
addInterceptor
(
TOKEN_AUTH_INTERCEPTOR
)
.
build
();
.
build
();
Gson
gson
=
new
GsonBuilder
()
Gson
gson
=
new
GsonBuilder
()
...
@@ -59,6 +66,8 @@ public class AppUtils {
...
@@ -59,6 +66,8 @@ public class AppUtils {
.
addConverterFactory
(
GsonConverterFactory
.
create
(
gson
))
.
addConverterFactory
(
GsonConverterFactory
.
create
(
gson
))
.
build
();
.
build
();
service
=
retrofit
.
create
(
CanteeneoApiInterface
.
class
);
service
=
retrofit
.
create
(
CanteeneoApiInterface
.
class
);
}
}
...
@@ -80,4 +89,19 @@ public class AppUtils {
...
@@ -80,4 +89,19 @@ public class AppUtils {
}
}
}
}
};
};
private
static
final
Interceptor
TOKEN_AUTH_INTERCEPTOR
=
new
Interceptor
()
{
@Override
public
Response
intercept
(
Chain
chain
)
throws
IOException
{
String
credentials
=
username
+
":"
+
password
;
final
String
basic
=
"Basic "
+
Base64
.
encodeToString
(
credentials
.
getBytes
(),
Base64
.
NO_WRAP
);
Request
original
=
chain
.
request
();
Request
.
Builder
requestBuilder
=
original
.
newBuilder
()
.
header
(
"Authorization"
,
basic
)
.
header
(
"Accept"
,
"application/json"
)
.
method
(
original
.
method
(),
original
.
body
());
Request
request
=
requestBuilder
.
build
();
return
chain
.
proceed
(
request
);
}
};
}
}
app/src/main/java/com/testapp/CanteeneoApiInterface.java
View file @
387625c9
...
@@ -7,6 +7,7 @@ import com.testapp.entities.DishType;
...
@@ -7,6 +7,7 @@ import com.testapp.entities.DishType;
import
com.testapp.entities.Location
;
import
com.testapp.entities.Location
;
import
com.testapp.entities.Stall
;
import
com.testapp.entities.Stall
;
import
com.testapp.entities.StallReview
;
import
com.testapp.entities.StallReview
;
import
com.testapp.entities.Token
;
import
java.util.List
;
import
java.util.List
;
...
@@ -44,12 +45,15 @@ public interface CanteeneoApiInterface {
...
@@ -44,12 +45,15 @@ public interface CanteeneoApiInterface {
@GET
(
"api/stalls/{id}/reviews"
)
@GET
(
"api/stalls/{id}/reviews"
)
Call
<
List
<
StallReview
>>
getStallReviews
(
@Path
(
"id"
)
int
id
);
Call
<
List
<
StallReview
>>
getStallReviews
(
@Path
(
"id"
)
int
id
);
@GET
(
"api/stalls
/
"
)
@GET
(
"api/stalls"
)
Call
<
Stall
>
getStallByName
(
@Query
(
"name"
)
String
name
);
Call
<
Stall
>
getStallByName
(
@Query
(
"name"
)
String
name
);
@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"
)
@POST
(
"api/dishes/{id}/reviews"
)
Call
<
ResponseBody
>
newDishReview
(
@Path
(
"id"
)
int
id
,
DishReview
review
);
Call
<
ResponseBody
>
newDishReview
(
@Path
(
"id"
)
int
id
,
@Body
DishReview
review
);
@GET
(
"api/token"
)
Call
<
Token
>
getToken
();
}
}
app/src/main/java/com/testapp/DishViewActivity.java
View file @
387625c9
...
@@ -68,7 +68,6 @@ public class DishViewActivity extends AppCompatActivity {
...
@@ -68,7 +68,6 @@ public class DishViewActivity extends AppCompatActivity {
Intent
i
=
new
Intent
(
DishViewActivity
.
this
,
AddDishReviewActivity
.
class
);
Intent
i
=
new
Intent
(
DishViewActivity
.
this
,
AddDishReviewActivity
.
class
);
i
.
putExtra
(
"ID"
,
i
.
getIntExtra
(
"ID"
,
0
));
i
.
putExtra
(
"ID"
,
i
.
getIntExtra
(
"ID"
,
0
));
startActivityForResult
(
i
,
0
);
startActivityForResult
(
i
,
0
);
}
}
});
});
...
...
app/src/main/java/com/testapp/LoginActivity.java
View file @
387625c9
...
@@ -31,9 +31,15 @@ import android.widget.EditText;
...
@@ -31,9 +31,15 @@ import android.widget.EditText;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.testapp.entities.Token
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
import
static
android
.
Manifest
.
permission
.
READ_CONTACTS
;
import
static
android
.
Manifest
.
permission
.
READ_CONTACTS
;
/**
/**
...
@@ -61,7 +67,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
...
@@ -61,7 +67,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
private
UserLoginTask
mAuthTask
=
null
;
private
UserLoginTask
mAuthTask
=
null
;
// UI references.
// UI references.
private
AutoCompleteTextView
m
Email
View
;
private
AutoCompleteTextView
m
Username
View
;
private
EditText
mPasswordView
;
private
EditText
mPasswordView
;
private
View
mProgressView
;
private
View
mProgressView
;
private
View
mLoginFormView
;
private
View
mLoginFormView
;
...
@@ -74,6 +80,8 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
...
@@ -74,6 +80,8 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
// mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
// mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
// populateAutoComplete();
// populateAutoComplete();
mUsernameView
=
(
AutoCompleteTextView
)
findViewById
(
R
.
id
.
username
);
mPasswordView
=
(
EditText
)
findViewById
(
R
.
id
.
password
);
mPasswordView
=
(
EditText
)
findViewById
(
R
.
id
.
password
);
mPasswordView
.
setOnEditorActionListener
(
new
TextView
.
OnEditorActionListener
()
{
mPasswordView
.
setOnEditorActionListener
(
new
TextView
.
OnEditorActionListener
()
{
@Override
@Override
...
@@ -156,18 +164,6 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
...
@@ -156,18 +164,6 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
if
(
checkSelfPermission
(
READ_CONTACTS
)
==
PackageManager
.
PERMISSION_GRANTED
)
{
if
(
checkSelfPermission
(
READ_CONTACTS
)
==
PackageManager
.
PERMISSION_GRANTED
)
{
return
true
;
return
true
;
}
}
if
(
shouldShowRequestPermissionRationale
(
READ_CONTACTS
))
{
Snackbar
.
make
(
mEmailView
,
R
.
string
.
permission_rationale
,
Snackbar
.
LENGTH_INDEFINITE
)
.
setAction
(
android
.
R
.
string
.
ok
,
new
View
.
OnClickListener
()
{
@Override
@TargetApi
(
Build
.
VERSION_CODES
.
M
)
public
void
onClick
(
View
v
)
{
requestPermissions
(
new
String
[]{
READ_CONTACTS
},
REQUEST_READ_CONTACTS
);
}
});
}
else
{
requestPermissions
(
new
String
[]{
READ_CONTACTS
},
REQUEST_READ_CONTACTS
);
}
return
false
;
return
false
;
}
}
...
@@ -196,11 +192,11 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
...
@@ -196,11 +192,11 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
}
}
// Reset errors.
// Reset errors.
m
Email
View
.
setError
(
null
);
m
Username
View
.
setError
(
null
);
mPasswordView
.
setError
(
null
);
mPasswordView
.
setError
(
null
);
// Store values at the time of the login attempt.
// Store values at the time of the login attempt.
String
email
=
mEmail
View
.
getText
().
toString
();
String
username
=
mUsername
View
.
getText
().
toString
();
String
password
=
mPasswordView
.
getText
().
toString
();
String
password
=
mPasswordView
.
getText
().
toString
();
boolean
cancel
=
false
;
boolean
cancel
=
false
;
...
@@ -214,13 +210,9 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
...
@@ -214,13 +210,9 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
}
}
// Check for a valid email address.
// Check for a valid email address.
if
(
TextUtils
.
isEmpty
(
email
))
{
if
(
TextUtils
.
isEmpty
(
username
))
{
mEmailView
.
setError
(
getString
(
R
.
string
.
error_field_required
));
mUsernameView
.
setError
(
getString
(
R
.
string
.
error_field_required
));
focusView
=
mEmailView
;
focusView
=
mUsernameView
;
cancel
=
true
;
}
else
if
(!
isEmailValid
(
email
))
{
mEmailView
.
setError
(
getString
(
R
.
string
.
error_invalid_email
));
focusView
=
mEmailView
;
cancel
=
true
;
cancel
=
true
;
}
}
...
@@ -232,7 +224,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
...
@@ -232,7 +224,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
// Show a progress spinner, and kick off a background task to
// Show a progress spinner, and kick off a background task to
// perform the user login attempt.
// perform the user login attempt.
showProgress
(
true
);
showProgress
(
true
);
mAuthTask
=
new
UserLoginTask
(
email
,
password
);
mAuthTask
=
new
UserLoginTask
(
username
,
password
);
mAuthTask
.
execute
((
Void
)
null
);
mAuthTask
.
execute
((
Void
)
null
);
}
}
...
@@ -328,7 +320,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
...
@@ -328,7 +320,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
new
ArrayAdapter
<>(
LoginActivity
.
this
,
new
ArrayAdapter
<>(
LoginActivity
.
this
,
android
.
R
.
layout
.
simple_dropdown_item_1line
,
emailAddressCollection
);
android
.
R
.
layout
.
simple_dropdown_item_1line
,
emailAddressCollection
);
m
Email
View
.
setAdapter
(
adapter
);
m
Username
View
.
setAdapter
(
adapter
);
}
}
...
@@ -342,40 +334,32 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
...
@@ -342,40 +334,32 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
int
IS_PRIMARY
=
1
;
int
IS_PRIMARY
=
1
;
}
}
/**
* Represents an asynchronous login/registration task used to authenticate
* the user.
*/
public
class
UserLoginTask
extends
AsyncTask
<
Void
,
Void
,
Boolean
>
{
public
class
UserLoginTask
extends
AsyncTask
<
Void
,
Void
,
Boolean
>
{
private
final
String
m
Email
;
private
final
String
m
Username
;
private
final
String
mPassword
;
private
final
String
mPassword
;
UserLoginTask
(
String
email
,
String
password
)
{
UserLoginTask
(
String
username
,
String
password
)
{
m
Email
=
email
;
m
Username
=
username
;
mPassword
=
password
;
mPassword
=
password
;
}
}
@Override
@Override
protected
Boolean
doInBackground
(
Void
...
params
)
{
protected
Boolean
doInBackground
(
Void
...
params
)
{
// TODO: attempt authentication against a network service.
AppUtils
.
username
=
mUsername
;
AppUtils
.
password
=
mPassword
;
try
{
Call
<
Token
>
call
=
AppUtils
.
service
.
getToken
();
// Simulate network access.
call
.
enqueue
(
new
Callback
<
Token
>()
{
Thread
.
sleep
(
2000
);
@Override
}
catch
(
InterruptedException
e
)
{
public
void
onResponse
(
Call
<
Token
>
call
,
Response
<
Token
>
respons
e
)
{
return
false
;
Toast
.
makeText
(
LoginActivity
.
this
,
response
.
body
().
getToken
(),
Toast
.
LENGTH_LONG
).
show
()
;
}
}
for
(
String
credential
:
DUMMY_CREDENTIALS
)
{
@Override
String
[]
pieces
=
credential
.
split
(
":"
);
public
void
onFailure
(
Call
<
Token
>
call
,
Throwable
t
)
{
if
(
pieces
[
0
].
equals
(
mEmail
))
{
// Account exists, return true if the password matches.
return
pieces
[
1
].
equals
(
mPassword
);
}
}
// TODO: register the new account here.
}
});
return
true
;
return
true
;
}
}
...
...
app/src/main/java/com/testapp/StallViewActivity.java
View file @
387625c9
...
@@ -4,12 +4,14 @@ import android.content.Intent;
...
@@ -4,12 +4,14 @@ 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
;
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
;
...
@@ -46,30 +48,6 @@ public class StallViewActivity extends AppCompatActivity {
...
@@ -46,30 +48,6 @@ public class StallViewActivity extends AppCompatActivity {
setTitle
(
name
);
setTitle
(
name
);
getStall
(
name
);
getStall
(
name
);
ListView
lvDishes
=
(
ListView
)
findViewById
(
R
.
id
.
stall_dishes
);
dAdapter
=
new
DishAdapter
(
this
,
dishes
);
getStallDishes
(
id
);
lvDishes
.
setAdapter
(
dAdapter
);
lvDishes
.
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
Intent
i
=
new
Intent
(
StallViewActivity
.
this
,
DishViewActivity
.
class
);
Dish
d
=
dishes
.
get
(
position
);
i
.
putExtra
(
"ID"
,
d
.
getId
());
i
.
putExtra
(
"NAME"
,
d
.
getName
());
i
.
putExtra
(
"PRICE"
,
d
.
getPrice
());
i
.
putExtra
(
"IMAGE"
,
d
.
getImagePath
());
i
.
putExtra
(
"DESCRIPTION"
,
d
.
getDescription
());
i
.
putExtra
(
"STALLNAME"
,
d
.
getStallName
());
startActivity
(
i
);
}
});
ListView
lvReviews
=
(
ListView
)
findViewById
(
R
.
id
.
stall_reviews
);
srAdapter
=
new
StallReviewAdapter
(
this
,
reviews
);
lvReviews
.
setAdapter
(
srAdapter
);
getStallReviews
(
id
);
}
}
@Override
@Override
...
@@ -91,12 +69,35 @@ public class StallViewActivity extends AppCompatActivity {
...
@@ -91,12 +69,35 @@ public class StallViewActivity extends AppCompatActivity {
Stall
s
=
response
.
body
();
Stall
s
=
response
.
body
();
id
=
s
.
getId
();
id
=
s
.
getId
();
TextView
location
=
(
TextView
)
findViewById
(
R
.
id
.
stall_location
);
TextView
location
=
(
TextView
)
findViewById
(
R
.
id
.
stall_location
);
location
.
setText
(
s
.
getLocation
());
location
.
setText
(
s
.
getLocation
()
+
" "
+
id
);
TextView
description
=
(
TextView
)
findViewById
(
R
.
id
.
stall_description
);
TextView
description
=
(
TextView
)
findViewById
(
R
.
id
.
stall_description
);
description
.
setText
(
s
.
getDescription
());
description
.
setText
(
s
.
getDescription
());
ImageView
image
=
(
ImageView
)
findViewById
(
R
.
id
.
stall_logo
);
ImageView
image
=
(
ImageView
)
findViewById
(
R
.
id
.
stall_logo
);
Picasso
.
with
(
getApplicationContext
()).
load
(
"http://"
+
getResources
().
getString
(
R
.
string
.
server_ip
)
+
":5000/static/uploads/"
+
s
.
getImagePath
()).
fit
().
centerCrop
().
into
(
image
);
Picasso
.
with
(
getApplicationContext
()).
load
(
"http://"
+
getResources
().
getString
(
R
.
string
.
server_ip
)
+
":5000/static/uploads/"
+
s
.
getImagePath
()).
fit
().
centerCrop
().
into
(
image
);
ListView
lvDishes
=
(
ListView
)
findViewById
(
R
.
id
.
stall_dishes
);
dAdapter
=
new
DishAdapter
(
StallViewActivity
.
this
,
dishes
);
getStallDishes
(
id
);
lvDishes
.
setAdapter
(
dAdapter
);
lvDishes
.
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
Intent
i
=
new
Intent
(
StallViewActivity
.
this
,
DishViewActivity
.
class
);
Dish
d
=
dishes
.
get
(
position
);
i
.
putExtra
(
"ID"
,
d
.
getId
());
i
.
putExtra
(
"NAME"
,
d
.
getName
());
i
.
putExtra
(
"PRICE"
,
d
.
getPrice
());
i
.
putExtra
(
"IMAGE"
,
d
.
getImagePath
());
i
.
putExtra
(
"DESCRIPTION"
,
d
.
getDescription
());
i
.
putExtra
(
"STALLNAME"
,
d
.
getStallName
());
startActivity
(
i
);
}
});
ListView
lvReviews
=
(
ListView
)
findViewById
(
R
.
id
.
stall_reviews
);
srAdapter
=
new
StallReviewAdapter
(
StallViewActivity
.
this
,
reviews
);
lvReviews
.
setAdapter
(
srAdapter
);
getStallReviews
(
id
);
}
}
@Override
@Override
...
@@ -115,6 +116,7 @@ public class StallViewActivity extends AppCompatActivity {
...
@@ -115,6 +116,7 @@ public class StallViewActivity extends AppCompatActivity {
dishes
.
clear
();
dishes
.
clear
();
dishes
.
addAll
(
newDishes
);
dishes
.
addAll
(
newDishes
);
dAdapter
.
notifyDataSetChanged
();
dAdapter
.
notifyDataSetChanged
();
Toast
.
makeText
(
StallViewActivity
.
this
,
newDishes
.
size
()
+
""
,
Toast
.
LENGTH_LONG
).
show
();
}
}
@Override
@Override
...
...
app/src/main/java/com/testapp/entities/Token.java
0 → 100644
View file @
387625c9
package
com
.
testapp
.
entities
;
public
class
Token
{
String
token
;
int
duration
;
public
Token
(
String
token
,
int
duration
)
{
this
.
token
=
token
;
this
.
duration
=
duration
;
}
public
String
getToken
()
{
return
token
;
}
public
void
setToken
(
String
token
)
{
this
.
token
=
token
;
}
}
\ No newline at end of file
app/src/main/res/layout/activity_login.xml
View file @
387625c9
...
@@ -46,11 +46,11 @@
...
@@ -46,11 +46,11 @@
android:layout_height=
"wrap_content"
>
android:layout_height=
"wrap_content"
>
<AutoCompleteTextView
<AutoCompleteTextView
android:id=
"@+id/
email
"
android:id=
"@+id/
username
"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:hint=
"@string/prompt_
email
"
android:hint=
"@string/prompt_
username
"
android:inputType=
"text
EmailAddress
"
android:inputType=
"text"
android:maxLines=
"1"
/>
android:maxLines=
"1"
/>
</android.support.design.widget.TextInputLayout>
</android.support.design.widget.TextInputLayout>
...
...
app/src/main/res/layout/content_stall_view.xml
View file @
387625c9
...
@@ -15,7 +15,10 @@
...
@@ -15,7 +15,10 @@
<ScrollView
<ScrollView
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
android:layout_alignParentTop=
"true"
android:layout_alignParentLeft=
"true"
android:layout_alignParentStart=
"true"
>
<LinearLayout
<LinearLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
@@ -89,8 +92,9 @@
...
@@ -89,8 +92,9 @@
<ListView
<ListView
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"131dp"
android:id=
"@+id/stall_dishes"
/>
android:id=
"@+id/stall_dishes"
android:fadeScrollbars=
"false"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
<LinearLayout
...
@@ -109,8 +113,9 @@
...
@@ -109,8 +113,9 @@
<ListView
<ListView
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"114dp"
android:id=
"@+id/stall_reviews"
/>
android:id=
"@+id/stall_reviews"
android:fadeScrollbars=
"false"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
...
...
app/src/main/res/layout/dish_row.xml
View file @
387625c9
...
@@ -12,19 +12,6 @@
...
@@ -12,19 +12,6 @@
android:layout_alignParentLeft=
"true"
android:layout_alignParentLeft=
"true"
android:layout_alignParentStart=
"true"
/>
android:layout_alignParentStart=
"true"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textAppearance=
"?android:attr/textAppearanceLarge"
android:text=
"Name"
android:id=
"@+id/tvName"
android:layout_marginRight=
"67dp"
android:layout_marginEnd=
"67dp"
android:layout_marginTop=
"17dp"
android:layout_alignParentTop=
"true"
android:layout_alignParentRight=
"true"
android:layout_alignParentEnd=
"true"
/>
<TextView
<TextView
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
...
@@ -35,4 +22,15 @@
...
@@ -35,4 +22,15 @@
android:layout_alignParentEnd=
"true"
android:layout_alignParentEnd=
"true"
android:layout_marginRight=
"16dp"
android:layout_marginRight=
"16dp"
android:layout_marginEnd=
"16dp"
/>
android:layout_marginEnd=
"16dp"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textAppearance=
"?android:attr/textAppearanceLarge"
android:text=
"Name"
android:id=
"@+id/tvName"
android:layout_marginTop=
"16dp"
android:layout_alignParentTop=
"true"
android:layout_alignRight=
"@+id/tvPrice"
android:layout_alignEnd=
"@+id/tvPrice"
/>
</RelativeLayout>
</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