diff --git a/.gitignore b/.gitignore index c6cbe56..31f119b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,37 @@ -*.iml -.gradle -/local.properties -/.idea/workspace.xml -/.idea/libraries -.DS_Store -/build -/captures +# Built application files +*.apk +*.ap_ + +# Files for the Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ + +# Gradle files +.gradle/ +**/build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio +.navigation/ +.idea/ +**/*.iml + +# Android Studio captures folder +captures/ + +# .DS_Store files +**/.DS_Store diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index f43a55b..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -RxActivityResult \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 1f2af51..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index 195dcc3..0000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 6438839..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - - - - - Android Lint - - - General - - - Maven - - - - - Android - - - - - - - - - - - - - - - - - - - - - - - - - 1.8 - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 0d080c4..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 830a534..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index df6e524..07f5628 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,13 +13,13 @@ buildscript { } android { - compileSdkVersion 23 - buildToolsVersion "23.0.3" + compileSdkVersion 24 + buildToolsVersion "24.0.1" defaultConfig { applicationId "io.victoralbertos.app" - minSdkVersion 18 - targetSdkVersion 23 + minSdkVersion 16 + targetSdkVersion 24 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -43,9 +43,9 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile project(":rx_activity_result") - compile 'com.android.support:appcompat-v7:23.4.0' - compile 'com.android.support:design:23.4.0' - compile 'io.reactivex:rxjava:1.1.0' + compile 'com.android.support:appcompat-v7:24.2.1' + compile 'com.android.support:design:24.2.1' + compile 'io.reactivex:rxjava:1.1.10' testCompile 'junit:junit:4.12' androidTestCompile ("com.android.support.test:runner:0.4.1") { diff --git a/app/src/androidTest/AndroidManifest.xml b/app/src/androidTest/AndroidManifest.xml new file mode 100644 index 0000000..1202373 --- /dev/null +++ b/app/src/androidTest/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/app/src/androidTest/java/app/OnPreResultTest.java b/app/src/androidTest/java/app/OnPreResultTest.java new file mode 100644 index 0000000..3677dec --- /dev/null +++ b/app/src/androidTest/java/app/OnPreResultTest.java @@ -0,0 +1,28 @@ +package app; + +import android.support.test.rule.ActivityTestRule; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import io.victoralbertos.app.R; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static android.support.test.espresso.matcher.ViewMatchers.withText; + +@RunWith(AndroidJUnit4.class) +public class OnPreResultTest { + @Rule public ActivityTestRule activityRule = new ActivityTestRule<>(OnPreResultActivity.class); + + @Test public void CheckHasBothResults() { + onView(withId(R.id.start_pre_for_result)).perform(click()); + onView(withId(R.id.pre_result)).check(matches(withText("Do whatever you want with the data, but not with the UI"))); + onView(withId(R.id.result)).check(matches(withText("Well done first"))); + } + +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 65455e0..3434065 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -36,6 +36,7 @@ + \ No newline at end of file diff --git a/app/src/main/java/app/OnPreResultActivity.java b/app/src/main/java/app/OnPreResultActivity.java new file mode 100644 index 0000000..367c88e --- /dev/null +++ b/app/src/main/java/app/OnPreResultActivity.java @@ -0,0 +1,42 @@ +package app; + +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.TextView; + +import app.multi_start.FirstActivity; +import io.victoralbertos.app.R; +import rx.Observable; +import rx_activity_result.RxActivityResult; + +public class OnPreResultActivity extends AppCompatActivity { + public static final String EXTRA_PRE = "EXTRA_PRE"; + private TextView preResult; + private TextView result; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.on_pre_result); + + View startPreForResult = findViewById(R.id.start_pre_for_result); + preResult = (TextView) findViewById(R.id.pre_result); + result = (TextView) findViewById(R.id.result); + + startPreForResult.setOnClickListener(v -> + RxActivityResult.on(this) + .startIntent(new Intent(this, FirstActivity.class), (resultCode, data) -> + Observable.just(data.getData()) + .map(uri -> data.putExtra(EXTRA_PRE, "Do whatever you want with the data, but not with the UI"))) + .subscribe(result -> { + result.targetUI() + .preResult.setText(result.data().getStringExtra(EXTRA_PRE)); + result.targetUI() + .result.setText(result.data().getStringExtra(FirstActivity.EXTRA)); + }) + ); + } + +} diff --git a/app/src/main/java/app/StartActivity.java b/app/src/main/java/app/StartActivity.java index d5df736..a421383 100644 --- a/app/src/main/java/app/StartActivity.java +++ b/app/src/main/java/app/StartActivity.java @@ -29,5 +29,8 @@ public class StartActivity extends AppCompatActivity { startActivity(new Intent(StartActivity.this, MultiStartActivity.class)); }); + findViewById(R.id.bt_pre_result).setOnClickListener(view -> { + startActivity(new Intent(StartActivity.this, OnPreResultActivity.class)); + }); } } diff --git a/app/src/main/res/layout/on_pre_result.xml b/app/src/main/res/layout/on_pre_result.xml new file mode 100644 index 0000000..be5102c --- /dev/null +++ b/app/src/main/res/layout/on_pre_result.xml @@ -0,0 +1,22 @@ + + + +