diff --git a/Paintroid/src/main/java/org/catrobat/paintroid/intro/IntroPageViewAdapter.java b/Paintroid/src/main/java/org/catrobat/paintroid/intro/IntroPageViewAdapter.java deleted file mode 100644 index b2bda1c573..0000000000 --- a/Paintroid/src/main/java/org/catrobat/paintroid/intro/IntroPageViewAdapter.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Paintroid: An image manipulation application for Android. - * Copyright (C) 2010-2015 The Catrobat Team - * () - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - *

- * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package org.catrobat.paintroid.intro; - -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import androidx.annotation.VisibleForTesting; -import androidx.viewpager.widget.PagerAdapter; - -public class IntroPageViewAdapter extends PagerAdapter { - @VisibleForTesting - public int[] layouts; - - public IntroPageViewAdapter(int[] layouts) { - this.layouts = new int[layouts.length]; - System.arraycopy(layouts, 0, this.layouts, 0, this.layouts.length); - } - - @Override - public Object instantiateItem(ViewGroup container, int position) { - LayoutInflater layoutInflater = LayoutInflater.from(container.getContext()); - - View view = layoutInflater.inflate(layouts[position], container, false); - container.addView(view); - return view; - } - - @Override - public int getCount() { - return layouts.length; - } - - @Override - public boolean isViewFromObject(View view, Object obj) { - return view == obj; - } - - @Override - public void destroyItem(ViewGroup container, int position, Object object) { - View view = (View) object; - container.removeView(view); - } -} diff --git a/Paintroid/src/main/java/org/catrobat/paintroid/intro/IntroPageViewAdapter.kt b/Paintroid/src/main/java/org/catrobat/paintroid/intro/IntroPageViewAdapter.kt new file mode 100644 index 0000000000..bfba16a1b4 --- /dev/null +++ b/Paintroid/src/main/java/org/catrobat/paintroid/intro/IntroPageViewAdapter.kt @@ -0,0 +1,45 @@ +/** + * Paintroid: An image manipulation application for Android. + * Copyright (C) 2010-2015 The Catrobat Team + * (//developer.catrobat.org/credits>) + * + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see //www.gnu.org/licenses/>. + */ +package org.catrobat.paintroid.intro + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.viewpager.widget.PagerAdapter + +class IntroPageViewAdapter(val layouts: IntArray) : PagerAdapter() { + + override fun instantiateItem(container: ViewGroup, position: Int): Any { + val inflater = LayoutInflater.from(container.context) + val view = inflater.inflate(layouts[position], container, false) + container.addView(view) + return view + } + + override fun getCount(): Int = layouts.size + + override fun isViewFromObject(view: View, obj: Any): Boolean = view === obj + + override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) { + container.removeView(`object` as View) + } +}