当前位置: 首页>>代码示例>>Java>>正文


Java StringCallback类代码示例

本文整理汇总了Java中com.zhy.http.okhttp.callback.StringCallback的典型用法代码示例。如果您正苦于以下问题:Java StringCallback类的具体用法?Java StringCallback怎么用?Java StringCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StringCallback类属于com.zhy.http.okhttp.callback包,在下文中一共展示了StringCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startCheck

import com.zhy.http.okhttp.callback.StringCallback; //导入依赖的package包/类
public void startCheck(Context context) {
    mcontext = context;
    if (App.ignore) {
        return;
    }
    OkHttpUtils//
            .get()//
            .url(Constant.APK_URL)//
            .build().execute(new StringCallback() {
        @Override
        public void onError(Call call, Exception e) {

        }

        @Override
        public void onResponse(String s) {
            Message message = new Message();
            message.what = 0;
            message.obj = s;
            mhanler.sendMessage(message);
        }
    });


}
 
开发者ID:Qrilee,项目名称:DevAsimpleApp,代码行数:26,代码来源:CheckUpdate.java

示例2: checkForUpdate

import com.zhy.http.okhttp.callback.StringCallback; //导入依赖的package包/类
private void checkForUpdate() {
    OkHttpUtils.get().url(updateUrl)
            .build()
            .connTimeOut(2000)
            .execute(new StringCallback() {
                @Override
                public void onError(Call call, Exception e) {
                    handler.sendEmptyMessageDelayed(1, 1000);
                }

                @Override
                public void onResponse(String response) {
                    Gson gson = new Gson();
                    versionInfo = gson.fromJson(response, VersionBean.class);
                    hasNewVersion();
                }
            });
}
 
开发者ID:hunao0221,项目名称:MyQlu,代码行数:19,代码来源:SplashAvtivity.java

示例3: getUserInfo

import com.zhy.http.okhttp.callback.StringCallback; //导入依赖的package包/类
/**
 * 获得用户基本信息
 */
private void getUserInfo() {
    OkHttpUtils.get().url(mainUrl)
            .addHeader("Referer", mainUrl)
            .addHeader("Host", "210.44.159.5")
            .build().execute(new StringCallback() {
        @Override
        public void onError(Call call, Exception e) {
            //获取基本信息失败
        }

        @Override
        public void onResponse(String response) {
            //解析html,获得个人信息,主要获得账号
            baseInfoMap = ParseCardInfo.parse(response);
            if (baseInfoMap.size() != 0) {
                initTitleUI();
                getTodayData();
                historyInfo();
            }
        }
    });
}
 
开发者ID:hunao0221,项目名称:MyQlu,代码行数:26,代码来源:SchoolCardActivity.java

示例4: historyInfo

import com.zhy.http.okhttp.callback.StringCallback; //导入依赖的package包/类
/**
 * 获得主页的action
 */
