Merge branch 'fix_crashes' into develop
This commit is contained in:
commit
7ae0f21f7c
|
@ -1720,11 +1720,11 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
public void onClick(DialogInterface dialog, int id) {
|
||||
new SearchDAO(BaseMainActivity.this, db).remove(title);
|
||||
String tag;
|
||||
if( position > 0)
|
||||
tag = tabLayout.getTabAt(position -1).getText().toString();
|
||||
else if( tabLayout.getTabCount() > 1 )
|
||||
if( position > 0 && tabLayout.getTabAt(position - 1).getText() != null) {
|
||||
tag = tabLayout.getTabAt(position - 1).getText().toString();
|
||||
}else if( tabLayout.getTabCount() > 1 && tabLayout.getTabAt(1).getText() != null) {
|
||||
tag = tabLayout.getTabAt(1).getText().toString();
|
||||
else //Last element
|
||||
}else //Last element
|
||||
tag = "";
|
||||
Helper.removeTab(tabLayout, adapter, position);
|
||||
adapter = new BaseMainActivity.PagerAdapter
|
||||
|
|
|
@ -188,6 +188,10 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
Account account = new AccountDAO(getApplicationContext(),db).getAccountByID(userId);
|
||||
if( account.getAvatar() == null){
|
||||
Toast.makeText(ShowConversationActivity.this,R.string.toast_error, Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
String url = account.getAvatar();
|
||||
if( url.startsWith("/") ){
|
||||
url = Helper.getLiveInstanceWithProtocol(getApplicationContext()) + account.getAvatar();
|
||||
|
|
|
@ -822,7 +822,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
|
|||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
Bundle extras = intent.getExtras();
|
||||
if (extras != null) {
|
||||
if (extras != null && extras.getString("imageUri") != null) {
|
||||
Uri imageUri = Uri.parse(extras.getString("imageUri"));
|
||||
picture_scrollview.setVisibility(View.VISIBLE);
|
||||
if( imageUri == null) {
|
||||
|
|
|
@ -55,6 +55,10 @@ public class RetrieveMetaDataAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
String potentialUrl = "";
|
||||
if (url == null) {
|
||||
error = true;
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Matcher matcher;
|
||||
if (url.startsWith("www."))
|
||||
|
|
|
@ -739,6 +739,12 @@ public class API {
|
|||
apiResponse.setSince_id(httpsConnection.getSince_id());
|
||||
apiResponse.setMax_id(httpsConnection.getMax_id());
|
||||
accounts = parseAccountResponse(new JSONArray(response));
|
||||
if( accounts != null && accounts.size() == 1 ){
|
||||
if(accounts.get(0).getAcct() == null){
|
||||
Throwable error = new Throwable(context.getString(R.string.toast_error));
|
||||
setError(500, error);
|
||||
}
|
||||
}
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
setError(e.getStatusCode(), e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
|
|
|
@ -523,6 +523,8 @@ public class Status implements Parcelable{
|
|||
|
||||
if( ((Activity)context).isFinishing() )
|
||||
return;
|
||||
if( status.getAccount() == null)
|
||||
return;
|
||||
final List<Emojis> emojis = status.getReblog() != null ? status.getReblog().getEmojis() : status.getEmojis();
|
||||
final List<Emojis> emojisAccounts = status.getAccount().getEmojis();
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ import android.database.sqlite.SQLiteDatabase;
|
|||
import android.os.Build;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
|
||||
import com.google.common.io.ByteStreams;
|
||||
import org.json.JSONObject;
|
||||
import java.io.BufferedInputStream;
|
||||
|
@ -149,7 +148,7 @@ public class HttpsConnection {
|
|||
httpsURLConnection.setRequestMethod("GET");
|
||||
String response;
|
||||
if (httpsURLConnection.getResponseCode() >= 200 && httpsURLConnection.getResponseCode() < 400) {
|
||||
response = new String(ByteStreams.toByteArray(httpsURLConnection.getInputStream()));
|
||||
response = converToString(httpsURLConnection.getInputStream());
|
||||
} else {
|
||||
String error = null;
|
||||
if( httpsURLConnection.getErrorStream() != null) {
|
||||
|
@ -198,7 +197,7 @@ public class HttpsConnection {
|
|||
httpURLConnection.setRequestMethod("GET");
|
||||
String response;
|
||||
if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) {
|
||||
response = new String(ByteStreams.toByteArray(httpURLConnection.getInputStream()));
|
||||
response = converToString(httpsURLConnection.getInputStream());
|
||||
}else {
|
||||
String error = null;
|
||||
if( httpsURLConnection.getErrorStream() != null) {
|
||||
|
@ -237,7 +236,7 @@ public class HttpsConnection {
|
|||
String response;
|
||||
if (httpsURLConnection.getResponseCode() >= 200 && httpsURLConnection.getResponseCode() < 400) {
|
||||
getSinceMaxId();
|
||||
response = new String(ByteStreams.toByteArray(httpsURLConnection.getInputStream()));
|
||||
response = converToString(httpsURLConnection.getInputStream());
|
||||
}else {
|
||||
String error = null;
|
||||
if( httpsURLConnection.getErrorStream() != null) {
|
||||
|
@ -269,7 +268,7 @@ public class HttpsConnection {
|
|||
String response;
|
||||
if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) {
|
||||
getSinceMaxId();
|
||||
response = new String(ByteStreams.toByteArray(httpURLConnection.getInputStream()));
|
||||
response = converToString(httpsURLConnection.getInputStream());
|
||||
}else {
|
||||
String error = null;
|
||||
if( httpsURLConnection.getErrorStream() != null) {
|
||||
|
@ -332,7 +331,7 @@ public class HttpsConnection {
|
|||
String response;
|
||||
if (httpsURLConnection.getResponseCode() >= 200 && httpsURLConnection.getResponseCode() < 400) {
|
||||
getSinceMaxId();
|
||||
response = new String(ByteStreams.toByteArray(httpsURLConnection.getInputStream()));
|
||||
response = converToString(httpsURLConnection.getInputStream());
|
||||
} else {
|
||||
String error = null;
|
||||
if( httpsURLConnection.getErrorStream() != null) {
|
||||
|
@ -387,7 +386,7 @@ public class HttpsConnection {
|
|||
String response;
|
||||
if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) {
|
||||
getSinceMaxId();
|
||||
response = new String(ByteStreams.toByteArray(httpURLConnection.getInputStream()));
|
||||
response = converToString(httpsURLConnection.getInputStream());
|
||||
} else {
|
||||
String error = null;
|
||||
if( httpsURLConnection.getErrorStream() != null) {
|
||||
|
@ -625,9 +624,7 @@ public class HttpsConnection {
|
|||
if (httpsURLConnection != null)
|
||||
try {
|
||||
httpsURLConnection.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception ignored) { }
|
||||
return null;
|
||||
}else {
|
||||
try {
|
||||
|
@ -700,7 +697,7 @@ public class HttpsConnection {
|
|||
lengthSentImage += 2 * (lineEnd).getBytes().length;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int lengthSent = lengthSentImage + (twoHyphens + boundary + twoHyphens + lineEnd).getBytes().length;
|
||||
if (proxy != null)
|
||||
|
@ -1161,7 +1158,7 @@ public class HttpsConnection {
|
|||
|
||||
BufferedReader responseStreamReader = new BufferedReader(new InputStreamReader(responseStream));
|
||||
|
||||
String response = new String(ByteStreams.toByteArray(httpsURLConnection.getInputStream()));
|
||||
String response = converToString(httpsURLConnection.getInputStream());
|
||||
((TootActivity) context).runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
listener.onUpdateProgress(101);
|
||||
|
@ -1191,9 +1188,7 @@ public class HttpsConnection {
|
|||
if (httpsURLConnection != null)
|
||||
try {
|
||||
httpsURLConnection.getInputStream().close();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} catch (Exception ignored) { }
|
||||
((TootActivity) context).runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
listener.onRetrieveAttachment(null, error);
|
||||
|
@ -1318,7 +1313,7 @@ public class HttpsConnection {
|
|||
|
||||
BufferedReader responseStreamReader = new BufferedReader(new InputStreamReader(responseStream));
|
||||
|
||||
String response = new String(ByteStreams.toByteArray(httpURLConnection.getInputStream()));
|
||||
String response = converToString(httpsURLConnection.getInputStream());
|
||||
((TootActivity)context).runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
listener.onUpdateProgress(101);
|
||||
|
@ -1343,10 +1338,8 @@ public class HttpsConnection {
|
|||
error.setError(e.getMessage());
|
||||
if(httpURLConnection != null)
|
||||
try {
|
||||
httpURLConnection.getInputStream().close();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
httpsURLConnection.getInputStream().close();
|
||||
} catch (Exception ignored) { }
|
||||
((TootActivity)context).runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
listener.onRetrieveAttachment(null, error);
|
||||
|
@ -1398,7 +1391,7 @@ public class HttpsConnection {
|
|||
String response;
|
||||
if (httpsURLConnection.getResponseCode() >= 200 && httpsURLConnection.getResponseCode() < 400) {
|
||||
getSinceMaxId();
|
||||
response = new String(ByteStreams.toByteArray(httpsURLConnection.getInputStream()));
|
||||
response = converToString(httpsURLConnection.getInputStream());
|
||||
} else {
|
||||
String error = null;
|
||||
if( httpsURLConnection.getErrorStream() != null) {
|
||||
|
@ -1455,7 +1448,7 @@ public class HttpsConnection {
|
|||
String response;
|
||||
if (httpURLConnection.getResponseCode() >= 200 && httpURLConnection.getResponseCode() < 400) {
|
||||
getSinceMaxId();
|
||||
response = new String(ByteStreams.toByteArray(httpURLConnection.getInputStream()));
|
||||
response = converToString(httpsURLConnection.getInputStream());
|
||||
} else {
|
||||
String error = null;
|
||||
if( httpsURLConnection.getErrorStream() != null) {
|
||||
|
@ -1473,7 +1466,7 @@ public class HttpsConnection {
|
|||
}
|
||||
getSinceMaxId();
|
||||
httpURLConnection.getInputStream().close();
|
||||
return response;
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1652,6 +1645,16 @@ public class HttpsConnection {
|
|||
}
|
||||
}
|
||||
|
||||
private String converToString(InputStream inputStream) throws IOException {
|
||||
BufferedReader r = new BufferedReader(new InputStreamReader(inputStream));
|
||||
StringBuilder total = new StringBuilder(inputStream.available());
|
||||
String line;
|
||||
while ((line = r.readLine()) != null) {
|
||||
total.append(line).append('\n');
|
||||
}
|
||||
return total.toString();
|
||||
}
|
||||
|
||||
int getActionCode() {
|
||||
if( Helper.getLiveInstanceWithProtocol(context).startsWith("https://")) {
|
||||
try {
|
||||
|
@ -1696,5 +1699,6 @@ public class HttpsConnection {
|
|||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue