
ืฉืคื ๐ฎ๐ฑ ืขืืจืืช
ืชืืขืื
ืืชืืื ืืืืจื
ืฉืืืืฉ
ืืืืืช
ืชืฆืืจื
Add Comments to Your Android App
ืืืื ืกืคืจืืืช Android ืืจืฉืืืช ืฉื FastComments.
ืืืืื'ืืื ืฉื ืชืืืืืช ืฉื FastComments ืขืืืจ Android
ืืืืจ
ืชืืื ืืช 
- ๐ ืชืืืืืช ืืืืช ืขื ืขืืืื ืื ืืืื ืืืช
- ๐ฑ ืจืืืื ืืืฉืง ืืฉืชืืฉ ืืงืืจืืื ื-Android
- ๐งต ืืืื ืื ืืฉืจืฉืจืื ืขื ืชืืืืืช
- ๐ค ืืืืืช SSO ืืืืืื
- ๐ ืืขืจืืช ืืฆืืขื ืขื ืกืื ืื ืืช ื ืืชื ืื ืืืชืืื ืืืฉืืช
- ๐ ืืชืจืืืช ืืฉืชืืฉ ืื ืืืืืช
- ๐ ืืืืืืช ืืืืจืฆืื ืฉื ืชืืืืืช
- ๐ฑ ืืื ืืืจืฆืื ืขื ืคืื ืืืจืชื
- โพ๏ธ ืืืืื ืืื ืกืืคืืช
- ๐จ ืชืืืื ืืขืจืืืช ื ืืฉื ืืงืืคืืช
ืืชืงื ื 
ืืืกืฃ ืืช ืโFastComments SDK ืืงืืืฅ build.gradle.kts ืฉื ืืืคืืืงืฆืื ืฉืื:
dependencies {
implementation("com.fastcomments:sdk:0.0.1")
}
ืืื ืฉืืฉ ืื ืืช ืืืืจ Repsy ืืงืืืฅ settings.gradle.kts ืฉื ืืคืจืืืงื ืฉืื:
dependencyResolutionManagement {
repositories {
maven {
url = uri("https://repo.repsy.io/mvn/winrid/fastcomments")
}
// other repositories...
}
}
ืฉืืืืฉ ืืกืืกื 
1. ืืืกืฃ FastCommentsView ืืคืจืืกื ืฉืื
<com.fastcomments.sdk.FastCommentsView
android:id="@+id/commentsView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
2. ืืชืืื ืืงืื ืคืืืืจืฆืื ืฉื ืโSDK
// ืงืืข ืืช ืชืฆืืจืช ืโSDK
val config = CommentWidgetConfig(
"your-tenant-id",
"page-url-id",
"Page Title",
"yourdomain.com",
"Site Name"
)
// ืืคืฉืจืืืืช ืงืื ืคืืืืจืฆืื ื ืืกืคืืช
config.voteStyle = VoteStyle.UpDown // ืื VoteStyle.Heart
config.enableInfiniteScrolling = true
config.hasDarkBackground = true // ืขืืืจ ืชืืืื ืืืฆื ืืื
// ืืชืื ืืช ืโSDK
val sdk = FastCommentsSDK(config)
// ืืฆื ืืช ืชืฆืืืช ืืชืืืืืช ืืคืจืืกื ืฉืื
val commentsView = findViewById<FastCommentsView>(R.id.commentsView)
// ืืืืจ ืืช ืืืคืข ืโSDK ืืชืฆืืื
commentsView.setSDK(sdk)
// ืืขื ืชืืืืืช
commentsView.load()
ืืืืืช SSO ืืืืืื 
ืืืืขืช ืืืืืช ืืืืืื ืขืืืจ ืืืฉืชืืฉืื ืฉืื:
// ืฆืืจ ื ืชืื ื ืืฉืชืืฉ (ืืืืืฅ ืืืฆืข ืืืช ืืฉืจืช ืฉืื)
val userData = SecureSSOUserData(
"user-id",
"user@example.com",
"User Name",
"https://path-to-avatar.jpg"
)
// ืืฆืืจืช ืืกืืืื SSO (ืืฉ ืืืฆืข ืืืช ืืฆื ืืฉืจืช!)
val sso = FastCommentsSSO.createSecure("YOUR_API_KEY", userData)
val token = sso.prepareToSend()
// ืืืกืฃ ืืงืื ืคืื
config.sso = token
ืฉืืืื ืคืื 
ืืฆื ืคืื ืืกืื ืื ืจืฉืช ืืืจืชืืช ืขื ืชืืืืืช:
// ืืืืจ ืืช ื-SDK
CommentWidgetConfig config = new CommentWidgetConfig();
config.tenantId = "your-tenant-id";
config.urlId = "page-url-id";
// ืืชืื ืืช Feed SDK
FastCommentsFeedSDK feedSDK = new FastCommentsFeedSDK(config);
// ืืืืจ ืืช ืชืฆืืืช ืืคืื
FastCommentsFeedView feedView = findViewById(R.id.feedView);
feedView.setSDK(feedSDK);
// ืืืืจ ืืืืื ืืืื ืืจืืงืฆืืืช
feedView.setFeedViewInteractionListener(new FastCommentsFeedView.OnFeedViewInteractionListener() {
@Override
public void onFeedLoaded(List<FeedPost> posts) {
// ืืคืื ืืืืขื ืืืฆืืื
}
@Override
public void onFeedError(String errorMessage) {
// ืืคื ืืฉืืืืืช
}
@Override
public void onPostSelected(FeedPost post) {
// ืืืฉืชืืฉ ืืืจ ืคืืกื
}
@Override
public void onCommentsRequested(FeedPost post) {
// ืืฆื ืชืืืืืช ืขืืืจ ืืคืืกื
CommentsDialog dialog = new CommentsDialog(context, post, feedSDK);
dialog.show();
}
});
// ืืขื ืืช ืืคืื
feedView.load();
ืฉืืืื ืฆ'ืื ืื 
ืืืกืฃ ืืืฉืง ืฆ'ืื ืืืื ืืืช ืืืคืืืงืฆืื ืฉืื:
// ืืืกืฃ ืืช LiveChatView ื-XML ืฉื ืืคืจืืกื ืฉืื
// <com.fastcomments.sdk.LiveChatView
// android:id="@+id/liveChatView"
// android:layout_width="match_parent"
// android:layout_height="match_parent" />
// ืฆืืจ ืชืฆืืจื ืขืืืจ ื-SDK
val config = CommentWidgetConfig().apply {
tenantId = "your-tenant-id"
urlId = "chat-room-identifier"
pageTitle = "Chat Room Name"
}
LiveChatView.setupLiveChatConfig(config)
// ืืืคืฆืืื ืื: ืืืกืฃ ืืืืืช ืืฉืชืืฉ
val userData = SimpleSSOUserData(
"User Name",
"user@example.com",
"https://path-to-avatar.jpg"
)
val sso = FastCommentsSSO(userData)
config.sso = sso.prepareToSend()
// ืืชืื ืืช ื-SDK
val sdk = FastCommentsSDK().configure(config)
// ืืืืจ ืืช LiveChatView
val liveChatView = findViewById<LiveChatView>(R.id.liveChatView)
liveChatView.setSDK(sdk)
liveChatView.load()
// ืื ืชืฉืื ืืืคื ืืืืืืจ ืืืืื
override fun onResume() {
super.onResume()
sdk.refreshLiveEvents()
}
override fun onDestroy() {
super.onDestroy()
sdk.cleanup()
}
ืืคืฉืจืืืืช ืชืฆืืจื 
ื-SDK ืืกืคืง ืืืืื ืืคืฉืจืืืืช ืชืฆืืจื ืืจื ืืืืืงื CommentWidgetConfig:
| ืืคืฉืจืืช | ืชืืืืจ |
|---|---|
tenantId |
ืืืื ืืืฉืืื ืฉืื ื-FastComments |
urlId |
ืืืื ืืืืืฆื ืืช ืืืฃ ืื ืืืื |
sso |
ืืกืืืื SSO ืืืืืืช |
allowAnon |
ืืคืฉืจ ืคืจืกืื ืชืืืืืช ืื ืื ืืืืืช |
voteStyle |
ืกืื ืื ืืฆืืขื โ UpDown ืื Heart |
hideAvatars |
ืืกืชืจืช ืืืืืจืื ืฉื ืืฉืชืืฉืื |
hasDarkBackground |
ืืฆืืื ืืฆื ืืื |
customCSS |
ืกืื ืื ืืช CSS ืืืชืืืื ืืืฉืืช |
enableInfiniteScrolling |
ืืคืขืืช ืืืืื ืืื ืกืืคืืช |
readonly |
ืื ืืขืช ืคืจืกืื ืชืืืืืช ืื ืืฆืืช ืชืืืืืช ืงืืืืืช |
disableVoting |
ืืฉืืชืช ืคืื ืงืฆืืืช ืืืฆืืขื |
disableLiveCommenting |
ืืฉืืชืช ืขืืืื ืื ืืืื ืืืช |
| --- |
ืืชืืื ืืงืืคื ืฉื ืขืจืืช ืื ืืฉื 
ืื ืืืคืชืืจืื ืืืืื ืืื ืืืืฉืง ืืืฉืชืืฉ ืืขืจืืช ืืคืืชืื ืฉื FastComments ื ืืชื ืื ืืขืืฆืื. ืืฉืชืืฉ ื- FastCommentsTheme.Builder ืืฉืืืื ืืืื ืืืืชืื ืฉื ืืืคืืืงืฆืื ืฉืื.
ืขืืฆืื ืชืื ืืชื (ืืืืืฅ)
val theme = FastCommentsTheme.Builder()
// ืืคืชืืจื ืคืขืืื: ืฉืืืื, ืืฆืืขื, ืชืคืจืื, ืืคืชืืจื ืืืืง/ืฉืืชืืฃ
.setActionButtonColor(Color.parseColor("#FF1976D2"))
// ืืคืชืืจื ืชืืืื: ืืคืชืืจื ืืขื ื ืืืขืจืืช
.setReplyButtonColor(Color.parseColor("#FF4CAF50"))
// ืืคืชืืจื ืืืืคื: ืืคืชืืจื ืืฆื/ืืกืชืจ ืชืืืืืช
.setToggleRepliesButtonColor(Color.parseColor("#FFFF5722"))
// ืืคืชืืจื ืืขืื ืช ืขืื: ืืคืชืืจื ืขืืืื
.setLoadMoreButtonTextColor(Color.parseColor("#FF9C27B0"))
.setPrimaryColor(Color.parseColor("#FF6200EE"))
.setLinkColor(Color.parseColor("#FF1976D2"))
.setDialogHeaderBackgroundColor(Color.parseColor("#FF333333"))
.build()
// ืืืืช ืืขืืฆืื
sdk.setTheme(theme)
ืืืืคื ืืืืจื ืฉื ืฆืืขืื
Override color resources in your colors.xml for simple branding:
<!-- ืืงืืืฅ res/values/colors.xml ืฉื ืืืคืืืงืฆืื ืฉืื -->
<resources>
<!-- ืฉื ื ืืช ืื ืจืืืื ืืืืฉืง ืืจืืฉืืื -->
<color name="primary">#FF1976D2</color>
<!-- ืื ืืชืื ืกืืื ืืคืชืืจืื ืกืคืฆืืคืืื -->
<color name="fastcomments_action_button_color">#FF1976D2</color>
<color name="fastcomments_reply_button_color">#FF4CAF50</color>
<color name="fastcomments_toggle_replies_button_color">#FFFF5722</color>
<color name="fastcomments_load_more_button_text_color">#FF9C27B0</color>
</resources>
ืืืกืื ืืคืชืืจืื ืืขืืฆืืื
ืื ืืคืชืืจ ื-SDK ืชืืื ืืขืืฆืื:
- ืืคืชืืจื ืฉืืืื, ืืคืชืืจื ืืฆืืขื, ืืคืชืืจื ืชืคืจืื, ืืคืชืืจื ืชืืืื
- ืืคืชืืจื ืืฆื/ืืกืชืจ ืชืืืืืช, ืืคืชืืจื 'ืืขืื ืขืื'
- ืืคืชืืจื ืคืขืืื ืืคืื (ืืืืง, ืชืืืื, ืฉืืชืืฃ)
- ืืคืชืืจื ืืืืืื (ืฉืื, ืืื, ืฉืืืจ)
- ืืคืชืืจื ืืฉืืืืช ืืื ืืืื ืืคืืกืืื ืฉื ืืคืื
ืืชืืขืื ืืคืืจื ืขื ืขืจืืืช ืขืืฆืื, ืจืื ืืช THEMING.md.
ื ืืืื ืืืืจืื 
ืื ืืขืช ืืืืคืืช ืืืืจืื
ืืื ืืื ืืข ืืืืคืืช ืืืืจืื ืืขืช ืฉืืืืฉ ืึพFastComments views ืึพActivities ืื Fragments, ืชืืื ืงืจืื ืึพcleanup() ืืืฉืจ ืืชืฆืืื ืืืจ ืื ื ืืจืฉืช:
ืึพActivities:
@Override
protected void onDestroy() {
super.onDestroy();
// ื ืงื ืชืฆืืืืช FastComments ืืื ืืื ืืข ืืืืคืืช ืืืืจืื
if (feedView != null) {
feedView.cleanup();
}
if (commentsView != null) {
commentsView.cleanup();
}
}
ืึพFragments:
@Override
public void onDestroyView() {
super.onDestroyView();
// ื ืงื ืชืฆืืืืช FastComments ืืืฉืจ ืชืฆืืืช ืึพFragment ื ืืจืกืช
if (feedView != null) {
feedView.cleanup();
feedView = null;
}
}
@Override
public void onDestroy() {
super.onDestroy();
// ื ืืงืื ื ืืกืฃ ืืืฉืจ ืึพFragment ื ืืจืก
if (feedSDK != null) {
feedSDK.cleanup();
feedSDK = null;
}
}
ืืขืช ืืืืคืช Fragments:
// ืืคื ื ืืืืคื ืื ืืกืจื ืฉื fragment ืืืืื ืชืฆืืืืช FastComments
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.container);
if (currentFragment instanceof YourFragmentWithFeedView) {
((YourFragmentWithFeedView) currentFragment).cleanupFeedView();
}
// ืืื ืืืฉืืื ืืขืกืงืช ืึพfragment
getSupportFragmentManager().beginTransaction()
.replace(R.id.container, newFragment)
.commit();
ืืฉืื: ืชืืื ืงืจืื ืืฉืืืืช cleanup() ืืื ืืื ืืข ืืืืคืืช ืืืืจืื, ืืืืืื ืืืฉืจ:
- ืึพActivities ื ืืจืกืืช
- ืชืฆืืืืช ืึพFragment ื ืืจืกืืช
- ืืืืคื ืืื Fragments
- ื ืืืื ืืืืฆื ืืืกืืื ืืืืืืื ืจืืืื FastComments
ืืงืืงืื ืืขืืจื?
ืื ืืชื ื ืชืงืืื ืืืขืืืช ืื ืืฉ ืืื ืฉืืืืช ืืืื ืกืคืจืืืช Android, ืื ื:
ืชืจืืืืช
ืชืจืืืืช ืืชืงืืืืช ืืืจืื! ืื ื ืืงืจื ื-ืืืืจ GitHub ืืื ืืืืช ืืชืจืืื.