Skip to content

Commit

Permalink
Merge branch 'PantallaPrincipal'
Browse files Browse the repository at this point in the history
  • Loading branch information
Franverri committed Oct 11, 2017
2 parents 4dc5a60 + 90b0f7c commit b61c46e
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 13 deletions.
20 changes: 20 additions & 0 deletions FIUBER/app/src/main/java/com/taller/fiuber/Car.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.taller.fiuber;

public class Car {

String modelo;
Integer imagen;

public Car(String modelo, Integer imagen) {
this.modelo = modelo;
this.imagen = imagen;
}

public String getModelo() {
return modelo;
}

public Integer getImagen() {
return imagen;
}
}
21 changes: 19 additions & 2 deletions FIUBER/app/src/main/java/com/taller/fiuber/CarAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@ public class CarAdapter extends BaseAdapter {

private Context context;
private List<Integer> images;
private List<Car> autos;

/*
public CarAdapter(Context context, List<Integer> images) {
this.context = context;
this.images = images;
}*/

public CarAdapter(Context context, List<Car> autos) {
this.context = context;
this.autos = autos;
}

@Override
public int getCount() {
return images.size();
//return images.size();
return autos.size();
}

@Override
Expand All @@ -33,12 +41,21 @@ public long getItemId(int i) {
return i;
}

public Integer getCarImage(int i){
return autos.get(i).getImagen();
}

public String getCarTitle(int i){
return autos.get(i).getModelo();
}

@Override
public View getView(int i, View view, ViewGroup viewGroup) {
if(view == null){
view = LayoutInflater.from(context).inflate(R.layout.car_item, viewGroup, false);
}
view.setBackgroundResource(images.get(i));
//view.setBackgroundResource(images.get(i));
view.setBackgroundResource(getCarImage(i));
return view;
}
}
26 changes: 15 additions & 11 deletions FIUBER/app/src/main/java/com/taller/fiuber/CarsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,29 @@ public class CarsActivity extends AppCompatActivity {
InfiniteCardView infiniteCardView;
CarAdapter carAdapter;
List<Integer> images = new ArrayList<>();
List<Car> autos = new ArrayList<>();
int indice;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cars_acctivity);
setContentView(R.layout.activity_cars);

btnNext = (Button) findViewById(R.id.cars_next);
btnSelect = (Button) findViewById(R.id.cars_select);
infiniteCardView = (InfiniteCardView) findViewById(R.id.cars_view);
carsTitle = (TextView) findViewById(R.id.cars_title);

//Seteo el primer nombre de titulo
carsTitle.setText("Auto 0");

//Creo la lista de autos junto con su indice
indice = 0;
images.add(R.drawable.auto1);
images.add(R.drawable.auto2);
images.add(R.drawable.auto3);
Car auto1 = new Car("Auto naranja", R.drawable.auto1);
Car auto2 = new Car("Auto rojo", R.drawable.auto2);
Car auto3 = new Car("Auto azul", R.drawable.auto3);
autos.add(auto1);
autos.add(auto2);
autos.add(auto3);

carAdapter = new CarAdapter(this, images);
carAdapter = new CarAdapter(this, autos);
infiniteCardView.setClickable(true);
infiniteCardView.setAnimType(InfiniteCardView.ANIM_TYPE_FRONT);
infiniteCardView.setAnimInterpolator(new LinearInterpolator());
Expand All @@ -55,6 +56,10 @@ protected void onCreate(Bundle savedInstanceState) {
infiniteCardView.setZIndexTransformerToBack(new DefaultZIndexTransformerCommon());
infiniteCardView.setAdapter(carAdapter);

//Seteo el nombre del primer a auto
String nombrePrimero = carAdapter.getCarTitle(indice);
carsTitle.setText(nombrePrimero);

//Click en "Siguiente"
btnNext.setOnClickListener(new View.OnClickListener() {
@Override
Expand All @@ -65,16 +70,15 @@ public void onClick(View view) {
} else {
indice --;
}
Log.v(TAG, "Auto "+ indice);
carsTitle.setText("Auto "+ indice);
carsTitle.setText(carAdapter.getCarTitle(indice));
}
});

//Click en "Seleccionar auto"
btnSelect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.v(TAG, "Auto "+ indice +" seleccionado.");
Log.v(TAG, carAdapter.getCarTitle(indice) +" seleccionado.");
}
});

Expand Down
58 changes: 58 additions & 0 deletions FIUBER/app/src/main/res/layout/activity_cars.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:background="@drawable/fondoautos"
android:orientation="vertical"
tools:context="com.taller.fiuber.CarsActivity">

<TextView
android:id="@+id/cars_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Auto X"
android:textSize="30dp"
android:layout_marginBottom="50dp"
android:textStyle="bold" />

<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_horizontal_margin">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<com.bakerj.infinitecards.InfiniteCardView
android:id="@+id/cars_view"
android:layout_width="380dp"
android:layout_height="400dp"
android:layout_gravity="center"
app:animDuration="1000"
app:cardRatio="1">

</com.bakerj.infinitecards.InfiniteCardView>

</LinearLayout>

</android.support.v7.widget.CardView>

<Button
android:id="@+id/cars_next"
android:layout_marginTop="60dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Siguiente" />

<Button
android:id="@+id/cars_select"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Seleccionar auto" />

</LinearLayout>

0 comments on commit b61c46e

Please sign in to comment.