Skip to content

Commit

Permalink
Añadida página producto
Browse files Browse the repository at this point in the history
  • Loading branch information
jalcaldea committed Oct 25, 2014
1 parent 73f72d8 commit 94fe18c
Show file tree
Hide file tree
Showing 10 changed files with 422 additions and 50 deletions.
9 changes: 5 additions & 4 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
Expand All @@ -37,22 +38,22 @@
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
Expand All @@ -79,8 +80,8 @@
</content>
<orderEntry type="jdk" jdkName="Android API 20 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-annotations-20.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-20.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-20.0.0" level="project" />
</component>
</module>

5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
android:name=".User"
android:label="@string/app_name" >

</activity>
<activity
android:name=".Product"
android:label="@string/app_name" >

</activity>
<activity
android:name=".SplashScreenActivity"
Expand Down
199 changes: 199 additions & 0 deletions app/src/main/java/worten/aebd/com/worten/Product.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
package worten.aebd.com.worten;

import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import worten.aebd.com.worten.products.Producto;
import worten.aebd.com.worten.products.Productos;


public class Product extends Activity
implements NavigationDrawerFragment.NavigationDrawerCallbacks {

/**
* Fragment managing the behaviors, interactions and presentation of the navigation drawer.
*/
private NavigationDrawerFragment mNavigationDrawerFragment;

/**
* Used to store the last screen title. For use in {@link #restoreActionBar()}.
*/
private CharSequence mTitle;

private Producto producto;

private TextView nombre;
private TextView desc;
private ImageView imagen;

private boolean cambio = false;

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

mNavigationDrawerFragment = (NavigationDrawerFragment)
getFragmentManager().findFragmentById(R.id.navigation_drawer);

mTitle = getTitle();

// Set up the drawer.
mNavigationDrawerFragment.setUp(
R.id.navigation_drawer,
(DrawerLayout) findViewById(R.id.drawer_layout),1);

Bundle bundle = getIntent().getExtras();
int n = bundle.getInt("producto");
producto = new Productos().getLista().get(n);

/*
mListView = (ListView) findViewById(R.id.product_label);
mListView.setAdapter(new ArrayAdapter<String>(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));
}
}

}
10 changes: 0 additions & 10 deletions app/src/main/java/worten/aebd/com/worten/Scaner.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 21 additions & 31 deletions app/src/main/java/worten/aebd/com/worten/Shop.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand All @@ -43,7 +34,6 @@ public class Shop extends Activity
*/
private NavigationDrawerFragment mNavigationDrawerFragment;


/**
* Used to store the last screen title. For use in {@link #restoreActionBar()}.
*/
Expand Down Expand Up @@ -82,33 +72,27 @@ public void onItemClick(AdapterView<?> pariente, View view, int posicion, long i
}
});*/

ArrayList<Productos> datos = new ArrayList<Productos>();

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()+"€");

}
}
Expand All @@ -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();
}
});

Expand All @@ -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()
Expand All @@ -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(
Expand Down
Loading

0 comments on commit 94fe18c

Please sign in to comment.