958
技術社區[雲棲]
天氣預報 將1-6天的數據源和7-9天的數據源的信息匹配起來了 代碼
晚上吃了晚飯,拿出兩張大白紙,對照中國天氣網和好天氣網,寫了兩份圖片和信息的對比表,主要匹配的是天氣情況圖片和文字的對應關係。
然後在程序裏,解析的那塊,做了一個匹配的IF ELSE處理。把這個問題大致解決了。
並且將JSON接口中的NULL值,和一些DNULL.GIF,NNULL.GIF的BUG都處理為不顯示
我的核心思路如下,不曉得有沒有更好地解決辦法:
/*以下為第七天上午信息*/
/*
* 以下為雨夾雪
*/
if(weather_title71.equals("雨或雪")) {
weather_title71="雨夾雪";
report[0].setImg1("06");
}
/*
* 以下為晴朗
*/
if(weather_title71.equals("晴")) {
weather_title71="晴";
report[0].setImg1("00");
}
if(weather_title71.equals("晴朗")) {
weather_title71="晴";
report[0].setImg1("00");
}
if(weather_title71.equals("大部晴朗")) {
weather_title71="晴";
report[0].setImg1("00");
}
/*
* 以下為多雲
*/
if(weather_title71.equals("多雲")) {
weather_title71="多雲";
report[0].setImg1("01");
}
if(weather_title71.equals("局部多雲")) {
weather_title71="多雲";
report[0].setImg1("01");
}
if(weather_title71.equals("大部多雲")) {
weather_title71="多雲";
report[0].setImg1("01");
}
if(weather_title71.equals("晴時多雲")) {
weather_title71="多雲";
report[0].setImg1("01");
}
if(weather_title71.equals("早多雲/晚轉晴")) {
weather_title71="多雲";
report[0].setImg1("01");
}
if(weather_title71.equals("上午有雲/下午後晴")) {
weather_title71="多雲";
report[0].setImg1("01");
}
/*
* 以下為陣雨
*/
if(weather_title71.equals("陣雨")) {
weather_title71="陣雨";
report[0].setImg1("03");
}
if(weather_title71.equals("零星陣雨")) {
weather_title71="陣雨";
report[0].setImg1("03");
}
if(weather_title71.equals("短暫陣雨")) {
weather_title71="陣雨";
report[0].setImg1("03");
}
/*
* 以下為陣雪
*/
if(weather_title71.equals("陣雪")) {
weather_title71="陣雪";
report[0].setImg1("13");
}
if(weather_title71.equals("雨或陣雪")) {
weather_title71="陣雪";
report[0].setImg1("13");
}
if(weather_title71.equals("短暫降雪")) {
weather_title71="陣雪";
report[0].setImg1("13");
}
if(weather_title71.equals("短暫陣雪")) {
weather_title71="陣雪";
report[0].setImg1("13");
}
if(weather_title71.equals("零星陣雪")) {
weather_title71="陣雪";
report[0].setImg1("13");
}
/*以下為第八天上午信息*/
/*
* 以下為雨夾雪
*/
if(weather_title81.equals("雨或雪")) {
weather_title81="雨夾雪";
report[1].setImg1("06");
}
/*
* 以下為晴朗
*/
if(weather_title81.equals("晴")) {
weather_title81="晴";
report[1].setImg1("00");
}
if(weather_title81.equals("晴朗")) {
weather_title81="晴";
report[1].setImg1("00");
}
if(weather_title81.equals("大部晴朗")) {
weather_title81="晴";
report[1].setImg1("00");
}
/*
* 以下為多雲
*/
if(weather_title81.equals("多雲")) {
weather_title81="多雲";
report[1].setImg1("01");
}
if(weather_title81.equals("局部多雲")) {
weather_title81="多雲";
report[1].setImg1("01");
}
if(weather_title81.equals("大部多雲")) {
weather_title81="多雲";
report[1].setImg1("01");
}
if(weather_title81.equals("晴時多雲")) {
weather_title81="多雲";
report[1].setImg1("01");
}
if(weather_title81.equals("早多雲/晚轉晴")) {
weather_title81="多雲";
report[1].setImg1("01");
}
if(weather_title81.equals("上午有雲/下午後晴")) {
weather_title81="多雲";
report[1].setImg1("01");
}
/*
* 以下為陣雨
*/
if(weather_title81.equals("陣雨")) {
weather_title81="陣雨";
report[1].setImg1("03");
}
if(weather_title81.equals("零星陣雨")) {
weather_title81="陣雨";
report[1].setImg1("03");
}
if(weather_title81.equals("短暫陣雨")) {
weather_title81="陣雨";
report[1].setImg1("03");
}
/*
* 以下為陣雪
*/
if(weather_title81.equals("陣雪")) {
weather_title81="陣雪";
report[1].setImg1("13");
}
if(weather_title81.equals("雨或陣雪")) {
weather_title81="陣雪";
report[1].setImg1("13");
}
if(weather_title81.equals("短暫降雪")) {
weather_title81="陣雪";
report[1].setImg1("13");
}
if(weather_title81.equals("短暫陣雪")) {
weather_title81="陣雪";
report[1].setImg1("13");
}
if(weather_title81.equals("零星陣雪")) {
weather_title81="陣雪";
report[1].setImg1("13");
}
/*以下為第九天上午信息*/
/*
* 以下為雨夾雪
*/
if(weather_title91.equals("雨或雪")) {
weather_title91="雨夾雪";
report[2].setImg1("06");
}
/*
* 以下為晴朗
*/
if(weather_title91.equals("晴")) {
weather_title91="晴";
report[2].setImg1("00");
}
if(weather_title91.equals("晴朗")) {
weather_title91="晴";
report[2].setImg1("00");
}
if(weather_title91.equals("大部晴朗")) {
weather_title91="晴";
report[2].setImg1("00");
}
/*
* 以下為多雲
*/
if(weather_title91.equals("多雲")) {
weather_title91="多雲";
report[2].setImg1("01");
}
if(weather_title91.equals("局部多雲")) {
weather_title91="多雲";
report[2].setImg1("01");
}
if(weather_title91.equals("大部多雲")) {
weather_title91="多雲";
report[2].setImg1("01");
}
if(weather_title91.equals("晴時多雲")) {
weather_title91="多雲";
report[2].setImg1("01");
}
if(weather_title91.equals("早多雲/晚轉晴")) {
weather_title91="多雲";
report[2].setImg1("01");
}
if(weather_title91.equals("上午有雲/下午後晴")) {
weather_title91="多雲";
report[2].setImg1("01");
}
/*
* 以下為陣雨
*/
if(weather_title91.equals("陣雨")) {
weather_title91="陣雨";
report[2].setImg1("03");
}
if(weather_title91.equals("零星陣雨")) {
weather_title91="陣雨";
report[2].setImg1("03");
}
if(weather_title91.equals("短暫陣雨")) {
weather_title91="陣雨";
report[0].setImg1("03");
}
/*
* 以下為陣雪
*/
if(weather_title91.equals("陣雪")) {
weather_title91="陣雪";
report[2].setImg1("13");
}
if(weather_title91.equals("雨或陣雪")) {
weather_title91="陣雪";
report[2].setImg1("13");
}
if(weather_title91.equals("短暫降雪")) {
weather_title91="陣雪";
report[2].setImg1("13");
}
if(weather_title91.equals("短暫陣雪")) {
weather_title91="陣雪";
report[2].setImg1("13");
}
if(weather_title91.equals("零星陣雪")) {
weather_title91="陣雪";
report[2].setImg1("13");
}
/*以下是下午信息
*
*
*
*
**/
/*以下為第七天下午信息*/
/*
* 以下為雨夾雪
*/
if(weather_title72.equals("雨或雪")) {
weather_title72="雨夾雪";
report[0].setImg2("06");
}
/*
* 以下為晴朗
*/
if(weather_title72.equals("晴")) {
weather_title72="晴";
report[0].setImg2("00");
}
if(weather_title72.equals("晴朗")) {
weather_title72="晴";
report[0].setImg2("00");
}
if(weather_title72.equals("大部晴朗")) {
weather_title72="晴";
report[0].setImg2("00");
}
/*
* 以下為多雲
*/
if(weather_title72.equals("多雲")) {
weather_title72="多雲";
report[0].setImg2("01");
}
if(weather_title72.equals("局部多雲")) {
weather_title72="多雲";
report[0].setImg2("01");
}
if(weather_title72.equals("大部多雲")) {
weather_title72="多雲";
report[0].setImg2("01");
}
if(weather_title72.equals("晴時多雲")) {
weather_title72="多雲";
report[0].setImg2("01");
}
if(weather_title72.equals("早多雲/晚轉晴")) {
weather_title72="晴";
report[0].setImg2("00");
}
if(weather_title72.equals("上午有雲/下午後晴")) {
weather_title72="晴";
report[0].setImg2("00");
}
/*
* 以下為陣雨
*/
if(weather_title72.equals("陣雨")) {
weather_title72="陣雨";
report[0].setImg2("03");
}
if(weather_title72.equals("零星陣雨")) {
weather_title72="陣雨";
report[0].setImg2("03");
}
if(weather_title72.equals("短暫陣雨")) {
weather_title72="陣雨";
report[0].setImg2("03");
}
/*
* 以下為陣雪
*/
if(weather_title72.equals("陣雪")) {
weather_title72="陣雪";
report[0].setImg2("13");
}
if(weather_title72.equals("雨或陣雪")) {
weather_title72="陣雪";
report[0].setImg2("13");
}
if(weather_title72.equals("短暫降雪")) {
weather_title72="陣雪";
report[0].setImg2("13");
}
if(weather_title72.equals("短暫陣雪")) {
weather_title72="陣雪";
report[0].setImg2("13");
}
if(weather_title72.equals("零星陣雪")) {
weather_title72="陣雪";
report[0].setImg2("13");
}
/*以下為第八天下午信息*/
/*
* 以下為雨夾雪
*/
if(weather_title82.equals("雨或雪")) {
weather_title82="雨夾雪";
report[1].setImg2("06");
}
/*
* 以下為晴朗
*/
if(weather_title82.equals("晴")) {
weather_title82="晴";
report[1].setImg2("00");
}
if(weather_title82.equals("晴朗")) {
weather_title82="晴";
report[1].setImg2("00");
}
if(weather_title82.equals("大部晴朗")) {
weather_title82="晴";
report[1].setImg2("00");
}
/*
* 以下為多雲
*/
if(weather_title82.equals("多雲")) {
weather_title82="多雲";
report[1].setImg2("01");
}
if(weather_title82.equals("局部多雲")) {
weather_title82="多雲";
report[1].setImg2("01");
}
if(weather_title82.equals("大部多雲")) {
weather_title82="多雲";
report[1].setImg2("01");
}
if(weather_title82.equals("晴時多雲")) {
weather_title82="多雲";
report[1].setImg2("01");
}
if(weather_title82.equals("早多雲/晚轉晴")) {
weather_title82="晴";
report[1].setImg2("00");
}
if(weather_title82.equals("上午有雲/下午後晴")) {
weather_title82="晴";
report[1].setImg2("00");
}
/*
* 以下為陣雨
*/
if(weather_title82.equals("陣雨")) {
weather_title82="陣雨";
report[1].setImg2("03");
}
if(weather_title82.equals("零星陣雨")) {
weather_title82="陣雨";
report[1].setImg2("03");
}
if(weather_title82.equals("短暫陣雨")) {
weather_title82="陣雨";
report[1].setImg2("03");
}
/*
* 以下為陣雪
*/
if(weather_title82.equals("陣雪")) {
weather_title82="陣雪";
report[1].setImg2("13");
}
if(weather_title82.equals("雨或陣雪")) {
weather_title82="陣雪";
report[1].setImg2("13");
}
if(weather_title82.equals("短暫降雪")) {
weather_title82="陣雪";
report[1].setImg2("13");
}
if(weather_title82.equals("短暫陣雪")) {
weather_title82="陣雪";
report[1].setImg2("13");
}
if(weather_title82.equals("零星陣雪")) {
weather_title82="陣雪";
report[1].setImg2("13");
}
/*以下為第九天下午信息*/
/*
* 以下為雨夾雪
*/
if(weather_title92.equals("雨或雪")) {
weather_title92="雨夾雪";
report[2].setImg2("06");
}
/*
* 以下為晴朗
*/
if(weather_title92.equals("晴")) {
weather_title92="晴";
report[2].setImg2("00");
}
if(weather_title92.equals("晴朗")) {
weather_title92="晴";
report[2].setImg2("00");
}
if(weather_title92.equals("大部晴朗")) {
weather_title92="晴";
report[2].setImg2("00");
}
/*
* 以下為多雲
*/
if(weather_title92.equals("多雲")) {
weather_title92="多雲";
report[2].setImg2("01");
}
if(weather_title92.equals("局部多雲")) {
weather_title92="多雲";
report[2].setImg2("01");
}
if(weather_title92.equals("大部多雲")) {
weather_title92="多雲";
report[2].setImg2("01");
}
if(weather_title92.equals("晴時多雲")) {
weather_title92="多雲";
report[2].setImg2("01");
}
if(weather_title92.equals("早多雲/晚轉晴")) {
weather_title92="晴";
report[2].setImg2("00");
}
if(weather_title92.equals("上午有雲/下午後晴")) {
weather_title92="晴";
report[2].setImg2("00");
}
/*
* 以下為陣雨
*/
if(weather_title92.equals("陣雨")) {
weather_title92="陣雨";
report[2].setImg2("03");
}
if(weather_title92.equals("零星陣雨")) {
weather_title92="陣雨";
report[2].setImg2("03");
}
if(weather_title92.equals("短暫陣雨")) {
weather_title92="陣雨";
report[2].setImg2("03");
}
/*
* 以下為陣雪
*/
if(weather_title92.equals("陣雪")) {
weather_title92="陣雪";
report[2].setImg2("13");
}
if(weather_title92.equals("雨或陣雪")) {
weather_title92="陣雪";
report[2].setImg2("13");
}
if(weather_title92.equals("短暫降雪")) {
weather_title92="陣雪";
report[2].setImg2("13");
}
if(weather_title92.equals("短暫陣雪")) {
weather_title92="陣雪";
report[2].setImg2("13");
}
if(weather_title92.equals("零星陣雪")) {
weather_title92="陣雪";
report[2].setImg2("13");
}
最後更新:2017-04-02 06:52:18