package com.wireguard.android.viewmodel import android.util.Log import androidx.databinding.BaseObservable import androidx.databinding.Bindable import androidx.databinding.Observable import com.wireguard.android.BR import com.wireguard.config.InetEndpoint import com.wireguard.config.Peer import java.util.Optional; class PeerDetail : BaseObservable { var peer: Peer private var owner: ConfigDetail? = null @get:Bindable var endpoint: Optional = Optional.empty() get() { if (!field.isEmpty()) { return field } else { return peer.endpoint } } set(value) { Log.i(TAG, "notifyPropertyChanged endpoint " + this + ", " + value) field = value notifyPropertyChanged(BR.endpoint) } constructor(other: Peer) { peer = other } fun bind(owner: ConfigDetail) { this.owner = owner } override fun addOnPropertyChangedCallback (callback: Observable.OnPropertyChangedCallback) { Log.i(TAG, "addOnPropertyChangedCallback " + this + ", " + callback) super.addOnPropertyChangedCallback(callback) } companion object { private const val TAG = "WireGuard/PeerDetail" } }