Skip to content
Permalink
Browse files

upgrade gradle & add rxbus

  • Loading branch information...
limedroid committed Aug 25, 2018
1 parent 0dedcb9 commit f9aa143b05653889a80e8e8b640a5ca365c2406c
@@ -1,9 +1,7 @@
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
buildToolsVersion rootProject.ext.android.buildToolsVersion

defaultConfig {
applicationId 'cn.droidlover.xdroidmvp.demo'
@@ -24,7 +22,7 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
apt rootProject.ext.dependencies["butterknife-apt"]
compile rootProject.ext.dependencies["avi-loading"]
compile project(":mvp")
annotationProcessor rootProject.ext.dependencies["butterknife-apt"]
implementation rootProject.ext.dependencies["avi-loading"]
implementation project(":mvp")
}
@@ -4,9 +4,13 @@ apply from: "conf.gradle"
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

@@ -20,6 +24,10 @@ allprojects {
jcenter()
maven { url "https://jitpack.io" }
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}

@@ -2,7 +2,7 @@ ext {

android = [
compileSdkVersion: 23,
buildToolsVersion: "23.0.2",
buildToolsVersion: "23.0.3",

minSdkVersion : 15,
targetSdkVersion : 23,
@@ -29,6 +29,7 @@ ext {
"picasso" : "com.squareup.picasso:picasso:2.5.2",
"xrecyclerview" : "com.github.limedroid:ARecyclerView:v1.2.3",
"avi-loading" : "com.wang.avi:library:1.0.2",
"rxbus" : "com.blankj:rxbus:1.2",

"gson" : "com.google.code.gson:gson:2.6.2",
"rxandroid" : "io.reactivex.rxjava2:rxandroid:2.0.1",
@@ -1,6 +1,6 @@
#Mon Dec 28 10:00:20 PST 2015
#Fri Apr 13 19:19:31 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
@@ -5,7 +5,6 @@ group = 'com.github.limedroid'

android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
buildToolsVersion rootProject.ext.android.buildToolsVersion

defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
@@ -19,32 +18,34 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '27.0.3'
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile rootProject.ext.dependencies["appcompat-v7"]
compile rootProject.ext.dependencies["support-v4"]
compile rootProject.ext.dependencies["design"]
compile rootProject.ext.dependencies["annotations"]
compile rootProject.ext.dependencies["recyclerview-v7"]

compile rootProject.ext.dependencies["xrecyclerview"]
compile rootProject.ext.dependencies["butterknife"]
compile rootProject.ext.dependencies["glide"]

compile rootProject.ext.dependencies["gson"]
compile rootProject.ext.dependencies["rxandroid"]
compile rootProject.ext.dependencies["rxjava"]
compile rootProject.ext.dependencies["retrofit"]
compile rootProject.ext.dependencies["retrofit-converter-gson"]
compile rootProject.ext.dependencies["retrofit-adapter-rxjava"]
compile rootProject.ext.dependencies["okhttp3"]

compile rootProject.ext.dependencies["rxlifecycle"]
compile rootProject.ext.dependencies["rxlifecycle-android"]
compile rootProject.ext.dependencies["rxlifecycle-components"]
compile rootProject.ext.dependencies["rxpermissions"]
api fileTree(dir: 'libs', include: ['*.jar'])
api rootProject.ext.dependencies["appcompat-v7"]
api rootProject.ext.dependencies["support-v4"]
api rootProject.ext.dependencies["design"]
api rootProject.ext.dependencies["annotations"]
api rootProject.ext.dependencies["recyclerview-v7"]

api rootProject.ext.dependencies["xrecyclerview"]
api rootProject.ext.dependencies["butterknife"]
api rootProject.ext.dependencies["glide"]

api rootProject.ext.dependencies["gson"]
api rootProject.ext.dependencies["rxandroid"]
api rootProject.ext.dependencies["rxjava"]
api rootProject.ext.dependencies["retrofit"]
api rootProject.ext.dependencies["retrofit-converter-gson"]
api rootProject.ext.dependencies["retrofit-adapter-rxjava"]
api rootProject.ext.dependencies["okhttp3"]
api rootProject.ext.dependencies["rxbus"]

api rootProject.ext.dependencies["rxlifecycle"]
api rootProject.ext.dependencies["rxlifecycle-android"]
api rootProject.ext.dependencies["rxlifecycle-components"]
api rootProject.ext.dependencies["rxpermissions"]
}

tasks.withType(JavaCompile) {
@@ -1,51 +1,53 @@
package cn.droidlover.xdroidmvp.event;


import io.reactivex.Flowable;
import io.reactivex.processors.FlowableProcessor;
import io.reactivex.processors.PublishProcessor;
import com.blankj.rxbus.RxBus;

/**
* Created by wanglei on 2016/12/22.
*/

public class RxBusImpl implements IBus {

private FlowableProcessor<Object> bus = null;

private RxBusImpl() {
bus = PublishProcessor.create().toSerialized();
}

public static RxBusImpl get() {
return Holder.instance;
}

@Override
public void register(Object object) {

}

@Override
public void unregister(Object object) {

RxBus.getDefault().unregister(object);
}

@Override
public void post(IEvent event) {
bus.onNext(event);
RxBus.getDefault().post(event);
}

@Override
public void postSticky(IEvent event) {
RxBus.getDefault().postSticky(event);
}

public <T> void subscribe(Object subscriber,
RxBus.Callback<T> callback) {
RxBus.getDefault().subscribe(subscriber, callback);
}

public <T> void subscribeSticky(Object subscriber,
RxBus.Callback<T> callback) {
RxBus.getDefault().subscribeSticky(subscriber, callback);
}

public <T extends IEvent> Flowable<T> toFlowable(Class<T> eventType) {
return bus.ofType(eventType).onBackpressureBuffer();
public static RxBusImpl get() {
return Holder.instance;
}

private static class Holder {
private static final RxBusImpl instance = new RxBusImpl();
}
}

@@ -34,6 +34,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
context = this;

getP();

if (getLayoutId() > 0) {
setContentView(getLayoutId());
bindUI(null);
@@ -54,6 +54,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getP();

if (useEventBus()) {
BusProvider.getBus().register(this);
}
@@ -26,6 +26,9 @@
@Override
protected void onCreateViewLazy(Bundle savedInstanceState) {
super.onCreateViewLazy(savedInstanceState);

getP();

if (getLayoutId() > 0) {
setContentView(getLayoutId());
bindUI(getRealRootView());
@@ -1,9 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'com.neenbedankt.android-apt'

android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
buildToolsVersion rootProject.ext.android.buildToolsVersion

defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
@@ -21,8 +19,8 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
apt rootProject.ext.dependencies["butterknife-apt"]
compile project(":mvp")
implementation fileTree(dir: 'libs', include: ['*.jar'])
annotationProcessor rootProject.ext.dependencies["butterknife-apt"]
implementation project(":mvp")
}

@@ -2,9 +2,10 @@

import android.os.Bundle;

import com.blankj.rxbus.RxBus;

import cn.droidlover.xdroidmvp.event.BusProvider;
import cn.droidlover.xdroidmvp.mvp.XActivity;
import io.reactivex.functions.Consumer;

/**
* Created by wanglei on 2017/1/30.
@@ -17,15 +18,14 @@ public void initData(Bundle savedInstanceState) {

BusProvider.getBus().post(new LoginEvent());

BusProvider.getBus().toFlowable(LoginEvent.class)
.subscribe(new Consumer<LoginEvent>() {
BusProvider.getBus()
.subscribe(this, new RxBus.Callback<LoginEvent>() {
@Override
public void accept(LoginEvent loginEvent) throws Exception {
public void onEvent(LoginEvent loginEvent) {
//TODO 事件处理
}
});


}

@Override

0 comments on commit f9aa143

Please sign in to comment.
You can’t perform that action at this time.