/* Copyright 2019 Joel Pyska * * This file is a part of Tusky. * * This program 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. * * Tusky 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 Tusky; if not, * see . */ package com.keylesspalace.tusky.components.search.adapter import android.content.Context import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentPagerAdapter import com.keylesspalace.tusky.R import com.keylesspalace.tusky.components.search.fragments.SearchAccountsFragment import com.keylesspalace.tusky.components.search.fragments.SearchHashtagsFragment import com.keylesspalace.tusky.components.search.fragments.SearchNotestockFragment import com.keylesspalace.tusky.components.search.fragments.SearchStatusesFragment class SearchPagerAdapter(private val context: Context, manager: FragmentManager) : FragmentPagerAdapter(manager) { override fun getItem(position: Int): Fragment { return when (position) { 0 -> SearchStatusesFragment.newInstance() 1 -> SearchAccountsFragment.newInstance() 2 -> SearchHashtagsFragment.newInstance() 3 -> SearchNotestockFragment.newInstance() else -> throw IllegalArgumentException("Unknown page index: $position") } } override fun getPageTitle(position: Int): CharSequence? { return when (position) { 0 -> context.getString(R.string.title_statuses) 1 -> context.getString(R.string.title_accounts) 2 -> context.getString(R.string.title_hashtags_dialog) 3 -> context.getString(R.string.title_notestock) else -> throw IllegalArgumentException("Unknown page index: $position") } } override fun getCount(): Int = 4 }