minor code style update

This commit is contained in:
tibbi 2017-11-13 17:45:20 +01:00
parent 064211a71a
commit 28aab35b4c
3 changed files with 10 additions and 12 deletions

View file

@ -1,7 +1,6 @@
package com.simplemobiletools.calendar.adapters
import android.graphics.PorterDuff
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.simplemobiletools.calendar.R
@ -35,7 +34,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: List<Event>, val li
}
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent?.context).inflate(R.layout.event_item_day_view, parent, false)
val view = activity.layoutInflater.inflate(R.layout.event_item_day_view, parent, false)
return createViewHolder(view)
}

View file

@ -1,6 +1,5 @@
package com.simplemobiletools.calendar.adapters
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.simplemobiletools.calendar.R
@ -30,7 +29,7 @@ class EventTypeAdapter(activity: SimpleActivity, val eventTypes: List<EventType>
}
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): MyAdapter.ViewHolder {
val view = LayoutInflater.from(parent?.context).inflate(R.layout.item_event_type, parent, false)
val view = activity.layoutInflater.inflate(R.layout.item_event_type, parent, false)
return createViewHolder(view)
}

View file

@ -100,7 +100,7 @@ class Config(context: Context) : BaseConfig(context) {
addDisplayEventTypes(HashSet<String>(Arrays.asList(type)))
}
fun addDisplayEventTypes(types: Set<String>) {
private fun addDisplayEventTypes(types: Set<String>) {
val currDisplayEventTypes = HashSet<String>(displayEventTypes)
currDisplayEventTypes.addAll(types)
displayEventTypes = currDisplayEventTypes
@ -112,11 +112,11 @@ class Config(context: Context) : BaseConfig(context) {
displayEventTypes = currDisplayEventTypes
}
fun getDefaultNotificationSound(): String {
try {
return RingtoneManager.getActualDefaultRingtoneUri(context, RingtoneManager.TYPE_NOTIFICATION)?.toString() ?: ""
private fun getDefaultNotificationSound(): String {
return try {
RingtoneManager.getActualDefaultRingtoneUri(context, RingtoneManager.TYPE_NOTIFICATION)?.toString() ?: ""
} catch (e: Exception) {
return ""
""
}
}
@ -126,7 +126,7 @@ class Config(context: Context) : BaseConfig(context) {
else -> getLargeFontSize()
}
fun getSmallFontSize() = getMediumFontSize() - 3f
fun getMediumFontSize() = context.resources.getDimension(R.dimen.day_text_size) / context.resources.displayMetrics.density
fun getLargeFontSize() = getMediumFontSize() + 3f
private fun getSmallFontSize() = getMediumFontSize() - 3f
private fun getMediumFontSize() = context.resources.getDimension(R.dimen.day_text_size) / context.resources.displayMetrics.density
private fun getLargeFontSize() = getMediumFontSize() + 3f
}