Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
likorn
/
Lavina
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
dc9497ac
authored
May 14, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
search resuts customized
parent
65bbea72
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
159 additions
and
20 deletions
app/src/main/AndroidManifest.xml
app/src/main/java/com/example/paktalin/lavina/OrderActivity.java
app/src/main/java/com/example/paktalin/lavina/QueryResultsActivity.java
app/src/main/java/com/example/paktalin/lavina/adapters/ExpandableListAdapter.java
app/src/main/res/layout/activity_order.xml
app/src/main/res/layout/activity_search_results.xml
app/src/main/AndroidManifest.xml
View file @
dc9497ac
...
...
@@ -30,6 +30,7 @@
<activity
android:name=
".MapActivity"
/>
<activity
android:name=
".CollectionActivity"
/>
<activity
android:name=
".OrderActivity"
/>
<activity
android:name=
".QueryResultsActivity"
/>
</application>
</manifest>
\ No newline at end of file
app/src/main/java/com/example/paktalin/lavina/OrderActivity.java
View file @
dc9497ac
...
...
@@ -25,7 +25,7 @@ public class OrderActivity extends AppCompatActivity {
ExpandableListView
expListView
;
List
<
String
>
listDataHeader
;
HashMap
<
String
,
List
<
String
>>
listDataChild
;
Bitmap
[]
colorImages
,
countriesImages
;
Bitmap
[]
colorImages
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -36,9 +36,8 @@ public class OrderActivity extends AppCompatActivity {
prepareListData
();
prepareColorImages
();
prepareCountriesImages
();
listAdapter
=
new
ExpandableListAdapter
(
this
,
listDataHeader
,
listDataChild
,
colorImages
,
countriesImages
);
listAdapter
=
new
ExpandableListAdapter
(
this
,
listDataHeader
,
listDataChild
,
colorImages
);
expListView
.
setAdapter
(
listAdapter
);
(
findViewById
(
R
.
id
.
button_proceed
)).
setOnClickListener
(
new
View
.
OnClickListener
()
{
...
...
@@ -50,19 +49,6 @@ public class OrderActivity extends AppCompatActivity {
});
}
private
void
prepareCountriesImages
()
{
countriesImages
=
new
Bitmap
[
9
];
countriesImages
[
0
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
color1
);
countriesImages
[
1
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
color2
);
countriesImages
[
2
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
color3
);
countriesImages
[
3
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
color4
);
countriesImages
[
4
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
color5
);
countriesImages
[
5
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
color6
);
countriesImages
[
6
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
color7
);
countriesImages
[
7
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
color8
);
countriesImages
[
8
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
color9
);
}
private
void
prepareColorImages
()
{
colorImages
=
new
Bitmap
[
9
];
colorImages
[
0
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
color1
);
...
...
app/src/main/java/com/example/paktalin/lavina/QueryResultsActivity.java
View file @
dc9497ac
package
com
.
example
.
paktalin
.
lavina
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.v7.app.AppCompatActivity
;
import
android.widget.ListView
;
import
com.example.paktalin.lavina.adapters.WineAdapterMain
;
/**
* Created by Paktalin on 14/05/2018.
*/
public
class
QueryResultsActivity
extends
AppCompatActivity
{
Bitmap
[]
winePics
;
String
[]
wineTitles
,
winePrices
;
WineBottle
[]
wines
;
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_search_results
);
extractWinePics
();
extractWineTitles
();
extractWinePrices
();
setWineArray
();
WineAdapterMain
adapter
=
new
WineAdapterMain
(
QueryResultsActivity
.
this
,
wines
);
ListView
listView
=
findViewById
(
R
.
id
.
list_view
);
listView
.
setAdapter
(
adapter
);
}
private
void
extractWinePrices
()
{
winePrices
=
new
String
[]
{
"€7.90"
,
"€8.85"
,
"€13.50"
,
"€5.74"
,
"€8.00"
,
"€15.90"
,
"€11.50"
,
"€9.79"
};
}
private
void
setWineArray
()
{
wines
=
new
WineBottle
[
8
];
for
(
int
i
=
0
;
i
<
wines
.
length
;
i
++)
{
wines
[
i
]
=
new
WineBottle
(
wineTitles
[
i
],
winePrices
[
i
],
winePics
[
i
]);
}
}
private
void
extractWineTitles
()
{
wineTitles
=
new
String
[]
{
"Colli Euganei Bianco Olivetani Ca' Lustra 2015"
,
"Pecorino Volo Di Berardino 2017"
,
"Langhe Nebbiolo Bric Cenciurio 2016"
,
"Grignolino Raniero Castello di Gabiano 2016"
,
"Le Fattorie Tenuta di Frassineto 2014"
,
"Doglio La Brugherata 2008"
,
"Lagrein Hofstätter 2016"
,
"Vermentino di Sardegna Cala Silente Santadi 2017"
};
}
private
void
extractWinePics
()
{
winePics
=
new
Bitmap
[
8
];
winePics
[
0
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
wine1
);
winePics
[
1
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
wine2
);
winePics
[
2
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
wine3
);
winePics
[
3
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
wine4
);
winePics
[
4
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
wine5
);
winePics
[
5
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
wine6
);
winePics
[
6
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
wine7
);
winePics
[
7
]
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
wine8
);
}
}
app/src/main/java/com/example/paktalin/lavina/adapters/ExpandableListAdapter.java
View file @
dc9497ac
...
...
@@ -7,6 +7,7 @@ import android.view.LayoutInflater;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.BaseExpandableListAdapter
;
import
android.widget.CheckBox
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
...
...
@@ -14,6 +15,7 @@ import com.example.paktalin.lavina.R;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Random
;
/**
* Created by Paktalin on 14/05/2018.
...
...
@@ -25,15 +27,15 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter {
private
List
<
String
>
_listDataHeader
;
// header titles
// child data in format of header title, child title
private
HashMap
<
String
,
List
<
String
>>
_listDataChild
;
private
Bitmap
[]
colorImages
,
countriesImages
;
private
Bitmap
[]
colorImages
;
private
String
resultString
=
""
;
public
ExpandableListAdapter
(
Context
context
,
List
<
String
>
listDataHeader
,
HashMap
<
String
,
List
<
String
>>
listChildData
,
Bitmap
[]
colorImages
,
Bitmap
[]
countriesImages
)
{
HashMap
<
String
,
List
<
String
>>
listChildData
,
Bitmap
[]
colorImages
)
{
this
.
_context
=
context
;
this
.
_listDataHeader
=
listDataHeader
;
this
.
_listDataChild
=
listChildData
;
this
.
colorImages
=
colorImages
;
this
.
countriesImages
=
countriesImages
;
}
@Override
...
...
@@ -70,9 +72,27 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter {
}
txtListChild
.
setText
(
childText
);
CheckBox
checkBox
=
convertView
.
findViewById
(
R
.
id
.
checkbox
);
checkBox
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Random
r
=
new
Random
();
int
randInt
=
r
.
nextInt
(
150
-
16
)
+
16
;
resultString
=
randInt
+
" results found"
;
}
});
return
convertView
;
}
public
String
getResultString
()
{
return
resultString
;
}
@Override
public
int
getChildrenCount
(
int
groupPosition
)
{
return
this
.
_listDataChild
.
get
(
this
.
_listDataHeader
.
get
(
groupPosition
))
...
...
app/src/main/res/layout/activity_order.xml
View file @
dc9497ac
...
...
@@ -49,7 +49,6 @@
android:id=
"@+id/found"
android:layout_width=
"200dp"
android:layout_height=
"wrap_content"
android:text=
"103 results found"
android:layout_centerVertical=
"true"
android:textSize=
"16dp"
android:textColor=
"@android:color/white"
/>
...
...
app/src/main/res/layout/activity_search_results.xml
0 → 100644
View file @
dc9497ac
<?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:background=
"@drawable/red_background"
>
<RelativeLayout
android:id=
"@+id/header"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
android:background=
"@android:color/transparent"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Select wine"
android:textColor=
"@android:color/white"
android:layout_centerHorizontal=
"true"
android:layout_centerVertical=
"true"
android:textSize=
"20dp"
/>
</RelativeLayout>
<RelativeLayout
android:id=
"@+id/sort_by"
android:layout_width=
"wrap_content"
android:layout_height=
"40dp"
android:layout_below=
"@+id/header"
android:background=
"@android:color/transparent"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"SORT BY"
android:layout_centerVertical=
"true"
android:layout_marginStart=
"20dp"
android:textColor=
"@android:color/white"
android:layout_marginLeft=
"20dp"
/>
<Spinner
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:entries=
"@array/sort_by"
android:layout_centerVertical=
"true"
android:layout_alignParentEnd=
"true"
android:layout_marginEnd=
"20dp"
android:layout_alignParentRight=
"true"
style=
"@style/Widget.MyTheme.HeaderBar.Spinner"
android:layout_marginRight=
"20dp"
/>
</RelativeLayout>
<ListView
android:id=
"@+id/list_view"
android:background=
"@android:color/white"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/sort_by"
>
</ListView>
</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