From fc2156374611421c242ff7d65315f52fe57ceecf Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Mon, 31 May 2021 15:15:39 +0200 Subject: Adding the base of bottom navigation. Also changing the the prev and next button for top manga --- .../presentation/view/activity/MainActivity.kt | 30 +++++++++++++++++++- .../presentation/view/fragment/TopMangaFragment.kt | 5 ---- app/src/main/res/drawable/ic_home_black_24dp.xml | 9 ++++++ app/src/main/res/layout/activity_main.xml | 32 ++++++++++++++++++++-- app/src/main/res/layout/content_main.xml | 2 +- app/src/main/res/layout/top_manga_page.xml | 16 ++++------- app/src/main/res/menu/bottom_nav_menu.xml | 19 +++++++++++++ app/src/main/res/navigation/mobile_navigation.xml | 25 +++++++++++++++++ app/src/main/res/values/strings.xml | 8 ++++-- 9 files changed, 123 insertions(+), 23 deletions(-) create mode 100644 app/src/main/res/drawable/ic_home_black_24dp.xml create mode 100644 app/src/main/res/menu/bottom_nav_menu.xml create mode 100644 app/src/main/res/navigation/mobile_navigation.xml (limited to 'app/src') diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/view/activity/MainActivity.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/view/activity/MainActivity.kt index 3a50028..4a3b08b 100644 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/view/activity/MainActivity.kt +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/view/activity/MainActivity.kt @@ -2,14 +2,42 @@ package xyz.adjutor.aniki.presentation.view.activity import android.os.Bundle import androidx.appcompat.app.AppCompatActivity +import androidx.navigation.NavController +import androidx.navigation.fragment.NavHostFragment +import androidx.navigation.ui.AppBarConfiguration +import androidx.navigation.ui.setupActionBarWithNavController +import androidx.navigation.ui.setupWithNavController +import com.google.android.material.bottomnavigation.BottomNavigationView import xyz.adjutor.aniki.R +import xyz.adjutor.aniki.databinding.ActivityMainBinding + class MainActivity : AppCompatActivity() { + private lateinit var binding: ActivityMainBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) + + binding = ActivityMainBinding.inflate(layoutInflater) + setContentView(binding.root) + + val navView: BottomNavigationView = binding.navView + + val navHostFragment = + supportFragmentManager.findFragmentById(R.id.nav_host_fragment_activity_main) as NavHostFragment + val navController: NavController = navHostFragment.navController + // Passing each menu ID as a set of Ids because each + // menu should be considered as top level destinations. + val appBarConfiguration = AppBarConfiguration( + setOf( + R.id.navigation_home, R.id.navigation_manga, R.id.navigation_anime + ) + ) setSupportActionBar(findViewById(R.id.toolbar)) + setupActionBarWithNavController(navController, appBarConfiguration) + navView.setupWithNavController(navController) + + } } \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/view/fragment/TopMangaFragment.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/view/fragment/TopMangaFragment.kt index 7821e50..eb76e86 100644 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/view/fragment/TopMangaFragment.kt +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/view/fragment/TopMangaFragment.kt @@ -6,7 +6,6 @@ import android.view.View import android.view.ViewGroup import android.widget.Button import androidx.fragment.app.Fragment -import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout @@ -38,10 +37,6 @@ class TopMangaFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - //button to return to the home page - view.findViewById