Search in sources :

Example 6 with ResponseHandler

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

the class ReplyCzActivity method replyCz.

// 回复层主
private void replyCz(String url) {
    String inputStr = PostActivity.getPreparedReply(this, input.getText().toString());
    params.put("message", inputStr);
    HttpUtil.post(url, params, new ResponseHandler() {

        @Override
        public void onSuccess(byte[] response) {
            String res = new String(response);
            handleReply(true, res + "层主");
        }

        @Override
        public void onFailure(Throwable e) {
            e.printStackTrace();
            handleReply(false, e.getMessage());
        }

        @Override
        public void onFinish() {
            super.onFinish();
            dialog.dismiss();
        }
    });
}
Also used : ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler)

Example 7 with ResponseHandler

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

the class SignActivity method startDaka.

// 点击签到按钮
private void startDaka() {
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setMessage("正在签到...");
    dialog.show();
    String xinqin = getGroup1_select();
    // String formhash = hash;
    String qdmode;
    String todaysay = "";
    EditText input = findViewById(R.id.input);
    if (!TextUtils.isEmpty(input.getText().toString())) {
        qdmode = "1";
        todaysay = input.getText().toString() + "  --来自睿思手机客户端";
    } else {
        qdmode = "3";
    }
    Map<String, String> params = new HashMap<>();
    // params.put("formhash", formhash);
    params.put("qdxq", xinqin);
    params.put("qdmode", qdmode);
    params.put("todaysay", todaysay);
    params.put("fastreplay", "0");
    String url = UrlUtils.getSignUrl();
    HttpUtil.post(url, params, new ResponseHandler() {

        @Override
        public void onSuccess(byte[] response) {
            String res = new String(response);
            int start = res.indexOf("恭喜你签到成功");
            if (start > 0) {
                int end = res.indexOf("</div>", start);
                showNtice(res.substring(start, end));
                signNo.setVisibility(View.GONE);
                checkState();
            } else {
                showNtice("未知错误,签到失败");
            }
        }

        @Override
        public void onFailure(Throwable e) {
            showNtice("网络错误!!!!!");
        }

        @Override
        public void onFinish() {
            super.onFinish();
            dialog.dismiss();
        }
    });
}
Also used : EditText(android.widget.EditText) ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler) HashMap(java.util.HashMap) ProgressDialog(android.app.ProgressDialog)

Example 8 with ResponseHandler

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

the class SignActivity method checkState.

// 看看是否已经签到
private void checkState() {
    progressBar.setVisibility(View.VISIBLE);
    Calendar c = Calendar.getInstance();
    int HOUR_OF_DAY = c.get(Calendar.HOUR_OF_DAY);
    if (!(7 <= HOUR_OF_DAY && HOUR_OF_DAY < 24)) {
        sign_error();
        return;
    }
    String urlget = "plugin.php?id=dsu_paulsign:sign";
    HttpUtil.get(urlget, new ResponseHandler() {

        @Override
        public void onSuccess(byte[] response) {
            String res = new String(response);
            // // TODO: 16-8-26
            Document doc = Jsoup.parse(res);
            if (res.contains("您今天已经签到过了或者签到时间还未开始")) {
                String daytxt = "0";
                String monthtxt = "0";
                for (Element temp : doc.select(".mn").select("p")) {
                    String temptext = temp.text();
                    if (temptext.contains("您累计已签到")) {
                        int pos = temptext.indexOf("您累计已签到");
                        daytxt = temptext.substring(pos);
                    } else if (temptext.contains("您本月已累计签到")) {
                        monthtxt = temptext;
                    }
                }
                sign_yes(daytxt, monthtxt);
            } else {
                sign_no();
            }
        }

        @Override
        public void onFailure(Throwable e) {
            showNtice("网络错误");
        }
    });
}
Also used : ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler) Calendar(java.util.Calendar) Element(org.jsoup.nodes.Element) Document(org.jsoup.nodes.Document)

Example 9 with ResponseHandler

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

the class EditActivity method start_edit.

