Skip to content

Commit

Permalink
Merge pull request #1 from phildupuis/listView
Browse files Browse the repository at this point in the history
List view
  • Loading branch information
phildupuis authored Mar 25, 2018
2 parents f510ce5 + 6a91b9f commit 35f737f
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MainActivity : FragmentActivity() {
}

private fun downloadData() {
retrofit.create(GitHubService::class.java).listRepos("olivierpineau").enqueue(object : Callback<List<Repo>> {
retrofit.create(GitHubService::class.java).listRepos("olivierpineuau").enqueue(object : Callback<List<Repo>> {
override fun onFailure(call: Call<List<Repo>>?, t: Throwable?) {
Log.d("street's test", "Oops")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String>, 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>()
var adapterlist : ArrayAdapter<String>?=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
}
}
85 changes: 5 additions & 80 deletions android/app/src/main/res/layout/fragment_piece.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,10 @@
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">


<android.support.v7.widget.CardView
android:layout_height="match_parent"
>
<ListView
android:layout_width="match_parent"
android:layout_height="106dp"
android:background="@android:color/white"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:gravity="center_vertical"
android:orientation="horizontal">

<ImageView
android:id="@+id/imageIcon"
android:layout_width="70dp"
android:layout_height="70dp"
android:scaleType="fitCenter"
android:background="@drawable/imageview_copper_border"
android:padding="12dp"
android:src="@drawable/ic_part_bulb" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="Bougie 4W"
android:textAppearance="@style/partTitle"
android:textColor="@color/purpleBrown" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="Moteur principal"
android:textColor="@color/purpleBrown" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="46.7552° N, 71.2265° W"
android:textColor="@color/brownishGrey" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:ellipsize="end"
android:maxLines="1"
android:text="(0.62 km)"
android:textColor="@color/brownishGrey"
android:textStyle="italic" />

</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>


android:layout_height="match_parent"
android:id="@+id/listContainer"/>
</android.support.constraint.ConstraintLayout>
84 changes: 84 additions & 0 deletions android/app/src/main/res/layout/item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container">

<android.support.v7.widget.CardView android:layout_width="match_parent"
android:layout_height="106dp"
android:background="@android:color/white"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:gravity="center_vertical"
android:orientation="horizontal">

<ImageView
android:id="@+id/imageIcon"
android:layout_width="70dp"
android:layout_height="70dp"
android:scaleType="fitCenter"
android:background="@drawable/imageview_copper_border"
android:padding="12dp"
android:src="@drawable/ic_part_bulb" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:id="@+id/txtObjectName"
android:textAppearance="@style/partTitle"
android:textColor="@color/purpleBrown" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:id="@+id/txtDescription"
android:textColor="@color/purpleBrown" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:id="@+id/txtPosition"
android:textColor="@color/brownishGrey" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/brownishGrey"
android:id="@+id/txtDistance"
android:textStyle="italic" />

</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>

0 comments on commit 35f737f

Please sign in to comment.