From 784626c738806b28bf4b48a2bc67851cb0f23305 Mon Sep 17 00:00:00 2001 From: Rd Date: Tue, 10 Oct 2023 15:04:48 +0530 Subject: [PATCH 1/3] PAINTROID-534: Refactored introPageViewAdapter to kotlin --- .../paintroid/intro/IntroPageViewAdapter.java | 62 ------------------- .../paintroid/intro/IntroPageViewAdapter.kt | 45 ++++++++++++++ 2 files changed, 45 insertions(+), 62 deletions(-) delete mode 100644 Paintroid/src/main/java/org/catrobat/paintroid/intro/IntroPageViewAdapter.java create mode 100644 Paintroid/src/main/java/org/catrobat/paintroid/intro/IntroPageViewAdapter.kt 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..20b2306d36 --- /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(private 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) + } +} From a118bc4af943cfea3f35cc61a14b22051fa47018 Mon Sep 17 00:00:00 2001 From: Rd Date: Tue, 10 Oct 2023 15:46:49 +0530 Subject: [PATCH 2/3] Fixed layouts not accessible error --- .../java/org/catrobat/paintroid/intro/IntroPageViewAdapter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Paintroid/src/main/java/org/catrobat/paintroid/intro/IntroPageViewAdapter.kt b/Paintroid/src/main/java/org/catrobat/paintroid/intro/IntroPageViewAdapter.kt index 20b2306d36..bfba16a1b4 100644 --- a/Paintroid/src/main/java/org/catrobat/paintroid/intro/IntroPageViewAdapter.kt +++ b/Paintroid/src/main/java/org/catrobat/paintroid/intro/IntroPageViewAdapter.kt @@ -26,7 +26,7 @@ import android.view.View import android.view.ViewGroup import androidx.viewpager.widget.PagerAdapter -class IntroPageViewAdapter(private val layouts: IntArray) : PagerAdapter() { +class IntroPageViewAdapter(val layouts: IntArray) : PagerAdapter() { override fun instantiateItem(container: ViewGroup, position: Int): Any { val inflater = LayoutInflater.from(container.context) From 68be476f001e0b90e1de05d6ab3688f2bfb63d34 Mon Sep 17 00:00:00 2001 From: Rd Date: Tue, 10 Oct 2023 20:49:14 +0530 Subject: [PATCH 3/3] Trigger Build