Fix crashes + improve split toots

This commit is contained in:
stom79 2018-09-07 07:58:20 +02:00
parent 6a6da81ccf
commit 0d8071331c
4 changed files with 36 additions and 33 deletions

View File

@ -482,10 +482,10 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
@Override
public void onRetrieveAccount(final Account account, Error error) {
if( error != null){
if( error != null || account.getAcct() == null){
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean show_error_messages = sharedpreferences.getBoolean(Helper.SET_SHOW_ERROR_MESSAGES, true);
if( show_error_messages)
if( show_error_messages && error != null)
Toast.makeText(getApplicationContext(), error.getError(),Toast.LENGTH_LONG).show();
return;
}

View File

@ -489,10 +489,11 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
boolean split_toot = sharedpreferences.getBoolean(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS, false);
int split_toot_size = sharedpreferences.getInt(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS_SIZE, Helper.SPLIT_TOOT_SIZE);
String tootContent;
if( toot_cw_content.getText() != null && toot_cw_content.getText().toString().trim().length() > 0 )
split_toot_size -= toot_cw_content.getText().toString().trim().length();
if( !split_toot || (toot_content.getText().toString().trim().length() < split_toot_size)){
tootContent = toot_content.getText().toString().trim();
}else{
splitToot = Helper.splitToots(toot_content.getText().toString().trim(), split_toot_size);
tootContent = splitToot.get(0);
stepSpliToot = 1;
@ -1604,8 +1605,10 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
boolean split_toot = sharedpreferences.getBoolean(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS, false);
int split_toot_size = sharedpreferences.getInt(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS_SIZE, Helper.SPLIT_TOOT_SIZE);
int cwSize = toot_cw_content.getText().toString().trim().length();
int size = toot_content.getText().toString().trim().length() + cwSize;
if( split_toot && (toot_content.getText().toString().trim().length() >= split_toot_size) && stepSpliToot < splitToot.size()){
if( split_toot && (size >= split_toot_size) && stepSpliToot < splitToot.size()){
String tootContent = splitToot.get(stepSpliToot);
stepSpliToot += 1;
Status toot = new Status();

View File

@ -199,13 +199,13 @@ public class HttpsConnection {
httpURLConnection.setRequestMethod("GET");
String response;
if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) {
response = converToString(httpsURLConnection.getInputStream());
response = converToString(httpURLConnection.getInputStream());
}else {
String error = null;
if( httpsURLConnection.getErrorStream() != null) {
InputStream stream = httpsURLConnection.getErrorStream();
if( httpURLConnection.getErrorStream() != null) {
InputStream stream = httpURLConnection.getErrorStream();
if (stream == null) {
stream = httpsURLConnection.getInputStream();
stream = httpURLConnection.getInputStream();
}
try (Scanner scanner = new Scanner(stream)) {
scanner.useDelimiter("\\Z");
@ -270,13 +270,13 @@ public class HttpsConnection {
String response;
if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) {
getSinceMaxId();
response = converToString(httpsURLConnection.getInputStream());
response = converToString(httpURLConnection.getInputStream());
}else {
String error = null;
if( httpsURLConnection.getErrorStream() != null) {
InputStream stream = httpsURLConnection.getErrorStream();
if( httpURLConnection.getErrorStream() != null) {
InputStream stream = httpURLConnection.getErrorStream();
if (stream == null) {
stream = httpsURLConnection.getInputStream();
stream = httpURLConnection.getInputStream();
}
try (Scanner scanner = new Scanner(stream)) {
scanner.useDelimiter("\\Z");
@ -388,13 +388,13 @@ public class HttpsConnection {
String response;
if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) {
getSinceMaxId();
response = converToString(httpsURLConnection.getInputStream());
response = converToString(httpURLConnection.getInputStream());
} else {
String error = null;
if( httpsURLConnection.getErrorStream() != null) {
InputStream stream = httpsURLConnection.getErrorStream();
if( httpURLConnection.getErrorStream() != null) {
InputStream stream = httpURLConnection.getErrorStream();
if (stream == null) {
stream = httpsURLConnection.getInputStream();
stream = httpURLConnection.getInputStream();
}
try (Scanner scanner = new Scanner(stream)) {
scanner.useDelimiter("\\Z");
@ -865,10 +865,10 @@ public class HttpsConnection {
new String(ByteStreams.toByteArray(httpURLConnection.getInputStream()));
} else {
String error = null;
if( httpsURLConnection.getErrorStream() != null) {
InputStream stream = httpsURLConnection.getErrorStream();
if( httpURLConnection.getErrorStream() != null) {
InputStream stream = httpURLConnection.getErrorStream();
if (stream == null) {
stream = httpsURLConnection.getInputStream();
stream = httpURLConnection.getInputStream();
}
try (Scanner scanner = new Scanner(stream)) {
scanner.useDelimiter("\\Z");
@ -1010,10 +1010,10 @@ public class HttpsConnection {
new String(ByteStreams.toByteArray(httpURLConnection.getInputStream()));
} else {
String error = null;
if( httpsURLConnection.getErrorStream() != null) {
InputStream stream = httpsURLConnection.getErrorStream();
if( httpURLConnection.getErrorStream() != null) {
InputStream stream = httpURLConnection.getErrorStream();
if (stream == null) {
stream = httpsURLConnection.getInputStream();
stream = httpURLConnection.getInputStream();
}
try (Scanner scanner = new Scanner(stream)) {
scanner.useDelimiter("\\Z");
@ -1295,10 +1295,10 @@ public class HttpsConnection {
if (200 != httpURLConnection.getResponseCode()) {
String error = null;
if( httpsURLConnection.getErrorStream() != null) {
InputStream stream = httpsURLConnection.getErrorStream();
if( httpURLConnection.getErrorStream() != null) {
InputStream stream = httpURLConnection.getErrorStream();
if (stream == null) {
stream = httpsURLConnection.getInputStream();
stream = httpURLConnection.getInputStream();
}
try (Scanner scanner = new Scanner(stream)) {
scanner.useDelimiter("\\Z");
@ -1448,13 +1448,13 @@ public class HttpsConnection {
String response;
if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) {
getSinceMaxId();
response = converToString(httpsURLConnection.getInputStream());
response = converToString(httpURLConnection.getInputStream());
} else {
String error = null;
if( httpsURLConnection.getErrorStream() != null) {
InputStream stream = httpsURLConnection.getErrorStream();
if( httpURLConnection.getErrorStream() != null) {
InputStream stream = httpURLConnection.getErrorStream();
if (stream == null) {
stream = httpsURLConnection.getInputStream();
stream = httpURLConnection.getInputStream();
}
try (Scanner scanner = new Scanner(stream)) {
scanner.useDelimiter("\\Z");
@ -1572,10 +1572,10 @@ public class HttpsConnection {
return httpURLConnection.getResponseCode();
}else {
String error = null;
if( httpsURLConnection.getErrorStream() != null) {
InputStream stream = httpsURLConnection.getErrorStream();
if( httpURLConnection.getErrorStream() != null) {
InputStream stream = httpURLConnection.getErrorStream();
if (stream == null) {
stream = httpsURLConnection.getInputStream();
stream = httpURLConnection.getInputStream();
}
try (Scanner scanner = new Scanner(stream)) {
scanner.useDelimiter("\\Z");

View File

@ -1149,7 +1149,7 @@ public class Helper {
@SuppressWarnings("SameParameterValue")
private static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int roundPixelSize) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(output);
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());