toggle the visibility of viewpager as needed
This commit is contained in:
parent
2f0cf1a024
commit
f58a1beba6
|
@ -5,6 +5,7 @@ import android.os.Bundle
|
|||
import android.support.v4.view.ViewPager
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import com.simplemobiletools.calendar.Constants
|
||||
import com.simplemobiletools.calendar.Formatter
|
||||
import com.simplemobiletools.calendar.NavigationListener
|
||||
|
@ -92,7 +93,7 @@ class MainActivity : SimpleActivity(), NavigationListener, ChangeViewDialog.Chan
|
|||
if (mConfig.view == Constants.YEARLY_VIEW) {
|
||||
fillYearlyViewPager()
|
||||
} else if (mConfig.view == Constants.EVENTS_LIST_VIEW) {
|
||||
view_pager.adapter = null
|
||||
fillEventsList()
|
||||
} else {
|
||||
val targetDay = DateTime().toString(Formatter.DAYCODE_PATTERN)
|
||||
fillMonthlyViewPager(targetDay)
|
||||
|
@ -113,6 +114,8 @@ class MainActivity : SimpleActivity(), NavigationListener, ChangeViewDialog.Chan
|
|||
view_pager.adapter = adapter
|
||||
view_pager.currentItem = codes.size / 2
|
||||
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> {
|
||||
|
@ -145,6 +148,8 @@ class MainActivity : SimpleActivity(), NavigationListener, ChangeViewDialog.Chan
|
|||
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> {
|
||||
|
@ -155,6 +160,13 @@ class MainActivity : SimpleActivity(), NavigationListener, ChangeViewDialog.Chan
|
|||
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() {
|
||||
view_pager.currentItem = view_pager.currentItem - 1
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
android:id="@+id/calendar_coordinator"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/calendar_coordinator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
@ -11,6 +11,15 @@
|
|||
android:layout_width="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:id="@+id/calendar_fab"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
Loading…
Reference in New Issue