use of com.moro.mtweaks.utils.WebpageReader in project MTweaks-KernelAdiutorMOD by morogoku.
the class ServerSearchDevice method getDevices.
public void getDevices(final DeviceSearchListener deviceSearchListener, final int page, String board) {
mDeviceReader = new WebpageReader(mActivity, new WebpageReader.WebpageListener() {
@Override
public void onSuccess(String url, String raw, CharSequence html) {
try {
JSONArray devices = new JSONArray(raw);
List<DeviceInfo> list = new ArrayList<>();
for (int i = 0; i < devices.length(); i++) {
list.add(new DeviceInfo(devices.getJSONObject(i)));
}
deviceSearchListener.onDevicesResult(list, page == 0 ? 1 : page);
} catch (JSONException ignored) {
deviceSearchListener.onDevicesFailure();
}
}
@Override
public void onFailure(String url) {
deviceSearchListener.onDevicesFailure();
}
});
mDeviceReader.get(getAddress(DEVICE_GET, new Query("page", String.valueOf(page == 0 ? 1 : page)), new Query("board", board)));
}
Aggregations