Fix issue #430 - Filter down instances from helper.
This commit is contained in:
parent
9ed4964793
commit
f7c7ea98ad
|
@ -23,7 +23,7 @@ import retrofit2.http.Query;
|
||||||
|
|
||||||
public interface InstancesSocialService {
|
public interface InstancesSocialService {
|
||||||
|
|
||||||
@GET("instances/search?name=true")
|
@GET("instances/search?name=true&count=50")
|
||||||
Call<InstanceSocial> getInstances(@Header("Authorization") String token, @Query("q") String search);
|
Call<InstanceSocial> getInstances(@Header("Authorization") String token, @Query("q") String search);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.lifecycle.AndroidViewModel;
|
import androidx.lifecycle.AndroidViewModel;
|
||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import app.fedilab.android.client.entities.app.InstanceSocial;
|
import app.fedilab.android.client.entities.app.InstanceSocial;
|
||||||
|
@ -73,7 +74,17 @@ public class InstanceSocialVM extends AndroidViewModel {
|
||||||
Response<InstanceSocial> response = instanceSocialCall.execute();
|
Response<InstanceSocial> response = instanceSocialCall.execute();
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable myRunnable = () -> instanceSocialMutableLiveData.setValue(response.body());
|
InstanceSocial instanceSocial = response.body();
|
||||||
|
InstanceSocial filtered = new InstanceSocial();
|
||||||
|
filtered.instances = new ArrayList<>();
|
||||||
|
if (instanceSocial != null && instanceSocial.instances != null) {
|
||||||
|
for (InstanceSocial.Instance instance : instanceSocial.instances) {
|
||||||
|
if (instance.up) {
|
||||||
|
filtered.instances.add(instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Runnable myRunnable = () -> instanceSocialMutableLiveData.setValue(filtered);
|
||||||
mainHandler.post(myRunnable);
|
mainHandler.post(myRunnable);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
Loading…
Reference in New Issue