mirror of
https://github.com/hmalik144/Android-developer-tech-test---Sliide.git
synced 2025-12-10 00:25:19 +00:00
Just some minor adjustments
This commit is contained in:
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
package com.example.h_mal.sliidenewsreader.ui.main
|
package com.example.h_mal.sliidenewsreader.ui.main
|
||||||
|
|
||||||
import android.content.Context
|
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.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@@ -25,14 +28,21 @@ class ListAdapter(context: Context, objects: MutableList<FeedResponse>) :
|
|||||||
|
|
||||||
val currentFeedItem = getItem(position)
|
val currentFeedItem = getItem(position)
|
||||||
|
|
||||||
|
//diplay the title and link to article
|
||||||
view.textView.text = currentFeedItem?.title
|
view.textView.text = currentFeedItem?.title
|
||||||
|
view.textView.setOnClickListener {
|
||||||
|
openLink(position)
|
||||||
|
}
|
||||||
|
|
||||||
|
//initialise views
|
||||||
val slider = view.seekBar
|
val slider = view.seekBar
|
||||||
val imageView = view.imageView
|
val imageView = view.imageView
|
||||||
|
|
||||||
|
//hide views for now
|
||||||
slider.visibility = View.GONE
|
slider.visibility = View.GONE
|
||||||
imageView.visibility = View.GONE
|
imageView.visibility = View.GONE
|
||||||
|
|
||||||
|
//get array of images
|
||||||
val imgArray = currentFeedItem?.images
|
val imgArray = currentFeedItem?.images
|
||||||
|
|
||||||
imgArray?.let {
|
imgArray?.let {
|
||||||
@@ -44,6 +54,7 @@ class ListAdapter(context: Context, objects: MutableList<FeedResponse>) :
|
|||||||
val count = it.count() -1
|
val count = it.count() -1
|
||||||
|
|
||||||
if (count > 0){
|
if (count > 0){
|
||||||
|
//setup slides to work with image view
|
||||||
slider.visibility = View.VISIBLE
|
slider.visibility = View.VISIBLE
|
||||||
slider.max = count
|
slider.max = count
|
||||||
slider.setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
|
slider.setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
|
||||||
@@ -70,4 +81,17 @@ class ListAdapter(context: Context, objects: MutableList<FeedResponse>) :
|
|||||||
.into(imageView)
|
.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)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,20 +2,23 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:padding="16dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView"
|
android:id="@+id/textView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="TextView" />
|
tools:text="TextView"
|
||||||
|
android:layout_marginBottom="6dp"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/imageView"
|
android:id="@+id/imageView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="6dp"
|
||||||
tools:srcCompat="@mipmap/ic_launcher" />
|
tools:srcCompat="@mipmap/ic_launcher" />
|
||||||
|
|
||||||
<SeekBar
|
<SeekBar
|
||||||
|
|||||||
Reference in New Issue
Block a user