我的第一个开源App(彩票开奖查询)
来源:互联网 发布:javac编译java文件夹 编辑:程序博客网 时间:2024/04/29 01:09
源码:https://github.com/feimengwang/lottery
这个App其实2年前就写好了,那时候是抓取的网页里面的内容,也没有用第三方开源
框架,写的也比较乱,最近没事的时候发现360有接口,返回JSON数据,所以重写了一次,这次也有很多不足,正在修正中。。。。
用到的第三方库
compile 'com.google.code.gson:gson:2.6.2'
compile 'io.reactivex:rxjava:1.1.0'
compile 'io.reactivex:rxandroid:1.1.0'
compile 'com.squareup.retrofit2:retrofit:2.0.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0'
先上图片(图片有点大)
读取网络数据用Rxjava+retrofit
public interface LotteryService { @GET("qkaijiang?r=1458219747840") Observable<Lottery> geLastData360(); @GET("qkj") Observable<LotteryDetail> getLotteryDetail(@Query("lotId") String lotId, @Query("issue") String issue); @GET("qkjlist") Observable<LotteryHistory> geLotteryHistory(@Query("lotId") String lotId, @Query("page") String page);}
下面就是create个retrofit 来取得数据了
retrofit = new Retrofit.Builder() .baseUrl(LotteryConstant.RETROFIT_BASE_URL) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .addConverterFactory(GsonConverterFactory.create()) .client(client) .build(); service = retrofit.create(LotteryService.class); service.geLastData360() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .map(new Func1<Lottery, List>() { @Override public List call(Lottery lottery) { return getLotteryList(lottery); } }).subscribe(subscriber);
其中遇到Toolbar的Overflow menu 没有图标,网上找了一些方案,但是不生效,最后简单重写了Toolbar,终于可以了
public class LotteryToolbar extends Toolbar{ public LotteryToolbar(Context context) { super(context); } public LotteryToolbar(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } public LotteryToolbar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override public void inflateMenu(@MenuRes int resId) { Menu m = getMenu(); if(m!=null &&m.getClass()== MenuBuilder.class){ try { Method method = m.getClass().getDeclaredMethod("setOptionalIconsVisible",Boolean.TYPE); method.setAccessible(true); method.invoke(m,true); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } super.inflateMenu(resId); }}
就写这么多吧,,,
阅读全文
0 0
- 我的第一个开源App(彩票开奖查询)
- 彩票开奖api 彩票开奖结果查询
- Android端的彩票开奖查询系统
- 我的第一个app(android)
- 我的彩票界面
- 我的第一个app
- 我的第一个 APP
- 微信公众号开发--双色球彩票开奖结果(Java版)
- 使用爬虫获取彩票开奖结果
- 我的彩票-制作笔记
- java 爬取彩票开奖信息,爬取双色球历史开奖,爬取大乐透历史开奖
- 我的第一个Android APP <Claculate>
- 我的第一个android app
- 我的第一个App开发过程
- 我的第一个ANDROID APP (一)
- 我的第一个android app(二)
- 我第一个上传市场的App
- 我的第一个iOS App
- 什么是WiFi(Wi-Fi)
- IT从业人员必看的10个论坛
- Android web交互方式
- Toolbar 设置OverFlow 图片
- 阻抗匹配和为什要进行阻抗匹配
- 我的第一个开源App(彩票开奖查询)
- 快速使用hyperlynx broadsimSim功能介绍
- JAVA多线程下载,断点续传(HTTP)
- 全球99%的人不知道的事情
- 自己写的简单HttpClient
- 常用的电平转换方案
- 面试后学习 -- Java GC机制
- UART
- Restful中的get, put 和post