1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.wallpaper.picker.di.navigation 18 19 import android.os.Bundle 20 import androidx.annotation.IdRes 21 import androidx.fragment.app.FragmentActivity 22 import com.android.wallpaper.model.WallpaperInfo 23 import com.android.wallpaper.picker.PreviewFragment 24 import com.android.wallpaper.picker.preview.ui.fragment.SmallPreviewFragment 25 import javax.inject.Inject 26 27 class NavigationControllerImpl @Inject constructor() : NavigationController { 28 navigateToPreviewnull29 override fun navigateToPreview( 30 activity: FragmentActivity, 31 wallpaperInfo: WallpaperInfo, 32 viewAsHome: Boolean, 33 viewFullScreen: Boolean, 34 testingModeEnabled: Boolean, 35 @IdRes viewId: Int, 36 transition: Transition, 37 isAssetIdPresent: Boolean 38 ) { 39 // TODO(b/295199906): arguments removed in next diff 40 val args = Bundle() 41 args.putParcelable(PreviewFragment.ARG_WALLPAPER, wallpaperInfo) 42 args.putBoolean(PreviewFragment.ARG_VIEW_AS_HOME, viewAsHome) 43 args.putBoolean(PreviewFragment.ARG_IS_ASSET_ID_PRESENT, isAssetIdPresent) 44 45 val previewFragment = SmallPreviewFragment() 46 previewFragment.arguments = args 47 48 when (transition) { 49 Transition.ADD -> 50 activity.supportFragmentManager 51 .beginTransaction() 52 .add(viewId, previewFragment) 53 .commit() 54 Transition.REPLACE -> 55 activity.supportFragmentManager 56 .beginTransaction() 57 .replace(viewId, previewFragment) 58 .commit() 59 } 60 } 61 } 62