Commit 8030d4ff authored by Alutulu's avatar Alutulu

pichu update

parent 78f44799
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
<project version="4"> <project version="4">
<component name="deploymentTargetDropDown"> <component name="deploymentTargetDropDown">
<value> <value>
<entry key="Basic">
<State />
</entry>
<entry key="app"> <entry key="app">
<State /> <State />
</entry> </entry>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
......
package com.example.elbuenopeso package com.example.elbuenopeso
import AdAdapter
import android.os.Bundle import android.os.Bundle
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
...@@ -8,6 +9,7 @@ import androidx.navigation.ui.AppBarConfiguration ...@@ -8,6 +9,7 @@ import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupActionBarWithNavController import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController import androidx.navigation.ui.setupWithNavController
import com.example.elbuenopeso.databinding.ActivityMainBinding import com.example.elbuenopeso.databinding.ActivityMainBinding
import com.example.elbuenopeso.models.AdModel
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
...@@ -31,5 +33,6 @@ class MainActivity : AppCompatActivity() { ...@@ -31,5 +33,6 @@ class MainActivity : AppCompatActivity() {
) )
setupActionBarWithNavController(navController, appBarConfiguration) setupActionBarWithNavController(navController, appBarConfiguration)
navView.setupWithNavController(navController) navView.setupWithNavController(navController)
} }
} }
\ No newline at end of file
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.ImageView
import android.widget.TextView
import com.example.elbuenopeso.R
import com.example.elbuenopeso.models.AdModel
import com.example.elbuenopeso.ui.dashboard.MarketFragment
class AdAdapter(private val context: Context, private val adModelArrayList: List<AdModel>) : BaseAdapter() {
private val inflater: LayoutInflater = LayoutInflater.from(context)
override fun getCount(): Int = adModelArrayList.size
override fun getItem(i: Int): Any = adModelArrayList[i]
override fun getItemId(i: Int): Long = i.toLong()
override fun getView(i: Int, view: View?, viewGroup: ViewGroup): View {
var convertView = view
val ad = adModelArrayList[i]
convertView = inflater.inflate(R.layout.item_listview_ad, viewGroup, false)
val imageIV: ImageView = convertView.findViewById(R.id.itemListViewImageView)
val titleTV: TextView = convertView.findViewById(R.id.itemListViewTitleView)
val addressTV: TextView = convertView.findViewById(R.id.itemListViewTextView)
imageIV.setImageResource(ad.image)
titleTV.text = ad.title
addressTV.text = ad.address
return convertView
}
}
\ No newline at end of file
package com.example.elbuenopeso.models
public class AdModel(var title: String, var address: String, var image: Int) {
}
\ No newline at end of file
package com.example.elbuenopeso.ui.dashboard package com.example.elbuenopeso.ui.dashboard
import AdAdapter
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView import android.widget.ListView
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import com.example.elbuenopeso.databinding.FragmentDashboardBinding import com.example.elbuenopeso.databinding.FragmentMarketBinding
import com.example.elbuenopeso.models.AdModel
import com.example.elbuenopeso.R
class DashboardFragment : Fragment() { class MarketFragment : Fragment() {
private var _binding: FragmentDashboardBinding? = null private var _binding: FragmentMarketBinding? = null
// This property is only valid between onCreateView and // This property is only valid between onCreateView and
// onDestroyView. // onDestroyView.
...@@ -22,16 +25,32 @@ class DashboardFragment : Fragment() { ...@@ -22,16 +25,32 @@ class DashboardFragment : Fragment() {
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View { ): View {
val dashboardViewModel = val marketViewModel =
ViewModelProvider(this).get(DashboardViewModel::class.java) ViewModelProvider(this)[MarketViewModel::class.java]
_binding = FragmentDashboardBinding.inflate(inflater, container, false) _binding = FragmentMarketBinding.inflate(inflater, container, false)
val root: View = binding.root val root: View = binding.root
val textView: TextView = binding.textDashboard val listView: ListView = binding.listView
dashboardViewModel.text.observe(viewLifecycleOwner) { // seed market items
var annonces: List<AdModel> = listOf<AdModel>(
AdModel("Poutre", "1 rue Jean-Pierre", R.drawable.pichu),
AdModel("Briques", "2 rue Jean-Michel", R.drawable.pichu),
AdModel("Mur en bois", "4 rue Alain-Juju", R.drawable.pichu),
AdModel("Maison de pierre", "7 rue Joris Belhomme", R.drawable.pichu),
AdModel("Téléphone de Timothé", "8 rue de Timothé", R.drawable.pichu),
AdModel("Oridnateur", "10 rue Jean-Charles", R.drawable.pichu),
AdModel("Charnières", "22 rue Jeanne-Marie", R.drawable.pichu),
AdModel("Porte en marbre", "1 rue Jean-Pierre", R.drawable.pichu),
AdModel("Cheminée", "33 rue du Gouvernement", R.drawable.pichu),
)
var adAdapter: AdAdapter = AdAdapter(requireContext(), annonces)
listView.adapter = adAdapter
/*marketViewModel.text.observe(viewLifecycleOwner) {
textView.text = it textView.text = it
} }*/
return root return root
} }
......
...@@ -4,7 +4,7 @@ import androidx.lifecycle.LiveData ...@@ -4,7 +4,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
class DashboardViewModel : ViewModel() { class MarketViewModel : ViewModel() {
private val _text = MutableLiveData<String>().apply { private val _text = MutableLiveData<String>().apply {
value = "This is dashboard Fragment" value = "This is dashboard Fragment"
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".test">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -4,18 +4,12 @@ ...@@ -4,18 +4,12 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".ui.dashboard.DashboardFragment"> tools:context=".ui.dashboard.MarketFragment">
<TextView <ListView
android:id="@+id/text_dashboard" android:id="@+id/listView"
android:layout_width="match_parent" android:layout_width="409dp"
android:layout_height="wrap_content" android:layout_height="681dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:textAlignment="center"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/itemListViewTitleView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="TextView"
android:textSize="20sp"
app:layout_constraintStart_toEndOf="@+id/itemListViewImageView"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/itemListViewImageView"
android:layout_width="117dp"
android:layout_height="94dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@drawable/pichu" />
<TextView
android:id="@+id/itemListViewTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:text="TextView"
app:layout_constraintBottom_toBottomOf="@+id/itemListViewImageView"
app:layout_constraintStart_toEndOf="@+id/itemListViewImageView" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
<fragment <fragment
android:id="@+id/navigation_dashboard" android:id="@+id/navigation_dashboard"
android:name="com.example.elbuenopeso.ui.dashboard.DashboardFragment" android:name="com.example.elbuenopeso.ui.dashboard.MarketFragment"
android:label="@string/title_dashboard" android:label="@string/title_dashboard"
tools:layout="@layout/fragment_dashboard" /> tools:layout="@layout/fragment_market" />
<fragment <fragment
android:id="@+id/navigation_notifications" android:id="@+id/navigation_notifications"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment