This repository has been archived by the owner on Aug 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from miguelbcr/master
Added interface in order to pre process data before finishing onActivityResult
- Loading branch information
Showing
23 changed files
with
208 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest | ||
package="${applicationId}.test" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<uses-sdk tools:overrideLibrary="android.support.test.uiautomator.v18"/> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<OnPreResultActivity> 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"))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
}) | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<Button | ||
android:id="@+id/start_pre_for_result" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="Start activity for result with pre data processing" /> | ||
|
||
<TextView | ||
android:id="@+id/pre_result" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
<TextView | ||
android:id="@+id/result" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.