GithubHelp home page GithubHelp logo

todaynews's Introduction

TodayNews

一个仿今日头条的开源项目,是基于MVP+RxJava+Retrofit

Blog

Android仿今日头条的开源项目

自适应Tab宽度可以滑动文字逐渐变色的TabLayout

Apk

点击下载

项目截图

第三方库

技术要点

  • 主要是一些第三方库的使用
  • 多种Item布局展示->BaseRecyclerViewAdapterHelper
  • 日夜间模式切换->MultipleTheme
  • 新闻详情我采用的是RecyclerView添加头的方式添加WebView(当然是Adapter里面添加),加载页面成功之后获取评论信息,点击评论图标滑动至评论第一条,这里我是调用recyclerView.smoothScrollToPosition(1);
  • 视频播放我使用的是JieCaoVideoPlayer,一群大牛封装的代码,底层实际使用ijkplayer,视频源均使用非正常手段获取,视频源地址分析请看我的另一篇博客手撸一个今日头条视频下载器

在使用MultipleTheme的时候唯一的缺陷就是需要在布局里面大量使用到自定义控件,这对于我们的项目而言,布局看着很冗余,也有点恶心。。我有时候就在想,那我可不可以写原生控件,然后在特定的时机来个偷梁换柱换成我们的自定义控件呢?似乎好像是可以的,当我们加载布局的时候最终都会用LayoutInflater来加载,所以我打算从这里入手,看源码我发现有一个接口可以利用->Factory,这个接口有一个方法

    public interface Factory {
        /**
         * Hook you can supply that is called when inflating from a LayoutInflater.
         * You can use this to customize the tag names available in your XML
         * layout files.
         * 
         * <p>
         * Note that it is good practice to prefix these custom names with your
         * package (i.e., com.coolcompany.apps) to avoid conflicts with system
         * names.
         * 
         * @param name Tag name to be inflated.
         * @param context The context the view is being created in.
         * @param attrs Inflation attributes as specified in XML file.
         * 
         * @return View Newly created view. Return null for the default
         *         behavior.
         */
        public View onCreateView(String name, Context context, AttributeSet attrs);
    }

果然功夫不负有心人,如果我们实现了这个接口,最终加载布局的时候那么就会调用onCreateView在这里面来实现偷梁换柱替换成我们的自定义控件

版本

v1.0.1

  • 修复栏目删除崩溃
  • 修改首页多个频道颜色渐变为ColorTrackTabLayout
  • 加入频道存储至本地
  • 添加修改或移动频道首页联动更新
  • 加入加载中动画

v1.0.0

  • 基本框架以及首页获取新闻数据展示、日夜间切换
  • 加入视频解析以及播放功能

TODO

  • 微头条
  • 无图模式
  • 加入今日头条的下拉刷新
  • 加入真实数据(登陆,注册、收藏等),使用Bmob后端云
  • 加入个人主页、搜索等未写界面
  • 待添加...

声明

这个属于个人开发作品,仅做学习交流使用,如用到实际项目还需多考虑其他因素如并发等,请多多斟酌。诸位勿传播于非技术人员,拒绝用于商业用途,数据均属于非正常渠道获取,原作公司拥有所有权利。

License

Copyright (C) 2017 WeyYe

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

todaynews's People

Contributors

yewei02538 avatar

Watchers

James Cloos avatar  avatar

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.