diff --git a/app/src/main/java/code/name/monkey/retromusic/views/ListItemView.kt b/app/src/main/java/code/name/monkey/retromusic/views/ListItemView.kt new file mode 100644 index 00000000..19f97ae1 --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/views/ListItemView.kt @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2019 Hemanth Savarala. + * + * Licensed under the GNU General Public License v3 + * + * This is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by + * the Free Software Foundation either version 3 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + */ + +package code.name.monkey.retromusic.views + +import android.content.Context +import android.util.AttributeSet +import android.view.View +import android.widget.FrameLayout +import code.name.monkey.retromusic.R +import code.name.monkey.retromusic.extensions.hide +import kotlinx.android.synthetic.main.list_item_view.view.* + +/** + * Created by hemanths on 2019-10-02. + */ +class ListItemView : FrameLayout { + constructor(context: Context) : super(context) { + init(context, null) + } + + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { + init(context, attrs) + } + + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { + init(context, attrs) + } + + private fun init(context: Context, attrs: AttributeSet?) { + View.inflate(context, R.layout.list_item_view, this) + + val typedArray = context.obtainStyledAttributes(attrs, R.styleable.ListItemView) + appCompatImageView.setImageDrawable(typedArray.getDrawable(R.styleable.ListItemView_listItemIcon)) + title.text = typedArray.getText(R.styleable.ListItemView_listItemTitle) + if (typedArray.hasValue(R.styleable.ListItemView_listItemSummary)) { + summary.text = typedArray.getText(R.styleable.ListItemView_listItemSummary) + } else { + summary.hide() + } + typedArray.recycle() + } +} diff --git a/app/src/main/res/layout-sw600dp-land/activity_settings.xml b/app/src/main/res/layout-sw600dp-land/activity_settings.xml index eba0ce0f..bb5a7e8e 100644 --- a/app/src/main/res/layout-sw600dp-land/activity_settings.xml +++ b/app/src/main/res/layout-sw600dp-land/activity_settings.xml @@ -1,5 +1,4 @@ - - + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/list_item_view.xml b/app/src/main/res/values/list_item_view.xml new file mode 100644 index 00000000..1d49c011 --- /dev/null +++ b/app/src/main/res/values/list_item_view.xml @@ -0,0 +1,21 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 6a10d75e..2ddf296e 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -39,12 +39,13 @@ - -