1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.exoplatform.model;
20
21 import android.os.Parcel;
22 import android.os.Parcelable;
23
24
25
26
27
28
29 public class ExoAccount implements Parcelable {
30
31
32 public String accountName;
33
34
35
36
37
38 public String username;
39
40
41 public String password;
42
43 public String avatarUrl;
44
45 public String userFullName;
46
47 public long lastLoginDate;
48
49
50
51
52
53 public boolean isRememberEnabled;
54
55
56 public boolean isAutoLoginEnabled;
57
58 public ExoAccount() {
59 accountName = "";
60 serverUrl = "";
61 username = "";
62 password = "";
63 isRememberEnabled = false;
64 isAutoLoginEnabled = false;
65 userFullName = "";
66 avatarUrl = "";
67 lastLoginDate = -1;
68 }
69
70 private ExoAccount(Parcel in) {
71 readFromParcel(in);
72 }
73
74 public static final Parcelable.Creator<ExoAccount> CREATOR = new Parcelable.Creator<ExoAccount>() {
75 public ExoAccount createFromParcel(Parcel in) {
76 return new ExoAccount(in);
77 }
78
79 public ExoAccount[] newArray(int size) {
80 return new ExoAccount[size];
81 }
82 };
83
84 private void readFromParcel(Parcel in) {
85 accountName = in.readString();
86 serverUrl = in.readString();
87 username = in.readString();
88 password = in.readString();
89 isRememberEnabled = in.readByte() == 1;
90 isAutoLoginEnabled = in.readByte() == 1;
91 userFullName = in.readString();
92 avatarUrl = in.readString();
93 lastLoginDate = in.readLong();
94 }
95
96 @Override
97 public int describeContents() {
98 return 0;
99 }
100
101 @Override
102 public void writeToParcel(Parcel dest, int flags) {
103 dest.writeString(accountName);
104 dest.writeString(serverUrl);
105 dest.writeString(username);
106 dest.writeString(password);
107 dest.writeByte((byte) (isRememberEnabled ? 1 : 0));
108 dest.writeByte((byte) (isAutoLoginEnabled ? 1 : 0));
109 dest.writeString(userFullName);
110 dest.writeString(avatarUrl);
111 dest.writeLong(lastLoginDate);
112 }
113
114
115
116
117
118 @Override
119 public boolean equals(Object obj) {
120 if (!(obj instanceof ExoAccount))
121 return false;
122 ExoAccount _server = (ExoAccount) obj;
123 if (_server.accountName.equals(accountName) && _server.serverUrl.equals(serverUrl)
124 && _server.username.equals(username))
125 return true;
126 return false;
127 }
128
129
130 public ExoAccount clone() {
131 ExoAccount newAccount = new ExoAccount();
132 newAccount.serverUrl = serverUrl;
133 newAccount.accountName = accountName;
134 newAccount.username = username;
135 newAccount.password = password;
136 newAccount.isAutoLoginEnabled = isAutoLoginEnabled;
137 newAccount.isRememberEnabled = isRememberEnabled;
138 newAccount.userFullName = userFullName;
139 newAccount.avatarUrl = avatarUrl;
140 newAccount.lastLoginDate = lastLoginDate;
141 return newAccount;
142 }
143
144 @Override
145 public int hashCode() {
146 return (serverUrl + username).hashCode();
147 }
148
149 @Override
150 public String toString() {
151 StringBuilder b = new StringBuilder("Account Details:\n");
152 b.append("* Name: ").append(accountName).append("\n");
153 b.append("* URL: ").append(serverUrl).append("\n");
154 b.append("* User: ").append(username).append("\n");
155 b.append("* RM: [")
156 .append(isRememberEnabled)
157 .append("] / AL: [")
158 .append(isAutoLoginEnabled)
159 .append("]\n");
160 b.append("* Full name: ").append(userFullName).append("\n");
161 b.append("* Last login: ").append(lastLoginDate).append("\n");
162 b.append("* Avatar: ").append(avatarUrl).append("\n");
163 return b.toString();
164 }
165 }