private void historyInfo() {
    OkHttpUtils.get().url(historyUrl)
            .build()
            .execute(new StringCallback() {
                @Override
                public void onError(Call call, Exception e) {
                    Toast.makeText(mContext, "数据初始化失败", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onResponse(String response) {
                    mainAction = ParseHistoryInfo.getMainAction(response);
                    getHistoryHomePage();
                }
            });
}
 
开发者ID:hunao0221,项目名称:MyQlu,代码行数:20,代码来源:SchoolCardActivity.java

示例5: getHistoryHomePage

import com.zhy.http.okhttp.callback.StringCallback; //导入依赖的package包/类
/**
 * 获得查询的页面的action,以及查询条件
 */
private void getHistoryHomePage() {
    OkHttpUtils.post().url(host + mainAction)
            .addHeader("Host", "210.44.159.5")
            .addHeader("Referer", historyUrl)
            .addParams("account", account)
            .addParams("inputObject", "15")
            .addParams("Submit", "+%C8%B7+%B6%A8+")
            .build()
            .execute(new StringCallback() {
                @Override
                public void onError(Call call, Exception e) {
                    Toast.makeText(mContext, "关键信息获取失败", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onResponse(String response) {
                    queryAction = ParseHistoryInfo.getQueryAction(response);
                    dayList = ParseHistoryInfo.getDayList(response);
                    dayList.add(3, "本月内");
                }
            });
}
 
开发者ID:hunao0221,项目名称:MyQlu,代码行数:26,代码来源:SchoolCardActivity.java

示例6: queryHistoryMustInfo

import com.zhy.http.okhttp.callback.StringCallback; //导入依赖的package包/类
/**
 * 获得等待页面的action
 */
private void queryHistoryMustInfo() {
    OkHttpUtils.post().url(host + queryAction)
            .addHeader("Host", "210.44.159.5")
            .addHeader("Referer", host + mainAction)
            .addParams("inputStartDate", inputStartDate)
            .addParams("inputEndDate", inputEndDate)
            // .addParams("__continue", cotinue)
            .build()
            .execute(new StringCallback() {

                @Override
                public void onError(Call call, Exception e) {
                    Toast.makeText(mContext, "链接获取失败", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onResponse(String response) {
                    lastAction = ParseHistoryInfo.getLastAction(response);
                    queryHistoryConsumption();
                }
            });
}
 
开发者ID:hunao0221,项目名称:MyQlu,代码行数:26,代码来源:SchoolCardActivity.java

示例7: initKSData

import com.zhy.http.okhttp.callback.StringCallback; //导入依赖的package包/类
private void initKSData() {
    OkHttpUtils.get().url(kscxUrl)
            .addParams("xh", stuXH)
            .addParams("xm", stuNameEncoding)
            .addParams("gnmkdm", "N121604")
            .addHeader("Host", "210.44.159.4")
            .addHeader("Referer", StuCenterUrl)
            .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36")
            .build().execute(new StringCallback() {
        @Override
        public void onError(Call call, Exception e) {
            //失败
            saveDataToDB();
        }

        @Override
        public void onResponse(String response) {
            //解析html,得到考试信息,保存到数据库
            ksInfoList = ParseExam.parse(response);
            saveDataToDB();
        }
    });
}
 
开发者ID:hunao0221,项目名称:MyQlu,代码行数:24,代码来源:LoginActivity.java

示例8: requestLoginByNoCode

import com.zhy.http.okhttp.callback.StringCallback; //导入依赖的package包/类
/**
 * 自动登录
 */
private void requestLoginByNoCode() {
    refresh.setRefreshing(true);
    OkHttpUtils.post().url(noCodeLoginUrl)
            .addParams("__VIEWSTATE", noCodeVIEWSTATE)
            .addParams("__VIEWSTATEGENERATOR", "89ADBA87")
            .addParams("tname", "")
            .addParams("tbtns", "")
            .addParams("tnameXw", "yhdl")
            .addParams("tbtnsXw", "yhdlyhdl|xwxsdl")
            .addParams("txtYhm", stuXH) //学号
            .addParams("txtXm", password) //不知道是什么,和密码一样
            .addParams("txtMm", password)
            .addParams("rblJs", "%D1%A7%C9%FA")
            .addParams("btnDl", "%B5%C7+%C2%BC")
            .addHeader("Referer", "http://210.44.159.4/default6.aspx")
            .addHeader("Host", "210.44.159.4")
            .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36")
            .build().execute(new StringCallback() {
        @Override
        public void onError(Call call, Exception e) {
            //自动登录失败
            Toast.makeText(mContext, "登录失败", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onResponse(String response) {
            //登录成功
            initExamData();
        }
    });
}
 
开发者ID:hunao0221,项目名称:MyQlu,代码行数:35,代码来源:ExamActivity.java

示例9: initExamData

import com.zhy.http.okhttp.callback.StringCallback; //导入依赖的package包/类
private void initExamData() {
    OkHttpUtils.get().url(kscxUrl)
            .addParams("xh", stuXH)
            .addParams("xm", stuNameEncoding)
            .addParams("gnmkdm", "N121604")
            .addHeader("Host", "210.44.159.4")
            .addHeader("Referer", stuCenterUrl)
            .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36")
            .build().execute(new StringCallback() {
        @Override
        public void onError(Call call, Exception e) {
            //失败
            refresh.setRefreshing(false);
            Toast.makeText(mContext, "刷新失败", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onResponse(String response) {
            //解析html,得到考试信息,保存到数据库
            refreshList = ParseExam.parse(response);
            for (ExamBean examBean : refreshList) {
                if (examDao.query(examBean.getExamName())) {
                    //更新数据
                    examDao.update(examBean.getExamName(), examBean.getExamTime(), examBean.getExamLocation());
                } else {
                    //插入数据库
                    examDao.add(examBean.getExamName(), examBean.getExamTime(), examBean.getExamLocation());
                }
            }
            examInfoList = examDao.queryAll();
            adapter.notifyDataSetChanged();
            refresh.setRefreshing(false);
        }
    });
}
 
开发者ID:hunao0221,项目名称:MyQlu,代码行数:36,代码来源:ExamActivity.java

示例10: getTodayData

import com.zhy.http.okhttp.callback.StringCallback; //导入依赖的package包/类
/**
 * 获得当日流水
 */
private void getTodayData() {
    OkHttpUtils.post().url(liushuiUrl)
            .addHeader("Host", "210.44.159.5")
            .addHeader("Origin", "http://210.44.159.5")
            .addHeader("Referer", liushuiUrl)
            .addParams("account", account)
            .addParams("inputObject", "15")
            .addParams("Submit", "+%C8%B7+%B6%A8+")
            .build().execute(new StringCallback() {

        @Override
        public void onError(Call call, Exception e) {
            Toast.makeText(mContext, "查询失败", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onResponse(String response) {
            ParseLiushui parseLiushui = new ParseLiushui(response);
            todayZhangList = parseLiushui.parse();

            if (todayZhangList.size() == 0) {
                tvNullData.setVisibility(View.VISIBLE);
                total = "0";
            } else {
                todayTotal = parseLiushui.getTotal().trim();
                total = todayTotal;
            }

            initRecyler();
        }
    });
}
 
开发者ID:hunao0221,项目名称:MyQlu,代码行数:36,代码来源:SchoolCardActivity.java

示例11: requestNextPage

import com.zhy.http.okhttp.callback.StringCallback; //导入依赖的package包/类
/**
 * 请求下一页的数据
 */
private synchronized void requestNextPage() {
    if (nextPage > totalPages) {
        return;
    }
    OkHttpUtils.post().url(nextPageUrl)
            .addHeader("Host", "210.44.159.5")
            .addHeader("Referer", "nextPageUrl")
            .addParams("inputStartDate", inputStartDate)
            .addParams("inputEndDate", inputEndDate)
            .addParams("pageNum", nextPage + "")
            .build()
            .execute(new StringCallback() {
                @Override
                public void onError(Call call, Exception e) {
                    Toast.makeText(mContext, "加载失败", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onResponse(String response) {
                    List<ZhangBean> nextInfo = ParseHistoryInfo.get(response);
                    for (ZhangBean next : nextInfo) {
                        historyLiushui.add(historyLiushui.size(), next);
                    }
                    consumeAdapter.notifyDataSetChanged();
                }
            });
}
 
开发者ID:hunao0221,项目名称:MyQlu,代码行数:31,代码来源:SchoolCardActivity.java

示例12: queryHistoryConsumption

import com.zhy.http.okhttp.callback.StringCallback; //导入依赖的package包/类
/**
 * 利用等待页面获取的action查询历史消费信息
 */
private void queryHistoryConsumption() {
    OkHttpUtils.post().url("http://210.44.159.5/accounthisTrjn3.action")
            .addHeader("Host", "210.44.159.5")
            .addHeader("Referer", "http://210.44.159.5/accounthisTrjn2.action")
            .build()
            .execute(new StringCallback() {
                @Override
                public void onError(Call call, Exception e) {

                    Toast.makeText(mContext, "查询失败", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onResponse(String response) {
                    String historyTotal = ParseHistoryInfo.getHistoryTotal(response);
                    historyLiushui = ParseHistoryInfo.get(response);
                    totalPages = ParseHistoryInfo.getTotalPages(response);
                    waitDialog.dismiss();
                    total = historyTotal;
                    if (historyLiushui.size() > 0) {
                        tvNullData.setVisibility(View.INVISIBLE);
                    }

                    consumeAdapter = new ConsumeAdapter(historyLiushui, false);
                    consumeAdapter.setTitleInfo(titleInfo);
                    consumeAdapter.setTotal(total);
                    recylerView.setAdapter(consumeAdapter);
                }
            });
}
 
开发者ID:hunao0221,项目名称:MyQlu,代码行数:34,代码来源:SchoolCardActivity.java

示例13: doLost

import com.zhy.http.okhttp.callback.StringCallback; //导入依赖的package包/类
/**
 * 请求挂失
 */
private void doLost() {
    OkHttpUtils.post().url(doLostUrl)
            .addHeader("Referer", "http://210.44.159.5/accountloss.action")
            .addHeader("Host", "210.44.159.5")
            .addParams("account", lost_account.getText().toString())
            .addParams("passwd", lost_password.getText().toString())
            .build()
            .execute(new StringCallback() {
                @Override
                public void onError(Call call, Exception e) {
                    Toast.makeText(mContext, "挂失失败", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onResponse(String response) {
                    String messenge = "";
                    if (response.contains("操作成功")) {
                        messenge = "您已挂失成功";
                    } else if (response.contains("密码错误")) {
                        messenge = "密码错误";
                        Toast.makeText(mContext, "密码错误", Toast.LENGTH_SHORT).show();
                    } else if (response.contains("已挂失")) {
                        messenge = "您的饭卡已经处于挂失状态";
                    }
                    Toast.makeText(mContext, messenge, Toast.LENGTH_LONG).show();
                }
            });
}
 
开发者ID:hunao0221,项目名称:MyQlu,代码行数:32,代码来源:SchoolCardActivity.java

示例14: initYearList

import com.zhy.http.okhttp.callback.StringCallback; //导入依赖的package包/类
/**
 * 查询成绩之前要先获得当前系统中的所有年份表
 */
private void initYearList() {
    if (pbCjcx.getVisibility() == View.INVISIBLE) {
        pbCjcx.setVisibility(View.VISIBLE);
    }
    OkHttpUtils.get()
            .url(cjcxUrl)
            .addHeader("Host", "210.44.159.4")
            .addHeader("Referer", stuCenterUrl)
            .build()
            .connTimeOut(2000)
            .execute(new StringCallback() {
                @Override
                public void onError(Call call, Exception e) {
                    //加载学年失败,原因:没有登录,或者已经掉线,静默登陆
                    Toast.makeText(mContext, "数据加载失败,成绩查询尚未开放", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onResponse(String response) {

                    HtmlUtils utils = new HtmlUtils(response);
                    //解析得到年份表
                    yearList = utils.parseSelectYearList();
                    initSpinner();
                }
            });
}
 
开发者ID:hunao0221,项目名称:MyQlu,代码行数:31,代码来源:ScoreActivity.java

示例15: requestLoginByNoCode

import com.zhy.http.okhttp.callback.StringCallback; //导入依赖的package包/类
/**
 * 自动登录
 */
private void requestLoginByNoCode() {

    OkHttpUtils.post().url(noCodeLoginUrl)
            .addParams("__VIEWSTATE", noCodeVIEWSTATE)
            .addParams("__VIEWSTATEGENERATOR", "89ADBA87")
            .addParams("tname", "")
            .addParams("tbtns", "")
            .addParams("tnameXw", "yhdl")
            .addParams("tbtnsXw", "yhdlyhdl|xwxsdl")
            .addParams("txtYhm", stuXH) //学号
            .addParams("txtXm", password) //不知道是什么,和密码一样
            .addParams("txtMm", password)
            .addParams("rblJs", "%D1%A7%C9%FA")
            .addParams("btnDl", "%B5%C7+%C2%BC")
            .addHeader("Referer", "http://210.44.159.4/default6.aspx")
            .addHeader("Host", "210.44.159.4")
            .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36")
            .build().execute(new StringCallback() {
        @Override
        public void onError(Call call, Exception e) {
            //自动登录失败
            Toast.makeText(mContext, "登录失败,请稍后再试", Toast.LENGTH_SHORT).show();
            pbCjcx.setVisibility(View.INVISIBLE);
        }

        @Override
        public void onResponse(String response) {
            //登录成功
            initYearList();
        }
    });
}
 
开发者ID:hunao0221,项目名称:MyQlu,代码行数:36,代码来源:ScoreActivity.java


注:本文中的com.zhy.http.okhttp.callback.StringCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。