Skip to content

Commit

Permalink
Merge pull request #144 from kizitonwose/dev
Browse files Browse the repository at this point in the history
Release 0.3.3
  • Loading branch information
kizitonwose authored Apr 9, 2020
2 parents 242bdb6 + 65c56e7 commit 6d30314
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 55 deletions.
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ buildscript {
'compile_sdk' : 28,
'version_code' : 1,
'version_name' : '0.3.1',
'kotlin_lang' : '1.3.50',
'material_library' : '1.0.0',
'androidx_appcompat' : '1.1.0',
'kotlin_lang' : '1.3.71',
'material_library' : '1.1.0',
'androidx_appcompat' : '1.2.0-beta01',
'androidx_legacy' : '1.0.0',
'androidx_core_ktx' : '1.2.0-rc01',
'constraint_layout' : '1.1.3',
'androidx_core_ktx' : '1.3.0-beta01',
'constraint_layout' : '2.0.0-beta4',
'cardview' : '1.0.0',
'recyclerview' : '1.1.0',
'threetenabp' : '1.1.1',
'threetenabp' : '1.2.3',
'junit' : '4.12',
'espresso' : '3.1.1',
'androidx_test_runner': '1.1.1',
Expand All @@ -27,7 +27,7 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.android.tools.build:gradle:3.6.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin_lang"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Aug 31 18:47:38 WAT 2019
#Sun Apr 05 08:20:22 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies {
api "androidx.recyclerview:recyclerview:$versions.recyclerview"

testImplementation "junit:junit:$versions.junit"
testImplementation('org.threeten:threetenbp:1.3.2') {
testImplementation('org.threeten:threetenbp:1.3.7') {
// Use threetenBP library for tests as context will
// not be available to initialise threetenABP
exclude group: 'com.jakewharton.threetenabp', module: 'threetenabp'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,6 @@ open class CalendarView : RecyclerView {
this.endMonth = endMonth
this.firstDayOfWeek = firstDayOfWeek

clipToPadding = false
clipChildren = false //#ClipChildrenFix

// Remove the listener before adding again to prevent
// multiple additions if we already added it before.
removeOnScrollListener(scrollListenerInternal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ internal class CalendarAdapter(
val rootLayout = LinearLayout(context).apply {
orientation = LinearLayout.VERTICAL
id = rootViewId
clipChildren = false //#ClipChildrenFix
}

if (viewConfig.monthHeaderRes != 0) {
Expand All @@ -83,7 +82,6 @@ internal class CalendarAdapter(
layoutParams = LinearLayout.LayoutParams(LP.WRAP_CONTENT, LP.WRAP_CONTENT)
orientation = LinearLayout.VERTICAL
id = bodyViewId
clipChildren = false //#ClipChildrenFix
}
rootLayout.addView(monthBodyLayout)

Expand All @@ -99,7 +97,8 @@ internal class CalendarAdapter(
}

fun setupRoot(root: ViewGroup) {
ViewCompat.setPaddingRelative(root,
ViewCompat.setPaddingRelative(
root,
calView.monthPaddingStart, calView.monthPaddingTop,
calView.monthPaddingEnd, calView.monthPaddingBottom
)
Expand Down Expand Up @@ -204,17 +203,19 @@ internal class CalendarAdapter(
val visibleVH =
calView.findViewHolderForAdapterPosition(visibleItemPos) as? MonthViewHolder ?: return
val newHeight = visibleVH.headerView?.height.orZero() +
// For some reason `visibleVH.bodyLayout.height` does not give us the updated height.
// So we calculate it again by checking the number of visible(non-empty) rows.
// visibleVH.bodyLayout.height` won't not give us the right height as it differs
// depending on row count in the month. So we calculate the appropriate height
// by checking the number of visible(non-empty) rows.
visibleMonth.weekDays.size * calView.dayHeight +
visibleVH.footerView?.height.orZero()
if (calView.layoutParams.height != newHeight)
if (calView.layoutParams.height != newHeight) {
calView.layoutParams = calView.layoutParams.apply {
this.height = newHeight
// If we reset the calendar's height from a short item view's height(month with 5 rows)
// to a longer one(month with 6 rows), the row outside the old height is not drawn.
// This is fixed by setting `clipChildren = false` on all parents. #ClipChildrenFix
}
visibleVH.itemView.layoutParams = visibleVH.itemView.layoutParams.apply {
this.height = newHeight
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ internal class WeekHolder(dayConfig: DayConfig) {
)
orientation = LinearLayout.HORIZONTAL
weightSum = dayHolders.count().toFloat()
clipChildren = false //#ClipChildrenFix
for (holder in dayHolders) {
addView(holder.inflateDayView(this))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class Example1Fragment : BaseFragment(), HasToolbar {
if (firstDate.yearMonth == lastDate.yearMonth) {
exOneCalendar.scrollToMonth(firstDate.yearMonth)
} else {
// We compare the next with the last month on the calendar so we don't go over.
exOneCalendar.scrollToMonth(minOf(firstDate.yearMonth.next, endMonth))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,10 @@ import kotlinx.android.synthetic.main.home_activity.*
class HomeActivity : AppCompatActivity() {

private val examplesAdapter = HomeOptionsAdapter {
val instance = when (it.titleRes) {
R.string.example_1_title -> Example1Fragment()
R.string.example_2_title -> Example2Fragment()
R.string.example_3_title -> Example3Fragment()
R.string.example_4_title -> Example4Fragment()
R.string.example_5_title -> Example5Fragment()
R.string.example_6_title -> Example6Fragment()
R.string.example_7_title -> Example7Fragment()
else -> throw IllegalArgumentException()
}
val fragment = it.createView()
supportFragmentManager.beginTransaction()
.run {
if (instance is Example1Fragment || instance is Example4Fragment || instance is Example5Fragment) {
if (fragment is Example1Fragment || fragment is Example4Fragment || fragment is Example5Fragment) {
return@run setCustomAnimations(
R.anim.slide_in_up,
R.anim.fade_out,
Expand All @@ -39,8 +30,8 @@ class HomeActivity : AppCompatActivity() {
R.anim.slide_out_right
)
}
.add(R.id.homeContainer, instance, instance.javaClass.simpleName)
.addToBackStack(instance.javaClass.simpleName)
.add(R.id.homeContainer, fragment, fragment.javaClass.simpleName)
.addToBackStack(fragment.javaClass.simpleName)
.commit()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@ import android.view.View
import android.view.ViewGroup
import androidx.annotation.StringRes
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.extensions.LayoutContainer
import kotlinx.android.synthetic.main.home_options_item_view.*

data class ExampleItem(@StringRes val titleRes: Int, @StringRes val subtitleRes: Int)
data class ExampleItem(@StringRes val titleRes: Int, @StringRes val subtitleRes: Int, val createView: () -> BaseFragment)

class HomeOptionsAdapter(val onClick: (ExampleItem) -> Unit) :
RecyclerView.Adapter<HomeOptionsAdapter.HomeOptionsViewHolder>() {

val examples = listOf(
ExampleItem(R.string.example_1_title, R.string.example_1_subtitle),
ExampleItem(R.string.example_2_title, R.string.example_2_subtitle),
ExampleItem(R.string.example_3_title, R.string.example_3_subtitle),
ExampleItem(R.string.example_4_title, R.string.example_4_subtitle),
ExampleItem(R.string.example_5_title, R.string.example_5_subtitle),
ExampleItem(R.string.example_6_title, R.string.example_6_subtitle),
ExampleItem(R.string.example_7_title, R.string.example_7_subtitle)
ExampleItem(R.string.example_1_title, R.string.example_1_subtitle) { Example1Fragment() },
ExampleItem(R.string.example_2_title, R.string.example_2_subtitle) { Example2Fragment() },
ExampleItem(R.string.example_3_title, R.string.example_3_subtitle) { Example3Fragment() },
ExampleItem(R.string.example_4_title, R.string.example_4_subtitle) { Example4Fragment() },
ExampleItem(R.string.example_5_title, R.string.example_5_subtitle) { Example5Fragment() },
ExampleItem(R.string.example_6_title, R.string.example_6_subtitle) { Example6Fragment() },
ExampleItem(R.string.example_7_title, R.string.example_7_subtitle) { Example7Fragment() }
)

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HomeOptionsViewHolder {
Expand Down
17 changes: 6 additions & 11 deletions sample/src/main/res/layout/example_1_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,38 +51,33 @@

</com.google.android.material.appbar.AppBarLayout>

<androidx.constraintlayout.widget.ConstraintLayout
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.kizitonwose.calendarview.CalendarView
android:id="@+id/exOneCalendar"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_height="wrap_content"
app:cv_dayViewResource="@layout/example_1_calendar_day"
app:cv_orientation="horizontal"
app:cv_outDateStyle="endOfRow"
app:cv_inDateStyle="allMonths"
app:cv_scrollMode="paged"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:cv_scrollMode="paged" />

<CheckBox
android:id="@+id/weekModeCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp"
android:layout_marginBottom="20dp"
android:buttonTint="@color/example_1_white"
android:padding="2dp"
android:text="@string/week_mode"
android:textColor="@color/example_1_white"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
android:layout_gravity="bottom|center_horizontal" />

</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>


</LinearLayout>

0 comments on commit 6d30314

Please sign in to comment.