luckybilly / preloader Goto Github PK
View Code? Open in Web Editor NEWPre-load data for android Activity/Fragment/View (android页面启动速度优化利器:在页面打开之前就预加载数据)
Home Page: https://medium.com/@billy.qiyi/preloader-3e2ff0d9279e
License: Apache License 2.0
Pre-load data for android Activity/Fragment/View (android页面启动速度优化利器:在页面打开之前就预加载数据)
Home Page: https://medium.com/@billy.qiyi/preloader-3e2ff0d9279e
License: Apache License 2.0
DataLoader接口 需要返回请求的数据。那么在子线程请求的数据只能通过接口或者handler获取到主线程,如何在DataLoader实现类中开一个子线程获取结果之后再返回给DataLoader的实现类呢?这是一个问题,不能像Demo那样简单的return一个模拟数据,子线程的数据是不能return给DataLoader实现类的!
这个策略想法挺不错的,之前在其它项目中也采取过类似的方案。
不过几个个问题我抛下:
(1)activity跟activity之间的切换,抛开自定义动画,在从点击到执行新页面的oncreate,时差在40ms(小米note2),这种场景下意义不是很大
(2)业务隔离问题,请求的触发跟业务页面直接是相互隔离的,就会存在接口维护的成本。
loadData()方法需要返回一个String类型数据。而当在该方法中调用接口以异步方式获取数据时,如何保证返回的String类型数据就是调取接口获取的数据?有可能还没等获取到数据,就返回了一个String类型数据,而返回的该数据为null
请问该如何解决?
监听中返回的数据上千条, 崩溃。
Demo中PreLoader的destroy放到activity的onDestroy里,如果Activity重新创建怎么办?这个时候根据Intent拿到的preLoadId是找不到对应的worker的。开发者控制台打开不保留活动栈可以复现。
private static ExecutorService defaultThreadPoolExecutor = new ThreadPoolExecutor(2, Integer.MAX_VALUE,60L, TimeUnit.SECONDS,new SynchronousQueue<Runnable>(), FACTORY);
问一个细节的问题 关于Worker的线程池设计 我觉得在并发量不大的情况下 改为
new ThreadPoolExecutor(0, Integer.MAX_VALUE,60L, TimeUnit.SECONDS,new SynchronousQueue<Runnable>(), FACTORY)
更好
即使用newCachedThreadPool 不知道作者是如何考虑的
场景:启动页实现主页数据预加载;
问题:偶现。用户打开APP进入主页,切换进后台一段时间,再切回来,首页数据白屏(未经过启动页,怀疑首页4个Fragment中当前这个被销毁)。下拉刷新,调用预加载刷新,数据监听回调无响应。
当网络请求全部是异步调用情况下,建议针对异步场景添加相关API。
泛型中可以传递webview实现提前加载吗?第一次进没问题,再一次进白屏呢?
Web Media Share (Browser, um Medien von Webseiten zu betrachten, zu teilen oder zu suchen) - https://f-droid.org/packages/com.tobykurien.webmediashare
网络请求时遇到:
Can't create handler inside thread that has not called Looper.prepare()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.