package cn.cxj.constellation.spider;
import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import cn.cxj.constellation.constant.Regular;
import cn.cxj.constellation.model.TodayLucky;
import cn.cxj.constellation.utils.Utils;
import cn.cxj.constellation.R;
import cn.cxj.constellation.TodayActivity;
public class TodayLuckySpider implements Runnable{
private TodayLucky today;
private String url;
//星星
private ImageView image_zhys;
private ImageView image_aqys;
private ImageView image_gzzk;
private ImageView image_lctz;
//文本
private TextView text_jkzs;
private TextView text_stzs;
private TextView text_xyys;
private TextView text_xysz;
private TextView text_spxz;
private TextView text_desc;
private ImageView logo=null;
private TextView text_name;
private TextView text_brithday;
private TextView text_date;
private TodayActivity con;
public TodayLuckySpider() {
}
public TodayLuckySpider(String url) {
today=new TodayLucky();
this.url = url;
}
public TodayLuckySpider(String url, ImageView image_zhys,
ImageView image_aqys, ImageView image_gzzk, ImageView image_lctz,
TextView text_jkzs, TextView text_stzs, TextView text_xyys,
TextView text_xysz, TextView text_spxz, TextView text_desc,
ImageView logo,TextView text_name,TextView text_brithday,TextView text_date) {
this.url = url;
this.image_zhys = image_zhys;
this.image_aqys = image_aqys;
this.image_gzzk = image_gzzk;
this.image_lctz = image_lctz;
this.text_jkzs = text_jkzs;
this.text_stzs = text_stzs;
this.text_xyys = text_xyys;
this.text_xysz = text_xysz;
this.text_spxz = text_spxz;
this.text_desc = text_desc;
this.logo = logo;
this.text_name=text_name;
this.text_brithday=text_brithday;
this.text_date=text_date;
today=new TodayLucky();
}
@Override
public void run() {
Document doc=null;
Elements eles=null;
Element ele=null;
String str=null;
int length=0;
if(!Utils.isNET(con)){
//Toast.makeText(con, "网络不可用哦,亲!", Toast.LENGTH_LONG).show();
Utils.showToast(con, "网络不可用哦,亲!", Toast.LENGTH_LONG);
con.finish();
return;
}
try {
doc=Jsoup.connect(url).timeout(8000).get();
if(doc==null){
//Toast.makeText(con, "网络不给力哦,亲,请返回再进入吧!", Toast.LENGTH_SHORT).show();
Utils.showToast(con, "网络不给力哦,亲,请返回再进入吧!", Toast.LENGTH_LONG);
return;
}
//出生日期
eles= doc.select(Regular.REG_BIRTHDAY);
//System.out.println("birthday="+eles.text());
today.setBrithday(eles.text());
//name
eles= doc.select(Regular.REG_NAME);
today.setName(eles.text().replace(today.getBrithday(),""));
//;
//明天运程的url
str= doc.select(Regular.REG_TOMORROW_URL).attr("href");
//System.out.println("明天运程的url="+str);
today.setTomorrowURL(str);
//有效期
ele= doc.select(Regular.REG_DATE).last();
//System.out.println("有效期="+ele.text());
today.setDate(ele.text());
//
eles= doc.select(Regular.REG_TAB);
////System.out.println("eles.length="+eles.size());
for(int i=0;i<eles.size()-1;i++){
switch (i) {
//综合运势
case 0:
length=getCount(eles.get(0));
//System.out.println("综合运势="+length);
today.setZhys(length);
break;
//爱情运势
case 1:
length=getCount(eles.get(1));
//System.out.println("爱情运势="+length);
today.setAqys(length);
break;
//工作状况
case 2:
length=getCount(eles.get(2));
//System.out.println("工作状况="+length);
today.setGzzk(length);
break;
//理财投资
case 3:
length=getCount(eles.get(3));
//System.out.println("理财投资="+length);
today.setLctz(length);
break;
//健康指数
case 4:
str=getDesc(eles.get(4));
//System.out.println("健康指数="+str);
today.setJkzs(str);
break;
//商谈指数
case 5:
str=getDesc(eles.get(5));
//System.out.println("商谈指数="+str);
today.setStzs(str);
break;
//幸运颜色
case 6:
str=getDesc(eles.get(6));
//System.out.println("幸运颜色="+str);
today.setXyys(str);
break;
//幸运数字
case 7:
str=getDesc(eles.get(7));
//System.out.println("幸运数字="+str);
today.setXysz(str);
break;
//速配星座
case 8:
str=getDesc(eles.get(8));
//System.out.println("速配星座="+str);
today.setSpxz(str);
break;
}
}
//描述
eles=doc.select(Regular.REG_DESC);
//System.out.println("描述="+eles.text());
today.setDesc(eles.text());
setTheViewContent(today);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
//Toast.makeText(con, "网络不给力哦,亲,请返回再进入吧!", Toast.LENGTH_SHORT).show();
Utils.showToast(con, "网络不给力哦,亲,请返回再进入吧!", Toast.LENGTH_LONG);
}
}
/**
* 填充view内容 show出去给用户看
* @param today
*/
private void setTheViewContent(TodayLucky today){
/**
* private ImageView image_zhys;
private ImageView image_aqys;
private ImageView image_gzzk;
private ImageView image_lctz;
//文本
private TextView text_jkzs;
private TextView text_stzs;
private TextView text_xyys;
private TextView ;
private TextView text_spxz;
private TextView text_desc;
private ImageView logo=null;
private TextView text_name;
*/
/**
* 笔记:不能直接在线程中操作UI
*/
//image_zhys.setImageResource(R.drawable.star_1);
setStar(today.getZhys(),image_zhys);
setStar(today.getAqys(),image_aqys);
setStar(today.getGzzk(),image_gzzk);
setStar(today.getLctz(),image_lctz);
//this.text_name.setText(today.getName());
textPost(text_name,today.getName());
//this.text_brithday.setText(today.getBrithday());
textPost(text_brithday, today.getBrithday());
//this.text_jkzs.setText(today.getJkzs());
textPost(text_jkzs, today.getJkzs());
//this.text_stzs.setText(today.getStzs());
textPost(text_stzs, today.getStzs());
//this.text_xyys.setText(today.getXyys());
textPost(text_xyys, today.getXyys());
//this.text_xysz.setText(today.getXysz());
textPost(text_xysz,today.getXysz());
//this.text_spxz.setText(today.getSpxz());
textPost(text_spxz,today.getSpxz());
//this.text_desc.setText(today.getDesc());
textPost(text_desc,today.getDesc());
//this.text_date.setText(today.getDate());
textPost(text_date,today.getDate());
//Toast.makeText(con, "成功", Toast.LENGTH_SHORT).show();
}
/**
* 通过post消息更新UI
* @param image
* @param id
*/
private void imagePost(final ImageView image,final int id){
image.post(new Runnable(){
@Override
public void run() {
image.setImageResource(id);
}
});
}
private void textPost(final TextView text,final String str){
text.post(new Runnable(){
@Override
public void run() {
text.setText(str);
}
});
}
/**
* 跟距星星的数量插入星星图
* @param num
* @param image
*/
private void setStar(int num,final ImageView image){
switch (num) {
case 1:
imagePost(image,R.drawable.star_1);
break;
case 2:
imagePost(image,R.drawable.star_2);
break;
case 3:
imagePost(image,R.drawable.star_3);
break;
case 4:
imagePost(image,R.drawable.star_4);
break;
case 5:
imagePost(image,R.drawable.star_5);
break;
default:
imagePost(image,R.drawable.star_5);
break;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
源码 今日星座运势.rar
共158个文件
class:56个
png:52个
java:23个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 140 浏览量
2023-03-27
07:38:55
上传
评论
收藏 1.12MB RAR 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
源码 今日星座运势.rar (158个子文件)
proguard.cfg 1KB
XingZuoActivity.class 8KB
TodayLuckySpider.class 7KB
TodayActivityService.class 6KB
TodayActivity.class 5KB
AsynImageLoader.class 4KB
ArticleSpider.class 3KB
XingZuoZhenXinHuaSpider.class 3KB
TouchListener.class 3KB
TodayLucky.class 3KB
Constant.class 3KB
MainActivity.class 3KB
ApplicationItemAdapter.class 3KB
ApplicationItemAdapter.class 3KB
Article.class 3KB
Utils.class 3KB
R$drawable.class 2KB
R$id.class 2KB
XingZuoActivityService.class 2KB
XingZuoZhenXinHua.class 2KB
XingZuoZhenXinHua.class 2KB
AsynImageLoader$4.class 2KB
XingZuoActivity$1.class 2KB
XingZuoActivity$2.class 2KB
TouchListener$ShuangYuZuoTouch.class 1KB
TouchListener$TianPingZuoTouch.class 1KB
TouchListener$ShuangZiZuoTouch.class 1KB
TouchListener$ShuiPingZuoTouch.class 1KB
TouchListener$TianXieZuoTouch.class 1KB
TouchListener$SheShouZuoTouch.class 1KB
TouchListener$BaiYangZuoTouch.class 1KB
TouchListener$JinNiuZuoTouch.class 1KB
TouchListener$ShiZiZuoTouch.class 1KB
TouchListener$ChuNvZuoTouch.class 1KB
TouchListener$MoJieZuoTouch.class 1KB
TouchListener$JuXieZuoTouch.class 1KB
AsynImageLoader$3.class 1KB
ArticleSpider$2.class 1KB
TouchListener$Buttton_MoreClick.class 1KB
R$string.class 1006B
TodayLuckySpider$2.class 986B
AsynImageLoader$2.class 945B
AsynImageLoader$1.class 941B
Article.class 938B
ArticleSpider$1.class 936B
TodayLuckySpider$1.class 926B
ApplicationItemAdapter$ViewHolder.class 914B
ApplicationItemAdapter$ViewHolder.class 893B
Regular.class 697B
R.class 643B
R$layout.class 547B
R$dimen.class 467B
Status.class 436B
R$menu.class 426B
BuildConfig.class 349B
R$attr.class 346B
AsynImageLoader$LoadCallBack.class 308B
.classpath 475B
YoumiSdk_v4.04_2013-07-29.jar 348KB
jsoup-1.7.2.jar 287KB
TodayLuckySpider.java 8KB
R.java 8KB
XingZuoActivity.java 6KB
TodayActivityService.java 6KB
TouchListener.java 5KB
TodayActivity.java 5KB
AsynImageLoader.java 4KB
Constant.java 4KB
MainActivity.java 3KB
XingZuoZhenXinHuaSpider.java 3KB
XingZuoActivityService.java 3KB
ArticleSpider.java 3KB
TodayLucky.java 2KB
Utils.java 2KB
ApplicationItemAdapter.java 2KB
ApplicationItemAdapter.java 2KB
Article.java 2KB
XingZuoZhenXinHua.java 1KB
XingZuoZhenXinHua.java 1KB
Regular.java 724B
Article.java 529B
Status.java 203B
BuildConfig.java 162B
bkg_img_default.jpg 87KB
star_titlebg.jpg 2KB
hs_err_pid5776.log 5KB
hs_err_pid260.log 5KB
hs_err_pid6604.log 5KB
mojiezuo.png 25KB
sheshouzuo.png 24KB
shuangzizuo.png 23KB
shuipingzuo.png 23KB
chunvzuo.png 22KB
jinniuzuo.png 22KB
shizizuo.png 22KB
shuangyuzuo.png 21KB
tianpingzuo.png 21KB
juxiezuo.png 20KB
tianxiezuo.png 20KB
baiyangzuo.png 19KB
共 158 条
- 1
- 2
资源评论
荣华富贵8
- 粉丝: 149
- 资源: 7649
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功