Skip to content

Commit

Permalink
Login mejorado
Browse files Browse the repository at this point in the history
  • Loading branch information
jalcaldea committed Oct 25, 2014
1 parent 0df3b07 commit 7dcd6e3
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 46 deletions.
9 changes: 1 addition & 8 deletions app/src/main/java/worten/aebd/com/worten/Games.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public class Games extends Activity

private boolean cambio = false;

private boolean login;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -57,9 +56,6 @@ protected void onCreate(Bundle savedInstanceState) {
R.id.navigation_drawer,
(DrawerLayout) findViewById(R.id.drawer_layout),2);

Bundle bundle = getIntent().getExtras();
login = bundle.getBoolean("login");


/*
mListView = (ListView) findViewById(R.id.product_label);
Expand Down Expand Up @@ -136,24 +132,21 @@ public void onNavigationDrawerItemSelected(int position) {
public void onSectionAttached(int number) {
if(cambio){
Intent mainIntent = new Intent();
if(login){
if(Session.isLogin()){
switch (number) {
case 1:
mainIntent = new Intent().setClass(
Games.this, Shop.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
case 2:
mainIntent = new Intent().setClass(
Games.this, Scaner.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
case 4:
mainIntent = new Intent().setClass(
Games.this, User.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
}}else{
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/java/worten/aebd/com/worten/Login.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class Login extends Activity
*/
private CharSequence mTitle;

private boolean login;

private Button enter;

Expand All @@ -54,18 +53,22 @@ protected void onCreate(Bundle savedInstanceState) {
enter.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Session.initSesion();
CharSequence texto = "Has añadido iniciado sesión correctamente.";
Toast toast = Toast.makeText(Login.this, texto, Toast.LENGTH_LONG);
toast.show();
Intent mainIntent = new Intent();
mainIntent = new Intent().setClass(
Login.this, Shop.class);
mainIntent.putExtra("login",true);
startActivity(mainIntent);
finish();

}
});
/*
int t = (Session.isLogin() ? View.VISIBLE:View.INVISIBLE);
getActionBar().getCustomView().findViewById(R.id.close_settings).setVisibility(t);*/

/*
mListView = (ListView) findViewById(R.id.product_label);
Expand Down Expand Up @@ -101,7 +104,7 @@ public void onNavigationDrawerItemSelected(int position) {
public void onSectionAttached(int number) {
if(cambio){
Intent mainIntent = new Intent();
if(login){
if(Session.isLogin()){
switch (number) {
case 1:
mainIntent = new Intent().setClass(
Expand Down
9 changes: 1 addition & 8 deletions app/src/main/java/worten/aebd/com/worten/Product.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class Product extends Activity
private Button follow;
private Button opinion;

private boolean login;

private boolean cambio = false;

Expand All @@ -68,8 +67,6 @@ protected void onCreate(Bundle savedInstanceState) {
producto = new Productos().getLista().get(n);


login = bundle.getBoolean("login");

/*
mListView = (ListView) findViewById(R.id.product_label);
mListView.setAdapter(new ArrayAdapter<String>(getActionBar().getThemedContext(),
Expand Down Expand Up @@ -124,31 +121,27 @@ public void onNavigationDrawerItemSelected(int position) {
public void onSectionAttached(int number) {
if(cambio){

if(login){
if(Session.isLogin()){
Intent mainIntent = new Intent();
switch (number) {
case 1:
mainIntent = new Intent().setClass(
Product.this, Shop.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
case 2:
mainIntent = new Intent().setClass(
Product.this, Scaner.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
case 3:
mainIntent = new Intent().setClass(
Product.this, Games.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
case 4:
mainIntent = new Intent().setClass(
Product.this, User.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
default:break;
Expand Down
9 changes: 1 addition & 8 deletions app/src/main/java/worten/aebd/com/worten/Scaner.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public class Scaner extends Activity
private Button follow;
private Button opinion;

private boolean login;

private boolean cambio = false;

Expand All @@ -69,8 +68,6 @@ protected void onCreate(Bundle savedInstanceState) {

producto = new Productos().getLista().get(0);

Bundle bundle = getIntent().getExtras();
login = bundle.getBoolean("login");

Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
Expand Down Expand Up @@ -131,30 +128,26 @@ public void onNavigationDrawerItemSelected(int position) {
public void onSectionAttached(int number) {
if(cambio){
Intent mainIntent = new Intent();
if(login){
if(Session.isLogin()){
switch (number) {
case 1:
mainIntent = new Intent().setClass(
Scaner.this, Shop.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
case 2:
mainIntent = new Intent().setClass(
Scaner.this, Scaner.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
case 3:
mainIntent = new Intent().setClass(
Scaner.this, Games.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
case 4:
mainIntent = new Intent().setClass(
Scaner.this, User.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
default:break;
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/worten/aebd/com/worten/Session.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package worten.aebd.com.worten;

/**
* Created by jesus on 25/10/14.
*/
public class Session {

private static boolean sesion = false;

public static void initSesion(){
sesion = true;
}

public static void closeSesion(){
sesion = false;
}

public static boolean isLogin(){
return sesion;
}

}
13 changes: 2 additions & 11 deletions app/src/main/java/worten/aebd/com/worten/Shop.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Intent;
import android.opengl.Visibility;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
Expand Down Expand Up @@ -39,7 +40,6 @@ public class Shop extends Activity
private CharSequence mTitle;
private ListView mListView;

