use of com.odysee.app.model.Comment in project odysee-android by OdyseeTeam.
the class ChannelCommentsFragment method postComment.
private void postComment() {
if (postingComment) {
return;
}
Comment comment = buildPostComment();
beforePostComment();
AccountManager am = AccountManager.get(getContext());
Account odyseeAccount = Helper.getOdyseeAccount(am.getAccounts());
CommentCreateTask task = new CommentCreateTask(comment, am.peekAuthToken(odyseeAccount, "auth_token_type"), progressPostComment, new CommentCreateTask.CommentCreateWithTipHandler() {
@Override
public void onSuccess(Comment createdComment) {
inputComment.setText(null);
clearReplyToComment();
ensureCommentListAdapterCreated(new ArrayList<Comment>());
if (commentListAdapter != null) {
createdComment.setPoster(comment.getPoster());
if (!Helper.isNullOrEmpty(createdComment.getParentId())) {
commentListAdapter.addReply(createdComment);
} else {
commentListAdapter.insert(0, createdComment);
}
}
afterPostComment();
checkNoComments();
Bundle bundle = new Bundle();
bundle.putString("claim_id", claim != null ? claim.getClaimId() : null);
bundle.putString("claim_name", claim != null ? claim.getName() : null);
LbryAnalytics.logEvent(LbryAnalytics.EVENT_COMMENT_CREATE, bundle);
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).showMessage(R.string.comment_posted);
}
}
@Override
public void onError(Exception error) {
try {
showError(error != null ? error.getMessage() : getString(R.string.comment_error));
} catch (IllegalStateException ex) {
// pass
}
afterPostComment();
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.model.Comment in project odysee-android by OdyseeTeam.
the class CommentCreateTask method doInBackground.
public Comment doInBackground(Void... params) {
Comment createdComment = null;
ResponseBody responseBody = null;
try {
// check comments status endpoint
Comments.checkCommentsEndpointStatus();
JSONObject comment_body = new JSONObject();
comment_body.put("comment", comment.getText());
comment_body.put("claim_id", comment.getClaimId());
if (!Helper.isNullOrEmpty(comment.getParentId())) {
comment_body.put("parent_id", comment.getParentId());
}
comment_body.put("channel_id", comment.getChannelId());
comment_body.put("channel_name", comment.getChannelName());
if (authToken != null) {
comment_body.put("auth_token", authToken);
}
JSONObject jsonChannelSign = Comments.channelSignWithCommentData(comment_body, comment, comment.getText());
if (jsonChannelSign.has("signature") && jsonChannelSign.has("signing_ts")) {
comment_body.put("signature", jsonChannelSign.getString("signature"));
comment_body.put("signing_ts", jsonChannelSign.getString("signing_ts"));
}
Response resp = Comments.performRequest(comment_body, "comment.Create");
responseBody = resp.body();
if (responseBody != null) {
String responseString = responseBody.string();
resp.close();
JSONObject jsonResponse = new JSONObject(responseString);
if (jsonResponse.has("result"))
createdComment = Comment.fromJSONObject(jsonResponse.getJSONObject("result"));
}
} catch (ApiCallException | ClassCastException | IOException | JSONException ex) {
error = ex;
} finally {
if (responseBody != null) {
responseBody.close();
}
}
return createdComment;
}
use of com.odysee.app.model.Comment in project odysee-android by OdyseeTeam.
the class FileViewFragment method loadComments.
private void loadComments() {
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
View root = getView();
if (root != null && actualClaim != null) {
ProgressBar commentsLoading = root.findViewById(R.id.file_view_comments_progress);
CommentListTask task = new CommentListTask(1, 200, actualClaim.getClaimId(), commentsLoading, new CommentListHandler() {
@Override
public void onSuccess(List<Comment> comments, boolean hasReachedEnd) {
if (!comments.isEmpty()) {
// Load and process comments reactions on a different thread so main thread is not blocked
Helper.setViewVisibility(commentsLoading, View.VISIBLE);
new Thread(new Runnable() {
@Override
public void run() {
Map<String, Reactions> commentReactions = loadReactions(comments);
Activity activity = getActivity();
if (activity != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
Helper.setViewVisibility(commentsLoading, View.GONE);
processCommentReactions(comments, commentReactions);
}
});
}
}
}).start();
}
}
@Override
public void onError(Exception error) {
if (error != null) {
error.printStackTrace();
}
checkNoComments();
}
private void processCommentReactions(List<Comment> comments, Map<String, Reactions> commentReactions) {
for (Comment c : comments) {
if (commentReactions != null) {
c.setReactions(commentReactions.get(c.getId()));
} else {
c.setReactions(new Reactions(0, 0, false, false));
}
}
List<Comment> rootComments = new ArrayList<>();
for (Comment c : comments) {
if (c.getParentId() == null) {
rootComments.add(c);
}
}
if (commentReactions != null) {
Collections.sort(rootComments, new Comparator<Comment>() {
@Override
public int compare(Comment o1, Comment o2) {
int o1SelfLiked = (Lbryio.isSignedIn() && o1.getReactions() != null && o1.getReactions().isLiked()) ? 1 : 0;
int o2SelfLiked = (Lbryio.isSignedIn() && o2.getReactions() != null && o2.getReactions().isLiked()) ? 1 : 0;
int o1OtherLikes = o1.getReactions() != null ? o1.getReactions().getOthersLikes() : 0;
int o2OtherLikes = o2.getReactions() != null ? o2.getReactions().getOthersLikes() : 0;
return (o2OtherLikes + o2SelfLiked) - (o1OtherLikes + o1SelfLiked);
}
});
}
// Direct comments are now sorted by their amount of likes. We can now pick the
// one to be displayed as the collapsed single comment.
Comment singleComment = rootComments.get(0);
TextView commentText = singleCommentRoot.findViewById(R.id.comment_text);
ImageView thumbnailView = singleCommentRoot.findViewById(R.id.comment_thumbnail);
View noThumbnailView = singleCommentRoot.findViewById(R.id.comment_no_thumbnail);
TextView alphaView = singleCommentRoot.findViewById(R.id.comment_thumbnail_alpha);
commentText.setText(singleComment.getText());
commentText.setMaxLines(3);
commentText.setEllipsize(TextUtils.TruncateAt.END);
commentText.setClickable(true);
commentText.setTextIsSelectable(false);
boolean hasThumbnail = singleComment.getPoster() != null && !Helper.isNullOrEmpty(singleComment.getPoster().getThumbnailUrl());
thumbnailView.setVisibility(hasThumbnail ? View.VISIBLE : View.INVISIBLE);
noThumbnailView.setVisibility(!hasThumbnail ? View.VISIBLE : View.INVISIBLE);
int bgColor = Helper.generateRandomColorForValue(singleComment.getChannelId());
Helper.setIconViewBackgroundColor(noThumbnailView, bgColor, false, getContext());
if (hasThumbnail) {
Context ctx = getContext();
if (ctx != null) {
Context appCtx = ctx.getApplicationContext();
Glide.with(appCtx).asBitmap().load(singleComment.getPoster().getThumbnailUrl()).apply(RequestOptions.circleCropTransform()).into(thumbnailView);
}
}
alphaView.setText(singleComment.getChannelName() != null ? singleComment.getChannelName().substring(1, 2).toUpperCase() : null);
singleCommentRoot.findViewById(R.id.comment_actions_area).setVisibility(View.GONE);
singleCommentRoot.findViewById(R.id.comment_time).setVisibility(View.GONE);
singleCommentRoot.findViewById(R.id.comment_channel_name).setVisibility(View.GONE);
singleCommentRoot.findViewById(R.id.comment_more_options).setVisibility(View.GONE);
singleCommentRoot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
expandButton.performClick();
}
});
List<Comment> parentComments = rootComments;
// rootComments.clear();
for (Comment c : comments) {
if (!parentComments.contains(c)) {
if (c.getParentId() != null) {
Comment item = parentComments.stream().filter(v -> c.getParentId().equalsIgnoreCase(v.getId())).findFirst().orElse(null);
if (item != null) {
parentComments.add(parentComments.indexOf(item) + 1, c);
}
}
}
}
comments = parentComments;
Context ctx = getContext();
View root = getView();
if (ctx != null && root != null) {
ensureCommentListAdapterCreated(comments);
}
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
use of com.odysee.app.model.Comment in project odysee-android by OdyseeTeam.
the class FileViewFragment method initUi.
@SuppressWarnings("ClickableViewAccessibility")
private void initUi(View root) {
buttonPublishSomething.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Context context = getContext();
if (!Helper.isNullOrEmpty(currentUrl) && context instanceof MainActivity) {
LbryUri uri = LbryUri.tryParse(currentUrl);
if (uri != null) {
Map<String, Object> params = new HashMap<>();
params.put("suggestedUrl", uri.getStreamName());
// ((MainActivity) context).openFragment(PublishFragment.class, true, NavMenuItem.ID_ITEM_NEW_PUBLISH, params);
}
}
}
});
root.findViewById(R.id.file_view_title_area).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ImageView descIndicator = root.findViewById(R.id.file_view_desc_toggle_arrow);
View descriptionArea = root.findViewById(R.id.file_view_description_area);
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
boolean hasDescription = actualClaim != null && !Helper.isNullOrEmpty(actualClaim.getDescription());
boolean hasTags = actualClaim != null && actualClaim.getTags() != null && actualClaim.getTags().size() > 0;
if (descriptionArea.getVisibility() != View.VISIBLE) {
if (hasDescription || hasTags) {
descriptionArea.setVisibility(View.VISIBLE);
}
descIndicator.setImageResource(R.drawable.ic_arrow_dropup);
} else {
descriptionArea.setVisibility(View.GONE);
descIndicator.setImageResource(R.drawable.ic_arrow_dropdown);
}
}
});
root.findViewById(R.id.file_view_action_like).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AccountManager am = AccountManager.get(root.getContext());
Account odyseeAccount = Helper.getOdyseeAccount(am.getAccounts());
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
if (actualClaim != null && odyseeAccount != null) {
react(actualClaim, true);
}
}
});
root.findViewById(R.id.file_view_action_dislike).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AccountManager am = AccountManager.get(root.getContext());
Account odyseeAccount = Helper.getOdyseeAccount(am.getAccounts());
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
if (actualClaim != null && odyseeAccount != null) {
react(actualClaim, false);
}
}
});
root.findViewById(R.id.file_view_action_share).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
if (actualClaim != null) {
try {
String shareUrl = LbryUri.parse(!Helper.isNullOrEmpty(actualClaim.getCanonicalUrl()) ? actualClaim.getCanonicalUrl() : (!Helper.isNullOrEmpty(actualClaim.getShortUrl()) ? actualClaim.getShortUrl() : actualClaim.getPermanentUrl())).toOdyseeString();
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, shareUrl);
MainActivity.startingShareActivity = true;
Intent shareUrlIntent = Intent.createChooser(shareIntent, getString(R.string.share_lbry_content));
shareUrlIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(shareUrlIntent);
} catch (LbryUriException ex) {
// pass
}
}
}
});
root.findViewById(R.id.file_view_action_tip).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
MainActivity activity = (MainActivity) getActivity();
if (activity != null && activity.isSignedIn()) {
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
if (actualClaim != null) {
CreateSupportDialogFragment dialog = CreateSupportDialogFragment.newInstance(actualClaim, (amount, isTip) -> {
double sentAmount = amount.doubleValue();
String message = getResources().getQuantityString(isTip ? R.plurals.you_sent_a_tip : R.plurals.you_sent_a_support, sentAmount == 1.0 ? 1 : 2, new DecimalFormat("#,###.##").format(sentAmount));
Snackbar.make(root.findViewById(R.id.file_view_claim_display_area), message, Snackbar.LENGTH_LONG).show();
});
Context context = getContext();
if (context instanceof MainActivity) {
dialog.show(((MainActivity) context).getSupportFragmentManager(), CreateSupportDialogFragment.TAG);
}
}
} else {
if (activity != null) {
activity.simpleSignIn(0);
}
}
}
});
root.findViewById(R.id.file_view_action_repost).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
if (actualClaim != null) {
RepostClaimDialogFragment dialog = RepostClaimDialogFragment.newInstance(actualClaim, claim -> {
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).showMessage(R.string.content_successfully_reposted);
}
});
Context context = getContext();
if (context instanceof MainActivity) {
dialog.show(((MainActivity) context).getSupportFragmentManager(), RepostClaimDialogFragment.TAG);
}
}
}
});
root.findViewById(R.id.file_view_action_edit).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Context context = getContext();
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
if (actualClaim != null && context instanceof MainActivity) {
((MainActivity) context).openPublishForm(actualClaim);
}
}
});
root.findViewById(R.id.file_view_action_delete).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
if (actualClaim != null) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()).setTitle(R.string.delete_file).setMessage(R.string.confirm_delete_file_message).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
deleteClaimFile();
}
}).setNegativeButton(R.string.no, null);
builder.show();
}
}
});
root.findViewById(R.id.file_view_action_unpublish).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
if (actualClaim != null) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()).setTitle(R.string.delete_content).setMessage(R.string.confirm_delete_content_message).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
deleteCurrentClaim();
}
}).setNegativeButton(R.string.no, null);
builder.show();
}
}
});
root.findViewById(R.id.file_view_action_download).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
if (actualClaim != null) {
if (downloadInProgress) {
onDownloadAborted();
} else {
checkStoragePermissionAndStartDownload();
}
}
}
});
root.findViewById(R.id.file_view_action_report).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
if (actualClaim != null) {
Context context = getContext();
CustomTabColorSchemeParams.Builder ctcspb = new CustomTabColorSchemeParams.Builder();
ctcspb.setToolbarColor(ContextCompat.getColor(context, R.color.colorPrimary));
CustomTabColorSchemeParams ctcsp = ctcspb.build();
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder().setDefaultColorSchemeParams(ctcsp);
CustomTabsIntent intent = builder.build();
intent.launchUrl(context, Uri.parse(String.format("https://odysee.com/$/report_content?claimId=%s", actualClaim.getClaimId())));
}
}
});
root.findViewById(R.id.player_toggle_cast).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
toggleCast();
}
});
PlayerView playerView = root.findViewById(R.id.file_view_exoplayer_view);
View playbackSpeedContainer = playerView.findViewById(R.id.player_playback_speed);
TextView textPlaybackSpeed = playerView.findViewById(R.id.player_playback_speed_label);
View qualityContainer = playerView.findViewById(R.id.player_quality);
TextView textQuality = playerView.findViewById(R.id.player_quality_label);
textPlaybackSpeed.setText(DEFAULT_PLAYBACK_SPEED);
textQuality.setText(AUTO_QUALITY_STRING);
playbackSpeedContainer.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
@Override
public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) {
Helper.buildPlaybackSpeedMenu(contextMenu);
}
});
playbackSpeedContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).openContextMenu(playbackSpeedContainer);
}
}
});
qualityContainer.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
@Override
public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) {
if (MainActivity.appPlayer != null) {
Helper.buildQualityMenu(contextMenu, MainActivity.appPlayer, MainActivity.videoIsTranscoded);
}
}
});
qualityContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).openContextMenu(qualityContainer);
}
}
});
playerView.findViewById(R.id.player_toggle_fullscreen).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// check full screen mode
if (isInFullscreenMode()) {
disableFullScreenMode();
} else {
enableFullScreenMode();
}
}
});
playerView.findViewById(R.id.player_skip_back_10).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (MainActivity.appPlayer != null) {
MainActivity.appPlayer.seekTo(Math.max(0, MainActivity.appPlayer.getCurrentPosition() - 10000));
}
}
});
playerView.findViewById(R.id.player_skip_forward_10).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (MainActivity.appPlayer != null) {
MainActivity.appPlayer.seekTo(MainActivity.appPlayer.getCurrentPosition() + 10000);
}
}
});
root.findViewById(R.id.file_view_publisher_info_area).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
if (actualClaim != null && actualClaim.getSigningChannel() != null) {
removeNotificationAsSource();
Claim publisher = actualClaim.getSigningChannel();
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).openChannelClaim(publisher);
}
}
}
});
View buttonFollow = root.findViewById(R.id.file_view_icon_follow);
View buttonUnfollow = root.findViewById(R.id.file_view_icon_unfollow);
View buttonBell = root.findViewById(R.id.file_view_icon_bell);
buttonFollow.setOnClickListener(followUnfollowListener);
buttonUnfollow.setOnClickListener(followUnfollowListener);
buttonBell.setOnClickListener(bellIconListener);
commentChannelSpinnerAdapter = new InlineChannelSpinnerAdapter(getContext(), R.layout.spinner_item_channel, new ArrayList<>());
commentChannelSpinnerAdapter.addPlaceholder(false);
initCommentForm(root);
expandButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Prevents crash for when comment list isn't loaded yet but user tries to expand.
if (commentListAdapter != null) {
switchCommentListVisibility(commentListAdapter.isCollapsed());
commentListAdapter.switchExpandedState();
}
}
});
singleCommentRoot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
expandButton.performClick();
}
});
RecyclerView relatedContentList = root.findViewById(R.id.file_view_related_content_list);
RecyclerView commentsList = root.findViewById(R.id.file_view_comments_list);
relatedContentList.setNestedScrollingEnabled(false);
commentsList.setNestedScrollingEnabled(false);
LinearLayoutManager relatedContentListLLM = new LinearLayoutManager(getContext());
LinearLayoutManager commentsListLLM = new LinearLayoutManager(getContext());
relatedContentList.setLayoutManager(relatedContentListLLM);
commentsList.setLayoutManager(commentsListLLM);
GestureDetector.SimpleOnGestureListener gestureListener = new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDoubleTap(MotionEvent e) {
ImageView seekOverlay = root.findViewById(R.id.seek_overlay);
int width = playerView.getWidth();
float eventX = e.getX();
if (eventX < width / 3.0) {
if (MainActivity.appPlayer != null) {
MainActivity.appPlayer.seekTo(Math.max(0, MainActivity.appPlayer.getCurrentPosition() - 10000));
seekOverlay.setVisibility(View.VISIBLE);
seekOverlay.setImageResource(R.drawable.ic_rewind);
}
} else if (eventX > width * 2.0 / 3.0) {
if (MainActivity.appPlayer != null) {
MainActivity.appPlayer.seekTo(MainActivity.appPlayer.getCurrentPosition() + 10000);
seekOverlay.setVisibility(View.VISIBLE);
seekOverlay.setImageResource(R.drawable.ic_forward);
}
} else {
return true;
}
if (seekOverlayHandler == null) {
seekOverlayHandler = new Handler();
} else {
// Clear pending messages
seekOverlayHandler.removeCallbacksAndMessages(null);
}
seekOverlayHandler.postDelayed(() -> {
seekOverlay.setVisibility(View.GONE);
}, 500);
return true;
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
if (playerView.isControllerVisible()) {
playerView.hideController();
} else {
playerView.showController();
}
return true;
}
};
GestureDetector detector = new GestureDetector(getContext(), gestureListener);
playerView.setOnTouchListener((view, motionEvent) -> {
detector.onTouchEvent(motionEvent);
return true;
});
}
use of com.odysee.app.model.Comment in project odysee-android by OdyseeTeam.
the class FileViewFragment method postComment.
private void postComment() {
if (postingComment) {
return;
}
Comment comment = buildPostComment();
beforePostComment();
AccountManager am = AccountManager.get(getContext());
Account odyseeAccount = Helper.getOdyseeAccount(am.getAccounts());
CommentCreateTask task = new CommentCreateTask(comment, am.peekAuthToken(odyseeAccount, "auth_token_type"), progressPostComment, new CommentCreateTask.CommentCreateWithTipHandler() {
@Override
public void onSuccess(Comment createdComment) {
inputComment.setText(null);
clearReplyToComment();
final boolean thisIsFirstComment = commentListAdapter == null;
ensureCommentListAdapterCreated(new ArrayList<Comment>());
if (commentListAdapter != null) {
createdComment.setPoster(comment.getPoster());
if (!Helper.isNullOrEmpty(createdComment.getParentId())) {
commentListAdapter.addReply(createdComment);
} else {
commentListAdapter.insert(0, createdComment);
}
}
afterPostComment();
checkNoComments();
if (thisIsFirstComment) {
expandButton.performClick();
}
singleCommentRoot.setVisibility(View.GONE);
Bundle bundle = new Bundle();
bundle.putString("claim_id", fileClaim != null ? fileClaim.getClaimId() : null);
bundle.putString("claim_name", fileClaim != null ? fileClaim.getName() : null);
LbryAnalytics.logEvent(LbryAnalytics.EVENT_COMMENT_CREATE, bundle);
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).showMessage(R.string.comment_posted);
}
}
@Override
public void onError(Exception error) {
try {
showError(error != null ? error.getMessage() : getString(R.string.comment_error));
} catch (IllegalStateException ex) {
// pass
}
afterPostComment();
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Aggregations