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() {
|
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
HashMap<String, String> parameters = new HashMap<>();
|
HashMap<String, String> parameters = new HashMap<>();
|
||||||
parameters.put("name", instance.trim());
|
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);
|
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)
|
if (response != null) {
|
||||||
instanceSocial = API.parseInstanceSocialResponse(getApplicationContext(), new JSONObject(response));
|
instanceSocial = API.parseInstanceSocialResponse(getApplicationContext(), new JSONObject(response));
|
||||||
|
}
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@SuppressLint({"SetTextI18n", "DefaultLocale"})
|
@SuppressLint({"SetTextI18n", "DefaultLocale"})
|
||||||
public void run() {
|
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();
|
}).start();
|
||||||
|
|
|
@ -28,6 +28,11 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:visibility="gone">
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:id="@+id/main_container">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/name"
|
android:id="@+id/name"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -79,7 +84,20 @@
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="via instances.social"
|
android:text="via instances.social"
|
||||||
tools:ignore="HardcodedText" />
|
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
|
<Button
|
||||||
android:id="@+id/close"
|
android:id="@+id/close"
|
||||||
style="@style/Base.Widget.AppCompat.Button.Colored"
|
style="@style/Base.Widget.AppCompat.Button.Colored"
|
||||||
|
@ -93,6 +111,7 @@
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/loader"
|
android:id="@+id/loader"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -1175,4 +1175,5 @@
|
||||||
<string name="poll_finish_in">End in %s</string>
|
<string name="poll_finish_in">End in %s</string>
|
||||||
<string name="release_note_title">What\'s new 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="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>
|
</resources>
|
Loading…
Reference in New Issue