Skip to content

Commit 291461b

Browse files
Some code cleaning
1 parent 9523d1b commit 291461b

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

library/src/main/java/com/alamkanak/weekview/WeekView.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class WeekView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
8989
private val mTimeTextPaint: Paint = Paint(Paint.ANTI_ALIAS_FLAG)
9090
private var mTimeTextWidth: Float = 0f
9191
private var mTimeTextHeight: Float = 0f
92-
private val mHeaderTextPaint: Paint = Paint(Paint.ANTI_ALIAS_FLAG)
92+
private val mHeaderTextPaint = TextPaint(Paint.ANTI_ALIAS_FLAG)
9393
private var mHeaderTextHeight: Float = 0f
9494
private var mHeaderHeight: Float = 0f
9595
private var mGestureDetector: GestureDetectorCompat? = null
@@ -108,7 +108,7 @@ class WeekView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
108108
private val mFutureWeekendBackgroundPaint = Paint()
109109
private val mPastWeekendBackgroundPaint = Paint()
110110
private val mNowLinePaint = Paint()
111-
private val mTodayHeaderTextPaint = Paint(Paint.ANTI_ALIAS_FLAG)
111+
private val mTodayHeaderTextPaint = TextPaint(Paint.ANTI_ALIAS_FLAG)
112112
private val mEventBackgroundPaint = Paint()
113113
private val mNewEventBackgroundPaint = Paint()
114114
private var mHeaderColumnWidth: Float = 0f
@@ -573,16 +573,16 @@ class WeekView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
573573

574574
private val xMinLimit: Float
575575
get() {
576-
return if (maxDate == null) {
577-
Integer.MIN_VALUE.toFloat()
576+
if (maxDate == null) {
577+
return Integer.MIN_VALUE.toFloat()
578578
} else {
579579
val date = maxDate!!.clone() as Calendar
580580
date.add(Calendar.DATE, 1 - realNumberOfVisibleDays)
581581
while (date.before(minDate)) {
582582
date.add(Calendar.DATE, 1)
583583
}
584584

585-
getXOriginForDate(date)
585+
return getXOriginForDate(date)
586586
}
587587
}
588588

@@ -1370,7 +1370,7 @@ class WeekView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
13701370
// Calculate the available width for each day.
13711371
mHeaderColumnWidth = mTimeTextWidth + mHeaderColumnPadding * 2
13721372
mWidthPerDay = width.toFloat() - mHeaderColumnWidth - (mColumnGap * (realNumberOfVisibleDays - 1)).toFloat()
1373-
mWidthPerDay = mWidthPerDay / realNumberOfVisibleDays
1373+
mWidthPerDay /= realNumberOfVisibleDays
13741374

13751375
calculateHeaderHeight() //Make sure the header is the right size (depends on AllDay events)
13761376

sample/src/main/java/com/alamkanak/weekview/sample/BaseActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ abstract class BaseActivity : AppCompatActivity(), WeekView.EventClickListener,
192192
}
193193

194194
override fun interpretDate(date: Calendar): String {
195-
return if (shortDate) shortDateFormat.format(date.time) else normalDateFormat.format(date.time)
195+
return "a\nb" // if (shortDate) shortDateFormat.format(date.time) else normalDateFormat.format(date.time)
196196
}
197197
}
198198
}

sample/src/main/java/com/alamkanak/weekview/sample/MainActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@ class MainActivity : AppCompatActivity() {
2828
buttonWholeViewSnap.setOnClickListener {
2929
startActivity(Intent(this@MainActivity, WholeViewSnappingActivity::class.java))
3030
}
31+
startActivity(Intent(this@MainActivity, WholeViewSnappingActivity::class.java))
32+
finish()
3133
}
3234
}

sample/src/main/java/com/alamkanak/weekview/sample/WholeViewSnappingActivity.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.alamkanak.weekview.sample
22

3+
import android.graphics.RectF
34
import android.os.Bundle
45
import android.view.Menu
56
import android.view.MenuItem
67
import android.view.View
78
import com.alamkanak.weekview.WeekView
9+
import com.alamkanak.weekview.WeekViewEvent
810
import kotlinx.android.synthetic.main.activity_base.*
911
import java.text.SimpleDateFormat
1012
import java.util.*
@@ -31,8 +33,10 @@ class WholeViewSnappingActivity : BasicActivity() {
3133
// override fun onEventClick(event: WeekViewEvent, eventRect: RectF) {
3234
// }
3335
// }
34-
// weekView.emptyViewClickListener = null
35-
// weekView.emptyViewLongPressListener = null
36+
// weekView.columnGap
37+
// weekView.dayBackgroundColor=0xffffffff.toInt()
38+
weekView.emptyViewClickListener = null
39+
weekView.emptyViewLongPressListener = null
3640
weekView.scrollListener = object : WeekView.ScrollListener {
3741
val monthFormatter = SimpleDateFormat("MMM", Locale.getDefault())
3842

@@ -43,6 +47,16 @@ class WholeViewSnappingActivity : BasicActivity() {
4347
}
4448

4549
draggable_view.visibility = View.GONE
50+
51+
52+
weekView.addEventClickListener = null
53+
weekView.headerRowBackgroundColor = 0xff242b3e.toInt()
54+
weekView.headerColumnTextColor = 0xc2c3c3c3.toInt()
55+
weekView.nowLineColor = 0xff112d71.toInt()
56+
weekView.eventClickListener = object : WeekView.EventClickListener {
57+
override fun onEventClick(event: WeekViewEvent, eventRect: RectF) {
58+
}
59+
}
4660
}
4761

4862
override fun onOptionsItemSelected(item: MenuItem): Boolean {

sample/src/main/res/values/styles.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
<item name="colorControlActivated">@color/accent</item>
1212
</style>
1313

14+
<style name="AppTheme.FullScreen" parent="@style/AppTheme">
15+
<item name="android:windowFullscreen">true</item>
16+
<item name="windowActionBar">false</item>
17+
<item name="android:windowNoTitle">true</item>
18+
<item name="windowNoTitle">true</item>
19+
</style>
20+
1421
<style name="Button">
1522
<item name="android:background">?selectableItemBackground</item>
1623
<item name="android:gravity">left|center_vertical</item>

0 commit comments

Comments
 (0)