private boolean login;

private boolean cambio = false;

Expand All @@ -57,12 +57,6 @@ protected void onCreate(Bundle savedInstanceState) {
R.id.navigation_drawer,
(DrawerLayout) findViewById(R.id.drawer_layout),0);

Bundle bundle = getIntent().getExtras();
try {
login = bundle.getBoolean("login");
}catch(NullPointerException e) {
login = false;
}

/*
mListView = (ListView) findViewById(R.id.product_label);
Expand Down Expand Up @@ -142,24 +136,21 @@ public void onNavigationDrawerItemSelected(int position) {
public void onSectionAttached(int number) {
if(cambio){
Intent mainIntent = new Intent();
if(login){
if(Session.isLogin()){
switch (number) {
case 2:
mainIntent = new Intent().setClass(
Shop.this, Scaner.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
case 3:
mainIntent = new Intent().setClass(
Shop.this, Games.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
case 4:
mainIntent = new Intent().setClass(
Shop.this, User.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
}}else{
Expand Down
9 changes: 1 addition & 8 deletions app/src/main/java/worten/aebd/com/worten/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class User extends Activity
private CharSequence mTitle;


private boolean login;
private boolean cambio = false;

@Override
Expand All @@ -45,8 +44,6 @@ protected void onCreate(Bundle savedInstanceState) {
R.id.navigation_drawer,
(DrawerLayout) findViewById(R.id.drawer_layout),1);

Bundle bundle = getIntent().getExtras();
login = bundle.getBoolean("login");

/*
mListView = (ListView) findViewById(R.id.product_label);
Expand Down Expand Up @@ -82,30 +79,26 @@ public void onNavigationDrawerItemSelected(int position) {
public void onSectionAttached(int number) {
if(cambio){
Intent mainIntent = new Intent();
if(login){
if(Session.isLogin()){
switch (number) {
case 1:
mainIntent = new Intent().setClass(
User.this, Shop.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
case 2:
mainIntent = new Intent().setClass(
User.this, Scaner.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
case 3:
mainIntent = new Intent().setClass(
User.this, Games.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
case 4:
mainIntent = new Intent().setClass(
User.this, User.class);
mainIntent.putExtra("login",login);
startActivity(mainIntent);
break;
default:break;
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/menu/shop.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@
android:orderInCategory="100"
android:showAsAction="never"
/>
<item android:id="@+id/close_settings"
android:title="@string/close_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:visible="false"
/>
</menu>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="action_settings">Ajustes</string>
<string name="close_settings">Cerrar Sesión</string>

</resources>

0 comments on commit 7dcd6e3

Please sign in to comment.