Fixes a crash and errors associated with a URL pasted into the composer being edited before its metadata is loaded.
This commit is contained in:
parent
d344f34ffb
commit
9d564ad3ec
@ -1472,10 +1472,12 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
|
||||
@Override
|
||||
public void onReceiveHeaderInfo(ParserUtils.HeaderInfo headerInfo) {
|
||||
if (!TextUtils.isEmpty(headerInfo.title)) {
|
||||
cleanBaseUrl(headerInfo);
|
||||
textEditor.append(headerInfo.title);
|
||||
textEditor.append(StringUtils.carriageReturn);
|
||||
textEditor.append(headerInfo.baseUrl);
|
||||
Editable text = textEditor.getText();
|
||||
int index = text.toString().indexOf(headerInfo.baseUrl);
|
||||
if (index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
text.insert(index, headerInfo.title + StringUtils.carriageReturn);
|
||||
}
|
||||
if (!TextUtils.isEmpty(headerInfo.image)) {
|
||||
Picasso.Builder builder = new Picasso.Builder(getApplicationContext());
|
||||
@ -1505,16 +1507,6 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
|
||||
}
|
||||
}
|
||||
|
||||
// remove the precedent paste from the edit text
|
||||
private void cleanBaseUrl(ParserUtils.HeaderInfo headerInfo) {
|
||||
int lengthBaseUrl = headerInfo.baseUrl.length();
|
||||
int total = textEditor.getText().length();
|
||||
int indexSubString = total - lengthBaseUrl;
|
||||
String text = textEditor.getText().toString();
|
||||
text = text.substring(0, indexSubString);
|
||||
textEditor.setText(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onErrorHeaderInfo() {
|
||||
displayTransientError(R.string.error_generic);
|
||||
|
Loading…
Reference in New Issue
Block a user