├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── customscrollactions │ │ └── azimolabs │ │ └── com │ │ └── customscrollactions │ │ ├── tests │ │ ├── CoordinatorLayout_CustomScrollActionsTest.java │ │ ├── NestedScrollView_CustomScrollActionsTest.java │ │ └── NormalScrollView_CustomScrollActionsTest.java │ │ └── utils │ │ └── CustomScrollActions.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── customscrollactions │ │ │ └── azimolabs │ │ │ └── com │ │ │ └── customscrollactions │ │ │ └── ui │ │ │ ├── CoordinatorLayoutActivity.java │ │ │ ├── NestedScrollViewActivity.java │ │ │ ├── NormalScrollViewActivity.java │ │ │ ├── WelcomeScreenActivity.java │ │ │ └── presenter │ │ │ └── WelcomeScreenPresenter.java │ └── res │ │ ├── layout │ │ ├── activity_coordinator.xml │ │ ├── activity_nested.xml │ │ ├── activity_normal.xml │ │ └── activity_welcome.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── customscrollactions │ └── azimolabs │ └── com │ └── customscrollactions │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | .idea 11 | .idea/* 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This repository contains example project. 2 | 3 | It was created in order to present solution to 4 | problem of scrolling to views that are children of NestedScrollView in Espresso 5 | UiAutomation tests. 6 | 7 | Contents: 8 | - Code responsible for scrolling is available [here](https://github.com/AzimoLabs/CustomScrollActions/blob/master/app/src/androidTest/java/customscrollactions/azimolabs/com/customscrollactions/utils/CustomScrollActions.java). 9 | 10 | - Guide, walkthrough and explanation is available in this blog post. (to be added) 11 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 31 5 | buildToolsVersion "25.0.3" 6 | defaultConfig { 7 | applicationId "customscrollactions.azimolabs.com.customscrollactions" 8 | minSdkVersion 19 9 | targetSdkVersion 31 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | testOptions { 21 | unitTests { 22 | includeAndroidResources = true 23 | } 24 | } 25 | } 26 | 27 | dependencies { 28 | implementation fileTree(dir: 'libs', include: ['*.jar']) 29 | 30 | androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") 31 | androidTestImplementation("androidx.test:core:1.4.0") 32 | androidTestImplementation("androidx.test.ext:junit:1.1.3") 33 | androidTestImplementation("androidx.test:runner:1.4.0") 34 | androidTestImplementation("androidx.test:rules:1.4.0") 35 | 36 | implementation("androidx.core:core:1.7.0") 37 | implementation("androidx.appcompat:appcompat:1.3.1") 38 | implementation("androidx.recyclerview:recyclerview:1.2.1") 39 | implementation("com.google.android.material:material:1.4.0") 40 | testImplementation("junit:junit:4.13.2") 41 | } 42 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/F1sherKK/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/androidTest/java/customscrollactions/azimolabs/com/customscrollactions/tests/CoordinatorLayout_CustomScrollActionsTest.java: -------------------------------------------------------------------------------- 1 | package customscrollactions.azimolabs.com.customscrollactions.tests; 2 | 3 | import static androidx.test.espresso.Espresso.onView; 4 | import static androidx.test.espresso.assertion.ViewAssertions.matches; 5 | import static androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed; 6 | import static androidx.test.espresso.matcher.ViewMatchers.withId; 7 | import static customscrollactions.azimolabs.com.customscrollactions.utils.CustomScrollActions.scrollTo; 8 | 9 | import androidx.test.core.app.ActivityScenario; 10 | import androidx.test.ext.junit.runners.AndroidJUnit4; 11 | 12 | import org.junit.Before; 13 | import org.junit.Test; 14 | import org.junit.runner.RunWith; 15 | 16 | import customscrollactions.azimolabs.com.customscrollactions.R; 17 | import customscrollactions.azimolabs.com.customscrollactions.ui.CoordinatorLayoutActivity; 18 | 19 | /** 20 | * Created by F1sherKK on 18/05/2017. 21 | */ 22 | 23 | @RunWith(AndroidJUnit4.class) 24 | public class CoordinatorLayout_CustomScrollActionsTest { 25 | 26 | @Before 27 | public void setUp() { 28 | ActivityScenario.launch(CoordinatorLayoutActivity.class); 29 | } 30 | 31 | @Test 32 | public void useCustomCoordinatorScrollAction() { 33 | onView(withId(R.id.tvText1)) 34 | .perform(scrollTo()) 35 | .check(matches(isCompletelyDisplayed())); 36 | 37 | onView(withId(R.id.tvText20)) 38 | .perform(scrollTo()) 39 | .check(matches(isCompletelyDisplayed())); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/androidTest/java/customscrollactions/azimolabs/com/customscrollactions/tests/NestedScrollView_CustomScrollActionsTest.java: -------------------------------------------------------------------------------- 1 | package customscrollactions.azimolabs.com.customscrollactions.tests; 2 | 3 | import static androidx.test.espresso.Espresso.onView; 4 | import static androidx.test.espresso.assertion.ViewAssertions.matches; 5 | import static androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed; 6 | import static androidx.test.espresso.matcher.ViewMatchers.withId; 7 | import static customscrollactions.azimolabs.com.customscrollactions.utils.CustomScrollActions.scrollTo; 8 | 9 | import androidx.test.core.app.ActivityScenario; 10 | import androidx.test.ext.junit.runners.AndroidJUnit4; 11 | 12 | import org.junit.Before; 13 | import org.junit.Test; 14 | import org.junit.runner.RunWith; 15 | 16 | import customscrollactions.azimolabs.com.customscrollactions.R; 17 | import customscrollactions.azimolabs.com.customscrollactions.ui.NestedScrollViewActivity; 18 | 19 | /** 20 | * Created by F1sherKK on 18/05/2017. 21 | */ 22 | 23 | @RunWith(AndroidJUnit4.class) 24 | public class NestedScrollView_CustomScrollActionsTest { 25 | 26 | @Before 27 | public void setUp() { 28 | ActivityScenario.launch(NestedScrollViewActivity.class); 29 | } 30 | 31 | @Test 32 | public void useCustomNestedScrollAction() { 33 | onView(withId(R.id.tvText1)) 34 | .perform(scrollTo()) 35 | .check(matches(isCompletelyDisplayed())); 36 | 37 | onView(withId(R.id.tvText20)) 38 | .perform(scrollTo()) 39 | .check(matches(isCompletelyDisplayed())); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/androidTest/java/customscrollactions/azimolabs/com/customscrollactions/tests/NormalScrollView_CustomScrollActionsTest.java: -------------------------------------------------------------------------------- 1 | package customscrollactions.azimolabs.com.customscrollactions.tests; 2 | 3 | import static androidx.test.espresso.Espresso.onView; 4 | import static androidx.test.espresso.assertion.ViewAssertions.matches; 5 | import static androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed; 6 | import static androidx.test.espresso.matcher.ViewMatchers.withId; 7 | import static customscrollactions.azimolabs.com.customscrollactions.utils.CustomScrollActions.scrollTo; 8 | 9 | import androidx.test.core.app.ActivityScenario; 10 | import androidx.test.ext.junit.runners.AndroidJUnit4; 11 | 12 | import org.junit.Before; 13 | import org.junit.Test; 14 | import org.junit.runner.RunWith; 15 | 16 | import customscrollactions.azimolabs.com.customscrollactions.R; 17 | import customscrollactions.azimolabs.com.customscrollactions.ui.NormalScrollViewActivity; 18 | 19 | /** 20 | * Created by F1sherKK on 18/05/2017. 21 | */ 22 | 23 | @RunWith(AndroidJUnit4.class) 24 | public class NormalScrollView_CustomScrollActionsTest { 25 | 26 | @Before 27 | public void setUp() { 28 | ActivityScenario.launch(NormalScrollViewActivity.class); 29 | } 30 | 31 | @Test 32 | public void fallbackToNativeScroll() { 33 | onView(withId(R.id.tvText1)) 34 | .perform(scrollTo()) 35 | .check(matches(isCompletelyDisplayed())); 36 | 37 | onView(withId(R.id.tvText20)) 38 | .perform(scrollTo()) 39 | .check(matches(isCompletelyDisplayed())); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/androidTest/java/customscrollactions/azimolabs/com/customscrollactions/utils/CustomScrollActions.java: -------------------------------------------------------------------------------- 1 | package customscrollactions.azimolabs.com.customscrollactions.utils; 2 | 3 | /** 4 | * Created by F1sherKK on 18/05/2017. 5 | */ 6 | 7 | import static androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom; 8 | import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA; 9 | import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; 10 | 11 | import static customscrollactions.azimolabs.com.customscrollactions.utils.CustomScrollActions.ScrollType.COORDINATOR_SCROLL; 12 | import static customscrollactions.azimolabs.com.customscrollactions.utils.CustomScrollActions.ScrollType.NESTED_SCROLL; 13 | import static customscrollactions.azimolabs.com.customscrollactions.utils.CustomScrollActions.ScrollType.NORMAL_SCROLL; 14 | 15 | import android.graphics.Rect; 16 | import android.view.View; 17 | import android.view.ViewGroup; 18 | import android.view.ViewParent; 19 | import android.widget.FrameLayout; 20 | 21 | import androidx.coordinatorlayout.widget.CoordinatorLayout; 22 | import androidx.core.view.NestedScrollingChild; 23 | import androidx.core.view.ViewCompat; 24 | import androidx.core.widget.NestedScrollView; 25 | import androidx.test.espresso.PerformException; 26 | import androidx.test.espresso.UiController; 27 | import androidx.test.espresso.ViewAction; 28 | import androidx.test.espresso.action.ViewActions; 29 | import androidx.test.espresso.matcher.ViewMatchers; 30 | import androidx.test.espresso.util.HumanReadables; 31 | 32 | import com.google.android.material.appbar.CollapsingToolbarLayout; 33 | 34 | import org.hamcrest.Description; 35 | import org.hamcrest.Matcher; 36 | import org.hamcrest.Matchers; 37 | import org.hamcrest.TypeSafeMatcher; 38 | 39 | /** 40 | * Created by F1sherKK on 07/03/2017. 41 | */ 42 | 43 | public class CustomScrollActions { 44 | public enum ScrollType { 45 | COORDINATOR_SCROLL, 46 | NESTED_SCROLL, 47 | NORMAL_SCROLL 48 | } 49 | 50 | public static ViewAction scrollTo() { 51 | return new ViewAction() { 52 | private ScrollType scrollType; 53 | 54 | @Override 55 | public Matcher getConstraints() { 56 | return new TypeSafeMatcher() { 57 | @Override 58 | protected boolean matchesSafely(View target) { 59 | Matcher nestedScrollViewMatcher = 60 | Matchers.allOf( 61 | isDescendantOfA(isAssignableFrom(NestedScrollView.class)), 62 | withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE) 63 | ); 64 | 65 | Matcher coordinatorLayoutMatcher = 66 | Matchers.allOf( 67 | isDescendantOfA(isAssignableFrom(CoordinatorLayout.class)), 68 | withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE) 69 | ); 70 | 71 | if (nestedScrollViewMatcher.matches(target)) { 72 | scrollType = NESTED_SCROLL; 73 | return true; 74 | } else if (coordinatorLayoutMatcher.matches(target)) { 75 | scrollType = COORDINATOR_SCROLL; 76 | return true; 77 | } else { 78 | scrollType = NORMAL_SCROLL; 79 | return ViewActions.scrollTo().getConstraints().matches(target); 80 | } 81 | } 82 | 83 | @Override 84 | public void describeTo(Description description) { 85 | description.appendText("View is not assignable from class NestedScrollView or CoordinatorLayout."); 86 | } 87 | }; 88 | } 89 | 90 | @Override 91 | public String getDescription() { 92 | return "scroll to"; 93 | } 94 | 95 | @Override 96 | public void perform(UiController uiController, View view) { 97 | switch (scrollType) { 98 | case NESTED_SCROLL: 99 | nestedScrollTo(view, getDescription()); 100 | break; 101 | case COORDINATOR_SCROLL: 102 | coordinatorScrollTo(view, getDescription()); 103 | break; 104 | case NORMAL_SCROLL: 105 | ViewActions.scrollTo().perform(uiController, view); 106 | break; 107 | } 108 | uiController.loopMainThreadUntilIdle(); 109 | } 110 | }; 111 | } 112 | 113 | private static void nestedScrollTo(View view, String description) { 114 | try { 115 | NestedScrollView nestedScrollView = (NestedScrollView) 116 | findFirstParentLayoutOfClass(view, NestedScrollView.class); 117 | if (nestedScrollView != null) { 118 | CoordinatorLayout coordinatorLayout = 119 | (CoordinatorLayout) findFirstParentLayoutOfClass(view, CoordinatorLayout.class); 120 | if (coordinatorLayout != null) { 121 | CollapsingToolbarLayout collapsingToolbarLayout = 122 | findCollapsingToolbarLayoutChildIn(coordinatorLayout); 123 | if (collapsingToolbarLayout != null) { 124 | int toolbarHeight = collapsingToolbarLayout.getHeight(); 125 | nestedScrollView.startNestedScroll(ViewCompat.SCROLL_AXIS_VERTICAL); 126 | nestedScrollView.dispatchNestedPreScroll(0, toolbarHeight, null, null); 127 | } 128 | } 129 | 130 | // ensure view fully visible 131 | Rect rect = new Rect(); 132 | view.getDrawingRect(rect); 133 | view.requestRectangleOnScreen(rect, true); 134 | } else { 135 | throw new Exception("Unable to find NestedScrollView parent."); 136 | } 137 | } catch (Exception e) { 138 | throw new PerformException.Builder() 139 | .withActionDescription(description) 140 | .withViewDescription(HumanReadables.describe(view)) 141 | .withCause(e) 142 | .build(); 143 | } 144 | } 145 | 146 | private static void coordinatorScrollTo(View view, String description) { 147 | try { 148 | CoordinatorLayout coordinatorLayout = (CoordinatorLayout) 149 | findFirstParentLayoutOfClass(view, CoordinatorLayout.class); 150 | if (coordinatorLayout != null) { 151 | NestedScrollingChild nestedScrollingChild = 152 | (NestedScrollingChild) findFirstParentLayoutOfClass(view, NestedScrollingChild.class); 153 | if (nestedScrollingChild != null) { 154 | CollapsingToolbarLayout collapsingToolbarLayout = 155 | findCollapsingToolbarLayoutChildIn(coordinatorLayout); 156 | if (collapsingToolbarLayout != null) { 157 | int toolbarHeight = collapsingToolbarLayout.getHeight(); 158 | nestedScrollingChild.startNestedScroll(ViewCompat.SCROLL_AXIS_VERTICAL); 159 | nestedScrollingChild.dispatchNestedPreScroll(0, toolbarHeight, null, null); 160 | } 161 | } 162 | 163 | // ensure view fully visible 164 | Rect rect = new Rect(); 165 | view.getDrawingRect(rect); 166 | view.requestRectangleOnScreen(rect, true); 167 | } else { 168 | throw new Exception("Unable to find CoordinatorLayout parent."); 169 | } 170 | } catch (Exception e) { 171 | throw new PerformException.Builder() 172 | .withActionDescription(description) 173 | .withViewDescription(HumanReadables.describe(view)) 174 | .withCause(e) 175 | .build(); 176 | } 177 | } 178 | 179 | private static CollapsingToolbarLayout findCollapsingToolbarLayoutChildIn(ViewGroup viewGroup) { 180 | for (int i = 0; i < viewGroup.getChildCount(); i++) { 181 | View child = viewGroup.getChildAt(i); 182 | if (child instanceof CollapsingToolbarLayout) { 183 | return (CollapsingToolbarLayout) child; 184 | } else if (child instanceof ViewGroup) { 185 | return findCollapsingToolbarLayoutChildIn((ViewGroup) child); 186 | } 187 | } 188 | return null; 189 | } 190 | 191 | private static View findFirstParentLayoutOfClass(View view, Class parentClass) { 192 | ViewParent parent = new FrameLayout(view.getContext()); 193 | ViewParent incrementView = null; 194 | int i = 0; 195 | while (parent != null && !(parent.getClass() == parentClass)) { 196 | if (i == 0) { 197 | parent = findParent(view); 198 | } else { 199 | parent = findParent(incrementView); 200 | } 201 | incrementView = parent; 202 | i++; 203 | } 204 | return (View) parent; 205 | } 206 | 207 | private static ViewParent findParent(View view) { 208 | return view.getParent(); 209 | } 210 | 211 | private static ViewParent findParent(ViewParent view) { 212 | return view.getParent(); 213 | } 214 | } 215 | 216 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 27 | 28 | 32 | 33 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /app/src/main/java/customscrollactions/azimolabs/com/customscrollactions/ui/CoordinatorLayoutActivity.java: -------------------------------------------------------------------------------- 1 | package customscrollactions.azimolabs.com.customscrollactions.ui; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | 7 | import customscrollactions.azimolabs.com.customscrollactions.R; 8 | 9 | /** 10 | * Created by F1sherKK on 16/05/2017. 11 | */ 12 | 13 | public class CoordinatorLayoutActivity extends Activity { 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_coordinator); 19 | } 20 | 21 | public static void openActivity(Activity activity) { 22 | Intent intent = new Intent(activity, CoordinatorLayoutActivity.class); 23 | activity.startActivity(intent); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/customscrollactions/azimolabs/com/customscrollactions/ui/NestedScrollViewActivity.java: -------------------------------------------------------------------------------- 1 | package customscrollactions.azimolabs.com.customscrollactions.ui; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | 7 | import customscrollactions.azimolabs.com.customscrollactions.R; 8 | 9 | /** 10 | * Created by F1sherKK on 16/05/2017. 11 | */ 12 | 13 | public class NestedScrollViewActivity extends Activity { 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_nested); 19 | } 20 | 21 | public static void openActivity(Activity activity) { 22 | Intent intent = new Intent(activity, NestedScrollViewActivity.class); 23 | activity.startActivity(intent); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/customscrollactions/azimolabs/com/customscrollactions/ui/NormalScrollViewActivity.java: -------------------------------------------------------------------------------- 1 | package customscrollactions.azimolabs.com.customscrollactions.ui; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | 7 | import customscrollactions.azimolabs.com.customscrollactions.R; 8 | 9 | /** 10 | * Created by F1sherKK on 16/05/2017. 11 | */ 12 | 13 | public class NormalScrollViewActivity extends Activity { 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_normal); 19 | } 20 | 21 | public static void openActivity(Activity activity) { 22 | Intent intent = new Intent(activity, NormalScrollViewActivity.class); 23 | activity.startActivity(intent); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/customscrollactions/azimolabs/com/customscrollactions/ui/WelcomeScreenActivity.java: -------------------------------------------------------------------------------- 1 | package customscrollactions.azimolabs.com.customscrollactions.ui; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.widget.Button; 6 | 7 | import customscrollactions.azimolabs.com.customscrollactions.R; 8 | import customscrollactions.azimolabs.com.customscrollactions.ui.presenter.WelcomeScreenPresenter; 9 | 10 | public class WelcomeScreenActivity extends Activity { 11 | 12 | Button btnCoordinatorLayoutActivity; 13 | Button btnNestedScrollViewActivity; 14 | 15 | WelcomeScreenPresenter welcomeScreenPresenter; 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_welcome); 21 | 22 | bindViews(); 23 | setupPresenter(); 24 | } 25 | 26 | private void bindViews() { 27 | btnCoordinatorLayoutActivity = (Button) findViewById(R.id.btn_coordinator_layout_activity); 28 | btnCoordinatorLayoutActivity.setOnClickListener(v -> welcomeScreenPresenter.enterCoordinatorLayoutScreen()); 29 | btnNestedScrollViewActivity = (Button) findViewById(R.id.btn_nested_scroll_view_activity); 30 | btnNestedScrollViewActivity.setOnClickListener(v -> welcomeScreenPresenter.enterNestedScrollView()); 31 | } 32 | 33 | private void setupPresenter() { 34 | welcomeScreenPresenter = new WelcomeScreenPresenter(this); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/customscrollactions/azimolabs/com/customscrollactions/ui/presenter/WelcomeScreenPresenter.java: -------------------------------------------------------------------------------- 1 | package customscrollactions.azimolabs.com.customscrollactions.ui.presenter; 2 | 3 | import customscrollactions.azimolabs.com.customscrollactions.ui.CoordinatorLayoutActivity; 4 | import customscrollactions.azimolabs.com.customscrollactions.ui.NestedScrollViewActivity; 5 | import customscrollactions.azimolabs.com.customscrollactions.ui.NormalScrollViewActivity; 6 | import customscrollactions.azimolabs.com.customscrollactions.ui.WelcomeScreenActivity; 7 | 8 | /** 9 | * Created by F1sherKK on 16/05/2017. 10 | */ 11 | 12 | public class WelcomeScreenPresenter { 13 | 14 | private WelcomeScreenActivity view; 15 | 16 | public WelcomeScreenPresenter(WelcomeScreenActivity view) { 17 | this.view = view; 18 | } 19 | 20 | public void enterCoordinatorLayoutScreen() { 21 | CoordinatorLayoutActivity.openActivity(view); 22 | } 23 | 24 | public void enterNestedScrollView() { 25 | NestedScrollViewActivity.openActivity(view); 26 | } 27 | 28 | public void enterNormalScrollView() { 29 | NormalScrollViewActivity.openActivity(view); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_coordinator.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 14 | 15 | 24 | 25 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 51 | 52 | 57 | 58 | 66 | 67 | 75 | 76 | 84 | 85 | 93 | 94 | 102 | 103 | 111 | 112 | 120 | 121 | 129 | 130 | 138 | 139 | 147 | 148 | 156 | 157 | 165 | 166 | 174 | 175 | 183 | 184 | 192 | 193 | 201 | 202 | 210 | 211 | 219 | 220 | 228 | 229 | 237 | 238 | 239 | 240 | 241 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_nested.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 22 | 23 | 31 | 32 | 40 | 41 | 49 | 50 | 58 | 59 | 67 | 68 | 76 | 77 | 85 | 86 | 94 | 95 | 103 | 104 | 112 | 113 | 121 | 122 | 130 | 131 | 139 | 140 | 148 | 149 | 157 | 158 | 166 | 167 | 175 | 176 | 184 | 185 | 193 | 194 | 195 | 196 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_normal.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 23 | 24 | 32 | 33 | 41 | 42 | 50 | 51 | 59 | 60 | 68 | 69 | 77 | 78 | 86 | 87 | 95 | 96 | 104 | 105 | 113 | 114 | 122 | 123 | 131 | 132 | 140 | 141 | 149 | 150 | 158 | 159 | 167 | 168 | 176 | 177 | 185 | 186 | 194 | 195 | 196 | 197 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_welcome.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |