Search in sources :

Example 6 with WebpageReader

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)));
}
Also used : WebpageReader(com.moro.mtweaks.utils.WebpageReader) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) JSONException(org.json.JSONException)

Aggregations

WebpageReader (com.moro.mtweaks.utils.WebpageReader)6 ArrayList (java.util.ArrayList)3 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 NavigationView (android.support.design.widget.NavigationView)1 Fragment (android.support.v4.app.Fragment)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 BaseFragment (com.moro.mtweaks.fragments.BaseFragment)1 RecyclerViewFragment (com.moro.mtweaks.fragments.RecyclerViewFragment)1 BatteryFragment (com.moro.mtweaks.fragments.kernel.BatteryFragment)1 BoefflaWakelockFragment (com.moro.mtweaks.fragments.kernel.BoefflaWakelockFragment)1 CPUFragment (com.moro.mtweaks.fragments.kernel.CPUFragment)1 CPUHotplugFragment (com.moro.mtweaks.fragments.kernel.CPUHotplugFragment)1 CPUVoltageCl0Fragment (com.moro.mtweaks.fragments.kernel.CPUVoltageCl0Fragment)1 CPUVoltageCl1Fragment (com.moro.mtweaks.fragments.kernel.CPUVoltageCl1Fragment)1 DvfsFragment (com.moro.mtweaks.fragments.kernel.DvfsFragment)1 EntropyFragment (com.moro.mtweaks.fragments.kernel.EntropyFragment)1 GPUFragment (com.moro.mtweaks.fragments.kernel.GPUFragment)1