Skip to content

Commit

Permalink
Fix server list being loaded on profile screen
Browse files Browse the repository at this point in the history
  • Loading branch information
dzolnai committed Jul 22, 2020
1 parent 4832584 commit 47944cc
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import nl.eduvpn.app.entity.Profile
import nl.eduvpn.app.utils.ErrorDialog
import nl.eduvpn.app.utils.ItemClickSupport
import nl.eduvpn.app.viewmodel.BaseConnectionViewModel
import nl.eduvpn.app.viewmodel.ProfileSelectionViewModel
import java.util.ArrayList

/**
Expand All @@ -40,7 +41,7 @@ import java.util.ArrayList
*/
class ProfileSelectionFragment : BaseFragment<FragmentProfileSelectionBinding>() {

private val viewModel by viewModels<BaseConnectionViewModel> { viewModelFactory }
private val viewModel by viewModels<ProfileSelectionViewModel> { viewModelFactory }

override val layout = R.layout.fragment_profile_selection

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/nl/eduvpn/app/inject/ViewModelModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ interface ViewModelModule {
@ViewModelKey(ConnectionStatusViewModel::class)
fun bindConnectionStatusViewModel(connectionStatusViewModel: ConnectionStatusViewModel): ViewModel

@Binds
@IntoMap
@ViewModelKey(ProfileSelectionViewModel::class)
fun bindProfileSelectionViewModel(profileSelectionViewModel: ProfileSelectionViewModel) : ViewModel

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import java.net.URLEncoder
* This viewmodel takes care of the entire flow, from connecting to the servers to fetching profiles.
*/
@Suppress("ConstantConditionIf")
open class BaseConnectionViewModel(
abstract class BaseConnectionViewModel(
private val context: Context,
private val apiService: APIService,
private val serializerService: SerializerService,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* This file is part of eduVPN.
*
* eduVPN 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.
*
* eduVPN 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.
*
* You should have received a copy of the GNU General Public License
* along with eduVPN. If not, see <http://www.gnu.org/licenses/>.
*
*/

package nl.eduvpn.app.viewmodel

import android.content.Context
import nl.eduvpn.app.service.APIService
import nl.eduvpn.app.service.ConnectionService
import nl.eduvpn.app.service.HistoryService
import nl.eduvpn.app.service.PreferencesService
import nl.eduvpn.app.service.SerializerService
import nl.eduvpn.app.service.VPNService
import javax.inject.Inject

class ProfileSelectionViewModel @Inject constructor(
context: Context, apiService: APIService, serializerService: SerializerService,
historyService: HistoryService, preferencesService: PreferencesService,
connectionService: ConnectionService, vpnService: VPNService) :
BaseConnectionViewModel(context, apiService, serializerService, historyService,
preferencesService, connectionService, vpnService)
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_profile_selection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<data>
<variable
name="viewModel"
type="nl.eduvpn.app.viewmodel.BaseConnectionViewModel" />
type="nl.eduvpn.app.viewmodel.ProfileSelectionViewModel" />
</data>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
Expand Down

0 comments on commit 47944cc

Please sign in to comment.