Android Open Source - photo-paper User






From Project

Back to project page photo-paper.

License

The source code is released under:

MIT License

If you think the Android project photo-paper 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.lukekorth.android_500px.models;
/*from w  w  w  . j av a 2s  .c om*/
import android.content.Context;
import android.content.Intent;

import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;
import com.activeandroid.query.Select;
import com.fivehundredpx.api.auth.AccessToken;
import com.lukekorth.android_500px.services.UserInfoIntentService;

@Table(name = "User")
public class User extends Model {

    @Column(name = "user_id")
    public int id;

    @Column(name = "username")
    public String userName;

    @Column(name = "firstname")
    public String firstName;

    @Column(name = "lastname")
    public String lastName;

    @Column(name = "photo")
    public String photo;

    @Column(name = "access_token")
    public String accessToken;

    @Column(name = "access_token_secret")
    public String accessTokenSecret;

    public static User getUser() {
        return new Select().from(User.class)
                .executeSingle();
    }

    public static boolean isUserLoggedIn() {
        return new Select().from(User.class)
                .exists();
    }

    public static void logout() {
        new Select().from(User.class)
                .executeSingle()
                .delete();
    }

    public static void newUser(Context context, AccessToken accessToken) {
        User user = getUser();
        if (user != null) {
            user.delete();
        }

        user = new User();
        user.accessToken = accessToken.getToken();
        user.accessTokenSecret = accessToken.getTokenSecret();
        user.save();

        context.startService(new Intent(context, UserInfoIntentService.class));
    }

    public static AccessToken getLoggedInUserAccessToken() {
        User user = getUser();
        if (user == null) {
            return null;
        }

        return new AccessToken(user.accessToken, user.accessTokenSecret);
    }

}




Java Source Code List

com.lukekorth.android_500px.HistoryActivity.java
com.lukekorth.android_500px.PhotoFragment.java
com.lukekorth.android_500px.SearchActivity.java
com.lukekorth.android_500px.SettingsActivity.java
com.lukekorth.android_500px.ViewPhotoActivity.java
com.lukekorth.android_500px.WallpaperApplication.java
com.lukekorth.android_500px.helpers.Cache.java
com.lukekorth.android_500px.helpers.LogReporting.java
com.lukekorth.android_500px.helpers.Settings.java
com.lukekorth.android_500px.helpers.ThreadBus.java
com.lukekorth.android_500px.helpers.Utils.java
com.lukekorth.android_500px.models.ActivityResumedEvent.java
com.lukekorth.android_500px.models.EnableCategoriesEvent.java
com.lukekorth.android_500px.models.Photos.java
com.lukekorth.android_500px.models.SearchCompleteEvent.java
com.lukekorth.android_500px.models.UserUpdatedEvent.java
com.lukekorth.android_500px.models.User.java
com.lukekorth.android_500px.models.WallpaperChangedEvent.java
com.lukekorth.android_500px.receivers.UserPresentReceiver.java
com.lukekorth.android_500px.receivers.WifiReceiver.java
com.lukekorth.android_500px.services.ApiService.java
com.lukekorth.android_500px.services.ClearCacheIntentService.java
com.lukekorth.android_500px.services.UserInfoIntentService.java
com.lukekorth.android_500px.services.WallpaperService.java
com.lukekorth.android_500px.views.FeatureListPreference.java
com.lukekorth.android_500px.views.SquareImageView.java
com.squareup.picasso.PicassoTools.java