Skip to content

Commit

Permalink
add border option
Browse files Browse the repository at this point in the history
  • Loading branch information
islandparadise14 committed Feb 23, 2020
1 parent f397fb5 commit 063cd14
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class MinTimeTableView : BaseTimeTable {
private var scheduleClickListener: OnScheduleClickListener? = null
private var timeCellClickListener: OnTimeCellClickListener? = null

private var border: Boolean = false
private var xEndLine: Boolean = false
private var yEndLine: Boolean = false


constructor(context: Context) : super(context){
initView(context, null)
Expand Down Expand Up @@ -79,6 +83,10 @@ class MinTimeTableView : BaseTimeTable {
menuColor = array.getColor(R.styleable.MinTimeTableView_menuColor, 0)
lineColor = array.getColor(R.styleable.MinTimeTableView_lineColor, 0)

border = array.getBoolean(R.styleable.MinTimeTableView_border, false)
xEndLine = array.getBoolean(R.styleable.MinTimeTableView_xEndLine, false)
yEndLine = array.getBoolean(R.styleable.MinTimeTableView_yEndLine, false)

if(lineColor != 0) {
mainTable.setBackgroundColor(lineColor)
topMenu.setBackgroundColor(lineColor)
Expand Down Expand Up @@ -123,6 +131,11 @@ class MinTimeTableView : BaseTimeTable {
timetable.setPadding(widthPaddingPx.roundToInt(), 0, widthPaddingPx.roundToInt(), 0)
}

if (border) {
leftMenu.setPadding(1, 0, 0, 0)
topMenu.setPadding(0, 1, 0, 0)
}

cellHeightPx = if (isRatio) averageWidth * cellRatio
else dpToPx(tableContext, cellHeight.toFloat())

Expand All @@ -135,16 +148,35 @@ class MinTimeTableView : BaseTimeTable {
zeroPoint.addView(ZeroPointView(tableContext, topMenuHeightPx.roundToInt(), leftMenuWidthPx.roundToInt(), menuColor))

for(i in 0 until (this.dayList).size) {
if(i == (this.dayList).size - 1) topMenu.addView(
XxisEndView(
if (xEndLine) {
if (i == (this.dayList).size - 1) topMenu.addView(
XxisEndView(
tableContext,
topMenuHeightPx.roundToInt(),
averageWidth,
(this.dayList)[(this.dayList).size - 1],
menuColor
)
)
else topMenu.addView(
XxisView(
tableContext,
topMenuHeightPx.roundToInt(),
averageWidth,
dayList[i],
menuColor
)
)
}
else topMenu.addView(
XxisView(
tableContext,
topMenuHeightPx.roundToInt(),
averageWidth,
(this.dayList)[(this.dayList).size - 1],
dayList[i],
menuColor
)
)
else topMenu.addView(XxisView(tableContext, topMenuHeightPx.roundToInt(), averageWidth, dayList[i], menuColor))
}

recycleTimeCell()
Expand Down Expand Up @@ -208,8 +240,36 @@ class MinTimeTableView : BaseTimeTable {
if ((tableStartTime + i)!=12) (tableStartTime + i) % 12
else (tableStartTime + i)
}
if(i == (tableEndTime - tableStartTime)-1) timeCell.addView(YxisEndView(tableContext, cellHeightPx.roundToInt(), leftMenuWidthPx.roundToInt(), hour.toString(), menuColor))
else timeCell.addView(YxisView(tableContext, cellHeightPx.roundToInt(), leftMenuWidthPx.roundToInt(), hour.toString(), menuColor))
if (yEndLine) {
if (i == (tableEndTime - tableStartTime) - 1) timeCell.addView(
YxisEndView(
tableContext,
cellHeightPx.roundToInt(),
leftMenuWidthPx.roundToInt(),
hour.toString(),
menuColor
)
)
else timeCell.addView(
YxisView(
tableContext,
cellHeightPx.roundToInt(),
leftMenuWidthPx.roundToInt(),
hour.toString(),
menuColor
)
)
}
else timeCell.addView(
YxisView(
tableContext,
cellHeightPx.roundToInt(),
leftMenuWidthPx.roundToInt(),
hour.toString(),
menuColor
)
)

}
}
}
3 changes: 3 additions & 0 deletions app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
<attr name="setTwentyFourHourClock" format="boolean"/>
<attr name="isFullWidth" format="boolean"/>
<attr name="widthPadding" format="integer"/>
<attr name="xEndLine" format="boolean"/>
<attr name="yEndLine" format="boolean"/>
<attr name="border" format="boolean"/>
</declare-styleable>
</resources>

0 comments on commit 063cd14

Please sign in to comment.