mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-17 12:20:51 +01:00
mark the pressed empty grid in weekly view on click
This commit is contained in:
parent
e72f6bae2a
commit
6ad9819ef3
@ -1,23 +1,41 @@
|
||||
package com.simplemobiletools.calendar.adapters
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.BaseAdapter
|
||||
import android.widget.ImageView
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.extensions.config
|
||||
|
||||
class WeekEventsAdapter(val context: Context) : BaseAdapter() {
|
||||
private val mInflater: LayoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
||||
private val defaultBackground = context.config.backgroundColor
|
||||
private val coloredBackground = context.config.primaryColor
|
||||
private var selectedGrid: ImageView? = null
|
||||
|
||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
|
||||
var view = convertView
|
||||
|
||||
if (view == null) {
|
||||
view = mInflater.inflate(R.layout.week_grid_item, parent, false)
|
||||
view = mInflater.inflate(R.layout.week_grid_item, parent, false) as ImageView
|
||||
view.background = ColorDrawable(defaultBackground)
|
||||
}
|
||||
|
||||
return view!!
|
||||
view.setOnClickListener {
|
||||
selectedGrid?.background = ColorDrawable(defaultBackground)
|
||||
if (selectedGrid == view) {
|
||||
selectedGrid = null
|
||||
} else {
|
||||
view!!.background = ColorDrawable(coloredBackground)
|
||||
(view as ImageView).setImageResource(R.drawable.ic_plus)
|
||||
selectedGrid = view as ImageView
|
||||
}
|
||||
}
|
||||
|
||||
return view
|
||||
}
|
||||
|
||||
override fun getItem(position: Int) = null
|
||||
|
@ -1,7 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
<ImageView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/week_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/weekly_view_row_minus_one_height"
|
||||
android:background="@android:color/white"/>
|
||||
android:background="@android:color/transparent"
|
||||
android:scaleType="centerInside"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user