diff --git a/README.md b/README.md index 6ea94b8..4118f2e 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Add the following to your `build.gradle`: ```groovy dependencies { - implementation("com.jedlix:sdk:1.2.0") + implementation("com.jedlix:sdk:1.4.0") } ``` diff --git a/example/build.gradle.kts b/example/build.gradle.kts index f3d7aea..b60fa5f 100644 --- a/example/build.gradle.kts +++ b/example/build.gradle.kts @@ -1,6 +1,7 @@ plugins { id("com.android.application") kotlin("android") + kotlin("kapt") id("com.github.triplet.play") version "3.7.0" } @@ -46,6 +47,7 @@ android { } dataBinding { + isEnabled = true addKtx = true } diff --git a/example/src/main/java/com/jedlix/sdk/example/activity/ConnectionsActivity.kt b/example/src/main/java/com/jedlix/sdk/example/activity/ConnectionsActivity.kt index bf7c850..1c9c317 100644 --- a/example/src/main/java/com/jedlix/sdk/example/activity/ConnectionsActivity.kt +++ b/example/src/main/java/com/jedlix/sdk/example/activity/ConnectionsActivity.kt @@ -23,6 +23,9 @@ import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.lifecycleScope import com.jedlix.sdk.connectSession.registerConnectSessionManager +import com.jedlix.sdk.example.adapter.ButtonListAdapter +import com.jedlix.sdk.example.adapter.ConnectSessionViewModelAdapter +import com.jedlix.sdk.example.adapter.GroupedConnectSessionViewModelAdapter import com.jedlix.sdk.example.databinding.ActivityConnectionsBinding import com.jedlix.sdk.example.viewModel.ConnectionsViewModel import kotlinx.coroutines.flow.collect @@ -47,6 +50,9 @@ class ConnectionsActivity : AppCompatActivity() { binding.viewModel = viewModel binding.lifecycleOwner = this + binding.vehicles.adapter = ConnectSessionViewModelAdapter(this) + binding.chargers.adapter = GroupedConnectSessionViewModelAdapter(this) + val connectSessionManager = registerConnectSessionManager { viewModel.reloadData() } diff --git a/example/src/main/java/com/jedlix/sdk/example/adapter/ButtonListAdapter.kt b/example/src/main/java/com/jedlix/sdk/example/adapter/ButtonListAdapter.kt new file mode 100644 index 0000000..49062fd --- /dev/null +++ b/example/src/main/java/com/jedlix/sdk/example/adapter/ButtonListAdapter.kt @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Jedlix B.V. The Netherlands + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.jedlix.sdk.example.adapter + +import android.annotation.SuppressLint +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.databinding.BindingAdapter +import androidx.recyclerview.widget.RecyclerView +import com.jedlix.sdk.example.databinding.ViewButtonRowBinding +import com.jedlix.sdk.example.model.Button + +class ButtonListAdapter : RecyclerView.Adapter() { + + companion object { + @BindingAdapter("modelButtons") + @JvmStatic + fun bindModelButtons(recyclerView: RecyclerView, buttons: List