If you think the Android project TuentiTV 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
/*
* Copyright (C) 2014 Pedro Vicente Gmez Snchez.
*//fromwww.java2s.com
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.github.pedrovgs.tuentitv.model;
import java.util.LinkedList;
import java.util.List;
import javax.inject.Inject;
/**
* Main class related to accounts feature. This class contains the responsibility to return recent
* logged accounts, check if the user is logged and perform login, logout operations. All the data
* this class returns is mocked for this sample.
*
* @author Pedro Vicente Gmez Snchez.
*/publicclass Accounts {
privatefinal List<Account> recentLoggedAccounts;
private Account loggedAccount;
@Inject public Accounts() {
this.recentLoggedAccounts = new LinkedList<Account>();
loadRecentLoggedAccounts();
}
/**
* @return last three recent logged accounts sorted by last login date.
*/public List<Account> getRecentLoggedAccounts() {
return recentLoggedAccounts;
}
/**
* Perform login using an Account object to be used as logged Account during the application
* lifecycle.
*/publicvoid login(Account account) {
loggedAccount = account;
}
/**
* @return true if there is any user logged in this application and false if not.
*/publicboolean isUserLogged() {
return loggedAccount != null;
}
/**
* Perform logout process and remove the previous logged account as logged account.
*/publicvoid logout() {
loggedAccount = null;
}
privatevoid loadRecentLoggedAccounts() {
recentLoggedAccounts.add(new Account("Juanma", "https://imrl.tuenti.net/MephbQPFZwIygHTjAA"));
recentLoggedAccounts.add(
new Account("Emanuela", "https://tuentiimg2-a.akamaihd.net/Meo8zgSyA0mYepIyAA"));
recentLoggedAccounts.add(
new Account("Luis Javier", "https://tuentiimg1-a.akamaihd.net/MeyvDQONIBaVEpFrAA"));
}
}