private void start_edit() {
    String url = "forum.php?mod=post&action=edit&tid=" + tid + "&pid=" + pid + "&mobile=2";
    HttpUtil.get(url, new ResponseHandler() {

        @Override
        public void onSuccess(byte[] response) {
            Document document = Jsoup.parse(new String(response));
            params = RuisUtils.getForms(document, "postform");
            String title = params.get("subject");
            if (TextUtils.isEmpty(title)) {
                edTitle.setVisibility(View.GONE);
            } else {
                edTitle.setText(title);
            }
            if (TextUtils.isEmpty(params.get("message"))) {
                showToast("本贴不支持编辑!");
                finish();
            }
            edContent.setText(params.get("message"));
            Elements types = document.select("#typeid").select("option");
            for (Element e : types) {
                typeiddatas.add(new Forum(Integer.parseInt(e.attr("value")), e.text()));
            }
            if (typeiddatas.size() > 0) {
                typeIdContainer.setVisibility(View.VISIBLE);
                tvSelectType.setText(typeiddatas.get(0).name);
                typeId = typeiddatas.get(0).fid;
            } else {
                typeIdContainer.setVisibility(View.GONE);
            }
        }

        @Override
        public void onFailure(Throwable e) {
            super.onFailure(e);
            showToast("网络错误");
        }
    });
}
Also used : ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler) Element(org.jsoup.nodes.Element) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements) Forum(me.yluo.ruisiapp.model.Forum)

Example 10 with ResponseHandler

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

the class LoginActivity method loadData.

private void loadData() {
    String url = UrlUtils.getLoginUrl();
    HttpUtil.get(url, new ResponseHandler() {

        @Override
        public void onSuccess(byte[] response) {
            String res = new String(response);
            Document doc = Jsoup.parse(res);
            // 判断是否有验证码
            Element element = doc.select("#loginform .sec_code").first();
            if (element != null) {
                haveValid = true;
                seccodehash = element.select("input[name=seccodehash]").attr("value");
                validImageSrc = element.select("img").attr("src");
            }
            loginUrl = doc.select("form#loginform").attr("action");
            String hash = doc.select("input#formhash").attr("value");
            App.setHash(LoginActivity.this, hash);
        }

        @Override
        public void onFailure(Throwable e) {
            AlertDialog dialog = new AlertDialog.Builder(LoginActivity.this).setTitle("加载失败").setMessage("是否重新加载").setPositiveButton("重新加载", (dialogInterface, i) -> loadData()).setNegativeButton("关闭", (dialogInterface, i) -> finish()).create();
            dialog.show();
        }
    });
}
Also used : AlertDialog(android.app.AlertDialog) Context(android.content.Context) Bundle(android.os.Bundle) UrlUtils(me.yluo.ruisiapp.utils.UrlUtils) ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler) Intent(android.content.Intent) HashMap(java.util.HashMap) GetId(me.yluo.ruisiapp.utils.GetId) Editable(android.text.Editable) TextInputLayout(android.support.design.widget.TextInputLayout) ArrayList(java.util.ArrayList) CheckBox(android.widget.CheckBox) Element(org.jsoup.nodes.Element) Map(java.util.Map) View(android.view.View) AdapterView(android.widget.AdapterView) HttpUtil(me.yluo.ruisiapp.myhttp.HttpUtil) Log(android.util.Log) ProgressDialog(android.app.ProgressDialog) InputValidDialog(me.yluo.ruisiapp.widget.InputValidDialog) TextUtils(android.text.TextUtils) R(me.yluo.ruisiapp.R) Spinner(android.widget.Spinner) AlertDialog(android.app.AlertDialog) ArrayAdapter(android.widget.ArrayAdapter) List(java.util.List) SharedPreferences(android.content.SharedPreferences) Document(org.jsoup.nodes.Document) TextInputEditText(android.support.design.widget.TextInputEditText) Jsoup(org.jsoup.Jsoup) EditText(android.widget.EditText) App(me.yluo.ruisiapp.App) TextWatcher(android.text.TextWatcher) ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler) Element(org.jsoup.nodes.Element) Document(org.jsoup.nodes.Document)

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