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

167 lines
5.3 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;
import android.os.Parcel;
import android.os.Parcelable;
2016-02-26 14:47:03 +01:00
import android.support.annotation.Nullable;
2014-07-03 07:48:39 +02:00
2015-04-23 17:09:13 +02:00
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
import com.hannesdorfmann.parcelableplease.annotation.ParcelableThisPlease;
2015-04-23 17:09:13 +02:00
2015-11-30 06:32:05 +01:00
import org.mariotaku.library.objectcursor.annotation.CursorField;
import org.mariotaku.library.objectcursor.annotation.CursorObject;
import org.mariotaku.twidere.model.util.LoganSquareCursorFieldConverter;
import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
2014-07-03 07:48:39 +02:00
2015-12-13 13:17:26 +01:00
@CursorObject(valuesCreator = true)
@ParcelablePlease(allFields = false)
2015-04-23 17:09:13 +02:00
@JsonObject
public class ParcelableAccount implements Parcelable {
2014-07-03 07:48:39 +02:00
2016-03-05 16:16:17 +01:00
@ParcelableThisPlease
@JsonField(name = "id")
@CursorField(value = Accounts._ID, excludeWrite = true)
public long id;
@ParcelableThisPlease
2015-04-23 17:09:13 +02:00
@JsonField(name = "screen_name")
2015-11-30 06:32:05 +01:00
@CursorField(Accounts.SCREEN_NAME)
2015-04-23 17:09:13 +02:00
public String screen_name;
@ParcelableThisPlease
2015-04-23 17:09:13 +02:00
@JsonField(name = "name")
2015-11-30 06:32:05 +01:00
@CursorField(Accounts.NAME)
2015-04-23 17:09:13 +02:00
public String name;
@ParcelableThisPlease
2015-04-23 17:09:13 +02:00
@JsonField(name = "profile_image_url")
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;
@ParcelableThisPlease
2015-04-23 17:09:13 +02:00
@JsonField(name = "profile_banner_url")
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;
@ParcelableThisPlease
2015-04-23 17:09:13 +02:00
@JsonField(name = "account_id")
2015-11-30 06:32:05 +01:00
@CursorField(Accounts.ACCOUNT_ID)
2015-04-23 17:09:13 +02:00
public long account_id;
@ParcelableThisPlease
2015-04-23 17:09:13 +02:00
@JsonField(name = "color")
2015-11-30 06:32:05 +01:00
@CursorField(Accounts.COLOR)
2015-04-23 17:09:13 +02:00
public int color;
@ParcelableThisPlease
2015-04-23 17:09:13 +02:00
@JsonField(name = "is_activated")
2015-11-30 06:32:05 +01:00
@CursorField(Accounts.IS_ACTIVATED)
2015-04-23 17:09:13 +02:00
public boolean is_activated;
2016-02-26 14:47:03 +01:00
@Nullable
@ParcelableThisPlease
@JsonField(name = "account_type")
@CursorField(Accounts.ACCOUNT_TYPE)
public String account_type;
2016-03-04 18:15:38 +01:00
@ParcelableThisPlease
@JsonField(name = "account_host")
@CursorField(Accounts.ACCOUNT_HOST)
public String account_host;
@Nullable
@ParcelableThisPlease
@JsonField(name = "account_user")
@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;
2016-02-12 07:53:57 +01:00
public static final Creator<ParcelableAccount> CREATOR = new Creator<ParcelableAccount>() {
public ParcelableAccount createFromParcel(Parcel source) {
ParcelableAccount target = new ParcelableAccount();
ParcelableAccountParcelablePlease.readFromParcel(target, source);
return target;
}
2015-04-23 17:09:13 +02:00
2016-02-12 07:53:57 +01:00
public ParcelableAccount[] newArray(int size) {
return new ParcelableAccount[size];
}
};
2015-11-30 06:32:05 +01:00
ParcelableAccount() {
}
2015-05-10 17:05:26 +02:00
public static ParcelableCredentials dummyCredentials() {
2015-11-30 06:32:05 +01:00
final ParcelableCredentials credentials = new ParcelableCredentials();
credentials.is_dummy = true;
return credentials;
2015-05-10 17:05:26 +02:00
}
@Override
public String toString() {
2016-02-12 07:53:57 +01:00
return "ParcelableAccount{" +
"screen_name='" + screen_name + '\'' +
", name='" + name + '\'' +
", profile_image_url='" + profile_image_url + '\'' +
", profile_banner_url='" + profile_banner_url + '\'' +
", account_id=" + account_id +
", color=" + color +
", is_activated=" + is_activated +
2016-02-26 14:47:03 +01:00
", account_type='" + account_type + '\'' +
2016-03-04 18:15:38 +01:00
", account_host='" + account_host + '\'' +
", 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;
if (id != account.id) return false;
return !(account_host != null ? !account_host.equals(account.account_host) : account.account_host != null);
}
@Override
public int hashCode() {
int result = (int) (id ^ (id >>> 32));
result = 31 * result + (account_host != null ? account_host.hashCode() : 0);
return result;
}
2015-11-30 06:32:05 +01:00
@Override
public int describeContents() {
return 0;
}
2015-02-03 06:22:02 +01:00
2015-11-30 06:32:05 +01:00
@Override
public void writeToParcel(Parcel dest, int flags) {
ParcelableAccountParcelablePlease.writeToParcel(this, dest, flags);
}
2014-07-03 07:48:39 +02:00
}