Skip to content
This repository was archived by the owner on Sep 19, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ def versionBuild = 9
def versionBuildNameSuffix = ""

android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
compileSdkVersion 26
buildToolsVersion '26.0.0'

defaultConfig {
applicationId "co.timetableapp"
minSdkVersion 14
targetSdkVersion 25
targetSdkVersion 26
versionCode versionMajor * 1000 + versionMinor * 100 + versionPatch * 10 + versionBuild
versionName "$versionMajor.$versionMinor.$versionPatch" + versionBuildNameSuffix

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ class LibraryDetailActivity : AppCompatActivity() {
private fun setupLayout() {
setupToolbar()

val container = findViewById(R.id.container) as LinearLayout
val container = findViewById<LinearLayout>(R.id.container)
container.addView(makeLicenseCard(container))
}

private fun setupToolbar() {
val toolbar = findViewById(R.id.toolbar) as Toolbar
val toolbar = findViewById<Toolbar>(R.id.toolbar)
setSupportActionBar(toolbar)

with(supportActionBar!!) {
Expand All @@ -85,10 +85,9 @@ class LibraryDetailActivity : AppCompatActivity() {
val card = layoutInflater.inflate(R.layout.item_license_card, container, false)

with(card) {
(findViewById(R.id.title) as TextView).text = getString(R.string.title_license)
(findViewById(R.id.subtitle) as TextView).text = mLibrary!!.license.name
(findViewById(R.id.content_text) as TextView).text =
mLibrary!!.license.getNotice(context)
findViewById<TextView>(R.id.title).text = getString(R.string.title_license)
findViewById<TextView>(R.id.subtitle).text = mLibrary!!.license.name
findViewById<TextView>(R.id.content_text).text = mLibrary!!.license.getNotice(context)
}

return card
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/co/timetableapp/licenses/LicensesActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class LicensesActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_container)

val toolbar = findViewById(R.id.toolbar) as Toolbar
val toolbar = findViewById<Toolbar>(R.id.toolbar)
setSupportActionBar(toolbar)

toolbar.navigationIcon = UiUtils.tintDrawable(this, R.drawable.ic_arrow_back_black_24dp)
Expand Down Expand Up @@ -85,7 +85,7 @@ class LicensesActivity : AppCompatActivity() {
}

private fun displayCards() {
val container = findViewById(R.id.container) as LinearLayout
val container = findViewById<LinearLayout>(R.id.container)

Collections.sort(mLibraries)

Expand All @@ -98,10 +98,10 @@ class LicensesActivity : AppCompatActivity() {
val card = layoutInflater.inflate(R.layout.item_license_card, container, false)

with(card) {
(findViewById(R.id.title) as TextView).text = library.name
(findViewById(R.id.subtitle) as TextView).text = library.author
findViewById<TextView>(R.id.title).text = library.name
findViewById<TextView>(R.id.subtitle).text = library.author

(findViewById(R.id.content_text) as TextView).text = library.license.getNotice(context)
findViewById<TextView>(R.id.content_text).text = library.license.getNotice(context)

setOnClickListener {
val intent = Intent(context, LibraryDetailActivity::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.support.design.widget.BottomSheetBehavior
import android.support.design.widget.BottomSheetDialogFragment
import android.support.design.widget.CoordinatorLayout
import android.view.View
import android.widget.FrameLayout
import co.timetableapp.R
import co.timetableapp.model.agenda.AgendaType

Expand Down Expand Up @@ -59,13 +60,13 @@ class NewItemSelectorFragment : BottomSheetDialogFragment() {
}

private fun setClickListeners(dialog: Dialog) {
dialog.findViewById(R.id.frameLayout_assignment).setOnClickListener {
dialog.findViewById<FrameLayout>(R.id.frameLayout_assignment).setOnClickListener {
newItemAction?.invoke(it, dialog, AgendaType.ASSIGNMENT)
}
dialog.findViewById(R.id.frameLayout_exam).setOnClickListener {
dialog.findViewById<FrameLayout>(R.id.frameLayout_exam).setOnClickListener {
newItemAction?.invoke(it, dialog, AgendaType.EXAM)
}
dialog.findViewById(R.id.frameLayout_event).setOnClickListener {
dialog.findViewById<FrameLayout>(R.id.frameLayout_event).setOnClickListener {
newItemAction?.invoke(it, dialog, AgendaType.EVENT)
}
}
Expand Down
15 changes: 8 additions & 7 deletions app/src/main/java/co/timetableapp/ui/agenda/AgendaActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package co.timetableapp.ui.agenda
import android.content.DialogInterface
import android.content.Intent
import android.os.Bundle
import android.support.design.widget.FloatingActionButton
import android.support.design.widget.NavigationView
import android.support.design.widget.Snackbar
import android.support.design.widget.TabLayout
Expand Down Expand Up @@ -59,7 +60,7 @@ class AgendaActivity : NavigationDrawerActivity() {
const val DEFAULT_SHOW_PAST = false
}

private val mViewPager by lazy { findViewById(R.id.viewPager) as ViewPager }
private val mViewPager by lazy { findViewById<ViewPager>(R.id.viewPager) }

private var mShowCompleted = true
private var mShowPast = DEFAULT_SHOW_PAST
Expand All @@ -75,14 +76,14 @@ class AgendaActivity : NavigationDrawerActivity() {
}

private fun setupToolbar() {
val toolbar = findViewById(R.id.toolbar) as Toolbar
val toolbar = findViewById<Toolbar>(R.id.toolbar)
setSupportActionBar(toolbar)
}

private fun setupLayout() {
mViewPager.adapter = PagerAdapter(supportFragmentManager)

val tabLayout = findViewById(R.id.tabLayout) as TabLayout
val tabLayout = findViewById<TabLayout>(R.id.tabLayout)
tabLayout.setTabTextColors(
ContextCompat.getColor(this, R.color.mdu_text_white_secondary),
ContextCompat.getColor(this, R.color.mdu_text_white))
Expand All @@ -95,7 +96,7 @@ class AgendaActivity : NavigationDrawerActivity() {
}

private fun setupFab() {
findViewById(R.id.fab).setOnClickListener {
findViewById<FloatingActionButton>(R.id.fab).setOnClickListener {
val dialogFragment = NewItemSelectorFragment()

dialogFragment.onCreateNewAgendaItem { _, dialog, agendaType ->
Expand Down Expand Up @@ -184,11 +185,11 @@ class AgendaActivity : NavigationDrawerActivity() {

override fun getSelfNavDrawerItem() = NAVDRAWER_ITEM_AGENDA

override fun getSelfToolbar() = findViewById(R.id.toolbar) as Toolbar
override fun getSelfToolbar(): Toolbar = findViewById(R.id.toolbar)

override fun getSelfDrawerLayout() = findViewById(R.id.drawerLayout) as DrawerLayout
override fun getSelfDrawerLayout(): DrawerLayout = findViewById(R.id.drawerLayout)

override fun getSelfNavigationView() = findViewById(R.id.navigationView) as NavigationView
override fun getSelfNavigationView(): NavigationView = findViewById(R.id.navigationView)

/**
* Interface definition for a callback to be invoked when the agenda filter has been updated.
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/co/timetableapp/ui/agenda/AgendaFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ class AgendaFragment : Fragment(), AgendaActivity.OnFilterChangeListener {
private fun setupLayout() {
setupList()

mPlaceholderLayout = mRootView.findViewById(R.id.placeholder) as FrameLayout
mPlaceholderLayout = mRootView.findViewById(R.id.placeholder)
refreshPlaceholderStatus()
}

private fun setupList() {
mDataHelper.createList(mItems)

setupAdapter()
mRecyclerView = mRootView.findViewById(R.id.recyclerView) as RecyclerView
mRecyclerView = mRootView.findViewById(R.id.recyclerView)
with(mRecyclerView) {
layoutManager = LinearLayoutManager(activity)
setHasFixedSize(true)
Expand Down
17 changes: 6 additions & 11 deletions app/src/main/java/co/timetableapp/ui/agenda/AgendaItemsAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,19 @@ class AgendaItemsAdapter(
}

class HeaderViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val textView: TextView = itemView.findViewById(R.id.text) as TextView
val textView: TextView = itemView.findViewById(R.id.text)
}

inner class AgendaViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

val colorView: View
val title: TextView
val subtitle: TextView
val info1: TextView
val info2: TextView
val colorView: View = itemView.findViewById(R.id.color)
val title: TextView = itemView.findViewById(R.id.text1)
val subtitle: TextView = itemView.findViewById(R.id.text2)
val info1: TextView = itemView.findViewById(R.id.text3)
val info2: TextView = itemView.findViewById(R.id.text4)

init {
itemView.setOnClickListener { onItemClick?.invoke(it, layoutPosition) }
colorView = itemView.findViewById(R.id.color)
title = itemView.findViewById(R.id.text1) as TextView
subtitle = itemView.findViewById(R.id.text2) as TextView
info1 = itemView.findViewById(R.id.text3) as TextView
info2 = itemView.findViewById(R.id.text4) as TextView
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ class AssignmentDetailActivity : ItemDetailActivity<Assignment>() {
setupToolbar()

val dateFormatter = DateUtils.FORMATTER_FULL_DATE
(findViewById(R.id.textView_date) as TextView).text = mItem.dueDate.format(dateFormatter)
findViewById<TextView>(R.id.textView_date).text = mItem.dueDate.format(dateFormatter)

val progressText = findViewById(R.id.textView_progress) as TextView
val progressText = findViewById<TextView>(R.id.textView_progress)
progressText.text = getString(R.string.property_progress, mItem.completionProgress)

val seekBar = findViewById(R.id.seekBar) as SeekBar
val seekBar = findViewById<SeekBar>(R.id.seekBar)
with(seekBar) {
max = 20 // so it goes up in 5s
progress = mItem.completionProgress / 5
Expand All @@ -77,12 +77,12 @@ class AssignmentDetailActivity : ItemDetailActivity<Assignment>() {
})
}

val detailText = findViewById(R.id.textView_detail) as TextView
val detailText = findViewById<TextView>(R.id.textView_detail)
UiUtils.formatNotesTextView(this, detailText, mItem.detail)
}

private fun setupToolbar() {
val toolbar = findViewById(R.id.toolbar) as Toolbar
val toolbar = findViewById<Toolbar>(R.id.toolbar)
setSupportActionBar(toolbar)

toolbar.navigationIcon = UiUtils.tintDrawable(this, R.drawable.ic_arrow_back_black_24dp)
Expand All @@ -91,10 +91,10 @@ class AssignmentDetailActivity : ItemDetailActivity<Assignment>() {
val cls = Class.create(this, mItem.classId)
val subject = Subject.create(this, cls.subjectId)

val textViewTitle = findViewById(R.id.title) as TextView
val textViewTitle = findViewById<TextView>(R.id.title)
textViewTitle.text = mItem.title

val textViewSubtitle = findViewById(R.id.subtitle) as TextView
val textViewSubtitle = findViewById<TextView>(R.id.subtitle)
textViewSubtitle.text = subject.name

val color = Color(subject.colorId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class AssignmentEditActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_assignment_edit)

mToolbar = findViewById(R.id.toolbar) as Toolbar
mToolbar = findViewById(R.id.toolbar)
setSupportActionBar(mToolbar)

val extras = intent.extras
Expand All @@ -105,12 +105,12 @@ class AssignmentEditActivity : AppCompatActivity() {
}

private fun setupLayout() {
mTitleEditText = findViewById(R.id.editText_title) as EditText
mTitleEditText = findViewById(R.id.editText_title)
if (!mIsNew) {
mTitleEditText.setText(mAssignment!!.title)
}

mDetailEditText = findViewById(R.id.editText_detail) as EditText
mDetailEditText = findViewById(R.id.editText_detail)
if (!mIsNew) {
mDetailEditText.setText(mAssignment!!.detail)
}
Expand All @@ -120,7 +120,7 @@ class AssignmentEditActivity : AppCompatActivity() {
}

private fun setupClassText() {
mClassText = findViewById(R.id.textView_class) as TextView
mClassText = findViewById(R.id.textView_class)

if (!mIsNew) {
mClass = Class.create(this, mAssignment!!.classId)
Expand Down Expand Up @@ -149,7 +149,7 @@ class AssignmentEditActivity : AppCompatActivity() {
}

val titleView = layoutInflater.inflate(R.layout.dialog_title_with_padding, null)
(titleView.findViewById(R.id.title) as TextView).setText(R.string.choose_class)
titleView.findViewById<TextView>(R.id.title).setText(R.string.choose_class)

builder.setView(recyclerView)
.setCustomTitle(titleView)
Expand All @@ -160,7 +160,7 @@ class AssignmentEditActivity : AppCompatActivity() {
}

private fun setupDateText() {
mDateText = findViewById(R.id.textView_date) as TextView
mDateText = findViewById(R.id.textView_date)

if (!mIsNew) {
mDueDate = mAssignment!!.dueDate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ abstract class ItemEditActivity<T : BaseItem> : AppCompatActivity() {
}

private fun setupToolbar(): Toolbar {
val toolbar = findViewById(R.id.toolbar) as Toolbar
val toolbar = findViewById<Toolbar>(R.id.toolbar)
setSupportActionBar(toolbar)

supportActionBar!!.setTitle(getTitleRes(mIsNew))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import android.support.v4.content.ContextCompat
import android.support.v7.widget.Toolbar
import android.text.Html
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import co.timetableapp.R
Expand Down Expand Up @@ -68,7 +69,7 @@ class ClassDetailActivity : ItemDetailActivity<Class>() {
setupToolbar()
setupClassDetailCard()

findViewById(R.id.main_card).setBackgroundColor(
findViewById<View>(R.id.main_card).setBackgroundColor(
ContextCompat.getColor(this, mColor.getLightAccentColorRes(this)))

setupRelatedItemCards()
Expand All @@ -77,7 +78,7 @@ class ClassDetailActivity : ItemDetailActivity<Class>() {
private fun setupToolbar() {
val subject = Subject.create(this, mItem.subjectId)

val toolbar = findViewById(R.id.toolbar) as Toolbar
val toolbar = findViewById<Toolbar>(R.id.toolbar)
setSupportActionBar(toolbar)

toolbar.navigationIcon = UiUtils.tintDrawable(this, R.drawable.ic_arrow_back_black_24dp)
Expand Down Expand Up @@ -161,19 +162,19 @@ class ClassDetailActivity : ItemDetailActivity<Class>() {
*/
private fun setClassDetailTexts(locations: String, teachers: String, classTimes: String) {
val locationVisibility = if (locations.isEmpty()) View.GONE else View.VISIBLE
findViewById(R.id.viewGroup_location).visibility = locationVisibility
findViewById<ViewGroup>(R.id.viewGroup_location).visibility = locationVisibility
if (locations.isNotEmpty()) {
(findViewById(R.id.textView_location) as TextView).text = locations
findViewById<TextView>(R.id.textView_location).text = locations
}

val teacherVisibility = if (teachers.isEmpty()) View.GONE else View.VISIBLE
findViewById(R.id.viewGroup_teacher).visibility = teacherVisibility
findViewById<ViewGroup>(R.id.viewGroup_teacher).visibility = teacherVisibility
if (teachers.isNotEmpty()) {
(findViewById(R.id.textView_teacher) as TextView).text = teachers
findViewById<TextView>(R.id.textView_teacher).text = teachers
}

// No need to check if it's empty - all class details must have a class time
val textViewTimes = findViewById(R.id.textView_times) as TextView
val textViewTimes = findViewById<TextView>(R.id.textView_times)
textViewTimes.text = classTimes
}

Expand All @@ -182,7 +183,7 @@ class ClassDetailActivity : ItemDetailActivity<Class>() {
* exams for this class.
*/
private fun setupRelatedItemCards() {
val cardContainer = findViewById(R.id.card_container) as LinearLayout
val cardContainer = findViewById<LinearLayout>(R.id.card_container)

val assignmentsCard = CardOfItems.Builder(this, cardContainer)
.setTitle(R.string.title_assignments)
Expand Down
Loading