Coder Social home page Coder Social logo

goldnews's Introduction

高仿掘金APP


##1、 技术选型 ##

框架采用MVP模式+retrofit+rxjava
主界面UI采用 bottomNavigation+fragment搭建
接口数据来自网络抓包(如有侵权,请联系删除)

2、项目的主要依赖

compile "com.android.support:appcompat-v7:$supportVersion"
compile "com.android.support:cardview-v7:$supportVersion"
compile "com.android.support:recyclerview-v7:$supportVersion"
compile "com.android.support:design:$supportVersion"
compile "com.android.support:support-vector-drawable:$supportVersion"
testCompile 'junit:junit:4.12'

compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.okhttp3:logging-interceptor:3.1.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
compile 'com.squareup.retrofit2:converter-scalars:2.0.2'
compile 'io.reactivex:rxandroid:1.1.0'
compile 'io.reactivex:rxjava:1.1.0'
compile 'com.jakewharton:butterknife:8.4.0'

compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.google.dagger:dagger:2.4'
apt 'com.google.dagger:dagger-compiler:2.4'
//java注解
compile 'org.glassfish:javax.annotation:10.0-b28'

//bottomnavigation
compile 'com.ashokvarma.android:bottom-navigation-bar:1.3.0'

compile 'com.orhanobut:logger:1.15'

3、开发流程

  1. 主题设置:

①、默认Valus下面 theme.xml文件的配置:
<style name="BaseTheme" parent="Theme.AppCompat.Light.NoActionBar"> @color/colorPrimary @color/colorPrimaryDark @color/colorAccent @color/colorAccent </style>

<style name="AppTheme" parent="BaseTheme"/>

<!--透明状态栏-->
<style name="AppTheme.TranslucentStatus"/>

<!--splash页面  防止启动白屏-->
<style name="AppTheme.Splash">
<item name="android:windowBackground">@mipmap/img_splash_bg</item>
</style>

<style name="AppTheme.PopupOverlay.White" parent="ThemeOverlay.AppCompat.Dark" />
<style name="AppTheme.AppBarOverlay.White" parent="ThemeOverlay.AppCompat.Light" />

<!--白色(设置相关页面)-->
<style name="AppTheme.White"/></resources>

② V19/Themes.xml

<resources>

<style name="AppTheme" parent="BaseTheme">
<item name="android:windowTranslucentStatus">true</item>
</style>

<!--透明状态栏-->
<style name="AppTheme.TranslucentStatus"/>

<style name="AppTheme.Splash">
<item name="android:windowBackground">@mipmap/img_splash_bg</item>
</style>

<!--白色  相关设置界面-->
<style name="AppTheme.White">
<item name="android:windowTranslucentStatus">false</item>
</style>
</resources>

③V21/Themes.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="AppTheme" parent="BaseTheme">
    <item name="android:statusBarColor">@color/colorPrimaryDark</item>
</style>

<style name="AppTheme.TranslucentStatus">
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:windowTranslucentStatus">true</item>
</style>

<style name="AppTheme.White">
    <item name="colorPrimaryDark">@android:color/black</item>
    <item name="android:statusBarColor">@android:color/black</item>
</style>

<style name="AppTheme.Splash">
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowBackground">@mipmap/img_splash_bg</item>
</style>
</resources>

Base封装

BaseView

public interface BaseView {

	void showLoading(String title);

	void stopLoading();

	void showError(String msg);
}

BasePresenter

public interface BasePresenter<T extends BaseView>{

/**
 * 与View层简历关联
 * @param view
 */
void attachView(T view);

/**
 * 解除关联
 */
void detachView();
}

RxPresenter
配rxjava的时候在生命周期的某个时刻取消订阅,一个很常见的模式就是使用CompsiteSubscription来持有所有的Subscriptions,然后在onDestroy()或者在onDestoryView()取消所有的订阅。

public class RxPresenter<T extends BaseView> implements BasePresenter<T> {

protected T mView;
protected CompositeSubscription mCompositeSubscription;

protected void unSubscribe() {
    if (mCompositeSubscription != null) {
        mCompositeSubscription.unsubscribe();
    }
}

protected void addSubscribe(Subscription subscription) {
    if (mCompositeSubscription == null) {
        mCompositeSubscription = new CompositeSubscription();
    }
    mCompositeSubscription.add(subscription);
}

@Override
public void attachView(T view) {
    this.mView = view;
}

@Override
public void detachView() {
    this.mView = null;
    unSubscribe();
}
}

goldnews's People

Watchers

James Cloos 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.