Android Open Source - passby Database Task






From Project

Back to project page passby.

License

The source code is released under:

Copyright 2014 Firebase, https://www.firebase.com/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ?Software??...

If you think the Android project passby listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

//#CSIT6000B#  Rio He       20227977 yheas@connect.ust.hk
//#CSIT6000B#  Cedric Liang 20220395 zliangag@connect.ust.hk
//#CSIT6000B#  Kevin Wang   20225577 zwangbo@connect.ust.hk 
package com.firebase.database;
/*  w ww  .  j  av  a2  s . c o  m*/
import com.firebase.client.LocateActivity;
import com.firebase.client.SettingActivity;

import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.os.AsyncTask;

public class DatabaseTask extends AsyncTask<String, String, String> {
  private DatabaseManager dbManager;
  private Activity activity;
  private String flag;
 
  public DatabaseTask(Activity activity){
    this.activity = activity;
    this.dbManager = new DatabaseManager(activity);
  }

  @Override
  protected String doInBackground(String... params) {
    // do query
    ContentValues cv = this.dbManager.query();
    if(cv.containsKey("nickname")){
      flag = "true"; // has set user's info
      
      // init User obj
      User.getInstance().setNickname(cv.getAsString("nickname"));
      User.getInstance().setGender(cv.getAsInteger("gender"));
    }
    else
      flag = "false"; // hasnt set user's info
    return flag;
  }

  @Override
  protected void onPostExecute(String result) {
    super.onPostExecute(result);
    Intent intent;
    
    if(flag.equals("true"))
      intent = new Intent(this.activity, LocateActivity.class);
    else
      intent = new Intent(this.activity, SettingActivity.class);
    this.activity.startActivity(intent);
  }
  
  
}




Java Source Code List

com.firebase.androidchat.ChatListAdapter.java
com.firebase.androidchat.Chat.java
com.firebase.androidchat.FirebaseListAdapter.java
com.firebase.androidchat.MainActivity.java
com.firebase.client.LaunchActivity.java
com.firebase.client.LocateActivity.java
com.firebase.client.SearchResultActivity.java
com.firebase.client.SettingActivity.java
com.firebase.database.DatabaseHelper.java
com.firebase.database.DatabaseManager.java
com.firebase.database.DatabaseTask.java
com.firebase.database.User.java