Fix some crashes
This commit is contained in:
parent
1b594568d2
commit
1e42bd353f
|
@ -1265,7 +1265,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
if( error != null){
|
||||
return;
|
||||
}
|
||||
if( relationship.isBlocked_by() ){
|
||||
if( relationship != null && relationship.isBlocked_by() ){
|
||||
warning_message.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
@ -2462,40 +2462,42 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
toot_content.setAdapter(emojisSearchAdapter);
|
||||
final String oldContent = toot_content.getText().toString();
|
||||
String[] searchA = oldContent.substring(0,currentCursorPosition).split(":");
|
||||
final String search = searchA[searchA.length-1];
|
||||
toot_content.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
String shortcode = emojis.get(position).getShortcode();
|
||||
String deltaSearch = "";
|
||||
int searchLength = 15;
|
||||
if (currentCursorPosition < 15) { //Less than 15 characters are written before the cursor position
|
||||
searchLength = currentCursorPosition;
|
||||
}
|
||||
if( currentCursorPosition-searchLength > 0 && currentCursorPosition < oldContent.length() )
|
||||
deltaSearch = oldContent.substring(currentCursorPosition-searchLength, currentCursorPosition);
|
||||
else {
|
||||
if( currentCursorPosition >= oldContent.length() )
|
||||
deltaSearch = oldContent.substring(currentCursorPosition-searchLength, oldContent.length());
|
||||
}
|
||||
if( searchA.length > 0 ) {
|
||||
final String search = searchA[searchA.length - 1];
|
||||
toot_content.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
String shortcode = emojis.get(position).getShortcode();
|
||||
String deltaSearch = "";
|
||||
int searchLength = 15;
|
||||
if (currentCursorPosition < 15) { //Less than 15 characters are written before the cursor position
|
||||
searchLength = currentCursorPosition;
|
||||
}
|
||||
if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length())
|
||||
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition);
|
||||
else {
|
||||
if (currentCursorPosition >= oldContent.length())
|
||||
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, oldContent.length());
|
||||
}
|
||||
|
||||
if( !search.equals(""))
|
||||
deltaSearch = deltaSearch.replace(":"+search,"");
|
||||
String newContent = oldContent.substring(0,currentCursorPosition-searchLength);
|
||||
newContent += deltaSearch;
|
||||
newContent += ":" + shortcode + ": ";
|
||||
int newPosition = newContent.length();
|
||||
if( currentCursorPosition < oldContent.length() )
|
||||
newContent += oldContent.substring(currentCursorPosition, oldContent.length()-1);
|
||||
toot_content.setText(newContent);
|
||||
toot_space_left.setText(String.valueOf(countLength(toot_content, toot_cw_content)));
|
||||
toot_content.setSelection(newPosition);
|
||||
EmojisSearchAdapter emojisSearchAdapter = new EmojisSearchAdapter(TootActivity.this, new ArrayList<>());
|
||||
toot_content.setThreshold(1);
|
||||
toot_content.setAdapter(emojisSearchAdapter);
|
||||
if (!search.equals(""))
|
||||
deltaSearch = deltaSearch.replace(":" + search, "");
|
||||
String newContent = oldContent.substring(0, currentCursorPosition - searchLength);
|
||||
newContent += deltaSearch;
|
||||
newContent += ":" + shortcode + ": ";
|
||||
int newPosition = newContent.length();
|
||||
if (currentCursorPosition < oldContent.length())
|
||||
newContent += oldContent.substring(currentCursorPosition, oldContent.length() - 1);
|
||||
toot_content.setText(newContent);
|
||||
toot_space_left.setText(String.valueOf(countLength(toot_content, toot_cw_content)));
|
||||
toot_content.setSelection(newPosition);
|
||||
EmojisSearchAdapter emojisSearchAdapter = new EmojisSearchAdapter(TootActivity.this, new ArrayList<>());
|
||||
toot_content.setThreshold(1);
|
||||
toot_content.setAdapter(emojisSearchAdapter);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,10 +114,12 @@ public class UpdateAccountInfoAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
|
||||
Intent mainActivity = new Intent(this.contextReference.get(), MainActivity.class);
|
||||
mainActivity.putExtra(Helper.INTENT_ACTION, Helper.ADD_USER_INTENT);
|
||||
this.contextReference.get().startActivity(mainActivity);
|
||||
((Activity) this.contextReference.get()).finish();
|
||||
if( this.contextReference.get() != null) {
|
||||
Intent mainActivity = new Intent(this.contextReference.get(), MainActivity.class);
|
||||
mainActivity.putExtra(Helper.INTENT_ACTION, Helper.ADD_USER_INTENT);
|
||||
this.contextReference.get().startActivity(mainActivity);
|
||||
((Activity) this.contextReference.get()).finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import android.os.Bundle;
|
|||
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import androidx.room.util.StringUtil;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
|
@ -297,6 +298,13 @@ public class API {
|
|||
}else if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
|
||||
url_action = Helper.instanceWithProtocol(this.context, this.instance) + "/api/pleroma" + endpoint;
|
||||
}
|
||||
if( url_action == null){
|
||||
apiResponse = new APIResponse();
|
||||
APIError = new Error();
|
||||
APIError.setError(context.getString(R.string.toast_error));
|
||||
apiResponse.setError(APIError);
|
||||
return apiResponse;
|
||||
}
|
||||
try {
|
||||
String response = new HttpsConnection(context, this.instance).get(url_action, 10, params, prefKeyOauthTokenT);
|
||||
if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA){
|
||||
|
@ -1619,8 +1627,13 @@ public class API {
|
|||
String response = httpsConnection.get("https://"+remoteInstance+"/api/statuses/public_timeline.json", 10, params, prefKeyOauthTokenT);
|
||||
statuses = GNUAPI.parseStatuses(context, new JSONArray(response));
|
||||
if( statuses.size() > 0) {
|
||||
apiResponse.setSince_id(String.valueOf(Long.parseLong(statuses.get(0).getId())+1));
|
||||
apiResponse.setMax_id(String.valueOf(Long.parseLong(statuses.get(statuses.size() - 1).getId())-1));
|
||||
if(statuses.get(0).getId() != null && statuses.get(0).getId().matches("-?\\d+(\\.\\d+)?")) {
|
||||
apiResponse.setSince_id(String.valueOf(Long.parseLong(statuses.get(0).getId()) + 1));
|
||||
apiResponse.setMax_id(String.valueOf(Long.parseLong(statuses.get(statuses.size() - 1).getId()) - 1));
|
||||
}else{
|
||||
apiResponse.setSince_id(statuses.get(0).getId());
|
||||
apiResponse.setMax_id(statuses.get(statuses.size() - 1).getId());
|
||||
}
|
||||
}
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -602,7 +602,7 @@ public class Status implements Parcelable{
|
|||
urlText += "|"+count;
|
||||
count++;
|
||||
}
|
||||
content = content.replaceFirst(Pattern.quote(beforemodification), urlText);
|
||||
content = content.replaceFirst(Pattern.quote(beforemodification), Matcher.quoteReplacement(urlText));
|
||||
}
|
||||
}
|
||||
spannableStringContent = new SpannableString(content);
|
||||
|
|
Loading…
Reference in New Issue