Commit 65bbea72 by Paktalin

query results activity created

parent 91b25ff1
package com.example.paktalin.lavina; package com.example.paktalin.lavina;
import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ExpandableListView; import android.widget.ExpandableListView;
import com.example.paktalin.lavina.adapters.ExpandableListAdapter; import com.example.paktalin.lavina.adapters.ExpandableListAdapter;
...@@ -23,7 +25,7 @@ public class OrderActivity extends AppCompatActivity { ...@@ -23,7 +25,7 @@ public class OrderActivity extends AppCompatActivity {
ExpandableListView expListView; ExpandableListView expListView;
List<String> listDataHeader; List<String> listDataHeader;
HashMap<String, List<String>> listDataChild; HashMap<String, List<String>> listDataChild;
Bitmap[] colorImages; Bitmap[] colorImages, countriesImages;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -33,13 +35,35 @@ public class OrderActivity extends AppCompatActivity { ...@@ -33,13 +35,35 @@ public class OrderActivity extends AppCompatActivity {
expListView = findViewById(R.id.expandable_list_view); expListView = findViewById(R.id.expandable_list_view);
prepareListData(); prepareListData();
prepareImages(); prepareColorImages();
prepareCountriesImages();
listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild, colorImages); listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild, colorImages, countriesImages);
expListView.setAdapter(listAdapter); expListView.setAdapter(listAdapter);
(findViewById(R.id.button_proceed)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(OrderActivity.this, QueryResultsActivity.class);
startActivity(intent);
}
});
} }
private void prepareImages() { 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 = new Bitmap[9];
colorImages[0] = BitmapFactory.decodeResource(getResources(), R.drawable.color1); colorImages[0] = BitmapFactory.decodeResource(getResources(), R.drawable.color1);
colorImages[1] = BitmapFactory.decodeResource(getResources(), R.drawable.color2); colorImages[1] = BitmapFactory.decodeResource(getResources(), R.drawable.color2);
...@@ -53,7 +77,7 @@ public class OrderActivity extends AppCompatActivity { ...@@ -53,7 +77,7 @@ public class OrderActivity extends AppCompatActivity {
} }
private void prepareHeadersData() { private void prepareHeadersData() {
String[] groups = new String[] {"COLOR", "BRAND", "PRICE", "YEAR", "STRENGTH", "COUNTRY", String[] groups = new String[] {"COLOR", "BRAND", "PRICE", "YEAR", "STRENGTH", "REGION",
"TITLE", "TYPE", "VARIETY"}; "TITLE", "TYPE", "VARIETY"};
listDataHeader = new ArrayList<>(); listDataHeader = new ArrayList<>();
listDataHeader.addAll(Arrays.asList(groups)); listDataHeader.addAll(Arrays.asList(groups));
...@@ -77,7 +101,10 @@ public class OrderActivity extends AppCompatActivity { ...@@ -77,7 +101,10 @@ public class OrderActivity extends AppCompatActivity {
"2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018")); "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018"));
List<String> strengths = new ArrayList<>(); List<String> strengths = new ArrayList<>();
List<String> countries = new ArrayList<>(); List<String> regions = new ArrayList<>();
regions.addAll(Arrays.asList("Abruzzo", "Apulia", "Basilicata", "Calabria", "Campania",
"Emilia-Romagna", "Friuli-Venezia Giulia"));
List<String> titles = new ArrayList<>(); List<String> titles = new ArrayList<>();
List<String> types = new ArrayList<>(); List<String> types = new ArrayList<>();
...@@ -91,7 +118,7 @@ public class OrderActivity extends AppCompatActivity { ...@@ -91,7 +118,7 @@ public class OrderActivity extends AppCompatActivity {
listDataChild.put(listDataHeader.get(2), prices); listDataChild.put(listDataHeader.get(2), prices);
listDataChild.put(listDataHeader.get(3), years); listDataChild.put(listDataHeader.get(3), years);
listDataChild.put(listDataHeader.get(4), strengths); listDataChild.put(listDataHeader.get(4), strengths);
listDataChild.put(listDataHeader.get(5), countries); listDataChild.put(listDataHeader.get(5), regions);
listDataChild.put(listDataHeader.get(6), titles); listDataChild.put(listDataHeader.get(6), titles);
listDataChild.put(listDataHeader.get(7), types); listDataChild.put(listDataHeader.get(7), types);
listDataChild.put(listDataHeader.get(8), varieties); listDataChild.put(listDataHeader.get(8), varieties);
......
package com.example.paktalin.lavina;
import android.support.v7.app.AppCompatActivity;
/**
* Created by Paktalin on 14/05/2018.
*/
public class QueryResultsActivity extends AppCompatActivity {
}
...@@ -3,7 +3,6 @@ package com.example.paktalin.lavina.adapters; ...@@ -3,7 +3,6 @@ package com.example.paktalin.lavina.adapters;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -26,14 +25,15 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter { ...@@ -26,14 +25,15 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter {
private List<String> _listDataHeader; // header titles private List<String> _listDataHeader; // header titles
// child data in format of header title, child title // child data in format of header title, child title
private HashMap<String, List<String>> _listDataChild; private HashMap<String, List<String>> _listDataChild;
Bitmap[] colorImages; private Bitmap[] colorImages, countriesImages;
public ExpandableListAdapter(Context context, List<String> listDataHeader, public ExpandableListAdapter(Context context, List<String> listDataHeader,
HashMap<String, List<String>> listChildData, Bitmap[] colorImages) { HashMap<String, List<String>> listChildData, Bitmap[] colorImages, Bitmap[] countriesImages) {
this._context = context; this._context = context;
this._listDataHeader = listDataHeader; this._listDataHeader = listDataHeader;
this._listDataChild = listChildData; this._listDataChild = listChildData;
this.colorImages = colorImages; this.colorImages = colorImages;
this.countriesImages = countriesImages;
} }
@Override @Override
...@@ -62,11 +62,8 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter { ...@@ -62,11 +62,8 @@ public class ExpandableListAdapter extends BaseExpandableListAdapter {
String group = (String)getGroup(groupPosition); String group = (String)getGroup(groupPosition);
Log.d("TEST", "current group" + group);
ImageView imageView = convertView.findViewById(R.id.image_item); ImageView imageView = convertView.findViewById(R.id.image_item);
if (group.equals("COLOR")) { if (group.equals("COLOR")) {
Log.d("TEST", "wohoo");
imageView.setImageBitmap(colorImages[childPosition]); imageView.setImageBitmap(colorImages[childPosition]);
} else { } else {
imageView.setImageResource(android.R.color.transparent); imageView.setImageResource(android.R.color.transparent);
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
android:textColor="@android:color/white"/> android:textColor="@android:color/white"/>
<Button <Button
android:id="@+id/button_proceed"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Proceed" android:text="Proceed"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment