Search in sources :

Example 36 with ResponseHandler

use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.

the class FrageTopicStar method getWebDatas.

private void getWebDatas() {
    String newurl = url + "&page=" + CurrentPage;
    HttpUtil.get(newurl, new ResponseHandler() {

        @Override
        public void onSuccess(byte[] response) {
            String res = new String(response);
            if (currentIndex == 0) {
                new GetUserArticles().execute(res);
            } else if (currentIndex == 1) {
                new GetUserStarTask().execute(res);
            }
        }

        @Override
        public void onFailure(Throwable e) {
            e.printStackTrace();
            adapter.changeLoadMoreState(BaseAdapter.STATE_LOAD_FAIL);
        }
    });
}
Also used : ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler)

Example 37 with ResponseHandler

use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.

the class AboutActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.transparent));
    }
    TextView version = findViewById(R.id.version);
    TextView serverVersion = findViewById(R.id.server_version);
    findViewById(R.id.btn_back).setOnClickListener(view -> finish());
    String ss = "<b>西电睿思手机客户端</b><br />功能不断完善中,bug较多还请多多反馈......<br />" + "bug反馈:<br />" + "1.到 <a href=\"forum.php?mod=viewthread&tid=" + App.POST_TID + "&mobile=2\">本帖</a> 回复<br />" + "2.本站 <a href=\"home.php?mod=space&uid=252553&do=profile&mobile=2\">@谁用了FREEDOM</a><br />" + "3.本站 <a href=\"home.php?mod=space&uid=261098&do=profile&mobile=2\">@wangfuyang</a><br />" + "4.本站 <a href=\"home.php?mod=space&uid=260255&do=profile&mobile=2\">@金鲨鱼</a><br />" + "5.github提交 <a href=\"https://github.com/freedom10086/Ruisi/issues\">点击这儿<br /></a><br />";
    TextView htmlView = findViewById(R.id.html_text);
    HtmlView.parseHtml(ss).into(htmlView);
    PackageInfo info = null;
    PackageManager manager = getPackageManager();
    try {
        info = manager.getPackageInfo(getPackageName(), 0);
    } catch (Exception e) {
        e.printStackTrace();
    }
    int versionCode = 0;
    if (info != null) {
        String version_name = info.versionName;
        versionCode = info.versionCode;
        String a = "当前版本:" + version_name;
        version.setText(a);
    }
    findViewById(R.id.fab).setOnClickListener(v -> Snackbar.make(v, "你要提交bug或者建议吗?", Snackbar.LENGTH_LONG).setAction("确定", view -> {
        String user = App.getName(AboutActivity.this);
        if (user != null) {
            user = "by:" + user;
        }
        IntentUtils.sendMail(getApplicationContext(), user);
    }).show());
    int finalVersionCode = versionCode;
    // 检查更新实现 读取我发帖的标题比较版本号
    // 我会把版本号写在标题上[code:xxx]
    HttpUtil.get(App.CHECK_UPDATE_URL, new ResponseHandler() {

        @Override
        public void onSuccess(byte[] response) {
            String res = new String(response);
            int ih = res.indexOf("keywords");
            int h_start = res.indexOf('\"', ih + 15);
            int h_end = res.indexOf('\"', h_start + 1);
            String title = res.substring(h_start + 1, h_end);
            if (title.contains("code")) {
                SharedPreferences.Editor editor = getSharedPreferences(App.MY_SHP_NAME, MODE_PRIVATE).edit();
                editor.putLong(App.CHECK_UPDATE_KEY, System.currentTimeMillis());
                editor.apply();
                int st = title.indexOf("code");
                int code = GetId.getNumber(title.substring(st));
                if (code > finalVersionCode) {
                    serverVersion.setText("检测到新版本点击查看");
                    serverVersion.setOnClickListener(view -> PostActivity.open(AboutActivity.this, App.CHECK_UPDATE_URL, "谁用了FREEDOM"));
                    return;
                }
            }
            serverVersion.setText("当前已是最新版本");
        }

        @Override
        public void onFailure(Throwable e) {
            super.onFailure(e);
            serverVersion.setText("检测新版本失败...");
        }
    });
}
Also used : Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) IntentUtils(me.yluo.ruisiapp.utils.IntentUtils) ContextCompat(android.support.v4.content.ContextCompat) ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler) GetId(me.yluo.ruisiapp.utils.GetId) PackageInfo(android.content.pm.PackageInfo) R(me.yluo.ruisiapp.R) TextView(android.widget.TextView) SharedPreferences(android.content.SharedPreferences) View(android.view.View) Build(android.os.Build) Snackbar(android.support.design.widget.Snackbar) HttpUtil(me.yluo.ruisiapp.myhttp.HttpUtil) App(me.yluo.ruisiapp.App) HtmlView(me.yluo.ruisiapp.widget.htmlview.HtmlView) PackageManager(android.content.pm.PackageManager) ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler) PackageInfo(android.content.pm.PackageInfo) TextView(android.widget.TextView)

Example 38 with ResponseHandler

use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.

the class InputValidDialog method loadImage.

private void loadImage(String hash) {
    if (TextUtils.isEmpty(update)) {
        loadUpdate();
        return;
    }
    // misc.php?mod=seccode&update=23834&idhash=cSAMi22nd
    String url = "misc.php?mod=seccode&update=" + update + "&idhash=cSAMi22nd&mobile=2";
    if (!url.contains(hash)) {
        int start = url.indexOf("idhash") + 7;
        int end = url.indexOf("&", start);
        if (end < 0)
            end = url.length();
        url = url.replace(url.substring(start, end), hash);
    }
    // Log.v("===", HttpUtil.getStore(getActivity()).getCookie());
    HttpUtil.getClient().addHeader("Referer", App.getBaseUrl() + UrlUtils.getLoginUrl());
    HttpUtil.get(url, new ResponseHandler() {

        @Override
        public void onStart() {
            super.onStart();
            gifImageView.setVisibility(View.GONE);
            progressBar.setVisibility(View.VISIBLE);
        }

        @Override
        public void onSuccess(byte[] response) {
            try {
                GifDrawable drawable = new GifDrawable(response);
                gifImageView.setImageDrawable(drawable);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onFinish() {
            super.onFinish();
            HttpUtil.getClient().removeHeader("Referer");
            progressBar.setVisibility(View.GONE);
            gifImageView.setVisibility(View.VISIBLE);
        }
    });
}
Also used : ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler) GifDrawable(pl.droidsonroids.gif.GifDrawable) IOException(java.io.IOException)

Aggregations

ResponseHandler (me.yluo.ruisiapp.myhttp.ResponseHandler)38 Document (org.jsoup.nodes.Document)13 HashMap (java.util.HashMap)12 ProgressDialog (android.app.ProgressDialog)8 Bundle (android.os.Bundle)8 Element (org.jsoup.nodes.Element)7 Elements (org.jsoup.select.Elements)7 Intent (android.content.Intent)5 View (android.view.View)5 R (me.yluo.ruisiapp.R)5 HttpUtil (me.yluo.ruisiapp.myhttp.HttpUtil)5 GetId (me.yluo.ruisiapp.utils.GetId)5 SharedPreferences (android.content.SharedPreferences)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 App (me.yluo.ruisiapp.App)4 Context (android.content.Context)3 PackageInfo (android.content.pm.PackageInfo)3 PackageManager (android.content.pm.PackageManager)3 Log (android.util.Log)3