diff --git a/android/app/src/main/java/com/mirego/csmapapplication/activity/MainActivity.kt b/android/app/src/main/java/com/mirego/csmapapplication/activity/MainActivity.kt index d94302b..eca0148 100644 --- a/android/app/src/main/java/com/mirego/csmapapplication/activity/MainActivity.kt +++ b/android/app/src/main/java/com/mirego/csmapapplication/activity/MainActivity.kt @@ -53,7 +53,7 @@ class MainActivity : FragmentActivity() { } private fun downloadData() { - retrofit.create(GitHubService::class.java).listRepos("olivierpineau").enqueue(object : Callback> { + retrofit.create(GitHubService::class.java).listRepos("olivierpineuau").enqueue(object : Callback> { override fun onFailure(call: Call>?, t: Throwable?) { Log.d("street's test", "Oops") } diff --git a/android/app/src/main/java/com/mirego/csmapapplication/component/LostObjectsAdapter.kt b/android/app/src/main/java/com/mirego/csmapapplication/component/LostObjectsAdapter.kt new file mode 100644 index 0000000..0498b74 --- /dev/null +++ b/android/app/src/main/java/com/mirego/csmapapplication/component/LostObjectsAdapter.kt @@ -0,0 +1,53 @@ +package com.mirego.csmapapplication.component + +import android.app.Activity +import android.content.Context +import android.support.v4.app.FragmentActivity +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.BaseAdapter +import com.mirego.csmapapplication.R +import android.widget.ImageView +import android.widget.TextView + +/** + * Created by Sagold on 2018-03-24. + */ +class LostObjectsAdapter(private val objects: ArrayList, private val activity: FragmentActivity) : BaseAdapter() { + + override fun getView(i: Int, p0: View?, viewGroup: ViewGroup?): View { + var view = p0 + if (view == null) { + view = View.inflate(activity,R.layout.item,null) + } + + + val s = this.getItem(i) as String + + val img = view!!.findViewById(R.id.imageIcon) as ImageView + var description = view!!.findViewById(R.id.txtDescription) as TextView + var position = view!!.findViewById(R.id.txtPosition) as TextView + var distance = view!!.findViewById(R.id.txtDistance) as TextView + var name = view!!.findViewById(R.id.txtObjectName) as TextView + + description.text = "..." + position.text = "jhdfhg" + distance.text = "hjbfdh" + name.text = "djfbhgbf" + + return view + } + + override fun getItem(p0: Int): Any { + return objects.get(p0) + } + + override fun getItemId(p0: Int): Long { + return p0.toLong() + } + + override fun getCount(): Int { + return objects.size; + } +} \ No newline at end of file diff --git a/android/app/src/main/java/com/mirego/csmapapplication/fragment/ListSegmentFragment.kt b/android/app/src/main/java/com/mirego/csmapapplication/fragment/ListSegmentFragment.kt index 3493d8b..1aa8108 100644 --- a/android/app/src/main/java/com/mirego/csmapapplication/fragment/ListSegmentFragment.kt +++ b/android/app/src/main/java/com/mirego/csmapapplication/fragment/ListSegmentFragment.kt @@ -5,14 +5,30 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.ArrayAdapter +import android.widget.ListView import com.mirego.csmapapplication.R +import com.mirego.csmapapplication.component.LostObjectsAdapter + class ListSegmentFragment : Fragment() { + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { - return inflater.inflate(R.layout.fragment_piece, container, false) + val view = inflater.inflate(R.layout.fragment_list, container, false) + val listView = view.findViewById(R.id.listContainer) as ListView + + val list = ArrayList() + var adapterlist : ArrayAdapter?=null + list.add("Hello") + list.add("Hello 1") + list.add("Hello 2") + adapterlist = ArrayAdapter(activity!!,android.R.layout.simple_list_item_1,list) + val adapter = LostObjectsAdapter(list, activity!!) + listView.adapter = adapter + return view } } diff --git a/android/app/src/main/res/layout/fragment_piece.xml b/android/app/src/main/res/layout/fragment_piece.xml index 9e96618..13a78c3 100644 --- a/android/app/src/main/res/layout/fragment_piece.xml +++ b/android/app/src/main/res/layout/fragment_piece.xml @@ -2,85 +2,10 @@ - - - + - - - - - - - - - - - - - - - - - - - - - - - + android:layout_height="match_parent" + android:id="@+id/listContainer"/> \ No newline at end of file diff --git a/android/app/src/main/res/layout/item.xml b/android/app/src/main/res/layout/item.xml new file mode 100644 index 0000000..e40212a --- /dev/null +++ b/android/app/src/main/res/layout/item.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file