mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Fix some crashes
This commit is contained in:
parent
c95dfda3df
commit
ff0ff6cedc
2 changed files with 28 additions and 15 deletions
|
@ -139,10 +139,11 @@ public class SpannableHelper {
|
||||||
apngDrawable.setBounds(0, 0, (int) convertDpToPixel(20, context), (int) convertDpToPixel(20, context));
|
apngDrawable.setBounds(0, 0, (int) convertDpToPixel(20, context), (int) convertDpToPixel(20, context));
|
||||||
apngDrawable.setVisible(true, true);
|
apngDrawable.setVisible(true, true);
|
||||||
imageSpan = new ImageSpan(apngDrawable);
|
imageSpan = new ImageSpan(apngDrawable);
|
||||||
content.setSpan(
|
if (endPosition <= content.length()) {
|
||||||
imageSpan, startPosition,
|
content.setSpan(
|
||||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
imageSpan, startPosition,
|
||||||
|
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
} else if (GifParser.isGif(file.getAbsolutePath())) {
|
} 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.setBounds(0, 0, (int) convertDpToPixel(20, context), (int) convertDpToPixel(20, context));
|
||||||
gifDrawable.setVisible(true, true);
|
gifDrawable.setVisible(true, true);
|
||||||
imageSpan = new ImageSpan(gifDrawable);
|
imageSpan = new ImageSpan(gifDrawable);
|
||||||
content.setSpan(
|
if (endPosition <= content.length()) {
|
||||||
imageSpan, startPosition,
|
content.setSpan(
|
||||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
imageSpan, startPosition,
|
||||||
|
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -162,9 +165,11 @@ public class SpannableHelper {
|
||||||
drawable.setBounds(0, 0, (int) convertDpToPixel(20, context), (int) convertDpToPixel(20, context));
|
drawable.setBounds(0, 0, (int) convertDpToPixel(20, context), (int) convertDpToPixel(20, context));
|
||||||
drawable.setVisible(true, true);
|
drawable.setVisible(true, true);
|
||||||
imageSpan = new ImageSpan(drawable);
|
imageSpan = new ImageSpan(drawable);
|
||||||
content.setSpan(
|
if (endPosition <= content.length()) {
|
||||||
imageSpan, startPosition,
|
content.setSpan(
|
||||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
imageSpan, startPosition,
|
||||||
|
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -682,9 +687,11 @@ public class SpannableHelper {
|
||||||
drawable.setBounds(0, 0, (int) convertDpToPixel(20, context), (int) convertDpToPixel(20, context));
|
drawable.setBounds(0, 0, (int) convertDpToPixel(20, context), (int) convertDpToPixel(20, context));
|
||||||
drawable.setVisible(true, true);
|
drawable.setVisible(true, true);
|
||||||
imageSpan = new ImageSpan(drawable);
|
imageSpan = new ImageSpan(drawable);
|
||||||
content.setSpan(
|
if (endPosition <= content.length()) {
|
||||||
imageSpan, startPosition,
|
content.setSpan(
|
||||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
imageSpan, startPosition,
|
||||||
|
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -656,9 +656,15 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
int currentLength = MastodonHelper.countLength(holder);
|
int currentLength = MastodonHelper.countLength(holder);
|
||||||
//Copy/past
|
//Copy/past
|
||||||
if (currentLength > instanceInfo.configuration.statusesConf.max_characters + 1) {
|
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) {
|
} 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();
|
statusList.get(holder.getAdapterPosition()).text = s.toString();
|
||||||
if (s.toString().trim().length() < 2) {
|
if (s.toString().trim().length() < 2) {
|
||||||
|
|
Loading…
Reference in a new issue