Fix some crashes
This commit is contained in:
parent
c95dfda3df
commit
ff0ff6cedc
|
@ -139,10 +139,11 @@ public class SpannableHelper {
|
|||
apngDrawable.setBounds(0, 0, (int) convertDpToPixel(20, context), (int) convertDpToPixel(20, context));
|
||||
apngDrawable.setVisible(true, true);
|
||||
imageSpan = new ImageSpan(apngDrawable);
|
||||
content.setSpan(
|
||||
imageSpan, startPosition,
|
||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
|
||||
if (endPosition <= content.length()) {
|
||||
content.setSpan(
|
||||
imageSpan, startPosition,
|
||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} else if (GifParser.isGif(file.getAbsolutePath())) {
|
||||
|
@ -151,9 +152,11 @@ public class SpannableHelper {
|
|||
gifDrawable.setBounds(0, 0, (int) convertDpToPixel(20, context), (int) convertDpToPixel(20, context));
|
||||
gifDrawable.setVisible(true, true);
|
||||
imageSpan = new ImageSpan(gifDrawable);
|
||||
content.setSpan(
|
||||
imageSpan, startPosition,
|
||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
if (endPosition <= content.length()) {
|
||||
content.setSpan(
|
||||
imageSpan, startPosition,
|
||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} else {
|
||||
|
@ -162,9 +165,11 @@ public class SpannableHelper {
|
|||
drawable.setBounds(0, 0, (int) convertDpToPixel(20, context), (int) convertDpToPixel(20, context));
|
||||
drawable.setVisible(true, true);
|
||||
imageSpan = new ImageSpan(drawable);
|
||||
content.setSpan(
|
||||
imageSpan, startPosition,
|
||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
if (endPosition <= content.length()) {
|
||||
content.setSpan(
|
||||
imageSpan, startPosition,
|
||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
@ -682,9 +687,11 @@ public class SpannableHelper {
|
|||
drawable.setBounds(0, 0, (int) convertDpToPixel(20, context), (int) convertDpToPixel(20, context));
|
||||
drawable.setVisible(true, true);
|
||||
imageSpan = new ImageSpan(drawable);
|
||||
content.setSpan(
|
||||
imageSpan, startPosition,
|
||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
if (endPosition <= content.length()) {
|
||||
content.setSpan(
|
||||
imageSpan, startPosition,
|
||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -656,9 +656,15 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||
int currentLength = MastodonHelper.countLength(holder);
|
||||
//Copy/past
|
||||
if (currentLength > instanceInfo.configuration.statusesConf.max_characters + 1) {
|
||||
holder.binding.content.setText(s.delete(instanceInfo.configuration.statusesConf.max_characters - holder.binding.contentSpoiler.getText().length(), (currentLength - holder.binding.contentSpoiler.getText().length())));
|
||||
int from = instanceInfo.configuration.statusesConf.max_characters - holder.binding.contentSpoiler.getText().length();
|
||||
int to = (currentLength - holder.binding.contentSpoiler.getText().length());
|
||||
if (to <= s.length()) {
|
||||
holder.binding.content.setText(s.delete(from, to));
|
||||
}
|
||||
} else if (currentLength > instanceInfo.configuration.statusesConf.max_characters) {
|
||||
holder.binding.content.setText(s.delete(cPosition, cPosition + 1));
|
||||
if (cPosition + 1 <= s.length()) {
|
||||
holder.binding.content.setText(s.delete(cPosition, cPosition + 1));
|
||||
}
|
||||
}
|
||||
statusList.get(holder.getAdapterPosition()).text = s.toString();
|
||||
if (s.toString().trim().length() < 2) {
|
||||
|
|
Loading…
Reference in New Issue