通過很多天的努力,新聞客戶端終於完成了,想用博客記錄一下開發過程當中遇到的問題和解決方法,以避免之後遇到一樣的問題罵本身記性差.html
項目的前期準備java
作項目前應該仔細的規劃一下功能需求,大致的預估一須要用到什麼知識.android
新聞客戶端須要用到的第三方jar包包括 json
volley Jar包:api
據我所知,在Android中主要提供了兩種方式來進行HTTP通訊,分別是httpURLconnect和httpclient ,可是用過這兩種方式的人都會感受到這樣的方法有些繁瑣,還要考慮主線程問題,volley的出現解決了這些繁瑣的問題,volley適合進行數據量不大可是至關頻繁的網絡操做,也不用考慮主線程問題,新聞客戶端正好須要這樣的框架.網絡
viewpagertransformslibrary.jar 包:
app
viewpagertransformslibrary 是給viewpager作切換動畫用的框架
com.haarman.listviewanimations-2.6.0.jar 包
ide
com.haarman.listviewanimations 是給列表控件的Item作動畫顯示用的
動畫
androidannotations-api-3.1.jar 包
androidannotations 是一個註解框架,如今的新聞客戶端沒有用到此框架,但我以爲這是一個至關不錯的框架,沒捨得刪掉,等有時間會把這個框架加到項目裏面的
nineoldandroids-2.4.0.jar 包
nineoldandroids 是一個不錯的動畫庫
open_sdk_r5756.jar 包 mta-sdk-1.6.2.jar包
這兩個包是騰訊提供的第三方jar包,經過這兩個包可實現騰訊提供的第三方功能
initActivity.jar
這個是我本身打的包,本身命的名,它其實是vitamio包,官網上提供了源代碼,我嫌麻引用外部庫太麻煩就直接源碼打包了.
除了以上一些第三方jar包之外,還要知道新聞來源,客戶端用到的是網易新聞的接口 ,如下是我整理的項目所須要的網址
package eNews.url; /** * * @author 王凱 * @date 2016-9-12 數據網址 */ public class Url { public static final String host = "http://c.m.163.com/"; public static final String endUrl = "-20.html"; public static final String endDetailUrl = "/full.html"; // 頭條 public static final String TopUrl = host + "nc/article/headline/"; public static final String TopId = "T1348647909107"; // 新聞詳情 public static final String NewDetail = host + "/nc/article/"; public static final String CommonUrl = host + "nc/article/list/"; // 足球 public static final String FootId = "T1399700447917"; // 娛樂 public static final String YuLeId = "T1348648517839"; // 體育 public static final String TiYuId = "T1348649079062"; // 財經 public static final String CaiJingId = "T1348648756099"; // 科技 public static final String KeJiId = "T1348649580692"; // 電影 public static final String DianYingId = "T1348648650048"; // 汽車 public static final String QiChiId = "T1348654060988"; // 笑話 public static final String XiaoHuaId = "T1350383429665"; // 笑話 public static final String YouXiId = "T1348654151579"; // 時尚 public static final String ShiShangId = "T1348650593803"; // 情感 public static final String QingGanId = "T1348650839000"; // 精選 public static final String JingXuanId = "T1370583240249"; // 電臺 public static final String DianTaiId = "T1379038288239"; // nba public static final String NBAId = "T1348649145984"; // 數碼 public static final String ShuMaId = "T1348649776727"; // 數碼 public static final String YiDongId = "T1351233117091"; // 彩票 public static final String CaiPiaoId = "T1356600029035"; // 教育 public static final String JiaoYuId = "T1348654225495"; // 論壇 public static final String LunTanId = "T1349837670307"; // 旅遊 public static final String LvYouId = "T1348654204705"; // 手機 public static final String ShouJiId = "T1348649654285"; // 博客 public static final String BoKeId = "T1349837698345"; // 社會 public static final String SheHuiId = "T1348648037603"; // 家居 public static final String JiaJuId = "T1348654105308"; // 暴雪遊戲 public static final String BaoXueId = "T1397016069906"; // 親子 public static final String QinZiId = "T1397116135282"; // CBA public static final String CBAId = "T1348649475931"; // 消息 public static final String MsgId = "T1371543208049"; public static final String FangChanId = "5YyX5Lqs"; // 美 圖 public static final String TuPianMeitu = "http://c.m.163.com/recommend/getChanRecomNews?channel=T1456112189138&size=20&offset="; // 體育 // 體壇 42262.json public static final String TuPianTiTanInit = host + "photo/api/morelist/0096/54GM0096/42262.json"; // 初始圖集 public static final String TuJiInit = host + "photo/api/list/0096/54GI0096.json";// 42358.json public static final String TuJi = host + "photo/api/morelist/0096/54GI0096/";// 42358.json // 圖集end public static final String TuJiEnd = ".json"; // 熱點42577 public static final String TuPianReDian = host + "photo/api/morelist/0096/54GI0096/42577.json"; // 獨家42010 public static final String TuPianDuJia = host + "photo/api/morelist/0096/54GJ0096/"; // 明星 42599.json public static final String TuPianMingXing = host + "photo/api/morelist/0096/54GK0096/"; // http://c.m.163.com/recommend/getChanRecomNews?channel=T1456112189138 // &size=20&offset=40&fn=1&passport=&devId=1W%2FpqPI0eimZMOMbswN2gw%3D%3D&lat=w7Ifc7bHs%2Bfw2bqO4TuUNw%3D%3D&lon=KuBH1jAZjiNo60aoq4e1Ag%3D%3D&version=14.2&net=wifi&ts=1472895595&sign=sU4j0lqP9jfsfmwV9dwTTAGpFOwYk2mWrXTRAA3nHPh48ErR02zJ6%2FKXOnxX046I&encryption=1&canal=meizu_store2014_news&mac=oHWFn0cEzVi3yidKr0L43U8dvF5D%2FPPigcKX35%2FLlyc%3D // http://c.m.163.com/recommend/getChanRecomNews?channel=T1456112189138 // 視頻 http://c.3g.163.com/nc/video/list/00850FRB/n/10-10.html public static final String Video = host + "nc/video/list/"; public static final String VideoCenter = "/n/"; public static final String videoEndUrl = "-20.html"; // 熱點視頻 public static final String VideoReDianId = "V9LG4B3A0"; // 娛樂視頻 public static final String VideoYuLeId = "V9LG4CHOR"; // 搞笑視頻 public static final String VideoGaoXiaoId = "V9LG4E6VR"; // 精品視頻 public static final String VideoJingPinId = "00850FRB"; // 天氣預報url public static final String WeatherHost = "http://wthrcdn.etouch.cn/weather_mini?city="; // http://v.juhe.cn/weather/index?cityname= // // http://api.k780.com:88/?app=weather.city&format=json 獲取城市列表 public static final String WeatherKey = "&key=1734f933d24634331a24aaadc1cb088f"; // 地址反編 public static final String GeocoderUrl = "http://maps.google.cn/maps/api/geocode/json?language=zh-CN&sensor=true&";// latlng=38.92,121.62&sensor=false }