messenger-android

Android graphical user interfaces for GNUnet Messenger
Log | Files | Refs | README | LICENSE

ChatViewModelFactory.kt (1493B)


      1 // Datei: ChatViewModelFactory.kt
      2 
      3 /*
      4    This file is part of GNUnet.
      5    Copyright (C) 2021--2025 GNUnet e.V.
      6 
      7    GNUnet is free software: you can redistribute it and/or modify it
      8    under the terms of the GNU Affero General Public License as published
      9    by the Free Software Foundation, either version 3 of the License,
     10    or (at your option) any later version.
     11 
     12    GNUnet is distributed in the hope that it will be useful, but
     13    WITHOUT ANY WARRANTY; without even the implied warranty of
     14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15    Affero General Public License for more details.
     16 
     17    You should have received a copy of the GNU Affero General Public License
     18    along with this program.  If not, see <http://www.gnu.org/licenses/>.
     19 
     20    SPDX-License-Identifier: AGPL3.0-or-later
     21  */
     22 /*
     23  * @author t3sserakt
     24  * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/viewmodel/ChatViewModelFactory.kt
     25  */
     26 
     27 package org.gnunet.gnunetmessenger.viewmodel
     28 
     29 import androidx.lifecycle.ViewModel
     30 import androidx.lifecycle.ViewModelProvider
     31 import org.gnunet.gnunetmessenger.model.ChatContext
     32 
     33 class ChatViewModelFactory(private val chatContext: ChatContext) : ViewModelProvider.Factory {
     34     override fun <T : ViewModel> create(modelClass: Class<T>): T {
     35         if (modelClass.isAssignableFrom(ChatViewModel::class.java)) {
     36             return ChatViewModel(chatContext) as T
     37         }
     38         throw IllegalArgumentException("Unknown ViewModel class")
     39     }
     40 }