diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/example/h_mal/sliidenewsreader/ui/main/FeedRecyclerViewAdapter.kt b/app/src/main/java/com/example/h_mal/sliidenewsreader/ui/main/ListAdapter.kt
similarity index 74%
rename from app/src/main/java/com/example/h_mal/sliidenewsreader/ui/main/FeedRecyclerViewAdapter.kt
rename to app/src/main/java/com/example/h_mal/sliidenewsreader/ui/main/ListAdapter.kt
index 2002500..6c888e9 100644
--- a/app/src/main/java/com/example/h_mal/sliidenewsreader/ui/main/FeedRecyclerViewAdapter.kt
+++ b/app/src/main/java/com/example/h_mal/sliidenewsreader/ui/main/ListAdapter.kt
@@ -1,6 +1,9 @@
package com.example.h_mal.sliidenewsreader.ui.main
import android.content.Context
+import android.content.Intent
+import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
+import android.net.Uri
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@@ -25,14 +28,21 @@ class ListAdapter(context: Context, objects: MutableList) :
val currentFeedItem = getItem(position)
+ //diplay the title and link to article
view.textView.text = currentFeedItem?.title
+ view.textView.setOnClickListener {
+ openLink(position)
+ }
+ //initialise views
val slider = view.seekBar
val imageView = view.imageView
+ //hide views for now
slider.visibility = View.GONE
imageView.visibility = View.GONE
+ //get array of images
val imgArray = currentFeedItem?.images
imgArray?.let {
@@ -44,6 +54,7 @@ class ListAdapter(context: Context, objects: MutableList) :
val count = it.count() -1
if (count > 0){
+ //setup slides to work with image view
slider.visibility = View.VISIBLE
slider.max = count
slider.setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
@@ -70,4 +81,17 @@ class ListAdapter(context: Context, objects: MutableList) :
.into(imageView)
}
+ //function for opening the link
+ fun openLink(position: Int){
+ val urlString = getItem(position)?.url
+ //open link to repo if the url is not null
+ if (urlString != null){
+ val openURL = Intent(Intent.ACTION_VIEW)
+ openURL.addFlags(FLAG_ACTIVITY_NEW_TASK)
+ openURL.data = Uri.parse(urlString)
+ context.startActivity(openURL)
+ }
+
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/feed_item.xml b/app/src/main/res/layout/feed_item.xml
index 3014366..08797bb 100644
--- a/app/src/main/res/layout/feed_item.xml
+++ b/app/src/main/res/layout/feed_item.xml
@@ -2,20 +2,23 @@
+ android:layout_height="wrap_content">
+ tools:text="TextView"
+ android:layout_marginBottom="6dp"/>