Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void busca(){
- String[] colunas = new String[]{"token", "nome"};
- Cursor cursor = db.query("user", colunas, null, null, null, null, "token ASC");
- if(cursor.getCount() > 0){
- cursor.moveToFirst();
- do{
- Utilizador u = new Utilizador();
- u.setToken(cursor.getString(0));
- u.setNome(cursor.getString(1));
- }while(cursor.moveToNext());
- }
- }
- package imm.pt.immflix;
- public class Utilizador {
- private String nome;
- private String mail;
- private String token;
- private String foto;
- private int typeService;
- public String getNome() {
- return nome;
- }
- public void setNome(String nome) {
- this.nome = nome;
- }
- public String getMail() {
- return mail;
- }
- public void setMail(String mail) {
- this.mail = mail;
- }
- public String getToken() {
- return token;
- }
- public void setToken(String token) {
- this.token = token;
- }
- public String getFoto() {
- return foto;
- }
- public void setFoto(String foto) {
- this.foto = foto;
- }
- public int getTypeService() {
- return typeService;
- }
- public void setTypeService(int typeService) {
- this.typeService = typeService;
- }
- }
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- getSupportActionBar().hide();
- TextView tvtitle = findViewById(R.id.tvTitle);
- ObjectAnimator anime = ObjectAnimator.ofFloat(tvtitle, "alpha", 0f, 1f);
- anime.setDuration(2000);
- anime.start();
- DB db = new DB(this);
- db.busca();
- Utilizador user = new Utilizador();
- token = user.getToken();
- if(token == null){
- Handler handler = new Handler();
- handler.postDelayed(new Runnable() {
- @Override
- public void run() {
- Intent intent = new Intent(MainActivity.this, Login.class);
- intent.putExtra("isNew", true);
- startActivity(intent);
- finish();
- }
- }, 3000);
- }else{
- Handler handler = new Handler();
- handler.postDelayed(new Runnable() {
- @Override
- public void run() {
- Intent intent = new Intent(MainActivity.this, Login.class);
- intent.putExtra("isNew", false);
- startActivity(intent);
- finish();
- }
- }, 3000);
- }
- }
- Utilizador user = new Utilizador();
- token = user.getToken();
- public Utilizador busca(){
- String[] colunas = new String[]{"token", "nome"};
- Cursor cursor = db.query("user", colunas, null, null, null, null, "token ASC");
- if(cursor.getCount() > 0){
- cursor.moveToFirst();
- do{
- Utilizador u = new Utilizador();
- u.setToken(cursor.getString(0));
- u.setNome(cursor.getString(1));
- }while(cursor.moveToNext());
- return u;
- }
- return null;
- }
- DB db = new DB(this);
- Utilizador user = db.busca();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement