Base Terminada
This commit is contained in:
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -4,6 +4,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
@@ -13,33 +14,23 @@ public class AddUserActivity extends AppCompatActivity {
|
|||||||
private DatabaseHelper databaseHelper;
|
private DatabaseHelper databaseHelper;
|
||||||
|
|
||||||
private Button grabarButton;
|
private Button grabarButton;
|
||||||
private Button verButton;
|
|
||||||
private EditText nombreText;
|
private EditText nombreText;
|
||||||
private EditText hobbyText;
|
private EditText hobbyText;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_add_user);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||||
|
|
||||||
databaseHelper = new DatabaseHelper(this);
|
databaseHelper = new DatabaseHelper(this);
|
||||||
|
|
||||||
grabarButton = findViewById(R.id.grabarButton);
|
grabarButton = findViewById(R.id.grabarButton);
|
||||||
verButton = findViewById(R.id.verButton);
|
|
||||||
nombreText = findViewById(R.id.nombreText);
|
nombreText = findViewById(R.id.nombreText);
|
||||||
hobbyText = findViewById(R.id.hobbyText);
|
hobbyText = findViewById(R.id.hobbyText);
|
||||||
|
|
||||||
grabarButton.setOnClickListener(onSave());
|
grabarButton.setOnClickListener(onSave());
|
||||||
verButton.setOnClickListener(onShow());
|
|
||||||
}
|
|
||||||
|
|
||||||
private View.OnClickListener onShow() {
|
|
||||||
return new View.OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
Intent intent = new Intent(AddUserActivity.this, GetAllUsersActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private View.OnClickListener onSave() {
|
private View.OnClickListener onSave() {
|
||||||
@@ -56,7 +47,16 @@ public class AddUserActivity extends AppCompatActivity {
|
|||||||
"Datos grabados!",
|
"Datos grabados!",
|
||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
).show();
|
).show();
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
if (item.getItemId() == android.R.id.home) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,11 +13,16 @@ public class CustomAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
private List<User> users;
|
private List<User> users;
|
||||||
|
|
||||||
public CustomAdapter(Context context, List<User> users) {
|
public CustomAdapter(Context context, List<User> users) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.users = users;
|
this.users = users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void changeList(List<User> users) {
|
||||||
|
this.users = users;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return users.size();
|
return users.size();
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ import androidx.appcompat.widget.Toolbar;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GetAllUsersActivity extends AppCompatActivity {
|
public class GetAllUsersActivity extends AppCompatActivity {
|
||||||
private ListView listView;
|
private ListView listView;
|
||||||
|
private Button agregarButton;
|
||||||
private List<User> users;
|
private List<User> users;
|
||||||
private CustomAdapter customAdapter;
|
private CustomAdapter customAdapter;
|
||||||
private DatabaseHelper databaseHelper;
|
private DatabaseHelper databaseHelper;
|
||||||
@@ -28,6 +30,8 @@ public class GetAllUsersActivity extends AppCompatActivity {
|
|||||||
setContentView(R.layout.activity_get_all_users);
|
setContentView(R.layout.activity_get_all_users);
|
||||||
|
|
||||||
listView = findViewById(R.id.listView);
|
listView = findViewById(R.id.listView);
|
||||||
|
agregarButton = findViewById(R.id.agregarButton);
|
||||||
|
|
||||||
databaseHelper = new DatabaseHelper(this);
|
databaseHelper = new DatabaseHelper(this);
|
||||||
users = databaseHelper.getAllUsers();
|
users = databaseHelper.getAllUsers();
|
||||||
customAdapter = new CustomAdapter(this, users);
|
customAdapter = new CustomAdapter(this, users);
|
||||||
@@ -41,5 +45,21 @@ public class GetAllUsersActivity extends AppCompatActivity {
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
agregarButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(GetAllUsersActivity.this, AddUserActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
users = databaseHelper.getAllUsers();
|
||||||
|
customAdapter.changeList(users);
|
||||||
|
customAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import android.app.AlertDialog;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
@@ -24,6 +25,8 @@ public class UpdateDeleteActivity extends AppCompatActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_update_delete);
|
setContentView(R.layout.activity_update_delete);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||||
|
|
||||||
user = (User) getIntent().getSerializableExtra("user");
|
user = (User) getIntent().getSerializableExtra("user");
|
||||||
databaseHelper = new DatabaseHelper(this);
|
databaseHelper = new DatabaseHelper(this);
|
||||||
@@ -55,16 +58,11 @@ public class UpdateDeleteActivity extends AppCompatActivity {
|
|||||||
"Usuario eliminado correctamente",
|
"Usuario eliminado correctamente",
|
||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
).show();
|
).show();
|
||||||
|
finish();
|
||||||
Intent intent = new Intent(UpdateDeleteActivity.this, AddUserActivity.class);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton("No", null)
|
.setNegativeButton("No", null)
|
||||||
.show();
|
.show();
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -104,4 +102,11 @@ public class UpdateDeleteActivity extends AppCompatActivity {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
if (item.getItemId() == android.R.id.home) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,18 +47,4 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/hobbyText" />
|
app:layout_constraintTop_toBottomOf="@+id/hobbyText" />
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/verButton"
|
|
||||||
style="@android:style/Widget.Material.Button.Colored"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:text="Ver Datos"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/grabarButton" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/button3"
|
app:layout_constraintBottom_toTopOf="@+id/agregarButton"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
@@ -23,13 +23,13 @@
|
|||||||
</ListView>
|
</ListView>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button3"
|
android:id="@+id/agregarButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
android:text="Button"
|
android:text="Agregar"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|||||||
Reference in New Issue
Block a user