Instance fixes when not available
This commit is contained in:
parent
e0d8c3f42d
commit
8975b09175
|
@ -124,17 +124,26 @@ public class InstanceHealthActivity extends BaseActivity {
|
|||
|
||||
private void checkInstance() {
|
||||
|
||||
if (instance == null)
|
||||
if (instance == null){
|
||||
LinearLayout main_container = findViewById(R.id.main_container);
|
||||
TextView no_instance = findViewById(R.id.no_instance);
|
||||
instance_container.setVisibility(View.VISIBLE);
|
||||
main_container.setVisibility(View.GONE);
|
||||
no_instance.setVisibility(View.VISIBLE);
|
||||
loader.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
HashMap<String, String> parameters = new HashMap<>();
|
||||
parameters.put("name", instance.trim());
|
||||
final String response = new HttpsConnection(InstanceHealthActivity.this, instance).get("https://instances.social/api/1.0/instances/show", 30, parameters, Helper.THEKINRAR_SECRET_TOKEN);
|
||||
if (response != null)
|
||||
final String response = new HttpsConnection(InstanceHealthActivity.this, instance).get("https://instances.social/api/1.0/instances/show", 5, parameters, Helper.THEKINRAR_SECRET_TOKEN);
|
||||
if (response != null) {
|
||||
instanceSocial = API.parseInstanceSocialResponse(getApplicationContext(), new JSONObject(response));
|
||||
}
|
||||
runOnUiThread(new Runnable() {
|
||||
@SuppressLint({"SetTextI18n", "DefaultLocale"})
|
||||
public void run() {
|
||||
|
@ -160,7 +169,17 @@ public class InstanceHealthActivity extends BaseActivity {
|
|||
}
|
||||
});
|
||||
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
LinearLayout main_container = findViewById(R.id.main_container);
|
||||
TextView no_instance = findViewById(R.id.no_instance);
|
||||
instance_container.setVisibility(View.VISIBLE);
|
||||
main_container.setVisibility(View.GONE);
|
||||
no_instance.setVisibility(View.VISIBLE);
|
||||
loader.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
|
|
@ -28,6 +28,11 @@
|
|||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/main_container">
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -79,7 +84,20 @@
|
|||
android:layout_weight="1"
|
||||
android:text="via instances.social"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_marginTop="50dp"
|
||||
android:layout_marginBottom="50dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textSize="16sp"
|
||||
android:id="@+id/no_instance"
|
||||
android:visibility="gone"
|
||||
android:autoLink="web"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/no_instance_reccord"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/close"
|
||||
style="@style/Base.Widget.AppCompat.Button.Colored"
|
||||
|
@ -93,6 +111,7 @@
|
|||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/loader"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -1175,4 +1175,5 @@
|
|||
<string name="poll_finish_in">End in %s</string>
|
||||
<string name="release_note_title">What\'s new in %s</string>
|
||||
<string name="follow_account_update">You can follow my account for updates</string>
|
||||
<string name="no_instance_reccord">This instance is not available on https://instances.social</string>
|
||||
</resources>
|
Loading…
Reference in New Issue