Create a GenericIdArgs instead of using unrelated GenericIdArgs

This commit is contained in:
Benoit Marty 2021-05-05 18:22:16 +02:00
parent ea3abee63a
commit cdb3d7c308
3 changed files with 34 additions and 6 deletions

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2021 New Vector Ltd
*
* 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 im.vector.app.core.platform
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
/**
* Generic argument with one String. Can be an id (ex: roomId, spaceId, callId, etc.), or anything else
*/
@Parcelize
data class GenericIdArgs(
val id: String
) : Parcelable

View File

@ -25,9 +25,9 @@ import com.airbnb.mvrx.MvRx
import im.vector.app.R
import im.vector.app.core.extensions.commitTransaction
import im.vector.app.core.extensions.hideKeyboard
import im.vector.app.core.platform.GenericIdArgs
import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivitySimpleLoadingBinding
import im.vector.app.features.roomprofile.RoomProfileArgs
import im.vector.app.features.spaces.ShareSpaceBottomSheet
class SpacePeopleActivity : VectorBaseActivity<ActivitySimpleLoadingBinding>() {
@ -57,7 +57,7 @@ class SpacePeopleActivity : VectorBaseActivity<ActivitySimpleLoadingBinding>() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val args = intent?.getParcelableExtra<RoomProfileArgs>(MvRx.KEY_ARG)
val args = intent?.getParcelableExtra<GenericIdArgs>(MvRx.KEY_ARG)
if (isFirstCreation()) {
val simpleName = SpacePeopleFragment::class.java.simpleName
if (supportFragmentManager.findFragmentByTag(simpleName) == null) {
@ -97,7 +97,7 @@ class SpacePeopleActivity : VectorBaseActivity<ActivitySimpleLoadingBinding>() {
companion object {
fun newIntent(context: Context, spaceId: String): Intent {
return Intent(context, SpacePeopleActivity::class.java).apply {
putExtra(MvRx.KEY_ARG, RoomProfileArgs(spaceId))
putExtra(MvRx.KEY_ARG, GenericIdArgs(spaceId))
}
}
}

View File

@ -19,13 +19,13 @@ package im.vector.app.features.spaces.people
import com.airbnb.mvrx.Async
import com.airbnb.mvrx.MvRxState
import com.airbnb.mvrx.Uninitialized
import im.vector.app.features.roomprofile.RoomProfileArgs
import im.vector.app.core.platform.GenericIdArgs
data class SpacePeopleViewState(
val spaceId: String,
val createAndInviteState: Async<String> = Uninitialized
) : MvRxState {
constructor(args: RoomProfileArgs) : this(
spaceId = args.roomId
constructor(args: GenericIdArgs) : this(
spaceId = args.id
)
}