CategoriesViewPagerAdapter.kt 1.61 KB
Newer Older
1
/*
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 * Copyright (C) 2019-2021  E FOUNDATION
 *
 * 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.
 *
 * This program 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 this program.  If not, see <https://www.gnu.org/licenses/>.
16
17
 */

18
package foundation.e.apps.categories
Nihar Thakkar's avatar
Nihar Thakkar committed
19

Arnau Vàzquez's avatar
Arnau Vàzquez committed
20
21
22
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
Nihar Thakkar's avatar
Nihar Thakkar committed
23

narinder Rana's avatar
narinder Rana committed
24
class CategoriesViewPagerAdapter(fragmentManager: FragmentManager, private val numberOfTabs: Int, color: Int?) :
Nihar Thakkar's avatar
Nihar Thakkar committed
25
        FragmentStatePagerAdapter(fragmentManager) {
Arnau Vàzquez's avatar
Arnau Vàzquez committed
26

27
28
    private val applicationsFragment = ApplicationsFragment.newInstance(color)
    private val gamesFragment = GamesFragment.newInstance(color)
Arnau Vàzquez's avatar
Arnau Vàzquez committed
29
30
    private val pwasFragment = PwasFragment()

Nihar Thakkar's avatar
Nihar Thakkar committed
31

Arnau Vàzquez's avatar
Arnau Vàzquez committed
32
    override fun getItem(position: Int): Fragment {
Nihar Thakkar's avatar
Nihar Thakkar committed
33
34
35
36
37
38
39
        when (position) {
            0 -> {
                return applicationsFragment
            }
            1 -> {
                return gamesFragment
            }
Arnau Vàzquez's avatar
Arnau Vàzquez committed
40
41
42
            2 -> {
                return pwasFragment
            }
Nihar Thakkar's avatar
Nihar Thakkar committed
43
        }
Arnau Vàzquez's avatar
Arnau Vàzquez committed
44
        return pwasFragment
Nihar Thakkar's avatar
Nihar Thakkar committed
45
46
47
48
49
50
    }

    override fun getCount(): Int {
        return numberOfTabs
    }
}