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
4f4cf8d4
Commit
4f4cf8d4
authored
Dec 01, 2016
by
Willard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove redundant SearchActivity and related files
parent
7b9c93e2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
176 deletions
+0
-176
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+0
-4
SearchActivity.java
app/src/main/java/com/testapp/SearchActivity.java
+0
-131
activity_search.xml
app/src/main/res/layout/activity_search.xml
+0
-26
content_search.xml
app/src/main/res/layout/content_search.xml
+0
-15
No files found.
app/src/main/AndroidManifest.xml
View file @
4f4cf8d4
...
...
@@ -29,10 +29,6 @@
android:name=
".NavDrawerActivity"
android:label=
"@string/title_activity_nav_drawer"
android:theme=
"@style/AppTheme.NoActionBar"
/>
<activity
android:name=
".SearchActivity"
android:label=
"@string/title_activity_search"
android:theme=
"@style/AppTheme.NoActionBar"
/>
<activity
android:name=
".DishViewActivity"
android:label=
"@string/title_activity_blahblah"
...
...
app/src/main/java/com/testapp/SearchActivity.java
deleted
100644 → 0
View file @
7b9c93e2
package
com
.
testapp
;
import
android.content.Context
;
import
android.os.Bundle
;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.widget.Toolbar
;
import
android.view.View
;
import
android.widget.CheckBox
;
import
android.widget.LinearLayout
;
import
android.widget.ListView
;
import
com.google.gson.Gson
;
import
com.google.gson.GsonBuilder
;
import
com.testapp.entities.Dish
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
okhttp3.Cache
;
import
okhttp3.Interceptor
;
import
okhttp3.OkHttpClient
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
import
retrofit2.Retrofit
;
import
retrofit2.converter.gson.GsonConverterFactory
;
public
class
SearchActivity
extends
AppCompatActivity
{
private
CanteeneoApiInterface
service
;
private
static
Context
c
;
private
DishAdapter
adapter
;
private
ArrayList
<
Dish
>
dishes
=
new
ArrayList
<>();
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_search
);
Toolbar
toolbar
=
(
Toolbar
)
findViewById
(
R
.
id
.
toolbar
);
setSupportActionBar
(
toolbar
);
getSupportActionBar
().
setDisplayHomeAsUpEnabled
(
true
);
getSupportActionBar
().
setDisplayShowHomeEnabled
(
true
);
String
dishName
=
getIntent
().
getStringExtra
(
"query"
);
ListView
lv
=
(
ListView
)
findViewById
(
R
.
id
.
listView
);
adapter
=
new
DishAdapter
(
this
,
dishes
);
lv
.
setAdapter
(
adapter
);
c
=
getApplicationContext
();
File
httpCacheDirectory
=
new
File
(
this
.
getCacheDir
(),
"responses"
);
int
cacheSize
=
10
*
1024
*
1024
;
// 10 MiB
Cache
cache
=
new
Cache
(
httpCacheDirectory
,
cacheSize
);
OkHttpClient
client
=
new
OkHttpClient
().
newBuilder
()
.
addNetworkInterceptor
(
REWRITE_CACHE_CONTROL_INTERCEPTOR
)
.
cache
(
cache
)
.
build
();
Gson
gson
=
new
GsonBuilder
()
.
setDateFormat
(
"yyyy-MM-dd'T'HH:mm:ssZ"
)
.
create
();
Retrofit
retrofit
=
new
Retrofit
.
Builder
()
.
baseUrl
(
"http://"
+
getResources
().
getString
(
R
.
string
.
server_ip
)
+
":5000/"
)
.
client
(
client
)
.
addConverterFactory
(
GsonConverterFactory
.
create
(
gson
))
.
build
();
service
=
retrofit
.
create
(
CanteeneoApiInterface
.
class
);
searchDish
(
dishName
);
}
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
)
{
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
>>()
{
@Override
public
void
onResponse
(
Call
<
List
<
Dish
>>
call
,
Response
<
List
<
Dish
>>
response
)
{
List
<
Dish
>
newDishes
=
response
.
body
();
dishes
.
clear
();
dishes
.
addAll
(
newDishes
);
adapter
.
notifyDataSetChanged
();
}
@Override
public
void
onFailure
(
Call
<
List
<
Dish
>>
call
,
Throwable
t
)
{
}
});
}
private
static
final
Interceptor
REWRITE_CACHE_CONTROL_INTERCEPTOR
=
new
Interceptor
()
{
@Override
public
okhttp3
.
Response
intercept
(
Chain
chain
)
throws
IOException
{
okhttp3
.
Response
origResponse
=
chain
.
proceed
(
chain
.
request
());
if
(
AppUtils
.
isNetworkAvailable
(
c
))
{
int
maxAge
=
60
;
// read from cache for 1 minute
return
origResponse
.
newBuilder
()
.
header
(
"Cache-Control"
,
"public, max-age="
+
maxAge
)
.
build
();
}
else
{
int
maxStale
=
60
*
60
*
24
*
28
;
// tolerate 4-weeks stale
return
origResponse
.
newBuilder
()
.
header
(
"Cache-Control"
,
"public, only-if-cached, max-stale="
+
maxStale
)
.
build
();
}
}
};
}
\ No newline at end of file
app/src/main/res/layout/activity_search.xml
deleted
100644 → 0
View file @
7b9c93e2
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:fitsSystemWindows=
"true"
tools:context=
"com.testapp.SearchActivity"
>
<android.support.design.widget.AppBarLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:theme=
"@style/AppTheme.AppBarOverlay"
>
<android.support.v7.widget.Toolbar
android:id=
"@+id/toolbar"
android:layout_width=
"match_parent"
android:layout_height=
"?attr/actionBarSize"
android:background=
"?attr/colorPrimary"
app:popupTheme=
"@style/AppTheme.PopupOverlay"
/>
</android.support.design.widget.AppBarLayout>
<include
layout=
"@layout/content_search"
/>
</android.support.design.widget.CoordinatorLayout>
app/src/main/res/layout/content_search.xml
deleted
100644 → 0
View file @
7b9c93e2
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/content_search"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:paddingBottom=
"@dimen/activity_vertical_margin"
android:paddingLeft=
"@dimen/activity_horizontal_margin"
android:paddingRight=
"@dimen/activity_horizontal_margin"
android:paddingTop=
"@dimen/activity_vertical_margin"
app:layout_behavior=
"@string/appbar_scrolling_view_behavior"
tools:context=
"com.testapp.SearchActivity"
tools:showIn=
"@layout/activity_search"
>
</RelativeLayout>
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