dynamic added to navigationView add the fragment movies maybe add a generic fragmentfeatures/retrofit/1
parent
48273833cc
commit
5a174fc2f6
@ -1,23 +1,63 @@
|
||||
package fr.iut.pm.movieapplication.ui.activity
|
||||
|
||||
import android.os.Build
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
import fr.iut.pm.movieapplication.R
|
||||
import fr.iut.pm.movieapplication.ui.fragments.HomeSectionsFragment
|
||||
import fr.iut.pm.movieapplication.ui.fragments.MoviesFragment
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
loadFragments(HomeSectionsFragment(this))
|
||||
|
||||
val navigationView = findViewById<BottomNavigationView>(R.id.navigation_view)
|
||||
navigationView.setOnItemSelectedListener {
|
||||
when(it.itemId)
|
||||
{
|
||||
R.id.home_page -> {
|
||||
loadFragments(HomeSectionsFragment(this))
|
||||
return@setOnItemSelectedListener true
|
||||
}
|
||||
|
||||
R.id.movies_page -> {
|
||||
loadFragments(MoviesFragment(this))
|
||||
return@setOnItemSelectedListener true
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
/*
|
||||
//Trends fragment injected in main activity
|
||||
val transaction = supportFragmentManager.beginTransaction()
|
||||
transaction.replace(R.id.trends_section_container, HomeSectionsFragment())
|
||||
transaction.replace(R.id.fragment_container, HomeSectionsFragment())
|
||||
transaction.addToBackStack(null)
|
||||
transaction.commit()
|
||||
*/
|
||||
if(Build.VERSION.SDK_INT < 33) {
|
||||
// Hide the status bar.
|
||||
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
// Remember that you should never show the action bar if the
|
||||
// status bar is hidden, so hide that too if necessary.
|
||||
actionBar?.hide()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//val bottomNavigationView = findViewById<BottomNavigationView>(R.id.navigation_view)
|
||||
|
||||
}
|
||||
|
||||
private fun loadFragments(fragment: Fragment) {
|
||||
val transaction = supportFragmentManager.beginTransaction()
|
||||
transaction.replace(R.id.fragment_container, fragment)
|
||||
transaction.addToBackStack(null)
|
||||
transaction.commit()
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package fr.iut.pm.movieapplication.ui.adapter
|
||||
|
||||
import android.graphics.Rect
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
class CategoryItemDecoration : RecyclerView.ItemDecoration() {
|
||||
|
||||
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
|
||||
outRect.bottom = 50
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:angle="0"
|
||||
android:startColor="@color/dark_blue"
|
||||
android:endColor="@color/light_blue"
|
||||
android:type="linear" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@+id/home_page"
|
||||
android:title="@string/bottom_home_item"
|
||||
android:icon="@drawable/ic_home"
|
||||
/>
|
||||
<item
|
||||
android:id="@+id/movies_page"
|
||||
android:title="@string/bottom_movies_item"
|
||||
android:icon="@drawable/ic_movie"
|
||||
/>
|
||||
<item
|
||||
android:id="@+id/series_page"
|
||||
android:title="@string/bottom_series_item"
|
||||
android:icon="@drawable/ic_tv_shows"
|
||||
/>
|
||||
<item
|
||||
android:id="@+id/artist_page"
|
||||
android:title="@string/bottom_artist_item"
|
||||
android:icon="@drawable/ic_baseline_star_border_24"/>
|
||||
</menu>
|
Loading…
Reference in new issue