本文整理汇总了Java中com.lzy.okgo.callback.StringCallback类的典型用法代码示例。如果您正苦于以下问题:Java StringCallback类的具体用法?Java StringCallback怎么用?Java StringCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringCallback类属于com.lzy.okgo.callback包,在下文中一共展示了StringCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onViewCreated
import com.lzy.okgo.callback.StringCallback; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// super.onViewCreated(view, savedInstanceState);
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
RecyclerView.LayoutManager layoutManager = getLayoutManager();
recyclerView.setLayoutManager(layoutManager);
OkGo.get(ApiUrls.URL_Query).cacheKey(ApiUrls.URL_Query).cacheMode(CacheMode.DEFAULT).execute(new StringCallback() {
@Override
public void onSuccess(String s, Call call, Response response) {
try {
JSONObject obj = new JSONObject(s);
String content = obj.getString("content");
List<VideoItem> videoItems = JSON.parseArray(content, VideoItem.class);
recyclerView.setAdapter(new VrVideoAdapter(videoItems));
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}
示例2: retrieveDrawerMenu
import com.lzy.okgo.callback.StringCallback; //导入依赖的package包/类
private void retrieveDrawerMenu() {
OkGo.get(WebUtils.getCategoriesURL())
.tag(this)
.cacheKey("cacheKey")
.cacheMode(CacheMode.DEFAULT)
.execute(new StringCallback() {
@Override
public void onSuccess(String s, Call call, Response response) {
categories = JSONParser.parseCategoryList(s);
// 获取导航栏内容后异步更新UI
if (categories != null) {
Message msg = new Message();
msg.what = UPDATE_DRAWER_MENU;
handler.sendMessage(msg);
}
}
});
}
示例3: initData
import com.lzy.okgo.callback.StringCallback; //导入依赖的package包/类
private void initData() {
OkGo.post(HttpUrlPath.GET_HOTEL_INFO)
.params("CityID", cityID)
.params("CurrentPage", currentPage)
.execute(new StringCallback() {
@Override
public void onSuccess(String s, Call call, Response response) {
Type type = new TypeToken<SelefHotelData>() {
}.getType();
SelefHotelData data = new Gson().fromJson(s, type);
mProductListEntities = data.getResult().getProductList();
if (mProductListEntities.size() > 0) {
totalPage = data.getResult().getTotalPage();
mHotelAdapter.setResultsBeen(mProductListEntities);
}
}
});
}
示例4: refreshData
import com.lzy.okgo.callback.StringCallback; //导入依赖的package包/类
private void refreshData() {
mTagDatas.clear();
CurrentPage = 1;
OkGo.post(HttpUrlPath.GET_TAG_DETAIL_INFO)
.params("Platform", "1")
.params("CurrentPage", CurrentPage)
.params("CityName", CityName)
.params("ProvinceID", ProvinceID)
.params("ClassID", ClassID)
.execute(new StringCallback() {
@Override
public void onSuccess(String s, Call call, Response response) {
Type type = new TypeToken<TagData>() {
}.getType();
TagData tagData = new Gson().fromJson(s, type);
mTagDatas = tagData.getResult().getProductList();
if (mTagDatas.size() > 0 && mTagDatas != null) {
mRefreshLayout.setRefreshing(false);
totalPage = tagData.getResult().getTotalPage();
mDetailAdapter.setDatas(mTagDatas);
}
}
});
}
示例5: initData
import com.lzy.okgo.callback.StringCallback; //导入依赖的package包/类
private void initData() {
OkGo.post(requestUrl)
.params("CityName", cityName)
.params("Latitude", mLatitude)
.params("Longitude", mLongitude)
.params("currentPage", currentPage)
.execute(new StringCallback() {
@Override
public void onSuccess(String s, Call call, Response response) {
Type type = new TypeToken<HomeTicketBean>() {
}.getType();
HomeTicketBean bean = new Gson().fromJson(s, type);
if (bean.getStatus().equals("0")) {
totalPage = Integer.parseInt(bean.getResult().getTotalPage());
mProductListEntities = bean.getResult().getProductList();
if (mProductListEntities.size() > 0) {
mAdapter.setDatas(mProductListEntities);
}
}
}
});
}
示例6: btn3
import com.lzy.okgo.callback.StringCallback; //导入依赖的package包/类
@OnClick(R.id.btn3)
public void btn3(View view) {
OkGo.<String>get("asdfasf")//
.tag(this)//
.headers(HttpHeaders.HEAD_KEY_USER_AGENT, "abcd")//
.execute(new StringCallback() {
@Override
public void onSuccess(Response<String> response) {
}
});
}
示例7: setHeaderView
import com.lzy.okgo.callback.StringCallback; //导入依赖的package包/类
private void setHeaderView() {
View headerView = LayoutInflater.from(getContext())
.inflate(R.layout.news_banner_item_layout, null);
mFlyBanner = (FlyBanner) headerView.findViewById(R.id.fly_banner);
OkGo.get(bannerUrl)
.tag(this)
.cacheMode(CacheMode.DEFAULT)
.execute(new StringCallback() {
@Override
public void onSuccess(String s, Call call, Response response) {
Type type = new TypeToken<NewsBannerBean>() {
}.getType();
NewsBannerBean bannerBean = new Gson().fromJson(s, type);
if (bannerBean.getCount() > 0) {
List<String> imgBanner = new ArrayList<>();
for (NewsBannerBean.DatasEntity entity : bannerBean.getDatas()) {
imgBanner.add(entity.getHeadPicUrl());
}
mFlyBanner.setImagesUrl(imgBanner);
mFlyBanner.setOnItemClickListener(position -> {
String id = bannerBean.getDatas().get(position).getId();
Intent intent = new Intent(getActivity(), NewsDetailActivity.class);
intent.putExtra("id", id);
intent.putExtra(Contants.TITLE, title);
startActivity(intent);
});
}
}
});
mNewsAdapter.setHeaderView(headerView);
}
示例8: getLoadMoreData
import com.lzy.okgo.callback.StringCallback; //导入依赖的package包/类
private void getLoadMoreData() {
currentPage++;
if (currentPage > totalPage) {
Toast.makeText(getActivity(),
getActivity().getResources()
.getString(R.string.loading_finish),
Toast.LENGTH_SHORT).show();
return;
}
OkGo.get(HttpUrlPath.GET_HOTEL_INFO)
.params("CityID", cityID)
.params("CurrentPage", currentPage)
.execute(new StringCallback() {
@Override
public void onSuccess(String s, Call call, Response response) {
Type type = new TypeToken<SelefHotelData>() {
}.getType();
SelefHotelData data = new Gson().fromJson(s, type);
// mProductListEntities.clear();
List<ProductListEntity> productList = data.getResult().getProductList();
mProductListEntities.addAll(productList);
if (mProductListEntities.size() > 0) {
mHotelAdapter.setResultsBeen(mProductListEntities);
}
}
});
}
示例9: getLoadMoreData
import com.lzy.okgo.callback.StringCallback; //导入依赖的package包/类
private void getLoadMoreData() {
CurrentPage++;
if (CurrentPage > totalPage) {
Toast.makeText(this, getResources()
.getString(R.string.loading_finish),
Toast.LENGTH_SHORT).show();
mDetailAdapter.notifyItemRemoved(mDetailAdapter.getItemCount());
return;
}
OkGo.post(HttpUrlPath.GET_TAG_DETAIL_INFO)
.params("Platform", "1")
.params("CurrentPage", CurrentPage)
.params("CityName", CityName)
.params("ProvinceID", ProvinceID)
.params("ClassID", ClassID)
.execute(new StringCallback() {
@Override
public void onSuccess(String s, Call call, Response response) {
Type type = new TypeToken<TagData>() {
}.getType();
TagData tagData = new Gson().fromJson(s, type);
List<ProductListEntity> productList = tagData.getResult().getProductList();
CustomPrograss.disMiss();
if (productList.size() > 0 && productList != null) {
//mRefreshLayout.setRefreshing(false);
// totalPage = tagData.getResult().getTotalPage();
mTagDatas.addAll(productList);
mDetailAdapter.setDatas(mTagDatas);
}
}
});
}
示例10: initData
import com.lzy.okgo.callback.StringCallback; //导入依赖的package包/类
@Override
public void initData() {
super.initData();
// TODO: 2016/11/25 在这里去请求数据
OkGo.post(HttpUrlPath.GET_SEARCH_DETAIL)
.params("Platform", 1)
.params("Key", key)
.params("currentPage", currentPage)
.execute(new StringCallback(){
@Override
public void onSuccess(String s, Call call, Response response) {
Type type = new TypeToken<SearchDetailInfo>() {
}.getType();
SearchDetailInfo detailInfo = new Gson().fromJson(s, type);
totalPage = Integer.parseInt(detailInfo.getResult().getTotalPage());
totalSize = detailInfo.getResult().getTotalRecord();
mProductListEntities = detailInfo.getResult().getProductList();
if (mProductListEntities.size() > 0) {
mTvCityName.setText(key);
mTvSearchCount.setText(totalSize);
mSearchDetailAdapter.setDatas(mProductListEntities);
}
}
});
// .getCall(StringConvert.create(), RxAdapter.<String>create())
// .doOnSubscribe(() -> {
//// CustomPrograss.show(SearchResultActivity.this,
//// getResources().getString(R.string.loading),
//// true, null);
// })
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(s -> {
//
// }, throwable -> {
// CustomPrograss.disMiss();
// });
}
示例11: load
import com.lzy.okgo.callback.StringCallback; //导入依赖的package包/类
private void load() {
OkGo.get("http://193.0.1.157:8080/feature.json") // 请求方式和请求url
.execute(new StringCallback() {
@Override
public void onSuccess(String s, Call call, Response response) {
XView yiew_1 = Util.gson.fromJson(s, XView.class);
View contentView = XViewMain.startProcess(context, yiew_1);
setContentView(contentView);
}
});
}
示例12: load
import com.lzy.okgo.callback.StringCallback; //导入依赖的package包/类
private void load() {
OkGo.get("http://193.0.1.157:8080/complaintDetail.json") // 请求方式和请求url
.execute(new StringCallback() {
@Override
public void onSuccess(String s, Call call, Response response) {
XView yiew_1 = Util.gson.fromJson(s, XView.class);
View contentView = XViewMain.startProcess(context, yiew_1 );
setContentView(contentView);
}
});
}
示例13: load
import com.lzy.okgo.callback.StringCallback; //导入依赖的package包/类
private void load() {
OkGo.get("http://193.0.1.157:9999/sales.json") // 请求方式和请求url
.execute(new StringCallback() {
@Override
public void onSuccess(String s, Call call, Response response) {
XView yiew_1 = Util.gson.fromJson(s, XView.class);
View aa = XViewMain.startProcess(context, yiew_1 );
setContentView(aa);
}
});
}
示例14: load
import com.lzy.okgo.callback.StringCallback; //导入依赖的package包/类
private void load() {
OkGo.get("http://193.0.1.157:8080/headcomponent.json") // 请求方式和请求url
.execute(new StringCallback() {
@Override
public void onSuccess(String s, Call call, Response response) {
XView yiewResp = Util.gson.fromJson(s, XView.class);
View contentView = XViewMain.startProcess(context, yiewResp);
setContentView(contentView);
}
});
}
示例15: load
import com.lzy.okgo.callback.StringCallback; //导入依赖的package包/类
private void load() {
OkGo.get("http://193.0.1.157:8080/images.json") // 请求方式和请求url
.execute(new StringCallback() {
@Override
public void onSuccess(String s, Call call, Response response) {
XView yiew_1 = Util.gson.fromJson(s, XView.class);
View contentView = XViewMain.startProcess(context, yiew_1 );
setContentView(contentView);
}
});
}