androidx.lifecycle.ViewModelProvider Java Examples
The following examples show how to use
androidx.lifecycle.ViewModelProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LicenseAdapter.java From LicenseAdapter with Apache License 2.0 | 7 votes |
@Override public ViewHolderBase onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); if (holder == null) { if (context instanceof FragmentActivity) { ViewModelProvider.AndroidViewModelFactory factory = ViewModelProvider.AndroidViewModelFactory.getInstance(((FragmentActivity) context).getApplication()); holder = new ViewModelProvider((FragmentActivity) context, factory).get(LibrariesHolder.class); } else if (context instanceof Activity) { holder = new LibrariesHolder(((Activity) context).getApplication()); } else { holder = new LibrariesHolder((Application) context.getApplicationContext()); } } if (viewType == TYPE_LIBRARY) { return new LibraryViewHolder(LayoutInflater.from(context) .inflate(R.layout.library, parent, false)); } else if (viewType == TYPE_LICENSE) { return new LicenseViewHolder(LayoutInflater.from(context) .inflate(R.layout.license, parent, false), holder); } else { throw new IllegalStateException("Unknown view type: " + viewType); } }
Example #2
Source File: LibraryFragment.java From Hentoid with Apache License 2.0 | 6 votes |
@Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_library, container, false); Preferences.registerPrefsChangedListener(prefsListener); ViewModelFactory vmFactory = new ViewModelFactory(requireActivity().getApplication()); viewModel = new ViewModelProvider(this, vmFactory).get(LibraryViewModel.class); initUI(rootView); initToolbar(rootView); initSelectionToolbar(rootView); toolbar.setOnMenuItemClickListener(this::toolbarOnItemClicked); selectionToolbar.setOnMenuItemClickListener(this::selectionToolbarOnItemClicked); return rootView; }
Example #3
Source File: BatchBackupDialogFragment.java From SAI with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setCancelable(false); Bundle args = getArguments(); ArrayList<String> packages = null; if (args != null) { packages = args.getStringArrayList(ARG_PACKAGES); } mViewModel = new ViewModelProvider(this, new BatchBackupDialogViewModelFactory(requireContext().getApplicationContext(), packages)).get(BatchBackupDialogViewModel.class); mViewModel.getIsBackupEnqueued().observe(this, (isBackupEnqueued) -> { if (isBackupEnqueued) { OnBatchBackupEnqueuedListener listener = Utils.getParentAs(this, OnBatchBackupEnqueuedListener.class); if (listener != null) listener.onBatchBackupEnqueued(getTag()); dismiss(); } }); }
Example #4
Source File: DetailActivity.java From android-popular-movies-app with Apache License 2.0 | 6 votes |
/** * When offline, display runtime, release year, and genre of the movie. */ private void loadMovieDetailData() { FavViewModelFactory factory = InjectorUtils.provideFavViewModelFactory( DetailActivity.this, mMovie.getId()); mFavViewModel = new ViewModelProvider(this, factory).get(FavViewModel.class); mFavViewModel.getMovieEntry().observe(this, new Observer<MovieEntry>() { @Override public void onChanged(@Nullable MovieEntry movieEntry) { if (movieEntry != null) { mDetailBinding.tvRuntime.setText(movieEntry.getRuntime()); mDetailBinding.tvReleaseYear.setText(movieEntry.getReleaseYear()); mDetailBinding.tvGenre.setText(movieEntry.getGenre()); } } }); }
Example #5
Source File: LicensesActivity.java From SAI with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_licenses); RecyclerView recyclerView = findViewById(R.id.rv_licenses); recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.getRecycledViewPool().setMaxRecycledViews(0, 16); LicensesAdapter adapter = new LicensesAdapter(this); recyclerView.setAdapter(adapter); LicensesViewModel viewModel = new ViewModelProvider(this).get(LicensesViewModel.class); viewModel.getLicenses().observe(this, adapter::setLicenses); }
Example #6
Source File: TopBarWidget.java From FirefoxReality with Mozilla Public License 2.0 | 6 votes |
@Override public void attachToWindow(@NonNull WindowWidget aWindow) { if (mAttachedWindow == aWindow) { return; } detachFromWindow(); mWidgetPlacement.parentHandle = aWindow.getHandle(); mAttachedWindow = aWindow; // ModelView creation and observers setup mViewModel = new ViewModelProvider( (VRBrowserActivity)getContext(), ViewModelProvider.AndroidViewModelFactory.getInstance(((VRBrowserActivity) getContext()).getApplication())) .get(String.valueOf(mAttachedWindow.hashCode()), WindowViewModel.class); mBinding.setViewmodel(mViewModel); mViewModel.getIsTopBarVisible().observe((VRBrowserActivity)getContext(), mIsVisible); }
Example #7
Source File: SettingsWidget.java From FirefoxReality with Mozilla Public License 2.0 | 6 votes |
@SuppressLint("ClickableViewAccessibility") private void initialize() { mSettingsViewModel = new ViewModelProvider( (VRBrowserActivity)getContext(), ViewModelProvider.AndroidViewModelFactory.getInstance(((VRBrowserActivity) getContext()).getApplication())) .get(SettingsViewModel.class); updateUI(); mOpenDialog = SettingsView.SettingViewType.MAIN; mAccounts = ((VRBrowserApplication)getContext().getApplicationContext()).getAccounts(); mAccounts.addAccountListener(mAccountObserver); mUIThreadExecutor = ((VRBrowserApplication)getContext().getApplicationContext()).getExecutors().mainThread(); mAudio = AudioEngine.fromContext(getContext()); mViewMarginH = mWidgetPlacement.width - WidgetPlacement.dpDimension(getContext(), R.dimen.options_width); mViewMarginH = WidgetPlacement.convertDpToPixel(getContext(), mViewMarginH); mViewMarginV = mWidgetPlacement.height - WidgetPlacement.dpDimension(getContext(), R.dimen.options_height); mViewMarginV = WidgetPlacement.convertDpToPixel(getContext(), mViewMarginV); }
Example #8
Source File: TitleBarWidget.java From FirefoxReality with Mozilla Public License 2.0 | 6 votes |
@Override public void attachToWindow(@NonNull WindowWidget aWindow) { if (aWindow == mAttachedWindow) { return; } detachFromWindow(); mWidgetPlacement.parentHandle = aWindow.getHandle(); mAttachedWindow = aWindow; // ModelView creation and observers setup mViewModel = new ViewModelProvider( (VRBrowserActivity)getContext(), ViewModelProvider.AndroidViewModelFactory.getInstance(((VRBrowserActivity) getContext()).getApplication())) .get(String.valueOf(mAttachedWindow.hashCode()), WindowViewModel.class); mBinding.setViewmodel(mViewModel); mViewModel.getIsTitleBarVisible().observe((VRBrowserActivity)getContext(), mIsVisibleObserver); }
Example #9
Source File: ListFragment.java From Pixiv-Shaft with MIT License | 6 votes |
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //获取viewmodel mModel = (BaseModel<Item>) new ViewModelProvider(this).get(modelClass()); allItems = mModel.getContent().getValue(); //为recyclerView设置Adapter mAdapter = adapter(); if (mAdapter != null) { mRecyclerView.setAdapter(mAdapter); } onAdapterPrepared(); //进页面主动刷新 if (autoRefresh() && !mModel.isLoaded()) { mRefreshLayout.autoRefresh(); } }
Example #10
Source File: DetailActivity.java From android-popular-movies-app with Apache License 2.0 | 6 votes |
/** * Return true and set a favoriteFab image to full heart image if the movie is in favorites collection. * Otherwise return false and set favoriteFab image to border heart image. */ private boolean isInFavoritesCollection() { // Get the FavViewModel from the factory FavViewModelFactory factory = InjectorUtils.provideFavViewModelFactory( DetailActivity.this, mMovie.getId()); mFavViewModel = new ViewModelProvider(this, factory).get(FavViewModel.class); // Changes the favoriteFab image based on whether or not the movie exists mFavViewModel.getMovieEntry().observe(this, new Observer<MovieEntry>() { @Override public void onChanged(@Nullable MovieEntry movieEntry) { if (mFavViewModel.getMovieEntry().getValue() == null) { mDetailBinding.fab.setImageResource(R.drawable.favorite_border); mIsInFavorites = false; } else { mDetailBinding.fab.setImageResource(R.drawable.favorite); mIsInFavorites = true; } } }); return mIsInFavorites; }
Example #11
Source File: DetailsFragment.java From ArchPackages with GNU General Public License v3.0 | 6 votes |
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (fragmentDetailsBinding != null) { // details DetailsViewModelFactory detailsViewModelFactory = new DetailsViewModelFactory(bundleRepo, bundleArch, bundlePkgname); DetailsViewModel detailsViewModel = new ViewModelProvider(this, detailsViewModelFactory).get(DetailsViewModel.class); detailsViewModel.getDetailsLiveData().observe(getViewLifecycleOwner(), details -> { if (details != null && fragmentDetailsBinding != null) { fragmentDetailsBinding.setDetails(details); fragmentDetailsBinding.executePendingBindings(); bindDetailsViewModel(details); } }); // files FilesViewModelFactory filesViewModelFactory = new FilesViewModelFactory(bundleRepo, bundleArch, bundlePkgname); FilesViewModel filesViewModel = new ViewModelProvider(this, filesViewModelFactory).get(FilesViewModel.class); filesViewModel.getFilesLiveData().observe(getViewLifecycleOwner(), files -> { if (files != null && fragmentDetailsBinding != null) { fragmentDetailsBinding.detailsFilesLayout.setFiles(files); bindFilesViewModel(files); } }); } }
Example #12
Source File: DfuFragment.java From Bluefruit_LE_Connect_Android_V2 with MIT License | 6 votes |
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // ViewModel FragmentActivity activity = getActivity(); if (activity != null) { mDfuViewModel = new ViewModelProvider(activity).get(DfuViewModel.class); // Dfu Update mDfuViewModel.getDfuCheckResult().observe(this, dfuCheckResult -> { if (dfuCheckResult != null) { onDfuUpdateCheckResultReceived(dfuCheckResult.blePeripheral, dfuCheckResult.isUpdateAvailable, dfuCheckResult.dfuInfo, dfuCheckResult.firmwareInfo); } }); // Check updates if needed Log.d(TAG, "Check firmware updates"); mWaitView.setVisibility(View.VISIBLE); mDfuViewModel.startUpdatesCheck(activity, mBlePeripheral); } }
Example #13
Source File: SearchBottomSheetFragment.java From Hentoid with Apache License 2.0 | 6 votes |
@Override public void onAttach(@NonNull Context context) { super.onAttach(context); Bundle bundle = getArguments(); if (bundle != null) { SearchActivityBundle.Parser parser = new SearchActivityBundle.Parser(bundle); selectedAttributeTypes = parser.getAttributeTypes(); currentPage = 1; if (selectedAttributeTypes.isEmpty()) { throw new IllegalArgumentException("Initialization failed"); } ViewModelFactory vmFactory = new ViewModelFactory(requireActivity().getApplication()); viewModel = new ViewModelProvider(requireActivity(), vmFactory).get(SearchViewModel.class); viewModel.setAttributeTypes(selectedAttributeTypes); } }
Example #14
Source File: HistoryView.java From FirefoxReality with Mozilla Public License 2.0 | 6 votes |
protected void initialize() { super.initialize(); mAccounts = ((VRBrowserApplication) getContext().getApplicationContext()).getAccounts(); if (ACCOUNTS_UI_ENABLED) { mAccounts.addAccountListener(mAccountListener); mAccounts.addSyncListener(mSyncListener); } mViewModel = new ViewModelProvider( (VRBrowserActivity) getContext(), ViewModelProvider.AndroidViewModelFactory.getInstance(((VRBrowserActivity) getContext()).getApplication())) .get(HistoryViewModel.class); SessionStore.get().getHistoryStore().addListener(this); updateUI(); }
Example #15
Source File: TrayWidget.java From FirefoxReality with Mozilla Public License 2.0 | 6 votes |
private void initialize(Context aContext) { // Downloads icon progress clipping doesn't work if HW acceleration is enabled. setIsHardwareAccelerationEnabled(false); mTrayViewModel = new ViewModelProvider( (VRBrowserActivity)getContext(), ViewModelProvider.AndroidViewModelFactory.getInstance(((VRBrowserActivity) getContext()).getApplication())) .get(TrayViewModel.class); mTrayViewModel.getIsVisible().observe((VRBrowserActivity) getContext(), mIsVisibleObserver); updateUI(); mIsWindowAttached = false; mTrayListeners = new ArrayList<>(); mMinPadding = WidgetPlacement.pixelDimension(getContext(), R.dimen.tray_icon_padding_min); mMaxPadding = WidgetPlacement.pixelDimension(getContext(), R.dimen.tray_icon_padding_max); mAudio = AudioEngine.fromContext(aContext); mWidgetManager.addUpdateListener(this); mWidgetManager.getServicesProvider().getDownloadsManager().addListener(this); }
Example #16
Source File: ReconnectActivity.java From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_reconnect); ButterKnife.bind(this); final Intent intent = getIntent(); final ExtendedBluetoothDevice device = intent.getParcelableExtra(Utils.EXTRA_DEVICE); final String deviceName = device.getName(); final String deviceAddress = device.getAddress(); final Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); //noinspection ConstantConditions getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle(deviceName); getSupportActionBar().setSubtitle(deviceAddress); final TextView connectionState = findViewById(R.id.connection_state); // Create view model containing utility methods for scanning mReconnectViewModel = new ViewModelProvider(this, mViewModelFactory).get(ReconnectViewModel.class); mReconnectViewModel.connect(this, device, true); mReconnectViewModel.isConnected().observe(this, isConnected -> { if (!isConnected) { finish(); } }); mReconnectViewModel.getConnectionState().observe(this, connectionState::setText); mReconnectViewModel.isDeviceReady().observe(this, deviceReady -> { if (mReconnectViewModel.getBleMeshManager().isDeviceReady()) { Intent returnIntent = new Intent(); returnIntent.putExtra(Utils.EXTRA_DATA, true); setResult(Activity.RESULT_OK, returnIntent); finish(); } }); }
Example #17
Source File: InstallerXDialogFragment.java From SAI with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); UriHostFactory uriHostFactory = null; if (args != null) { String uriHostFactoryClass = args.getString(ARG_URI_HOST_FACTORY); if (uriHostFactoryClass != null) { try { uriHostFactory = (UriHostFactory) Class.forName(uriHostFactoryClass).getConstructor().newInstance(); } catch (Exception e) { throw new RuntimeException(e); } } } mHelper = PreferencesHelper.getInstance(requireContext()); mViewModel = new ViewModelProvider(this, new InstallerXDialogViewModelFactory(requireContext(), uriHostFactory)).get(InstallerXDialogViewModel.class); if (args == null) return; Uri apkSourceUri = args.getParcelable(ARG_APK_SOURCE_URI); if (apkSourceUri != null) mViewModel.setApkSourceUris(Collections.singletonList(apkSourceUri)); }
Example #18
Source File: BackupDialogFragment.java From SAI with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewModel = new ViewModelProvider(this).get(BackupDialogViewModel.class); Bundle args = getArguments(); if (args == null) return; mPackage = Objects.requireNonNull(args.getParcelable(ARG_PACKAGE)); if (savedInstanceState == null) mViewModel.setPackage(mPackage); }
Example #19
Source File: ErrorsFragment.java From Hentoid with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ViewModelFactory vmFactory = new ViewModelFactory(requireActivity().getApplication()); viewModel = new ViewModelProvider(this, vmFactory).get(QueueViewModel.class); viewModel.getErrorsPaged().observe(getViewLifecycleOwner(), this::onErrorsChanged); }
Example #20
Source File: DarkLightThemeSelectionDialogFragment.java From SAI with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); if (args != null) { mMode = args.getInt(EXTRA_MODE, MODE_CHOOSE); } mViewModel = new ViewModelProvider(this).get(DarkLightThemeSelectionViewModel.class); }
Example #21
Source File: FilesDownloadFragment.java From mcumgr-android with Apache License 2.0 | 5 votes |
@Override public void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewModel = new ViewModelProvider(this, mViewModelFactory) .get(FilesDownloadViewModel.class); mImm = (InputMethodManager) requireContext().getSystemService(Context.INPUT_METHOD_SERVICE); }
Example #22
Source File: QueueFragment.java From Hentoid with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ViewModelFactory vmFactory = new ViewModelFactory(requireActivity().getApplication()); viewModel = new ViewModelProvider(this, vmFactory).get(QueueViewModel.class); viewModel.getQueuePaged().observe(getViewLifecycleOwner(), this::onQueueChanged); }
Example #23
Source File: MainActivity.java From android-room-with-a-view with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RecyclerView recyclerView = findViewById(R.id.recyclerview); final WordListAdapter adapter = new WordListAdapter(this); recyclerView.setAdapter(adapter); recyclerView.setLayoutManager(new LinearLayoutManager(this)); // Get a new or existing ViewModel from the ViewModelProvider. mWordViewModel = new ViewModelProvider(this).get(WordViewModel.class); // Add an observer on the LiveData returned by getAlphabetizedWords. // The onChanged() method fires when the observed data changes and the activity is // in the foreground. mWordViewModel.getAllWords().observe(this, new Observer<List<Word>>() { @Override public void onChanged(@Nullable final List<Word> words) { // Update the cached copy of the words in the adapter. adapter.setWords(words); } }); FloatingActionButton fab = findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(MainActivity.this, NewWordActivity.class); startActivityForResult(intent, NEW_WORD_ACTIVITY_REQUEST_CODE); } }); }
Example #24
Source File: SettingsStore.java From FirefoxReality with Mozilla Public License 2.0 | 5 votes |
public void initModel(@NonNull Context context) { mSettingsViewModel = new ViewModelProvider( (VRBrowserActivity)context, ViewModelProvider.AndroidViewModelFactory.getInstance(((VRBrowserActivity) context).getApplication())) .get(SettingsViewModel.class); // Setup the stored properties until we get updated ones String json = mPrefs.getString(mContext.getString(R.string.settings_key_remote_props), null); mSettingsViewModel.setProps(json); mSettingsViewModel.refresh(); update(); }
Example #25
Source File: NavigationURLBar.java From FirefoxReality with Mozilla Public License 2.0 | 5 votes |
public void attachToWindow(@NonNull WindowWidget aWindow) { mViewModel = new ViewModelProvider( (VRBrowserActivity)getContext(), ViewModelProvider.AndroidViewModelFactory.getInstance(((VRBrowserActivity) getContext()).getApplication())) .get(String.valueOf(aWindow.hashCode()), WindowViewModel.class); mBinding.setViewmodel(mViewModel); mViewModel.getIsLoading().observe((VRBrowserActivity)getContext(), mIsLoadingObserver); mViewModel.getIsBookmarked().observe((VRBrowserActivity)getContext(), mIsBookmarkedObserver); }
Example #26
Source File: Fragment_step5.java From android-lifecycles with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View root = inflater.inflate(R.layout.fragment_step5, container, false); mSeekBar = root.findViewById(R.id.seekBar); mSeekBarViewModel = new ViewModelProvider(requireActivity()).get(SeekBarViewModel.class); subscribeSeekBar(); return root; }
Example #27
Source File: BaseActivity.java From CloudReader with Apache License 2.0 | 5 votes |
/** * 初始化ViewModel */ private void initViewModel() { Class<VM> viewModelClass = ClassUtil.getViewModel(this); if (viewModelClass != null) { this.viewModel = new ViewModelProvider(this).get(viewModelClass); } }
Example #28
Source File: SettingFragment.java From webrtc_android with MIT License | 5 votes |
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { notificationsViewModel = new ViewModelProvider(requireActivity()).get(SettingViewModel.class); View root = inflater.inflate(R.layout.fragment_setting, container, false); final TextView textView = root.findViewById(R.id.text_notifications); button = root.findViewById(R.id.exit); button.setOnClickListener(view -> { SocketManager.getInstance().unConnect(); }); notificationsViewModel.getText().observe(getViewLifecycleOwner(), textView::setText); return root; }
Example #29
Source File: MainActivity.java From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mViewModel = new ViewModelProvider(this).get(SharedViewModel.class); ButterKnife.bind(this); final Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); //noinspection ConstantConditions getSupportActionBar().setTitle(R.string.app_name); mNetworkFragment = (NetworkFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_network); mGroupsFragment = (GroupsFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_groups); mProxyFilterFragment = (ProxyFilterFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_proxy); mSettingsFragment = getSupportFragmentManager().findFragmentById(R.id.fragment_settings); final BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation_view); bottomNavigationView.setOnNavigationItemSelectedListener(this); bottomNavigationView.setOnNavigationItemReselectedListener(this); if (savedInstanceState == null) { onNavigationItemSelected(bottomNavigationView.getMenu().findItem(R.id.action_network)); } else { bottomNavigationView.setSelectedItemId(savedInstanceState.getInt(CURRENT_FRAGMENT)); } }
Example #30
Source File: PlaylistTracksFragment.java From odyssey with GNU General Public License v3.0 | 5 votes |
@Override GenericViewModel<TrackModel> getViewModel() { if (mPlaylistPath == null) { return new ViewModelProvider(this, new TrackViewModel.TrackViewModelFactory(getActivity().getApplication(), mPlaylistID)).get(TrackViewModel.class); } else { return new ViewModelProvider(this, new PlaylistTrackViewModel.PlaylistTrackViewModelFactory(getActivity().getApplication(), mPlaylistPath)).get(PlaylistTrackViewModel.class); } }