1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 06:37:30 +00:00
This commit is contained in:
Ammar Githam 2021-04-14 01:08:08 +09:00
parent 548582a6d2
commit ea2956f3ca

View File

@ -5,6 +5,7 @@ import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.StringRes; import androidx.annotation.StringRes;
import androidx.fragment.app.FragmentManager;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
@ -59,7 +60,7 @@ public class IgErrorsInterceptor implements Interceptor {
return; return;
case 302: // redirect case 302: // redirect
final String location = response.header("location"); final String location = response.header("location");
if (location.equals("https://www.instagram.com/accounts/login/")) { if (location != null && location.equals("https://www.instagram.com/accounts/login/")) {
// rate limited // rate limited
showErrorDialog(R.string.rate_limit); showErrorDialog(R.string.rate_limit);
} }
@ -70,7 +71,7 @@ public class IgErrorsInterceptor implements Interceptor {
try { try {
final String bodyString = body.string(); final String bodyString = body.string();
final JSONObject jsonObject = new JSONObject(bodyString); final JSONObject jsonObject = new JSONObject(bodyString);
String message = jsonObject.optString("message", null); String message = jsonObject.optString("message");
if (!TextUtils.isEmpty(message)) { if (!TextUtils.isEmpty(message)) {
message = message.toLowerCase(); message = message.toLowerCase();
switch (message) { switch (message) {
@ -91,7 +92,7 @@ public class IgErrorsInterceptor implements Interceptor {
return; return;
} }
} }
final String errorType = jsonObject.optString("error_type", null); final String errorType = jsonObject.optString("error_type");
if (TextUtils.isEmpty(errorType)) return; if (TextUtils.isEmpty(errorType)) return;
if (errorType.equals("sentry_block")) { if (errorType.equals("sentry_block")) {
showErrorDialog(R.string.sentry_block); showErrorDialog(R.string.sentry_block);
@ -127,7 +128,9 @@ public class IgErrorsInterceptor implements Interceptor {
0, 0,
0 0
); );
dialogFragment.show(mainActivity.getSupportFragmentManager(), "network_error_dialog"); final FragmentManager fragmentManager = mainActivity.getSupportFragmentManager();
if (fragmentManager.isStateSaved()) return;
dialogFragment.show(fragmentManager, "network_error_dialog");
} }
public void destroy() { public void destroy() {