Skip to content

islandparadise14/MinTimetable

Repository files navigation

MinTimetable

MinTimeTable is Customizable library to generate Timetable of University.
If you only add a course, the course time is automatically calculated and added to the timetable.
(default 09:00 ~ 16:00)

iOS version

Elliotable

Author Information


Timetable Library for Android Development
Author : Mint Park / Seoul, South Korea
Email : nasamk3@gmail.com

Platform API License: MIT

Screenshot

Portrait & Landscape Timetable

screenshot

Installation

JitPack

MinTimeTable is available through JitPack, to install it simply add the following line to your Gradle:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
implementation 'com.github.islandparadise14:Mintable:x.y.z'

Usage

Add View

<com.islandparadise14.mintable.MinTimeTableView
                android:id="@+id/table"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

Day Symbol Definition

private val day = arrayOf("Mon", "Tue", "Wen", "Thu", "Fri")  

Make Table

override onWindowFocusChanged because we know the size of the view after onCreate is finished. If you don't want to use this method, see the optimization options below.

override fun onWindowFocusChanged(hasFocus: Boolean) {
    super.onWindowFocusChanged(hasFocus)
    table.initTable(day)
}

Add Schedules

private val scheduleList: ArrayList<ScheduleEntity> = ArrayList()
val schedule = ScheduleEntity(
                  32, //originId
                  "Database", //scheduleName
                  "IT Building 301", //roomInfo
                  ScheduleDay.TUESDAY, //ScheduleDay object (MONDAY ~ SUNDAY)
                  "8:20", //startTime format: "HH:mm"
                  "10:30", //endTime  format: "HH:mm"
                  "#73fcae68", //backgroundColor (optional)
                  "#000000" //textcolor (optional)
                )
scheduleList.add(schedule)
override fun onWindowFocusChanged(hasFocus: Boolean) {
    super.onWindowFocusChanged(hasFocus)
    table.initTable(day)
    table.updateSchedules(scheduleList)
}

If you want to start on Sunday, use 'ScheduleDayOption.${weekday}' (SUNDAY ~ SATURDAY)

Optimization Option

Make the view fullWidth

add attribute 'isFullWidth' (default: false)

<com.islandparadise14.mintable.MinTimeTableView
                android:id="@+id/table"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:isFullWidth="true" />

then you don't need override onWindowFocusChanged

if you want to add padding using optimization option, add attribute 'widthPadding' (default: 0)

<com.islandparadise14.mintable.MinTimeTableView
                android:id="@+id/table"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:isFullWidth="true"
                app:widthPadding="20" />

More Options

Add Listener

ScheduleEntity has onClickListener

schedule.setOnClickListener(View.OnClickListener {
    //do something
})

MinTimeTableView has three kinds of Listener

When you click on a schedule,
if you need ScheduleEntity in Listener, you can use OnScheduleClickListener

table.setOnScheduleClickListener(
    object :OnScheduleClickListener {
        override fun scheduleClicked(entity: ScheduleEntity) {
            //do something
        }
    }
)

When you click on a timeCell,
if you need weekdayInfo and timeInfo, you can use OnTimeCellClickListener

table.setOnTimeCellClickListener(object :OnTimeCellClickListener{
    override fun timeCellClicked(scheduleDay: Int, time: Int) {
        //do something
    }
})

When you LongClick on a schedule, if you need ScheduleEntity in Listener, you can use OnScheduleLongClickListener

table.setOnScheduleLongClickListener(
        object :OnScheduleLongClickListener{
            override fun scheduleLongClicked(entity: ScheduleEntity) {
                //do something
            }
        }
)

Length options

Length

baseSetting(topMenuHeight: Int, leftMenuWidth: Int, cellHeight: Int)

table.baseSetting(30, 40, 60) //default (20, 30, 50)

Rate

ratioCellSetting(topMenuHeight: Int, leftMenuWidth: Int, cellRatio: Float)

table.ratioCellSetting(20, 30, 1.5f)

Border Option

add attribute 'radiusOption' ( none | left | right | round )

<com.islandparadise14.mintable.MinTimeTableView
                android:id="@+id/table"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:radiusOption="left" />

screenshot

Color options

add attribute 'cellColor', 'lineColor', 'menuColor'

<com.islandparadise14.mintable.MinTimeTableView
                android:id="@+id/table"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:cellColor="@color/black"
                app:lineColor="@color/colorAccent"
                app:menuColor="@color/colorPrimary" />

TwentyFourHourClock option

add attribute 'isTwentyFourHourClock' (default: true)

<com.islandparadise14.mintable.MinTimeTableView
                android:id="@+id/table"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:isTwentyFourHourClock="false" />

screenshot

Border Option

add attribute 'xEndLine'(blue), 'yEndLine'(red), 'border'(green)

(default: false)

<com.islandparadise14.mintable.MinTimeTableView
                android:id="@+id/table"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:border="true"
                app:xEndLine="true"
                app:yEndLine="true" />

Menu Text Color,Size Option

add attribute 'menuTextSize'(float) 'menuTextColor'(color)