forked from sendbird/sendbird-uikit-android
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fb7a5a
commit d845cb3
Showing
5 changed files
with
139 additions
and
1 deletion.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
uikit/src/main/java/com/sendbird/uikit/model/admin/AdminMessageData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.sendbird.uikit.model.admin; | ||
|
||
import androidx.annotation.Keep; | ||
|
||
import com.sendbird.android.shadow.com.google.gson.annotations.SerializedName; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Keep | ||
public class AdminMessageData { | ||
@SerializedName("type") | ||
private String type; | ||
|
||
@SerializedName("users") | ||
private List<AdminMessageUser> users; | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
public List<AdminMessageUser> getUsers() { | ||
return users; | ||
} | ||
|
||
public void setUsers(List<AdminMessageUser> users) { | ||
this.users = users; | ||
} | ||
|
||
public String getContent() { | ||
if (type.equalsIgnoreCase(AdminMessageType.USER_JOINED)) { | ||
return joinUserNames() + " joined"; | ||
} | ||
return ""; | ||
} | ||
|
||
public String joinUserNames() { | ||
List<String> names = getUserNames(); | ||
StringBuilder builder = new StringBuilder(); | ||
for (int i = 0; i < names.size(); i++) { | ||
builder.append(names.get(i)); | ||
if (i != names.size() - 1) { | ||
builder.append(", "); | ||
} | ||
} | ||
return builder.toString(); | ||
} | ||
|
||
public List<String> getUserNames() { | ||
List<String> names = new ArrayList<>(); | ||
for (AdminMessageUser user : users) { | ||
names.add(user.getName()); | ||
} | ||
return names; | ||
} | ||
} | ||
|
31 changes: 31 additions & 0 deletions
31
uikit/src/main/java/com/sendbird/uikit/model/admin/AdminMessageMetaData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.sendbird.uikit.model.admin; | ||
|
||
import androidx.annotation.Keep; | ||
|
||
import com.sendbird.android.shadow.com.google.gson.annotations.SerializedName; | ||
|
||
@Keep | ||
public class AdminMessageMetaData { | ||
|
||
@SerializedName("username") | ||
private String username; | ||
|
||
@SerializedName("phone") | ||
private String phone; | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public void setUsername(String username) { | ||
this.username = username; | ||
} | ||
|
||
public String getPhone() { | ||
return phone; | ||
} | ||
|
||
public void setPhone(String phone) { | ||
this.phone = phone; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
uikit/src/main/java/com/sendbird/uikit/model/admin/AdminMessageType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.sendbird.uikit.model.admin; | ||
|
||
public class AdminMessageType { | ||
public static final String USER_JOINED = "USER_JOIN"; | ||
} |
30 changes: 30 additions & 0 deletions
30
uikit/src/main/java/com/sendbird/uikit/model/admin/AdminMessageUser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.sendbird.uikit.model.admin; | ||
|
||
import androidx.annotation.Keep; | ||
|
||
import com.sendbird.android.shadow.com.google.gson.annotations.SerializedName; | ||
import com.sendbird.uikit.SendBirdUIKit; | ||
import com.sendbird.uikit.utils.TextUtils; | ||
|
||
@Keep | ||
public class AdminMessageUser { | ||
|
||
@SerializedName("metadata") | ||
private AdminMessageMetaData metaData; | ||
|
||
public AdminMessageMetaData getMetaData() { | ||
return metaData; | ||
} | ||
|
||
public void setMetaData(AdminMessageMetaData metaData) { | ||
this.metaData = metaData; | ||
} | ||
|
||
public String getName() { | ||
String phone = metaData.getPhone(); | ||
String username = metaData.getUsername(); | ||
|
||
String phonebookName = SendBirdUIKit.findPhoneBookName(phone); | ||
return TextUtils.isEmpty(phonebookName) ? username : phonebookName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters