Fix with attahcments and notifications
This commit is contained in:
parent
a0d7ed4efa
commit
20f4bd621d
|
@ -408,6 +408,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
||||||
}
|
}
|
||||||
if( type.equals("favourite") || type.equals("reblog")){
|
if( type.equals("favourite") || type.equals("reblog")){
|
||||||
holder.status_document_container.setVisibility(View.GONE);
|
holder.status_document_container.setVisibility(View.GONE);
|
||||||
|
holder.status_show_more.setVisibility(View.GONE);
|
||||||
}else {
|
}else {
|
||||||
if (status.getReblog() == null) {
|
if (status.getReblog() == null) {
|
||||||
if (status.getMedia_attachments().size() < 1) {
|
if (status.getMedia_attachments().size() < 1) {
|
||||||
|
@ -416,7 +417,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
||||||
} else {
|
} else {
|
||||||
//If medias are loaded without any conditions or if device is on wifi
|
//If medias are loaded without any conditions or if device is on wifi
|
||||||
if (!status.isSensitive() && (behaviorWithAttachments == Helper.ATTACHMENT_ALWAYS || (behaviorWithAttachments == Helper.ATTACHMENT_WIFI && isOnWifi))) {
|
if (!status.isSensitive() && (behaviorWithAttachments == Helper.ATTACHMENT_ALWAYS || (behaviorWithAttachments == Helper.ATTACHMENT_WIFI && isOnWifi))) {
|
||||||
loadAttachments(status, holder);
|
loadAttachments(notification, holder);
|
||||||
holder.status_show_more.setVisibility(View.GONE);
|
holder.status_show_more.setVisibility(View.GONE);
|
||||||
status.setAttachmentShown(true);
|
status.setAttachmentShown(true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -427,29 +428,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
||||||
holder.status_show_more.setVisibility(View.VISIBLE);
|
holder.status_show_more.setVisibility(View.VISIBLE);
|
||||||
holder.status_document_container.setVisibility(View.GONE);
|
holder.status_document_container.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
loadAttachments(status, holder);
|
loadAttachments(notification, holder);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else { //Attachments for reblogs
|
|
||||||
if (status.getReblog().getMedia_attachments().size() < 1) {
|
|
||||||
holder.status_document_container.setVisibility(View.GONE);
|
|
||||||
holder.status_show_more.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
//If medias are loaded without any conditions or if device is on wifi
|
|
||||||
if (!status.getReblog().isSensitive() && (behaviorWithAttachments == Helper.ATTACHMENT_ALWAYS || (behaviorWithAttachments == Helper.ATTACHMENT_WIFI && isOnWifi))) {
|
|
||||||
loadAttachments(status.getReblog(), holder);
|
|
||||||
holder.status_show_more.setVisibility(View.GONE);
|
|
||||||
status.getReblog().setAttachmentShown(true);
|
|
||||||
} else {
|
|
||||||
//Text depending if toots is sensitive or not
|
|
||||||
String textShowMore = (status.getReblog().isSensitive()) ? context.getString(R.string.load_sensitive_attachment) : context.getString(R.string.load_attachment);
|
|
||||||
holder.status_show_more.setText(textShowMore);
|
|
||||||
if (!status.isAttachmentShown()) {
|
|
||||||
holder.status_show_more.setVisibility(View.VISIBLE);
|
|
||||||
holder.status_document_container.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
loadAttachments(status.getReblog(), holder);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -498,8 +477,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
||||||
holder.status_show_more.setOnClickListener(new View.OnClickListener() {
|
holder.status_show_more.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
loadAttachments(status, holder);
|
loadAttachments(notification, holder);
|
||||||
holder.status_show_more.setVisibility(View.GONE);
|
|
||||||
notification.getStatus().setAttachmentShown(true);
|
notification.getStatus().setAttachmentShown(true);
|
||||||
notifyNotificationChanged(notification);
|
notifyNotificationChanged(notification);
|
||||||
/*
|
/*
|
||||||
|
@ -520,8 +498,6 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
||||||
|
|
||||||
public void onFinish() {
|
public void onFinish() {
|
||||||
notification.getStatus().setAttachmentShown(false);
|
notification.getStatus().setAttachmentShown(false);
|
||||||
holder.status_show_more.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
notifyNotificationChanged(notification);
|
notifyNotificationChanged(notification);
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
|
@ -945,8 +921,8 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadAttachments(final Status status, ViewHolder holder){
|
private void loadAttachments(final Notification notification, ViewHolder holder){
|
||||||
List<Attachment> attachments = status.getMedia_attachments();
|
List<Attachment> attachments = notification.getStatus().getMedia_attachments();
|
||||||
if( attachments != null && attachments.size() > 0){
|
if( attachments != null && attachments.size() > 0){
|
||||||
int i = 0;
|
int i = 0;
|
||||||
holder.status_document_container.setVisibility(View.VISIBLE);
|
holder.status_document_container.setVisibility(View.VISIBLE);
|
||||||
|
@ -1014,7 +990,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent intent = new Intent(context, MediaActivity.class);
|
Intent intent = new Intent(context, MediaActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
intent.putParcelableArrayListExtra("mediaArray", status.getMedia_attachments());
|
intent.putParcelableArrayListExtra("mediaArray", notification.getStatus().getMedia_attachments());
|
||||||
b.putInt("position", finalPosition);
|
b.putInt("position", finalPosition);
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
|
@ -1249,14 +1249,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
-> Default value is set to 5 seconds
|
-> Default value is set to 5 seconds
|
||||||
*/
|
*/
|
||||||
final int timeout = sharedpreferences.getInt(Helper.SET_NSFW_TIMEOUT, 5);
|
final int timeout = sharedpreferences.getInt(Helper.SET_NSFW_TIMEOUT, 5);
|
||||||
|
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
|
|
||||||
new CountDownTimer((timeout * 1000), 1000) {
|
new CountDownTimer((timeout * 1000), 1000) {
|
||||||
|
|
||||||
public void onTick(long millisUntilFinished) {
|
public void onTick(long millisUntilFinished) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onFinish() {
|
public void onFinish() {
|
||||||
status.setAttachmentShown(false);
|
status.setAttachmentShown(false);
|
||||||
notifyStatusChanged(status);
|
notifyStatusChanged(status);
|
||||||
|
@ -1885,18 +1881,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
height = (int) Helper.convertDpToPixel(200, context);
|
height = (int) Helper.convertDpToPixel(200, context);
|
||||||
resource = Bitmap.createScaledBitmap(resource, width, height, false);
|
resource = Bitmap.createScaledBitmap(resource, width, height, false);
|
||||||
}
|
}
|
||||||
//Allow to put full width for preview for single attachment -> disabled for the moment
|
|
||||||
/*int tootWidth = holder.status_content_container.getWidth();
|
|
||||||
|
|
||||||
if( width < tootWidth && attachments.size() == 1){
|
|
||||||
double ratio = ((double)tootWidth/ (double)width);
|
|
||||||
height = (int)(ratio * (double)height);
|
|
||||||
width = tootWidth;
|
|
||||||
holder.status_horizontal_document_container.getLayoutParams().height = height;
|
|
||||||
resource = Bitmap.createScaledBitmap(resource, width, height, false);
|
|
||||||
}else{
|
|
||||||
holder.status_horizontal_document_container.getLayoutParams().height = (int)Helper.convertDpToPixel(200, context);
|
|
||||||
}*/
|
|
||||||
imageView.setImageBitmap(resource);
|
imageView.setImageBitmap(resource);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue