本文整理汇总了Java中com.coolweather.app.util.Utility类的典型用法代码示例。如果您正苦于以下问题:Java Utility类的具体用法?Java Utility怎么用?Java Utility使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Utility类属于com.coolweather.app.util包,在下文中一共展示了Utility类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateWeather
import com.coolweather.app.util.Utility; //导入依赖的package包/类
protected void updateWeather() {
// TODO �Զ����ɵķ������
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String weatherCode = prefs.getString("weather_code", "");
String address = "http://www.weather.com.cn/data/cityInfo/"+weatherCode+".html";
HttpUtil.sendHttpRequest(address, new HttpCallbckListener() {
@Override
public void onFinish(String response) {
// TODO �Զ����ɵķ������
Utility.handleWeatherResponse(AutoUpdateService.this, response);
}
@Override
public void onError(Exception e) {
// TODO �Զ����ɵķ������
e.printStackTrace();
}
});
}
示例2: updateWeather
import com.coolweather.app.util.Utility; //导入依赖的package包/类
/**
* 更新天气信息。
*/
private void updateWeather() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String weatherCode = prefs.getString("weather_code", "");
String address = "http://www.weather.com.cn/data/cityinfo/" + weatherCode + ".html";
HttpUtil.sendHttpRequest(address, new HttpCallbackListener() {
@Override
public void onFinish(String response) {
Log.d("TAG", response);
Utility.handleWeatherResponse(AutoUpdateService.this, response);
}
@Override
public void onError(Exception e) {
e.printStackTrace();
}
});
}
示例3: queryFromServer
import com.coolweather.app.util.Utility; //导入依赖的package包/类
/**
* 根据传入的地址和类型去向服务器查询天气代号或者天气信息。
*/
private void queryFromServer(final String address, final String type) {
HttpUtil.sendHttpRequest(address, new HttpCallbackListener() {
@Override
public void onFinish(final String response) {
if ("countyCode".equals(type)) {
if (!TextUtils.isEmpty(response)) {
// 从服务器返回的数据中解析出天气代号
String[] array = response.split("\\|");
if (array != null && array.length == 2) {
String weatherCode = array[1];
queryWeatherInfo(weatherCode);
}
}
} else if ("weatherCode".equals(type)) {
// 处理服务器返回的天气信息
Utility.handleWeatherResponse(WeatherActivity.this, response);
runOnUiThread(new Runnable() {
@Override
public void run() {
showWeather();
}
});
}
}
@Override
public void onError(Exception e) {
runOnUiThread(new Runnable() {
@Override
public void run() {
publishText.setText("同步失败");
}
});
}
});
}
示例4: queryFromServer
import com.coolweather.app.util.Utility; //导入依赖的package包/类
private void queryFromServer(String code, final String type) {
// TODO �Զ����ɵķ������
String address;
if(!TextUtils.isEmpty(code)){
address = "http://weather.com.cn/data/list3/city"+code+".xml";
} else {
address = "http://weather.com.cn/data/list3/city.xml";
// address = "http://weather.com.cn/data/cityinfo.html";
}
showProgressDialog();
HttpUtil.sendHttpRequest(address, new HttpCallbckListener() {
@Override
public void onFinish(String response) {
// TODO �Զ����ɵķ������
boolean result = false;
if("province".equals(type)){
result = Utility.handleProvincesResponse(coolWeatherDB, response);
} else if("city".equals(type)){
result = Utility.handlecitiesResponse(coolWeatherDB, response, selectedProvince.getId());
}else if("county".equals(type)){
result = Utility.handlecountiesResponse(coolWeatherDB, response, selectedCity.getId());
}
if(result){
//ͨ��runOnUiThread()�����ص����̴߳�����
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO �Զ����ɵķ������
closeProgressDialog();
if("province".equals(type)){
queryProvinces();
}else if("city".equals(type)){
queryCities();
}else if("county".equals(type)){
queryCounties();
}
}
});
}
}
@Override
public void onError(Exception e) {
// TODO �Զ����ɵķ������
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO �Զ����ɵķ������
closeProgressDialog();
Toast.makeText(ChooseAreaActivity.this, "����ʧ��", Toast.LENGTH_SHORT).show();
}
});
}
});
}
示例5: queryFromSever
import com.coolweather.app.util.Utility; //导入依赖的package包/类
private void queryFromSever(String address, final String type) {
// TODO �Զ����ɵķ������
HttpUtil.sendHttpRequest(address, new HttpCallbckListener() {
@Override
public void onFinish(String request) {
// TODO �Զ����ɵķ������
if("countyCode".equals(type)){
if(!TextUtils.isEmpty(request)){
String[] array = request.split("\\|");
if(array!=null&&array.length==2){
String weatherCode = array[1];
quertWeatherInfo(weatherCode);
}
}
}else if("weatherCode".equals(type)){
Utility.handleWeatherResponse(WeatherActivity.this, request);
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO �Զ����ɵķ������
showWeather();
}
});
}
}
@Override
public void onError(Exception e) {
// TODO �Զ����ɵķ������
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO �Զ����ɵķ������
publishText.setText("ͬ��ʧ��");
}
});
}
});
}
示例6: queryFromServer
import com.coolweather.app.util.Utility; //导入依赖的package包/类
/**
* 根据传入的代号和类型从服务器上查询省市县数据。
*/
private void queryFromServer(final String code, final String type) {
String address;
if (!TextUtils.isEmpty(code)) {
address = "http://www.weather.com.cn/data/list3/city" + code + ".xml";
} else {
address = "http://www.weather.com.cn/data/list3/city.xml";
}
showProgressDialog();
HttpUtil.sendHttpRequest(address, new HttpCallbackListener() {
@Override
public void onFinish(String response) {
boolean result = false;
if ("province".equals(type)) {
result = Utility.handleProvincesResponse(coolWeatherDB,
response);
} else if ("city".equals(type)) {
result = Utility.handleCitiesResponse(coolWeatherDB,
response, selectedProvince.getId());
} else if ("county".equals(type)) {
result = Utility.handleCountiesResponse(coolWeatherDB,
response, selectedCity.getId());
}
if (result) {
// 通过runOnUiThread()方法回到主线程处理逻辑
runOnUiThread(new Runnable() {
@Override
public void run() {
closeProgressDialog();
if ("province".equals(type)) {
queryProvinces();
} else if ("city".equals(type)) {
queryCities();
} else if ("county".equals(type)) {
queryCounties();
}
}
});
}
}
@Override
public void onError(Exception e) {
// 通过runOnUiThread()方法回到主线程处理逻辑
runOnUiThread(new Runnable() {
@Override
public void run() {
closeProgressDialog();
Toast.makeText(ChooseAreaActivity.this,
"加载失败", Toast.LENGTH_SHORT).show();
}
});
}
});
}
示例7: queryFromServer
import com.coolweather.app.util.Utility; //导入依赖的package包/类
/**
* ���ݴ���Ĵ��ź����ʹӷ������ϲ�ѯʡ��������
*/
private void queryFromServer(final String code,final String type) {
String address;
if(!TextUtils.isEmpty(code)){
address="http://www.weather.com.cn/data/list3/city"+code+".xml";
}else{
address="http://www.weather.com.cn/data/list3/city.xml";
}
showProgressDialog();//��ʾ���ȶԻ���
//��8���ӵĴ���ʱ��
HttpUtil.sendHttpRequest(address, new HttpCallbackListener() {
@Override
public void onFinish(String response) {
boolean result = false;
if("province".equals(type)){
result = Utility.handleProvincesResponse(coolWeatherDB, response);
}else if("city".equals(type)){
result = Utility.handleCitiesResponse(coolWeatherDB, response, selectedProvince.getId());
}else if("county".equals(type)){
result = Utility.handleCountiseResponse(coolWeatherDB, response, selectedCity.getId());
}
if(result){
runOnUiThread(new Runnable() {
@Override
public void run() {
closeProgressDialog();
if("province".equals(type)){
queryProvinces();
}else if("city".equals(type)){
queryCities();
}else if("county".equals(type)){
queryCounties();
}
}
});
}
}
@Override
public void onError(Exception e) {
runOnUiThread(new Runnable() {
@Override
public void run() {
closeProgressDialog();
Toast.makeText(ChooseAreaActivity.this, "����ʧ��",Toast.LENGTH_SHORT).show();
}
});
}
});
}