mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +01:00
Show error message when loading RPAN broadcasts failed.
This commit is contained in:
parent
b856f5baeb
commit
f6aca0e9a0
@ -7,6 +7,7 @@ import android.content.pm.PackageManager;
|
|||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@ -189,6 +190,7 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (path.matches(RPAN_BROADCAST_PATTERN)) {
|
} else if (path.matches(RPAN_BROADCAST_PATTERN)) {
|
||||||
Intent intent = new Intent(this, RPANActivity.class);
|
Intent intent = new Intent(this, RPANActivity.class);
|
||||||
|
Log.i("asdfasdf", "sd " + path);
|
||||||
intent.putExtra(RPANActivity.EXTRA_RPAN_BROADCAST_FULLNAME_OR_ID, path.substring(path.lastIndexOf('/') + 1));
|
intent.putExtra(RPANActivity.EXTRA_RPAN_BROADCAST_FULLNAME_OR_ID, path.substring(path.lastIndexOf('/') + 1));
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (authority.equals("redd.it") && path.matches(REDD_IT_POST_PATTERN)) {
|
} else if (authority.equals("redd.it") && path.matches(REDD_IT_POST_PATTERN)) {
|
||||||
|
@ -27,12 +27,14 @@ import androidx.viewpager2.adapter.FragmentStateAdapter;
|
|||||||
import androidx.viewpager2.widget.ViewPager2;
|
import androidx.viewpager2.widget.ViewPager2;
|
||||||
|
|
||||||
import com.evernote.android.state.State;
|
import com.evernote.android.state.State;
|
||||||
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
import com.livefront.bridge.Bridge;
|
import com.livefront.bridge.Bridge;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
@ -53,6 +55,7 @@ import ml.docilealligator.infinityforreddit.font.TitleFontFamily;
|
|||||||
import ml.docilealligator.infinityforreddit.fragments.ViewRPANBroadcastFragment;
|
import ml.docilealligator.infinityforreddit.fragments.ViewRPANBroadcastFragment;
|
||||||
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
|
import okhttp3.ResponseBody;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -131,8 +134,26 @@ public class RPANActivity extends AppCompatActivity {
|
|||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
parseRPANBroadcasts(response.body());
|
parseRPANBroadcasts(response.body());
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(RPANActivity.this,
|
try {
|
||||||
R.string.load_rpan_broadcasts_failed, Toast.LENGTH_SHORT).show();
|
ResponseBody responseBody = response.errorBody();
|
||||||
|
if (responseBody != null) {
|
||||||
|
JSONObject errorObject = new JSONObject(responseBody.string());
|
||||||
|
String errorMessage = errorObject.getString(JSONUtils.DATA_KEY);
|
||||||
|
if (!errorMessage.isEmpty() && !errorMessage.equals("null")) {
|
||||||
|
Snackbar.make(coordinatorLayout, errorMessage, Snackbar.LENGTH_LONG).show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(RPANActivity.this,
|
||||||
|
R.string.load_rpan_broadcasts_failed, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Toast.makeText(RPANActivity.this,
|
||||||
|
R.string.load_rpan_broadcasts_failed, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} catch (IOException | JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Toast.makeText(RPANActivity.this,
|
||||||
|
R.string.load_rpan_broadcasts_failed, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,8 +183,26 @@ public class RPANActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(RPANActivity.this,
|
try {
|
||||||
R.string.load_rpan_broadcasts_failed, Toast.LENGTH_SHORT).show();
|
ResponseBody responseBody = response.errorBody();
|
||||||
|
if (responseBody != null) {
|
||||||
|
JSONObject errorObject = new JSONObject(responseBody.string());
|
||||||
|
String errorMessage = errorObject.getString(JSONUtils.DATA_KEY);
|
||||||
|
if (!errorMessage.isEmpty() && !errorMessage.equals("null")) {
|
||||||
|
Snackbar.make(coordinatorLayout, errorMessage, Snackbar.LENGTH_LONG).show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(RPANActivity.this,
|
||||||
|
R.string.load_rpan_broadcasts_failed, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Toast.makeText(RPANActivity.this,
|
||||||
|
R.string.load_rpan_broadcasts_failed, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} catch (IOException | JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Toast.makeText(RPANActivity.this,
|
||||||
|
R.string.load_rpan_broadcasts_failed, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user