Android Open Source - tasktracker-android User






From Project

Back to project page tasktracker-android.

License

The source code is released under:

Copyright (c) 2012 Remo Mueller https://github.com/remomueller This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this lice...

If you think the Android project tasktracker-android 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

package com.github.remomueller.tasktracker.android;
/*from   w w  w  .  j  a va2 s.com*/
import android.content.Context;
import java.util.HashMap;
import android.util.Log;

import com.github.remomueller.tasktracker.android.util.DatabaseHandler;

// Debug
import android.util.Log;

public class User {
    private static final String TAG = "TaskTrackerAndroid";

    public int id = 0;
    public String first_name = "";
    public String last_name = "";
    public String email = "";
    public String password = "";
    public String cookie = "";

    public String site_url = "";
    public String authentication_token = "";

    private transient DatabaseHandler db;

    // Given a Context, return user from database
    public User(Context context){
        db = new DatabaseHandler(context);
        HashMap<String,String> user;
        user = db.getLogin();
        // if(user.get("id") != null && user.get("id") != "") // Put in with migration 3
        //     id = Integer.parseInt(user.get("id"));

        if(user.get("cookie") != null && user.get("cookie") != "") {
            try {
                id = Integer.parseInt(user.get("cookie"));
            } catch(NumberFormatException e) {
                Log.d(TAG, "Caught NumberFormatException: " + e.getMessage());
                id = 0;
            }
        }


        first_name = user.get("first_name");
        last_name = user.get("last_name");
        email = user.get("email");
        password = user.get("password");

        site_url = user.get("site_url");
        authentication_token = user.get("authentication_token");


        // if(first_name != null) Log.d(TAG, "First Name: " + first_name);
        // if(last_name != null) Log.d(TAG, "Last Name: " + last_name);
        // if(email != null) Log.d(TAG, "Email: " + email);
        // if(site_url != null) Log.d(TAG, "Site URL: " + site_url);
    }


    public void print(){
        Log.d(TAG, "USER id: " + Integer.toString(id));
        if(first_name != null) Log.d(TAG, "USER first_name: " + first_name);
        if(last_name != null) Log.d(TAG, "USER last_name: " + last_name);
        if(email != null) Log.d(TAG, "USER email: " + email);
        if(site_url != null) Log.d(TAG, "USER site_url: " + site_url);
        if(authentication_token != null) Log.d(TAG, "USER authentication_token: " + authentication_token);
    }

    /**
     * Function get Login status
     * */
    public boolean isUserLoggedIn(){
        if(db == null) return false;
        int count = db.getRowCount();
        if(count > 0){
            return true;
        }
        return false;
    }

    /**
     * Function to logout user
     * Reset Database
     * */
    public boolean logoutUser(){
        if(db != null) db.resetLogin(email, site_url);
        return true;
    }

    public String name(){
        String result = "";
        if(first_name != null && first_name != "" && last_name != null && last_name != "")
            result = first_name + " " + last_name;
        else if(first_name != null && first_name != "")
            result = first_name;
        else if(last_name != null && last_name != "")
            result = last_name;
        return result;
    }

}




Java Source Code List

com.github.remomueller.tasktracker.android.AboutActivity.java
com.github.remomueller.tasktracker.android.DashboardActivity.java
com.github.remomueller.tasktracker.android.LoginActivity.java
com.github.remomueller.tasktracker.android.MainActivity.java
com.github.remomueller.tasktracker.android.ProjectAdapter.java
com.github.remomueller.tasktracker.android.Project.java
com.github.remomueller.tasktracker.android.ProjectsIndex.java
com.github.remomueller.tasktracker.android.ProjectsNew.java
com.github.remomueller.tasktracker.android.StickiesFragment.java
com.github.remomueller.tasktracker.android.StickiesIndex.java
com.github.remomueller.tasktracker.android.StickiesNew.java
com.github.remomueller.tasktracker.android.StickiesShow.java
com.github.remomueller.tasktracker.android.StickyAdapter.java
com.github.remomueller.tasktracker.android.Sticky.java
com.github.remomueller.tasktracker.android.Tag.java
com.github.remomueller.tasktracker.android.TaskTracker.java
com.github.remomueller.tasktracker.android.User.java
com.github.remomueller.tasktracker.android.util.AsyncRequest.java
com.github.remomueller.tasktracker.android.util.Base64.java
com.github.remomueller.tasktracker.android.util.DatabaseHandler.java
com.github.remomueller.tasktracker.android.util.ProjectsRequest.java
com.github.remomueller.tasktracker.android.util.StickiesRequest.java
com.github.remomueller.tasktracker.android.util.WebRequest.java