-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContact.java
More file actions
93 lines (74 loc) · 2 KB
/
Contact.java
File metadata and controls
93 lines (74 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package me.hoen.android_auth_sync.db;
import org.json.JSONObject;
import android.database.Cursor;
public class Contact {
protected int id;
protected String title;
protected String firstName;
protected String lastName;
protected String url;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Override
public String toString() {
return "Contact [id=" + id + ", title=" + title + ", firstName="
+ firstName + ", lastName=" + lastName + ", url=" + url + "]";
}
public static Contact fromJsonObject(JSONObject json) {
try {
Contact c = new Contact();
c.setTitle(json.getJSONObject("name").getString("title"));
c.setFirstName(json.getJSONObject("name").getString("first"));
c.setLastName(json.getJSONObject("name").getString("last"));
c.setUrl(json.getJSONObject("picture").getString("thumbnail"));
return c;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
static public Contact fromCursor(Cursor cursor) {
if (cursor != null && cursor.getCount() != 0) {
Contact c = new Contact();
c.setId(cursor.getInt(cursor.getColumnIndex(SqliteHelper.COLUMN_ID)));
c.setTitle(cursor.getString(cursor
.getColumnIndex(SqliteHelper.COLUMN_TITLE)));
c.setFirstName(cursor.getString(cursor
.getColumnIndex(SqliteHelper.COLUMN_FIRST_NAME)));
c.setLastName(cursor.getString(cursor
.getColumnIndex(SqliteHelper.COLUMN_LAST_NAME)));
c.setUrl(cursor.getString(cursor
.getColumnIndex(SqliteHelper.COLUMN_URL)));
return c;
}
return null;
}
}