修复笔记内容太多 预览出现anr

This commit is contained in:
xingxing
2017-03-03 12:55:56 +08:00
parent a1271d9c6d
commit e0e4ce83be
2 changed files with 7 additions and 4 deletions

View File

@@ -202,9 +202,9 @@ public class NoteAdapter extends RecyclerView.Adapter<NoteAdapter.NoteHolder> {
} }
} }
if (note.isMarkDown()) { if (note.isMarkDown()) {
holder.contentTv.setText(note.getContent()); holder.contentTv.setText(note.getNoteAbstract());
} else { } else {
Spanned spannedContent = Html.fromHtml(note.getContent()); Spanned spannedContent = Html.fromHtml(note.getNoteAbstract());
String contentStr = spannedContent.toString(); String contentStr = spannedContent.toString();
contentStr = contentStr.replaceAll("\\n\\n+", "\n"); contentStr = contentStr.replaceAll("\\n\\n+", "\n");
holder.contentTv.setText(contentStr); holder.contentTv.setText(contentStr);

View File

@@ -104,12 +104,15 @@ public class NoteService {
localId = localNote.getId(); localId = localNote.getId();
} }
remoteNote.setIsDirty(false); remoteNote.setIsDirty(false);
String content;
if (remoteNote.isMarkDown()) { if (remoteNote.isMarkDown()) {
remoteNote.setContent(convertToLocalImageLinkForMD(localId, remoteNote.getContent())); content = convertToLocalImageLinkForMD(localId, remoteNote.getContent());
} else { } else {
remoteNote.setContent(convertToLocalImageLinkForRichText(localId, remoteNote.getContent())); content = convertToLocalImageLinkForRichText(localId, remoteNote.getContent());
} }
XLog.i(TAG + "content=" + remoteNote.getContent()); XLog.i(TAG + "content=" + remoteNote.getContent());
remoteNote.setContent(content);
remoteNote.setNoteAbstract(content.length() < 500 ? content : content.substring(0, 500));
remoteNote.update(); remoteNote.update();
handleFile(localId, remoteNote.getNoteFiles()); handleFile(localId, remoteNote.getNoteFiles());
updateTagsToLocal(localId, remoteNote.getTagData()); updateTagsToLocal(localId, remoteNote.getTagData());