creation of navigation and fragments
continuous-integration/drone/push Build is passing Details

fragment_navigation
Emre KARTAL 2 years ago
parent 5afe09859d
commit ae34b24cb5

@ -34,6 +34,8 @@ android {
dependencies { dependencies {
implementation 'com.github.bumptech.glide:glide:4.12.0' implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.appcompat:appcompat:1.6.1'

@ -15,7 +15,7 @@
android:theme="@style/Theme.Scor_It" android:theme="@style/Theme.Scor_It"
tools:targetApi="31"> tools:targetApi="31">
<activity <activity
android:name=".view.HomeActivity" android:name=".view.MainActivity"
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

@ -1,12 +0,0 @@
package uca.iut.clermont.view
import android.app.Activity
import android.os.Bundle
import uca.iut.clermont.R
class FavoriteActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_favorite)
}
}

@ -0,0 +1,18 @@
package uca.iut.clermont.view
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import uca.iut.clermont.R
class FavoriteFragment: Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_favorite, container, false)
}
}

@ -0,0 +1,28 @@
package uca.iut.clermont.view
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import uca.iut.clermont.R
class HomeFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
/*val adapterMatches = findViewById<RecyclerView>(R.id.ListRecentsMatches)
with(adapterMatches) {
adapter = MatchesAdapter(manager.matchesMgr.getItems().toList().toTypedArray())
}
adapterMatches.layoutManager = LinearLayoutManager(this)*/
return inflater.inflate(R.layout.fragment_home, container, false)
}
}

@ -2,31 +2,27 @@ package uca.iut.clermont.view
import android.app.Activity import android.app.Activity
import android.os.Bundle import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager import androidx.navigation.NavController
import androidx.recyclerview.widget.RecyclerView import androidx.navigation.findNavController
import androidx.navigation.fragment.NavHostFragment
import uca.iut.clermont.R import uca.iut.clermont.R
import uca.iut.clermont.data.StubData import uca.iut.clermont.data.StubData
import uca.iut.clermont.view.adapter.MatchesAdapter
class HomeActivity : Activity() { class MainActivity : Activity() {
private var manager = StubData() private var manager = StubData()
private lateinit var navController: NavController
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home) setContentView(R.layout.activity_main)
//val imageFirstTeam = findViewById<ImageView>(R.id.ImageFirstTeam)
val adapterMatches = findViewById<RecyclerView>(R.id.ListRecentsMatches)
with(adapterMatches) { val navHostFragment = findNavController(R.id.fragment) as NavHostFragment
adapter = MatchesAdapter(manager.matchesMgr.getItems().toList().toTypedArray())
}
adapterMatches.layoutManager = LinearLayoutManager(this)
adapterMatches navController = navHostFragment.navController
//val imageFirstTeam = findViewById<ImageView>(R.id.ImageFirstTeam)
/*Glide.with(this) /*Glide.with(this)
.load("https://crests.football-data.org/1765.svg") .load("https://crests.football-data.org/1765.svg")
.error(R.drawable.imagenotfound) .error(R.drawable.imagenotfound)

@ -0,0 +1,20 @@
<?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=".view.MainActivity">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="409dp"
android:layout_height="729dp"
app:defaultNavHost="true"
app:navGraph="@navigation/my_nav"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -6,7 +6,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingHorizontal="30dp" android:paddingHorizontal="30dp"
android:paddingVertical="30dp" android:paddingVertical="30dp"
tools:context=".view.FavoriteActivity"> tools:context=".view.FavoriteFragment">
<LinearLayout <LinearLayout
android:id="@+id/exitContainer" android:id="@+id/exitContainer"

@ -5,7 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingHorizontal="30dp" android:paddingHorizontal="30dp"
tools:context=".view.HomeActivity"> tools:context=".view.HomeFragment">
<TextView <TextView
android:id="@+id/textViewTitle" android:id="@+id/textViewTitle"

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_nav"
app:startDestination="@id/homeFragment">
<fragment
android:id="@+id/homeFragment"
android:name="uca.iut.clermont.view.HomeFragment"
android:label="HomeFragment">
<action
android:id="@+id/action_homeFragment_to_favoriteFragment"
app:destination="@id/favoriteFragment" />
</fragment>
<fragment
android:id="@+id/favoriteFragment"
android:name="uca.iut.clermont.view.FavoriteFragment"
android:label="FavoriteFragment">
<action
android:id="@+id/action_favoriteFragment_to_homeFragment"
app:destination="@id/homeFragment" />
</fragment>
</navigation>
Loading…
Cancel
Save