From b350519917b88e6a00d06aa754380a11e508de8c Mon Sep 17 00:00:00 2001 From: Bogdan Yevtushenko Date: Fri, 19 Jul 2019 16:53:05 +0300 Subject: [PATCH 1/2] #142. Fix bug connected to fab clicker. --- .../com/bogdan/codeforceswatcher/activity/MainActivity.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/java/com/bogdan/codeforceswatcher/activity/MainActivity.kt b/app/src/main/java/com/bogdan/codeforceswatcher/activity/MainActivity.kt index 92dd10862..eec2aaeb3 100644 --- a/app/src/main/java/com/bogdan/codeforceswatcher/activity/MainActivity.kt +++ b/app/src/main/java/com/bogdan/codeforceswatcher/activity/MainActivity.kt @@ -51,6 +51,11 @@ class MainActivity : AppCompatActivity() { val adapter = ViewPagerAdapter(supportFragmentManager) viewPager.adapter = adapter + fab.setOnClickListener { + val intent = Intent(this, AddUserActivity::class.java) + startActivity(intent) + } + spSort.background.setColorFilter(ContextCompat.getColor(this, R.color.white), PorterDuff.Mode.SRC_ATOP) viewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { From 09c79e447cdf1ad3101e66f80ec6f9506bc9caee Mon Sep 17 00:00:00 2001 From: Bogdan Yevtushenko Date: Fri, 19 Jul 2019 17:10:57 +0300 Subject: [PATCH 2/2] Add some refactoring. --- .../codeforceswatcher/activity/MainActivity.kt | 16 +++++++--------- app/src/main/res/layout/activity_main.xml | 1 - 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/bogdan/codeforceswatcher/activity/MainActivity.kt b/app/src/main/java/com/bogdan/codeforceswatcher/activity/MainActivity.kt index eec2aaeb3..c7fd31847 100644 --- a/app/src/main/java/com/bogdan/codeforceswatcher/activity/MainActivity.kt +++ b/app/src/main/java/com/bogdan/codeforceswatcher/activity/MainActivity.kt @@ -51,14 +51,7 @@ class MainActivity : AppCompatActivity() { val adapter = ViewPagerAdapter(supportFragmentManager) viewPager.adapter = adapter - fab.setOnClickListener { - val intent = Intent(this, AddUserActivity::class.java) - startActivity(intent) - } - - spSort.background.setColorFilter(ContextCompat.getColor(this, R.color.white), PorterDuff.Mode.SRC_ATOP) - - viewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + val viewPagerListener = object : ViewPager.OnPageChangeListener { override fun onPageScrollStateChanged(state: Int) { } @@ -89,7 +82,12 @@ class MainActivity : AppCompatActivity() { } } - }) + } + + viewPagerListener.onPageSelected(0) + viewPager.addOnPageChangeListener(viewPagerListener) + + spSort.background.setColorFilter(ContextCompat.getColor(this, R.color.white), PorterDuff.Mode.SRC_ATOP) bottomNavigation.setOnNavigationItemSelectedListener { item -> when (item.itemId) { diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 579520e71..cb6816bc6 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -72,7 +72,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="20dp" - android:src="@drawable/ic_plus" app:elevation="10dp" app:layout_constraintBottom_toBottomOf="@id/bottomNavigation" app:layout_constraintEnd_toEndOf="@id/bottomNavigation"