Skip to content

Commit

Permalink
Scaner Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jalcaldea committed Oct 25, 2014
1 parent bfc775a commit f557d4a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 32 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/worten/aebd/com/worten/Carro.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ public static ArrayList<Producto> getCarro(){
return carro;
}

public static String tString(){

return "Carro ("+getCarro().size()+")";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class NavigationDrawerFragment extends Fragment {
private boolean mFromSavedInstanceState;
//private String[] categorias = {"Imagen y sonido", "Pequeños electrodomésticos", "Informatica", "Fotografía y Revelado","Telefonía","Juegos y Consolas","Electrodomésticos"};

private String[] actividades = {"Tienda","Escanear","Cazadescuentos","Usuario", "Carro"};
private String[] actividades = {"Tienda","Escanear","Cazadescuentos","Usuario", Carro.tString()};

private boolean mUserLearnedDrawer;
public NavigationDrawerFragment() {
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/worten/aebd/com/worten/Product.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ public void onClick(View v) {
toast.show();

Carro.add(producto);

Intent mainIntent = new Intent();
mainIntent = new Intent().setClass(
Product.this, Shop.class);
startActivity(mainIntent);

}
});

Expand Down
59 changes: 28 additions & 31 deletions app/src/main/java/worten/aebd/com/worten/Scaner.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;

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

Expand All @@ -31,7 +29,6 @@ public class Scaner extends Activity
* Fragment managing the behaviors, interactions and presentation of the navigation drawer.
*/
private NavigationDrawerFragment mNavigationDrawerFragment;
static final int REQUEST_IMAGE_CAPTURE = 1;

/**
* Used to store the last screen title. For use in {@link #restoreActionBar()}.
Expand All @@ -43,14 +40,14 @@ public class Scaner extends Activity
private TextView nombre;
private TextView desc;
private ImageView imagen;


private Button juego;
private Button buy;
private Button follow;
private Button opinion;


static final int REQUEST_IMAGE_CAPTURE = 1;

private boolean cambio = false;

@Override
Expand All @@ -77,6 +74,7 @@ protected void onCreate(Bundle savedInstanceState) {
}



/*
mListView = (ListView) findViewById(R.id.product_label);
mListView.setAdapter(new ArrayAdapter<String>(getActionBar().getThemedContext(),
Expand Down Expand Up @@ -115,6 +113,26 @@ public void onClick(View v) {
}
});

buy = (Button) findViewById(R.id.button2);

buy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CharSequence texto = "Has añadido "+producto.get_Nombre()+" a tu carro.";
Toast toast = Toast.makeText(Scaner.this, texto, Toast.LENGTH_LONG);
toast.show();

Carro.add(producto);

Intent mainIntent = new Intent();
mainIntent = new Intent().setClass(
Scaner.this, Shop.class);
startActivity(mainIntent);

}
});


}

@Override
Expand All @@ -129,8 +147,9 @@ public void onNavigationDrawerItemSelected(int position) {

public void onSectionAttached(int number) {
if(cambio){
Intent mainIntent = new Intent();

if(Session.isLogin()){
Intent mainIntent = new Intent();
switch (number) {
case 1:
mainIntent = new Intent().setClass(
Expand All @@ -152,14 +171,9 @@ public void onSectionAttached(int number) {
Scaner.this, User.class);
startActivity(mainIntent);
break;
case 5:
mainIntent = new Intent().setClass(
Scaner.this, Compra.class);
startActivity(mainIntent);
break;
default:break;
}}else{

Intent mainIntent = new Intent();
switch (number) {
case 1:
mainIntent = new Intent().setClass(
Expand All @@ -181,20 +195,10 @@ public void onSectionAttached(int number) {
Scaner.this, Login.class);
startActivity(mainIntent);
break;
case 5:
mainIntent = new Intent().setClass(
Scaner.this, Login.class);
startActivity(mainIntent);
break;
default:break;
}






}}else{
}
}else{
cambio = true;
}
}
Expand Down Expand Up @@ -235,12 +239,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
Toast toast = Toast.makeText(Scaner.this, texto, Toast.LENGTH_LONG);
toast.show();

Intent mainIntent = new Intent();
mainIntent = new Intent().setClass(
Scaner.this, Shop.class);
startActivity(mainIntent);
finish();

return true;
}
return super.onOptionsItemSelected(item);
Expand Down Expand Up @@ -286,5 +284,4 @@ public void onAttach(Activity activity) {
}
}


}

0 comments on commit f557d4a

Please sign in to comment.