Skip to content

Commit

Permalink
list caline
Browse files Browse the repository at this point in the history
  • Loading branch information
Sag0ld authored and phildupuis committed Mar 25, 2018
1 parent 5637a91 commit 6a91b9f
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 102 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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
Expand All @@ -9,30 +11,27 @@ import com.mirego.csmapapplication.R
import android.widget.ImageView
import android.widget.TextView





/**
* Created by Sagold on 2018-03-24.
*/
class LostObjectsAdapter(private val context: Context, private val objects: ArrayList<String>) : BaseAdapter() {
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 = LayoutInflater.from(viewGroup!!.context).inflate(R.layout.fragment_list, viewGroup, false)
view = View.inflate(activity,R.layout.item,null)
}


val s = this.getItem(i) as String

val img = view!!.findViewById(R.id.imageIcon) as ImageView
val description = view!!.findViewById(R.id.txtDescription) as TextView
val position = view!!.findViewById(R.id.txtPosition) as TextView
val distance = view!!.findViewById(R.id.txtDistance) as TextView
val name = view!!.findViewById(R.id.txtObjectName) as TextView
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 = "ici"
description.text = "..."
position.text = "jhdfhg"
distance.text = "hjbfdh"
name.text = "djfbhgbf"
Expand All @@ -49,6 +48,6 @@ class LostObjectsAdapter(private val context: Context, private val objects: Arra
}

override fun getCount(): Int {
return objects.size
return objects.size;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package com.mirego.csmapapplication.fragment

import android.support.v4.app.Fragment
import android.os.Bundle
import android.support.constraint.ConstraintLayout
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ArrayAdapter
import android.widget.ListView
import com.mirego.csmapapplication.R
import com.mirego.csmapapplication.component.LostObjectsAdapter
Expand All @@ -20,11 +19,16 @@ class ListSegmentFragment : Fragment() {
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_list, container, false)
val constraintLayout = view.findViewById(R.id.container) as ConstraintLayout
val listView = ListView(context)
val adapter = LostObjectsAdapter(context!!, ArrayList())
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
constraintLayout.addView(listView)
return view
}
}
88 changes: 4 additions & 84 deletions android/app/src/main/res/layout/fragment_piece.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,89 +3,9 @@
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
>
<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:id="@+id/txtObjectName"
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:id="@+id/txtDescription"
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: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:text="(0.62 km)"
android:textColor="@color/brownishGrey"
android:id="@+id/txtDistance"
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 6a91b9f

Please sign in to comment.