Commit b4d22dc8 by Paktalin

activity collection created

parent 641df47b
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;
/**
* Created by Paktalin on 14/05/2018.
*/
public class CollectionActivity extends AppCompatActivity {
Bitmap[] winePics;
String[] wineTitles, winePrices;
WineBottle[] wines;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_collection);
extractWinePics();
extractWineTitles();
extractWinePrices();
setWineArray();
WineAdapterCollection adapter = new WineAdapterCollection(CollectionActivity.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);
}
}
......@@ -17,7 +17,6 @@ import android.widget.ListView;
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
Bitmap[] winePics;
String[] wineTitles, winePrices;
WineBottle[] wines;
......@@ -33,7 +32,7 @@ public class MainActivity extends AppCompatActivity
setWineArray();
WineAdapter adapter = new WineAdapter(MainActivity.this, wines);
WineAdapterMain adapter = new WineAdapterMain(MainActivity.this, wines);
ListView listView = findViewById(R.id.list_view);
listView.setAdapter(adapter);
......@@ -139,6 +138,8 @@ public class MainActivity extends AppCompatActivity
} else if (id == R.id.wine) {
} else if (id == R.id.collection) {
Intent intent = new Intent(MainActivity.this, CollectionActivity.class);
startActivity(intent);
} else if (id == R.id.community) {
......
......@@ -12,6 +12,6 @@ public class MapActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_activity);
setContentView(R.layout.activity_map);
}
}
......@@ -12,12 +12,12 @@ import android.widget.TextView;
* Created by Paktalin on 14/05/2018.
*/
public class WineAdapter extends BaseAdapter {
public class WineAdapterCollection extends BaseAdapter {
private LayoutInflater inflater;
private WineBottle[] wines;
WineAdapter(Context context, WineBottle[] wines) {
WineAdapterCollection(Context context, WineBottle[] wines) {
this.wines = wines;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
......@@ -42,7 +42,7 @@ public class WineAdapter extends BaseAdapter {
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.wine_item, null);
convertView = inflater.inflate(R.layout.item_wine_main, null);
}
WineBottle bottle = (WineBottle)getItem(position);
......
package com.example.paktalin.lavina;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
/**
* Created by Paktalin on 14/05/2018.
*/
public class WineAdapterMain extends BaseAdapter {
private LayoutInflater inflater;
private WineBottle[] wines;
WineAdapterMain(Context context, WineBottle[] wines) {
this.wines = wines;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return wines.length;
}
@Override
public Object getItem(int position) {
return wines[position];
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.item_wine_main, null);
}
WineBottle bottle = (WineBottle)getItem(position);
((TextView)convertView.findViewById(R.id.wine_title)).setText(bottle.getTitle());
((TextView)convertView.findViewById(R.id.wine_price)).setText(bottle.getPrice());
((ImageView)convertView.findViewById(R.id.wine_image)).setImageBitmap(bottle.getImage());
return convertView;
}
}
<?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="My collection"
android:textColor="@android:color/white"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textSize="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/header">
</ListView>
</RelativeLayout>
\ No newline at end of file
......@@ -5,7 +5,7 @@
android:background="@drawable/red_background">
<RelativeLayout
android:id="@+id/map_title"
android:id="@+id/header"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="50dp"
......@@ -23,7 +23,7 @@
<ImageView
android:id="@+id/imageView2"
android:layout_below="@+id/map_title"
android:layout_below="@+id/header"
android:layout_width="400dp"
android:layout_height="match_parent"
android:background="@drawable/locationmap1"
......
<?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="100dp"
android:padding="10dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/wine_image"
android:layout_toRightOf="@+id/wine_image">
<TextView
android:id="@+id/wine_title"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:textColor="@color/colorPrimaryDark"
android:textSize="14sp"
android:layout_marginLeft="20dp" />
<TextView
android:id="@+id/wine_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/wine_title"
android:textColor="@color/colorPrimary"
android:layout_marginTop="5dp"
android:textStyle="bold"
android:textSize="20sp"
android:layout_alignLeft="@+id/wine_title" />
</RelativeLayout>
<ImageView
android:id="@+id/wine_image"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerVertical="true" />
<ImageButton
android:id="@+id/arrow"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="10dp"
android:background="@drawable/order_button3"
android:layout_marginRight="30dp"
android:layout_alignParentRight="true" />
</RelativeLayout>
\ No newline at end of file
......@@ -15,7 +15,7 @@
<item
android:id="@+id/collection"
android:icon="@drawable/favorites_icon"
android:title="Your collection" />
android:title="My collection" />
<item
android:id="@+id/community"
android:icon="@drawable/community_icon"
......
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