Add live comments
This commit is contained in:
parent
aba09af7ac
commit
f4907a4c7b
|
@ -88,7 +88,9 @@ public class PostStatusAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
apiResponse.setError(error);
|
apiResponse.setError(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if( status.getIn_reply_to_id() != null){
|
||||||
|
apiResponse.setTargetedId(status.getIn_reply_to_id());
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,6 +187,20 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
||||||
Toasty.info(context, context.getString(R.string.toast_toot_saved_error), Toast.LENGTH_LONG).show();
|
Toasty.info(context, context.getString(R.string.toast_toot_saved_error), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( apiResponse.getTargetedId() != null && apiResponse.getStatuses() != null && apiResponse.getStatuses().size() > 0){
|
||||||
|
int position = 0;
|
||||||
|
for(Status tl: this.statuses){
|
||||||
|
if( tl.getId().equals(apiResponse.getTargetedId())){
|
||||||
|
List<Status> comments = this.statuses.get(position).getComments();
|
||||||
|
comments.add(comments.size(), apiResponse.getStatuses().get(0));
|
||||||
|
this.statuses.get(position).setComments(comments);
|
||||||
|
notifyStatusChanged(this.statuses.get(position));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,18 +427,11 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
holder.quick_reply_switch_to_full.setVisibility(View.GONE);
|
||||||
if (status.isShortReply()) {
|
if (status.isShortReply()) {
|
||||||
holder.quick_reply_container.setVisibility(View.VISIBLE);
|
holder.quick_reply_container.setVisibility(View.VISIBLE);
|
||||||
holder.pixelfed_comments.setVisibility(View.VISIBLE);
|
holder.pixelfed_comments.setVisibility(View.VISIBLE);
|
||||||
holder.quick_reply_switch_to_full.setVisibility(View.GONE);
|
|
||||||
in_reply_to_status = status.getReblog() != null ? status.getReblog().getId() : status.getId();
|
in_reply_to_status = status.getReblog() != null ? status.getReblog().getId() : status.getId();
|
||||||
for (Status s : statuses) {
|
|
||||||
if (s.isShortReply() && !s.getId().equals(status.getId())) {
|
|
||||||
s.setShortReply(false);
|
|
||||||
notifyStatusChanged(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( status.isCommentsFetched()){
|
if( status.isCommentsFetched()){
|
||||||
StatusListAdapter statusListAdapter = new StatusListAdapter(0, status.getId(), true, status.getComments());
|
StatusListAdapter statusListAdapter = new StatusListAdapter(0, status.getId(), true, status.getComments());
|
||||||
final LinearLayoutManager mLayoutManager;
|
final LinearLayoutManager mLayoutManager;
|
||||||
|
@ -541,8 +548,6 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
||||||
} else {
|
} else {
|
||||||
holder.quick_reply_container.setVisibility(View.GONE);
|
holder.quick_reply_container.setVisibility(View.GONE);
|
||||||
holder.pixelfed_comments.setVisibility(View.GONE);
|
holder.pixelfed_comments.setVisibility(View.GONE);
|
||||||
holder.quick_reply_container.setVisibility(View.GONE);
|
|
||||||
holder.pixelfed_comments.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -588,7 +593,6 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
||||||
notifyStatusChanged(status);
|
notifyStatusChanged(status);
|
||||||
});
|
});
|
||||||
theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||||
holder.quick_reply_container.setVisibility(View.VISIBLE);
|
|
||||||
holder.pf_description.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
|
holder.pf_description.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
|
||||||
holder.pf_date.setText(Helper.longDateToString(status.getCreated_at()));
|
holder.pf_date.setText(Helper.longDateToString(status.getCreated_at()));
|
||||||
holder.quick_reply_text.setHint(R.string.leave_a_comment);
|
holder.quick_reply_text.setHint(R.string.leave_a_comment);
|
||||||
|
@ -596,7 +600,14 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
||||||
holder.pf_comment.setOnClickListener(new View.OnClickListener() {
|
holder.pf_comment.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
status.setShortReply(!status.isShortReply());
|
boolean currentValue = status.isShortReply();
|
||||||
|
for (Status s : statuses) {
|
||||||
|
if (s.isShortReply() && !s.getId().equals(status.getId())) {
|
||||||
|
s.setShortReply(false);
|
||||||
|
notifyStatusChanged(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
status.setShortReply(!currentValue);
|
||||||
if( !status.isShortReply()){
|
if( !status.isShortReply()){
|
||||||
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||||
assert imm != null;
|
assert imm != null;
|
||||||
|
|
|
@ -862,7 +862,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
if (statuses.get(position).isFocused() && type == RetrieveFeedsAsyncTask.Type.CONTEXT && statuses.get(position).getViewType() != CONSOLE_STATUS)
|
if (statuses.get(position).isFocused() && type == RetrieveFeedsAsyncTask.Type.CONTEXT && statuses.get(position).getViewType() != CONSOLE_STATUS)
|
||||||
return FOCUSED_STATUS;
|
return FOCUSED_STATUS;
|
||||||
else {
|
else {
|
||||||
if( social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED) {
|
if( social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED && type == RetrieveFeedsAsyncTask.Type.CONTEXT) {
|
||||||
return COMPACT_STATUS;
|
return COMPACT_STATUS;
|
||||||
}else {
|
}else {
|
||||||
return statuses.get(position).getViewType();
|
return statuses.get(position).getViewType();
|
||||||
|
@ -917,6 +917,9 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
status.setItemViewType(viewHolder.getItemViewType());
|
status.setItemViewType(viewHolder.getItemViewType());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
boolean fullAttachement = sharedpreferences.getBoolean(Helper.SET_FULL_PREVIEW, false);
|
boolean fullAttachement = sharedpreferences.getBoolean(Helper.SET_FULL_PREVIEW, false);
|
||||||
boolean isCompactMode = sharedpreferences.getBoolean(Helper.SET_COMPACT_MODE, false);
|
boolean isCompactMode = sharedpreferences.getBoolean(Helper.SET_COMPACT_MODE, false);
|
||||||
boolean isConsoleMode = sharedpreferences.getBoolean(Helper.SET_CONSOLE_MODE, false);
|
boolean isConsoleMode = sharedpreferences.getBoolean(Helper.SET_CONSOLE_MODE, false);
|
||||||
|
@ -961,7 +964,18 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED && type == RetrieveFeedsAsyncTask.Type.CONTEXT) {
|
||||||
|
if (theme == Helper.THEME_DARK) {
|
||||||
|
holder.main_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_1));
|
||||||
|
holder.main_container.setAlpha(.5f);
|
||||||
|
} else if (theme == Helper.THEME_BLACK) {
|
||||||
|
holder.main_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_black_1));
|
||||||
|
holder.main_container.setAlpha(.5f);
|
||||||
|
} else {
|
||||||
|
holder.main_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_light_1));
|
||||||
|
holder.main_container.setAlpha(.5f);
|
||||||
|
}
|
||||||
|
}
|
||||||
//Display a preview for accounts that have replied *if enabled and only for home timeline*
|
//Display a preview for accounts that have replied *if enabled and only for home timeline*
|
||||||
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
|
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
|
||||||
holder.rated.setVisibility(View.GONE);
|
holder.rated.setVisibility(View.GONE);
|
||||||
|
|
Loading…
Reference in New Issue