diff --git a/app/app.iml b/app/app.iml
index 17f3d39..de41f2f 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -13,6 +13,7 @@
+
@@ -37,22 +38,22 @@
+
-
+
-
+
-
@@ -79,8 +80,8 @@
-
+
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 189f773..3a0e3d4 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -27,6 +27,11 @@
android:name=".User"
android:label="@string/app_name" >
+
+
+
(getActionBar().getThemedContext(),
+ android.R.layout.simple_list_item_1, categorias));
+
+ mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> pariente, View view, int posicion, long id) {
+ String elegido = (String) pariente.getItemAtPosition(posicion);
+
+ CharSequence texto = "Seleccionado: " + elegido;
+ Toast toast = Toast.makeText(Shop.this, texto, Toast.LENGTH_LONG);
+ toast.show();
+ }
+ });*/
+
+
+ nombre = (TextView) findViewById(R.id.nombre);
+ nombre.setText((CharSequence) producto.get_Nombre());
+
+ desc = (TextView) findViewById(R.id.desc);
+ desc.setText((CharSequence) producto.getDesc());
+
+ imagen = (ImageView) findViewById(R.id.imageView);
+ if (imagen != null)
+ imagen.setImageResource(producto.get_idImagen());
+
+
+ }
+
+ @Override
+ public void onNavigationDrawerItemSelected(int position) {
+ // update the main content by replacing fragments
+ FragmentManager fragmentManager = getFragmentManager();
+ fragmentManager.beginTransaction()
+ .replace(R.id.container, PlaceholderFragment.newInstance(position + 1))
+ .commit();
+
+ }
+
+ public void onSectionAttached(int number) {
+ if(cambio){
+ Intent mainIntent = new Intent();
+ switch (number) {
+ case 2:
+ mainIntent = new Intent().setClass(
+ Product.this, Scaner.class);
+ startActivity(mainIntent);
+ break;
+ case 3:
+ mainIntent = new Intent().setClass(
+ Product.this, Games.class);
+ startActivity(mainIntent);
+ break;
+ case 4:
+ mainIntent = new Intent().setClass(
+ Product.this, User.class);
+ startActivity(mainIntent);
+ break;
+ }}else{
+ cambio = true;
+ }
+ }
+
+ public void restoreActionBar() {
+ ActionBar actionBar = getActionBar();
+ actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
+ actionBar.setDisplayShowTitleEnabled(true);
+ actionBar.setTitle(mTitle);
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ if (!mNavigationDrawerFragment.isDrawerOpen()) {
+ // Only show items in the action bar relevant to this screen
+ // if the drawer is not showing. Otherwise, let the drawer
+ // decide what to show in the action bar.
+ getMenuInflater().inflate(R.menu.shop, menu);
+ restoreActionBar();
+ return true;
+ }
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+ if (id == R.id.action_settings) {
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ /**
+ * A placeholder fragment containing a simple view.
+ */
+ public static class PlaceholderFragment extends Fragment {
+ /**
+ * The fragment argument representing the section number for this
+ * fragment.
+ */
+ private static final String ARG_SECTION_NUMBER = "section_number";
+
+ /**
+ * Returns a new instance of this fragment for the given section
+ * number.
+ */
+ public static PlaceholderFragment newInstance(int sectionNumber) {
+ PlaceholderFragment fragment = new PlaceholderFragment();
+ Bundle args = new Bundle();
+ args.putInt(ARG_SECTION_NUMBER, sectionNumber);
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ public PlaceholderFragment() {
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.fragment_shop, container, false);
+ return rootView;
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ ((Product) activity).onSectionAttached(
+ getArguments().getInt(ARG_SECTION_NUMBER));
+ }
+ }
+
+}
diff --git a/app/src/main/java/worten/aebd/com/worten/Scaner.java b/app/src/main/java/worten/aebd/com/worten/Scaner.java
index 1dafaa8..296f967 100644
--- a/app/src/main/java/worten/aebd/com/worten/Scaner.java
+++ b/app/src/main/java/worten/aebd/com/worten/Scaner.java
@@ -13,16 +13,6 @@
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import java.util.ArrayList;
-
-import worten.aebd.com.worten.adapter.ListAdapter;
public class Scaner extends Activity
diff --git a/app/src/main/java/worten/aebd/com/worten/Shop.java b/app/src/main/java/worten/aebd/com/worten/Shop.java
index 9b8621c..02e4604 100644
--- a/app/src/main/java/worten/aebd/com/worten/Shop.java
+++ b/app/src/main/java/worten/aebd/com/worten/Shop.java
@@ -1,21 +1,12 @@
package worten.aebd.com.worten;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-
import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Intent;
-import android.hardware.Camera;
import android.os.Bundle;
-import android.os.Environment;
-import android.provider.MediaStore;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@@ -30,9 +21,9 @@
import android.widget.AdapterView.OnItemClickListener;
-import worten.aebd.com.worten.adapter.ListAdapter;
-
-import static android.hardware.Camera.PictureCallback;
+import worten.aebd.com.worten.products.ListAdapter;
+import worten.aebd.com.worten.products.Producto;
+import worten.aebd.com.worten.products.Productos;
public class Shop extends Activity
@@ -43,7 +34,6 @@ public class Shop extends Activity
*/
private NavigationDrawerFragment mNavigationDrawerFragment;
-
/**
* Used to store the last screen title. For use in {@link #restoreActionBar()}.
*/
@@ -82,33 +72,27 @@ public void onItemClick(AdapterView> pariente, View view, int posicion, long i
}
});*/
- ArrayList datos = new ArrayList();
-
- datos.add(new Productos(R.drawable.im_mac, "MacBook Air 13,3'' APPLE MD760B 128 GB", "Intel Core i5 / Disco Duro 128 GB / RAM 4 GB / OS X Mavericks", 888, "pepe"));
- datos.add(new Productos(R.drawable.im_hdd, "Disco Duro Portátil 1 TB WESTERN DIGITAL My Passport Ultra Metal Azul", "1 TB / USB 3.0",67.99,"pepe"));
- datos.add(new Productos(R.drawable.im_lavadora, "Lavadora LG F1296QDP7", "",524,"pepe"));
- datos.add(new Productos(R.drawable.im_lavadora, "TV OLED LG Smart TV 3D 55'' 55EA980V", "Televisor de última generación",2499,"pepe"));
mListView = (ListView) findViewById(R.id.product_label);
- mListView.setAdapter(new ListAdapter(this, R.layout.entrada, datos){
+ mListView.setAdapter(new ListAdapter(this, R.layout.entrada, new Productos().getLista()){
@Override
public void onEntrada(Object entrada, View view) {
if (entrada != null) {
TextView texto_superior_entrada = (TextView) view.findViewById(R.id.textView_superior);
if (texto_superior_entrada != null)
- texto_superior_entrada.setText(((Productos) entrada).get_Nombre());
+ texto_superior_entrada.setText(((Producto) entrada).get_Nombre());
TextView texto_inferior_entrada = (TextView) view.findViewById(R.id.textView_inferior);
if (texto_inferior_entrada != null)
- texto_inferior_entrada.setText(((Productos) entrada).get_textoDebajo());
+ texto_inferior_entrada.setText(((Producto) entrada).get_textoDebajo());
ImageView imagen_entrada = (ImageView) view.findViewById(R.id.imageView_imagen);
if (imagen_entrada != null)
- imagen_entrada.setImageResource(((Productos) entrada).get_idImagen());
+ imagen_entrada.setImageResource(((Producto) entrada).get_idImagen());
TextView texto_precio = (TextView) view.findViewById(R.id.textView_precio);
if (texto_precio != null)
- texto_precio.setText(((Productos) entrada).getPrecio()+"€");
+ texto_precio.setText(((Producto) entrada).getPrecio()+"€");
}
}
@@ -117,11 +101,20 @@ public void onEntrada(Object entrada, View view) {
mListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView> pariente, View view, int posicion, long id) {
- Productos elegido = (Productos) pariente.getItemAtPosition(posicion);
+ Producto elegido = (Producto) pariente.getItemAtPosition(posicion);
- CharSequence texto = "Seleccionado: " + elegido.get_textoDebajo();
- Toast toast = Toast.makeText(Shop.this, texto, Toast.LENGTH_LONG);
- toast.show();
+ // pariente
+
+
+ Intent mainIntent = new Intent();
+ mainIntent = new Intent().setClass(
+ Shop.this, Product.class);
+ mainIntent.putExtra("producto", elegido.getId());
+ startActivity(mainIntent);
+
+ // CharSequence texto = "Seleccionado: " + elegido.get_textoDebajo();
+ //Toast toast = Toast.makeText(Shop.this, texto, Toast.LENGTH_LONG);
+ //toast.show();
}
});
@@ -131,7 +124,6 @@ public void onItemClick(AdapterView> pariente, View view, int posicion, long i
@Override
public void onNavigationDrawerItemSelected(int position) {
-
// update the main content by replacing fragments
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
@@ -144,11 +136,9 @@ public void onSectionAttached(int number) {
Intent mainIntent = new Intent();
switch (number) {
case 2:
-
mainIntent = new Intent().setClass(
Shop.this, Scaner.class);
startActivity(mainIntent);
-
break;
case 3:
mainIntent = new Intent().setClass(
diff --git a/app/src/main/java/worten/aebd/com/worten/adapter/ListAdapter.java b/app/src/main/java/worten/aebd/com/worten/products/ListAdapter.java
similarity index 97%
rename from app/src/main/java/worten/aebd/com/worten/adapter/ListAdapter.java
rename to app/src/main/java/worten/aebd/com/worten/products/ListAdapter.java
index dd6b86a..55a282b 100644
--- a/app/src/main/java/worten/aebd/com/worten/adapter/ListAdapter.java
+++ b/app/src/main/java/worten/aebd/com/worten/products/ListAdapter.java
@@ -1,4 +1,4 @@
-package worten.aebd.com.worten.adapter;
+package worten.aebd.com.worten.products;
/**
* Created by jesus on 25/10/14.
diff --git a/app/src/main/java/worten/aebd/com/worten/Productos.java b/app/src/main/java/worten/aebd/com/worten/products/Producto.java
similarity index 76%
rename from app/src/main/java/worten/aebd/com/worten/Productos.java
rename to app/src/main/java/worten/aebd/com/worten/products/Producto.java
index c38bb62..9e8d357 100644
--- a/app/src/main/java/worten/aebd/com/worten/Productos.java
+++ b/app/src/main/java/worten/aebd/com/worten/products/Producto.java
@@ -1,17 +1,19 @@
-package worten.aebd.com.worten;
+package worten.aebd.com.worten.products;
/**
* Created by jesus on 25/10/14.
*/
-public class Productos {
+public class Producto {
private int idImagen;
+ private int id;
private String nombre;
private String desc;
private double precio;
private String categorias;
- public Productos (int idImagen, String nombre, String desc,double precio,String categorias) {
+ public Producto(int id, int idImagen, String nombre, String desc, double precio, String categorias) {
+ this.id = id;
this.idImagen = idImagen;
this.nombre = nombre;
this.desc = desc;
@@ -50,4 +52,8 @@ public double getPrecio() {
public String getCategorias() {
return categorias;
}
+
+ public int getId() {
+ return id;
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/worten/aebd/com/worten/products/Productos.java b/app/src/main/java/worten/aebd/com/worten/products/Productos.java
new file mode 100644
index 0000000..447f0f9
--- /dev/null
+++ b/app/src/main/java/worten/aebd/com/worten/products/Productos.java
@@ -0,0 +1,42 @@
+package worten.aebd.com.worten.products;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import worten.aebd.com.worten.Product;
+import worten.aebd.com.worten.R;
+
+/**
+ * Created by jesus on 25/10/14.
+ */
+public class Productos {
+
+ private ArrayList lista;
+ private Producto selected;
+
+ public Productos(){
+
+ lista = new ArrayList();
+
+ getLista().add(new Producto(0, R.drawable.im_mac, "MacBook Air 13,3'' APPLE MD760B 128 GB", "Intel Core i5 / Disco Duro 128 GB / RAM 4 GB / OS X Mavericks", 888, "pepe"));
+ getLista().add(new Producto(1, R.drawable.im_hdd, "Disco Duro Portátil 1 TB WESTERN DIGITAL My Passport Ultra Metal Azul", "1 TB / USB 3.0", 67.99, "pepe"));
+ getLista().add(new Producto(2, R.drawable.im_lavadora, "Lavadora LG F1296QDP7", "", 524, "pepe"));
+ getLista().add(new Producto(3, R.drawable.im_tv, "TV OLED LG Smart TV 3D 55'' 55EA980V", "Televisor de última generación", 2499, "pepe"));
+
+
+ }
+
+ public ArrayList getLista() {
+ return lista;
+ }
+
+ public void setSelected(Producto selected){
+ this.selected = selected;
+ }
+
+ public Producto getSelected(){
+ return selected;
+ }
+
+
+}
diff --git a/app/src/main/res/layout/activity_product.xml b/app/src/main/res/layout/activity_product.xml
new file mode 100644
index 0000000..7eb55ff
--- /dev/null
+++ b/app/src/main/res/layout/activity_product.xml
@@ -0,0 +1,140 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_shop.xml b/app/src/main/res/layout/activity_shop.xml
index 2ff5496..91bf0d0 100644
--- a/app/src/main/res/layout/activity_shop.xml
+++ b/app/src/main/res/layout/activity_shop.xml
@@ -18,7 +18,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
-
android:id="@+id/product_label"
/>