Skip to content

Commit

Permalink
Moved LCE classes into own module. sockeqwe#148
Browse files Browse the repository at this point in the history
  • Loading branch information
sockeqwe committed Mar 9, 2017
1 parent 26a44a3 commit e7cf93e
Show file tree
Hide file tree
Showing 29 changed files with 226 additions and 30 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ dependencies {
Mosby3 preview:
```groovy
dependencies {
compile 'com.hannesdorfmann.mosby3:mvp:3.0.0-alpha4'
compile 'com.hannesdorfmann.mosby3:mvp:3.0.0-alpha4' // Plain MVP
compile 'com.hannesdorfmann.mosby3:viewstate:3.0.0-alpha4' // ViewState support
compile 'com.hannesdorfmann.mosby3:mvp-lce:3.0.0' // LCE View
compile 'com.hannesdorfmann.mosby3:viewstate:3.0.0-alpha4'
// or
compile 'com.hannesdorfmann.mosby3:mvi:3.0.0-alpha4'
}
Expand Down
59 changes: 59 additions & 0 deletions mvp-lce/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Built application files
*.apk
*.ap_
bin/
gen/
classes/
gen-external-apklibs/

# Eclipse project files
.classpath
.project
.metadata
.settings

# IntelliJ files
.idea
*.iml

# OSX files
.DS_Store

# Windows files
Thumbs.db

# vi swap files
*.swp

# backup files
*.bak


# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

# Gradle files
.gradle/
build/
.gradle

#maven files
target/
/null

# Local configuration file (sdk path, etc)

local.properties

# Proguard folder generated by Eclipse
proguard/

#Log Files
*.log
60 changes: 60 additions & 0 deletions mvp-lce/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2017 Hannes Dorfmann.
*
* 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.
*
*/

apply plugin: 'com.android.library'
apply from: '../maven-push.gradle'
apply from: '../findbugs.gradle'
// apply plugin: 'com.getkeepsafe.dexcount'

android {

compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
minSdkVersion rootProject.ext.minSdk
targetSdkVersion rootProject.ext.targetSdk
versionName project.VERSION_NAME
versionCode Integer.parseInt(project.VERSION_CODE)

packagingOptions {
exclude 'LICENSE.txt'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility rootProject.ext.javaSourceCompatibility
targetCompatibility rootProject.ext.javaTargetCompatibility
}

/*
testOptions {
unitTests.returnDefaultValues = true
}
*/
}

dependencies {
compile project(':viewstate')
testCompile 'junit:junit:' + rootProject.ext.junitVersion
}
20 changes: 20 additions & 0 deletions mvp-lce/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright 2017 Hannes Dorfmann.
#
# 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.
#
#

POM_NAME = Mosby Model-View-Presenter Loading-Content-Error (LCE)
POM_ARTIFACT_ID = mvp-lce
POM_PACKAGING = aar
25 changes: 25 additions & 0 deletions mvp-lce/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/hannes/android-sdks/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
24 changes: 24 additions & 0 deletions mvp-lce/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!--
~ Copyright 2017 Hannes Dorfmann.
~
~ 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.
~
-->

<manifest

package="com.hannesdorfmann.mosby3.mvp.lce"
>

<application />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ public class MvpBasePresenter<V extends MvpView> implements MvpPresenter<V> {
*
* @return <code>null</code>, if view is not attached, otherwise the concrete view instance
*/
@UiThread
@Nullable public V getView() {
@UiThread public V getView() {
return viewRef == null ? null : viewRef.get();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,43 @@
/*
* Copyright 2017 Hannes Dorfmann.
*
* 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.
*
*/

package com.hannesdorfmann.mosby3.mvp;

import org.junit.Assert;
import org.junit.Test;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;

/**
* @author Hannes Dorfmann
*/
public class MvpBasePresenterTest {

@Test
public void testAttachView() {
@Test public void testAttachView() {
MvpBasePresenter<MvpView> presenter = new MvpBasePresenter<>();
MvpView mvpView = new MvpView() {
};

assertFalse(presenter.isViewAttached());
Assert.assertFalse(presenter.isViewAttached());
presenter.attachView(mvpView);
assertTrue(presenter.isViewAttached());
Assert.assertTrue(presenter.isViewAttached());
}

@Test
public void testDetachView() {
@Test public void testDetachView() {
MvpBasePresenter<MvpView> presenter = new MvpBasePresenter<>();
MvpView mvpView = new MvpView() {
};
Expand All @@ -35,19 +47,17 @@ public void testDetachView() {
assertViewNotAttachedAndNull(presenter);
}

@Test
public void testGetView() {
@Test public void testGetView() {
MvpBasePresenter<MvpView> presenter = new MvpBasePresenter<>();
MvpView mvpView = new MvpView() {
};

assertNull(presenter.getView());
Assert.assertNull(presenter.getView());
presenter.attachView(mvpView);
assertNotNull(presenter.getView());
Assert.assertNotNull(presenter.getView());
}

@Test
public void testOnDestroy() {
@Test public void testOnDestroy() {
MvpBasePresenter<MvpView> presenter = new MvpBasePresenter<>();
MvpView view = new MvpView() {
};
Expand All @@ -67,12 +77,12 @@ public void testOnDestroy() {
}

private void assertViewAttachedAndNotNull(final MvpBasePresenter presenter) {
assertTrue(presenter.isViewAttached());
assertNotNull(presenter.getView());
Assert.assertTrue(presenter.isViewAttached());
Assert.assertNotNull(presenter.getView());
}

private void assertViewNotAttachedAndNull(final MvpBasePresenter presenter) {
assertFalse(presenter.isViewAttached());
assertNull(presenter.getView());
Assert.assertFalse(presenter.isViewAttached());
Assert.assertNull(presenter.getView());
}
}
2 changes: 1 addition & 1 deletion sample-mail/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
compile 'com.android.support:appcompat-v7:' + rootProject.ext.appcompat7Version
compile 'com.android.support:recyclerview-v7:' + rootProject.ext.recyclerviewVersion

compile project(':viewstate')
compile project(':mvp-lce')


compile 'de.greenrobot:eventbus:2.4.0'
Expand Down
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {


dependencies {
compile project(':viewstate')
compile project(':mvp-lce')

compile 'com.android.support:design:'+ rootProject.ext.appcompat7Version
compile 'com.android.support:recyclerview-v7:'+ rootProject.ext.recyclerviewVersion
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ':mvp-common', ':mvp', ':viewstate', ':sample', ':mvi', ':sample-mail',
include ':mvp-common', ':mvp', ':viewstate', ':sample', ':mvi', ':sample-mail', ':mvp-lce',
':mvp-nullobject-presenter',
':mvi-common',
':utils-fragment-integration-test',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import com.hannesdorfmann.mosby3.mvp.MvpView;
import com.hannesdorfmann.mosby3.mvp.viewstate.lce.AbsParcelableLceViewState;

/**
* A ViewState that is parcelable. Activities can only use this kind of ViewState, because saving
Expand All @@ -45,8 +44,7 @@ public interface RestorableViewState<V extends MvpView> extends ViewState<V> {
*
* @param in the bundle to read the data from
* @return null, if view state could not be restored or the restore viestate instance. Typically
* this method will return <code>this</code>. {@link AbsParcelableLceViewState} will return a
* copy, which is also ok.
* this method will return <code>this</code>.
*/
public RestorableViewState<V> restoreInstanceState(Bundle in);
}

0 comments on commit e7cf93e

Please sign in to comment.