mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-10 06:44:17 +00:00
add first iteration of activity with NavComponent and BottomNavigation
This commit is contained in:
parent
477cd77600
commit
7dfdad2f53
11 changed files with 122 additions and 13 deletions
|
@ -1,7 +1,7 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.50'
|
||||
ext.kotlin_version = '1.3.61'
|
||||
repositories {
|
||||
mavenLocal()
|
||||
google()
|
||||
|
@ -9,7 +9,7 @@ buildscript {
|
|||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.3'
|
||||
classpath 'com.android.tools.build:gradle:3.6.1'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jlleitschuh.gradle:ktlint-gradle:9.1.1"
|
||||
|
||||
|
|
|
@ -123,14 +123,14 @@ dependencies {
|
|||
|
||||
api 'androidx.appcompat:appcompat:1.1.0'
|
||||
|
||||
def lifecycle_version = "2.1.0"
|
||||
def lifecycle_version = "2.2.0"
|
||||
api "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
|
||||
api "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
|
||||
api "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
|
||||
|
||||
api 'androidx.recyclerview:recyclerview:1.1.0'
|
||||
|
||||
def roomVersion = "2.2.3"
|
||||
def roomVersion = "2.2.4"
|
||||
api "androidx.room:room-runtime:$roomVersion"
|
||||
kapt "androidx.room:room-compiler:$roomVersion"
|
||||
api "androidx.room:room-ktx:$roomVersion"
|
||||
|
@ -147,12 +147,12 @@ dependencies {
|
|||
|
||||
api 'commons-io:commons-io:2.4'
|
||||
|
||||
def appCenterSdkVersion = '2.2.0'
|
||||
def appCenterSdkVersion = '2.5.1'
|
||||
noFreeImplementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
|
||||
noFreeImplementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
|
||||
noFreeImplementation "com.microsoft.appcenter:appcenter-distribute:${appCenterSdkVersion}"
|
||||
|
||||
debugImplementation 'com.facebook.stetho:stetho:1.5.0'
|
||||
debugImplementation 'com.facebook.stetho:stetho:1.5.1'
|
||||
debugImplementation 'com.facebook.stetho:stetho-okhttp3:1.4.2'
|
||||
debugImplementation 'com.facebook.stetho:stetho-okhttp:1.4.2'
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0'
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
org.gradle.jvmargs=-XX\:MaxHeapSize\=2048m -Xmx1536m
|
||||
android.enableR8=true
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
|
|
|
@ -113,6 +113,8 @@ android {
|
|||
defaultConfig.testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
lintOptions.abortOnError false
|
||||
dataBinding.enabled = true
|
||||
viewBinding.enabled = true
|
||||
|
||||
testOptions.unitTests.includeAndroidResources = true
|
||||
|
||||
playConfigs {
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
android:pathPrefix="/c/"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".NavigationActivity"
|
||||
android:exported="true"/>
|
||||
<activity android:name=".browse.BrowseActivity">
|
||||
<meta-data
|
||||
android:name="android.app.searchable"
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package de.nicidienase.chaosflix.touch
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Conference
|
||||
import de.nicidienase.chaosflix.touch.browse.ConferencesTabBrowseFragment
|
||||
import de.nicidienase.chaosflix.touch.browse.streaming.LivestreamListFragment
|
||||
import de.nicidienase.chaosflix.touch.browse.streaming.StreamingItem
|
||||
|
||||
class NavigationActivity : AppCompatActivity(),
|
||||
ConferencesTabBrowseFragment.OnInteractionListener,
|
||||
LivestreamListFragment.InteractionListener {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_navigation)
|
||||
val bottomNavigationView = findViewById<BottomNavigationView>(R.id.bottom_navigation)
|
||||
val navController = findNavController(R.id.nav_host)
|
||||
bottomNavigationView.setupWithNavController(navController)
|
||||
}
|
||||
|
||||
override fun onConferenceSelected(conference: Conference?) {
|
||||
// TODO move navigation to fragment
|
||||
Log.d(TAG, "Should navigate to ${conference?.acronym}")
|
||||
}
|
||||
|
||||
override fun onStreamSelected(streamingItem: StreamingItem) {
|
||||
// TODO move navigation to fragment
|
||||
Log.d(TAG, "Should navigate to $streamingItem")
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val TAG = NavigationActivity::class.java.simpleName
|
||||
}
|
||||
}
|
|
@ -3,6 +3,8 @@ package de.nicidienase.chaosflix.touch.browse;
|
|||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -68,7 +70,14 @@ public class ConferencesTabBrowseFragment extends BrowseFragment {
|
|||
ConferenceGroupsFragmentPager fragmentPager = new ConferenceGroupsFragmentPager(this.getContext(), getChildFragmentManager());
|
||||
fragmentPager.setContent(conferenceGroups);
|
||||
binding.viewpager.setAdapter(fragmentPager);
|
||||
binding.viewpager.onRestoreInstanceState(getArguments().getParcelable(VIEWPAGER_STATE));
|
||||
Bundle arguments = getArguments();
|
||||
Parcelable viewpagerState = null;
|
||||
if (arguments != null) {
|
||||
viewpagerState = arguments.getParcelable(VIEWPAGER_STATE);
|
||||
if(viewpagerState != null){
|
||||
binding.viewpager.onRestoreInstanceState(viewpagerState);
|
||||
}
|
||||
}
|
||||
|
||||
binding.slidingTabs.setupWithViewPager(binding.viewpager);
|
||||
if (conferenceGroups.size() > 0) {
|
||||
|
@ -110,7 +119,7 @@ public class ConferencesTabBrowseFragment extends BrowseFragment {
|
|||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
getArguments().putParcelable(VIEWPAGER_STATE, binding.viewpager.onSaveInstanceState());
|
||||
// getArguments().putParcelable(VIEWPAGER_STATE, binding.viewpager.onSaveInstanceState());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -134,7 +134,7 @@ class EventDetailsFragment : androidx.fragment.app.Fragment() {
|
|||
viewModel.getBookmarkForEvent(guid)
|
||||
.observe(viewLifecycleOwner, Observer { watchlistItem: WatchlistItem? ->
|
||||
this.watchlistItem = watchlistItem
|
||||
listener?.invalidateOptionsMenu()
|
||||
activity?.invalidateOptionsMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ class EventDetailsFragment : androidx.fragment.app.Fragment() {
|
|||
R.id.action_unbookmark -> {
|
||||
viewModel.removeBookmark(event.guid)
|
||||
watchlistItem = null
|
||||
listener?.invalidateOptionsMenu()
|
||||
activity?.invalidateOptionsMenu()
|
||||
return true
|
||||
}
|
||||
R.id.action_download -> {
|
||||
|
@ -234,7 +234,6 @@ class EventDetailsFragment : androidx.fragment.app.Fragment() {
|
|||
|
||||
interface OnEventDetailsFragmentInteractionListener {
|
||||
fun onToolbarStateChange()
|
||||
fun invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
26
touch/src/main/res/layout/activity_navigation.xml
Normal file
26
touch/src/main/res/layout/activity_navigation.xml
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_host"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/bottom_navigation"
|
||||
app:defaultNavHost="true"
|
||||
app:navGraph="@navigation/main_navigation"/>
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/bottom_navigation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:menu="@menu/bottom_nav"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
24
touch/src/main/res/menu/bottom_nav.xml
Normal file
24
touch/src/main/res/menu/bottom_nav.xml
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@+id/conferencesTabBrowseFragment"
|
||||
android:icon="@drawable/ic_video_archive"
|
||||
android:title="@string/recordings"/>
|
||||
<item
|
||||
android:id="@+id/livestreamListFragment"
|
||||
android:icon="@drawable/ic_camera"
|
||||
android:title="@string/livestreams"/>
|
||||
<!-- <item-->
|
||||
<!-- android:id="@+id/nav_bookmarks"-->
|
||||
<!-- android:icon="@drawable/ic_bookmark"-->
|
||||
<!-- android:title="@string/bookmarks"/>-->
|
||||
<!-- <item-->
|
||||
<!-- android:id="@+id/nav_inprogress"-->
|
||||
<!-- android:icon="@android:drawable/ic_media_play"-->
|
||||
<!-- android:title="@string/continue_watching"/>-->
|
||||
<item
|
||||
android:id="@+id/downloadsListFragment"
|
||||
android:icon="@drawable/ic_download_dark"
|
||||
android:title="Downloads"/>
|
||||
</menu>
|
|
@ -17,10 +17,19 @@
|
|||
android:id="@+id/eventDetailsFragment"
|
||||
android:name="de.nicidienase.chaosflix.touch.eventdetails.EventDetailsFragment"
|
||||
android:label="EventDetailsFragment"
|
||||
tools:layout="@layout/fragment_event_details"/>
|
||||
tools:layout="@layout/fragment_event_details">
|
||||
<argument
|
||||
android:name="event"
|
||||
app:argType="de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/livestreamListFragment"
|
||||
android:name="de.nicidienase.chaosflix.touch.browse.streaming.LivestreamListFragment"
|
||||
android:label="LivestreamListFragment"
|
||||
tools:layout="@layout/fragment_livestreams"/>
|
||||
<fragment
|
||||
android:id="@+id/downloadsListFragment"
|
||||
android:name="de.nicidienase.chaosflix.touch.browse.download.DownloadsListFragment"
|
||||
android:label="DownloadsListFragment"
|
||||
tools:layout="@layout/fragment_downloads"/>
|
||||
</navigation>
|
Loading…
Reference in a new issue