|
| 1 | +/** |
| 2 | + * Paintroid: An image manipulation application for Android. |
| 3 | + * Copyright (C) 2010-2015 The Catrobat Team |
| 4 | + * (<http:></http:>//developer.catrobat.org/credits>) |
| 5 | + * |
| 6 | + * |
| 7 | + * This program is free software: you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU Affero General Public License as |
| 9 | + * published by the Free Software Foundation, either version 3 of the |
| 10 | + * License, or (at your option) any later version. |
| 11 | + * |
| 12 | + * |
| 13 | + * This program is distributed in the hope that it will be useful, |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | + * GNU Affero General Public License for more details. |
| 17 | + * |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU Affero General Public License |
| 20 | + * along with this program. If not, see <http:></http:>//www.gnu.org/licenses/>. |
| 21 | + */ |
| 22 | +package org.catrobat.paintroid.intro |
| 23 | + |
| 24 | +import android.view.LayoutInflater |
| 25 | +import android.view.View |
| 26 | +import android.view.ViewGroup |
| 27 | +import androidx.viewpager.widget.PagerAdapter |
| 28 | + |
| 29 | +class IntroPageViewAdapter(val layouts: IntArray) : PagerAdapter() { |
| 30 | + |
| 31 | + override fun instantiateItem(container: ViewGroup, position: Int): Any { |
| 32 | + val inflater = LayoutInflater.from(container.context) |
| 33 | + val view = inflater.inflate(layouts[position], container, false) |
| 34 | + container.addView(view) |
| 35 | + return view |
| 36 | + } |
| 37 | + |
| 38 | + override fun getCount(): Int = layouts.size |
| 39 | + |
| 40 | + override fun isViewFromObject(view: View, obj: Any): Boolean = view === obj |
| 41 | + |
| 42 | + override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) { |
| 43 | + container.removeView(`object` as View) |
| 44 | + } |
| 45 | +} |
0 commit comments