mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
toggle the visibility of viewpager as needed
This commit is contained in:
@@ -5,6 +5,7 @@ import android.os.Bundle
|
|||||||
import android.support.v4.view.ViewPager
|
import android.support.v4.view.ViewPager
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
import com.simplemobiletools.calendar.Constants
|
import com.simplemobiletools.calendar.Constants
|
||||||
import com.simplemobiletools.calendar.Formatter
|
import com.simplemobiletools.calendar.Formatter
|
||||||
import com.simplemobiletools.calendar.NavigationListener
|
import com.simplemobiletools.calendar.NavigationListener
|
||||||
@@ -92,7 +93,7 @@ class MainActivity : SimpleActivity(), NavigationListener, ChangeViewDialog.Chan
|
|||||||
if (mConfig.view == Constants.YEARLY_VIEW) {
|
if (mConfig.view == Constants.YEARLY_VIEW) {
|
||||||
fillYearlyViewPager()
|
fillYearlyViewPager()
|
||||||
} else if (mConfig.view == Constants.EVENTS_LIST_VIEW) {
|
} else if (mConfig.view == Constants.EVENTS_LIST_VIEW) {
|
||||||
view_pager.adapter = null
|
fillEventsList()
|
||||||
} else {
|
} else {
|
||||||
val targetDay = DateTime().toString(Formatter.DAYCODE_PATTERN)
|
val targetDay = DateTime().toString(Formatter.DAYCODE_PATTERN)
|
||||||
fillMonthlyViewPager(targetDay)
|
fillMonthlyViewPager(targetDay)
|
||||||
@@ -113,6 +114,8 @@ class MainActivity : SimpleActivity(), NavigationListener, ChangeViewDialog.Chan
|
|||||||
view_pager.adapter = adapter
|
view_pager.adapter = adapter
|
||||||
view_pager.currentItem = codes.size / 2
|
view_pager.currentItem = codes.size / 2
|
||||||
title = getString(R.string.app_launcher_name)
|
title = getString(R.string.app_launcher_name)
|
||||||
|
view_pager.visibility = View.VISIBLE
|
||||||
|
calendar_events_list.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getMonths(code: String): List<String> {
|
private fun getMonths(code: String): List<String> {
|
||||||
@@ -145,6 +148,8 @@ class MainActivity : SimpleActivity(), NavigationListener, ChangeViewDialog.Chan
|
|||||||
title = "${getString(R.string.app_launcher_name)} - ${years[position]}"
|
title = "${getString(R.string.app_launcher_name)} - ${years[position]}"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
view_pager.visibility = View.VISIBLE
|
||||||
|
calendar_events_list.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getYears(targetYear: Int): List<Int> {
|
private fun getYears(targetYear: Int): List<Int> {
|
||||||
@@ -155,6 +160,13 @@ class MainActivity : SimpleActivity(), NavigationListener, ChangeViewDialog.Chan
|
|||||||
return years
|
return years
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun fillEventsList() {
|
||||||
|
title = getString(R.string.app_launcher_name)
|
||||||
|
view_pager.adapter = null
|
||||||
|
view_pager.visibility = View.GONE
|
||||||
|
calendar_events_list.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
override fun goLeft() {
|
override fun goLeft() {
|
||||||
view_pager.currentItem = view_pager.currentItem - 1
|
view_pager.currentItem = view_pager.currentItem - 1
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.design.widget.CoordinatorLayout
|
<android.support.design.widget.CoordinatorLayout
|
||||||
android:id="@+id/calendar_coordinator"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/calendar_coordinator"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
@@ -11,6 +11,15 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/calendar_events_list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:choiceMode="multipleChoiceModal"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:paddingLeft="@dimen/activity_margin"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<android.support.design.widget.FloatingActionButton
|
<android.support.design.widget.FloatingActionButton
|
||||||
android:id="@+id/calendar_fab"
|
android:id="@+id/calendar_fab"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
Reference in New Issue
Block a user