com.grarak.kerneladiutor.utils.WebpageReader Java Examples

The following examples show how to use com.grarak.kerneladiutor.utils.WebpageReader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScreenFragment.java    From KA27 with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(CardViewItem.DCardView dCardView) {
    if (dCardView == mAdditionalProfilesCard) {
        final MaterialDialog progressDialog = new MaterialDialog.Builder(getActivity())
            .content(getString(R.string.loading))
            .progress(true, 0)
            .canceledOnTouchOutside(false)
            .show();
        new WebpageReader(new WebpageReader.WebpageCallback() {
            @Override
            public void onCallback(String raw, String html) {
                progressDialog.dismiss();
                if (getActivity() == null) return;
                GammaProfiles gammaProfiles = new GammaProfiles(raw);
                String path = getActivity().getApplicationContext().getCacheDir() + "/gamma_profiles.json";
                if (gammaProfiles.readable()) {
                    Utils.writeFile(path, raw, false, false);
                    showMoreGammaProfiles(gammaProfiles);
                } else {
                    if (Utils.existFile(path)) {
                        gammaProfiles.refresh(Utils.readFile(path));
                        if (gammaProfiles.readable()) {
                            showMoreGammaProfiles(gammaProfiles);
                            return;
                        }
                    }
                    Utils.toast(getString(R.string.no_internet), getActivity());
                }
            }
        }).execute(Constants.GAMMA_URL);
    }
}
 
Example #2
Source File: ScreenFragment.java    From kernel_adiutor with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(CardViewItem.DCardView dCardView) {
    if (dCardView == mAdditionalProfilesCard) {
        final ProgressDialog progressDialog = new ProgressDialog(getActivity());
        progressDialog.setMessage(getString(R.string.loading));
        progressDialog.setCancelable(false);
        progressDialog.show();
        new WebpageReader(new WebpageReader.WebpageCallback() {
            @Override
            public void onCallback(String raw, String html) {
                progressDialog.dismiss();
                if (getActivity() == null) return;
                GammaProfiles gammaProfiles = new GammaProfiles(raw);
                String path = getActivity().getApplicationContext().getCacheDir() + "/gamma_profiles.json";
                if (gammaProfiles.readable()) {
                    Tools.writeFile(path, raw, false, false);
                    showMoreGammaProfiles(gammaProfiles);
                } else {
                    if (Utils.existFile(path)) {
                        gammaProfiles.refresh(Utils.readFile(path));
                        if (gammaProfiles.readable()) {
                            showMoreGammaProfiles(gammaProfiles);
                            return;
                        }
                    }
                    Utils.toast(getString(R.string.no_internet), getActivity());
                }
            }
        }).execute(Constants.GAMMA_URL);
    }
}
 
Example #3
Source File: DownloadsFragment.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();
    if (mWebpageReader != null) {
        mWebpageReader.cancel();
        mWebpageReader = null;
    }
    if (mErrorBar != null) {
        mErrorBar.dismiss();
        mErrorBar = null;
    }
    for (WebpageReader reader : mKernelWebpageReader) {
        reader.cancel();
    }
}
 
Example #4
Source File: DownloadsFragment.java    From kernel_adiutor with Apache License 2.0 4 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();
    jsonWebpageReader.cancel();
    for (WebpageReader webpageReader : kernelWebpageReaders) webpageReader.cancel();
}