From 0bab675560e206cf967de2247d534f46cdc1bc5f Mon Sep 17 00:00:00 2001 From: davidoskky Date: Sat, 12 Dec 2020 03:14:12 +0100 Subject: [PATCH] First stub of the fragment to show the image in full screen --- .../fragments/ImageFragment.kt | 52 +++++++++++++++++++ app/src/main/res/layout/fragment_image.xml | 10 ++++ 2 files changed, 62 insertions(+) create mode 100644 app/src/main/java/apps/amine/bou/readerforselfoss/fragments/ImageFragment.kt create mode 100644 app/src/main/res/layout/fragment_image.xml diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/fragments/ImageFragment.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/fragments/ImageFragment.kt new file mode 100644 index 0000000..974af6c --- /dev/null +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/fragments/ImageFragment.kt @@ -0,0 +1,52 @@ +package apps.amine.bou.readerforselfoss.fragments + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import apps.amine.bou.readerforselfoss.R +import apps.amine.bou.readerforselfoss.api.selfoss.Item +import kotlinx.android.synthetic.main.fragment_article.* +import kotlinx.android.synthetic.main.fragment_article.view.* +import retrofit2.http.Url + +class ImageFragment : Fragment() { + + private lateinit var position: Number + private lateinit var allImages: ArrayList + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + position = arguments!!.getInt("position") + allImages = arguments!!.getStringArrayList("allImages") + + } + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + val view : View = inflater.inflate(R.layout.fragment_image, container, false) + + view.webcontent.visibility = View.VISIBLE + view.webcontent.loadUrl(allImages[0]) + + return view + } + + companion object { + private const val ARG_POSITION = "position" + private const val ARG_IMAGES = "allImages" + + fun newInstance( + position: Int, + allImages: ArrayList + ): ImageFragment { + val fragment = ImageFragment() + val args = Bundle() + args.putInt(ARG_POSITION, position) + args.putStringArrayList(ARG_IMAGES, allImages) + fragment.arguments = args + return fragment + } + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_image.xml b/app/src/main/res/layout/fragment_image.xml new file mode 100644 index 0000000..99c3549 --- /dev/null +++ b/app/src/main/res/layout/fragment_image.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file