Git Product home page Git Product logo

neteasecloudmusic-mvvm's Introduction

仿网易云客户端V6.0 MVVM版本

根据开源项目Jetpack-MVVM-Best-Practice架构重构之前使用MVC架构的项目, 原项目的地址
PS. 如果编译时提示找不到BR类,把 C:\Users\User\AndroidStudio4.0\config 路径下的studio64.exe.vmoptions文件加上-Dfile.encoding=UTF-8, 然后重启AndroidStudio就OK。

对Jetpack架构的思考

  1. layout.xml文件复用问题,layout文件中引入变量,尽可能的抽取出公共的变量才能复用布局文件,若引入ViewModel则尽可能引入CommomViewModel否则会导致语义不清晰。
  2. BindingAdapter中绑定方法调用,若两次变量相同则不会被调用,绑定刷新状态方法若两次刷新状态都是True则第二次不会响应,需考虑其他方法(new Object(state))。
  3. 需要绑定生命周期的方法调用时不太优雅(调用时需要与View绑定)、使用动画时需要持有对View的引用。
  4. 尽可能避免在layout文件中写逻辑操作。

Room持久化存储框架的思考

  1. 保存单一数据不如SharePreference方便(如登陆时间、用户信息)。
  2. Dao与实体类绑定,单一实体类只能作为一张表,若存在需保存相同实体类的数据不方便,例如AudioBean,既需要在保存音乐播放列表时使用也需要在保存到最近播放的歌曲时使用。目前的解决方法是用一个相同的类代替,有无更好的方法??
  3. Room在操作数据库时需要重新开线程访问,那么在无法开线程访问的情况下使用Room不方便(目前解决方法是在构建时调用allowMainThreadQueries())。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.