Twidere-App-Android-Twitter.../twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableAccount.java

127 lines
3.6 KiB
Java
Raw Normal View History

2014-07-03 07:48:39 +02:00
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.model;
2016-02-26 14:47:03 +01:00
import android.support.annotation.Nullable;
2014-07-03 07:48:39 +02:00
2016-04-30 07:35:35 +02:00
import org.mariotaku.commons.objectcursor.LoganSquareCursorFieldConverter;
2016-03-09 17:12:09 +01:00
import org.mariotaku.library.objectcursor.annotation.AfterCursorObjectCreated;
2015-11-30 06:32:05 +01:00
import org.mariotaku.library.objectcursor.annotation.CursorField;
import org.mariotaku.library.objectcursor.annotation.CursorObject;
2016-12-03 06:48:40 +01:00
import org.mariotaku.twidere.annotation.AccountType;
2016-03-07 18:25:18 +01:00
import org.mariotaku.twidere.model.util.UserKeyCursorFieldConverter;
import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
2014-07-03 07:48:39 +02:00
2016-12-03 06:48:40 +01:00
@CursorObject
@Deprecated
2016-12-04 06:45:57 +01:00
public class ParcelableAccount {
2014-07-03 07:48:39 +02:00
2016-03-05 16:16:17 +01:00
@CursorField(value = Accounts._ID, excludeWrite = true)
public long id;
2016-12-04 06:45:57 +01:00
2016-03-07 18:25:18 +01:00
@CursorField(value = Accounts.ACCOUNT_KEY, converter = UserKeyCursorFieldConverter.class)
public UserKey account_key;
2016-03-07 06:05:08 +01:00
2016-12-04 06:45:57 +01:00
2015-11-30 06:32:05 +01:00
@CursorField(Accounts.SCREEN_NAME)
2015-04-23 17:09:13 +02:00
public String screen_name;
2016-12-04 06:45:57 +01:00
2015-11-30 06:32:05 +01:00
@CursorField(Accounts.NAME)
2015-04-23 17:09:13 +02:00
public String name;
2016-03-07 06:05:08 +01:00
@Nullable
2016-12-03 06:48:40 +01:00
@AccountType
2016-03-07 06:05:08 +01:00
@CursorField(Accounts.ACCOUNT_TYPE)
public String account_type;
2016-12-04 06:45:57 +01:00
2015-11-30 06:32:05 +01:00
@CursorField(Accounts.PROFILE_IMAGE_URL)
2015-04-23 17:09:13 +02:00
public String profile_image_url;
2016-12-04 06:45:57 +01:00
2015-11-30 06:32:05 +01:00
@CursorField(Accounts.PROFILE_BANNER_URL)
2015-04-23 17:09:13 +02:00
public String profile_banner_url;
2016-12-04 06:45:57 +01:00
2015-11-30 06:32:05 +01:00
@CursorField(Accounts.COLOR)
2015-04-23 17:09:13 +02:00
public int color;
2016-12-04 06:45:57 +01:00
2015-11-30 06:32:05 +01:00
@CursorField(Accounts.IS_ACTIVATED)
2015-04-23 17:09:13 +02:00
public boolean is_activated;
@Nullable
2016-12-04 06:45:57 +01:00
@CursorField(value = Accounts.ACCOUNT_USER, converter = LoganSquareCursorFieldConverter.class)
public ParcelableUser account_user;
2016-02-26 14:47:03 +01:00
2016-03-04 18:15:38 +01:00
public boolean is_dummy;
2015-11-30 06:32:05 +01:00
ParcelableAccount() {
}
@Override
public String toString() {
2016-02-12 07:53:57 +01:00
return "ParcelableAccount{" +
2016-03-07 06:05:08 +01:00
"id=" + id +
", account_key=" + account_key +
", screen_name='" + screen_name + '\'' +
2016-02-12 07:53:57 +01:00
", name='" + name + '\'' +
2016-03-07 06:05:08 +01:00
", account_type='" + account_type + '\'' +
2016-02-12 07:53:57 +01:00
", profile_image_url='" + profile_image_url + '\'' +
", profile_banner_url='" + profile_banner_url + '\'' +
", color=" + color +
", is_activated=" + is_activated +
2016-03-04 18:15:38 +01:00
", account_user=" + account_user +
2016-02-12 07:53:57 +01:00
", is_dummy=" + is_dummy +
'}';
}
2016-03-07 03:43:09 +01:00
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ParcelableAccount account = (ParcelableAccount) o;
2016-03-07 06:05:08 +01:00
return account_key.equals(account.account_key);
2016-03-07 03:43:09 +01:00
}
@Override
public int hashCode() {
2016-03-18 17:04:03 +01:00
// Dummy account
if (account_key == null) return 0;
2016-03-07 06:05:08 +01:00
return account_key.hashCode();
2016-03-07 03:43:09 +01:00
}
2016-03-09 17:12:09 +01:00
@AfterCursorObjectCreated
void afterObjectCreated() {
if (account_user != null) {
account_user.is_cache = true;
account_user.account_color = color;
}
}
2016-03-10 17:02:16 +01:00
2014-07-03 07:48:39 +02:00
}