android-jetpack

How to navigate from nested Fragment to parent fragment using Jetpack Navigation?

烈酒焚心 提交于 2019-12-10 16:48:04
问题 I have main navigation: SplashFragment -> RegistrationFragment -> RootFragment <fragment android:id="@+id/splashFragment" android:name="com.low6.low6.features.splash.SplashFragment" android:label="Splash" tools:layout="@layout/fragment_splash" > <action android:id="@+id/action_next" app:clearTask="true" app:destination="@id/registrationFragment" /> </fragment> <fragment android:id="@+id/registrationFragment" android:name="com.low6.low6.features.registration.RegistrationFragment" android:label

Navigation Architecture Fragment Reload Problem

给你一囗甜甜゛ 提交于 2019-12-10 16:46:22
问题 I am using Navigation Architecture in an image gallery, when I go from fragment A to B and then return back to A, these 3 methods are called again which will cause my gallery to reload , where I should load my data in fragment so when I come back from B to A my methods don't get called? : OnCreateView OnViewCreated OnResume 回答1: The fragment's lifecycle methods anyway will called again. You can google it how to work with fragment or activity lifecycle. The main idea how to deal with lifecycle

DatePickerDialog has blacked out buttons in androidx.fragment.app.DialogFragment

梦想的初衷 提交于 2019-12-10 16:25:50
问题 This simple class: class DateSelectionDialogFragment : DialogFragment() { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { val calendar = Calendar.getInstance() val year = calendar.get(Calendar.YEAR) val month = calendar.get(Calendar.MONTH) val dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH) return DatePickerDialog(requireContext(), this, year, month, dayOfMonth) } } results in strangely behaving buttons. What's important I didn't specify any style for the dialog. The

Why addDefaultArguments() removed from Navigation Component version 1.0.0-alpha09? What is WorkAround to pass arg to StartDestination from Activity?

谁说我不能喝 提交于 2019-12-10 15:13:37
问题 Hello i am working on Navigation Architecture Component and i and setting up NavHostFragment for my Activity programatically. MainActivity.xml : <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.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=".MainActivity">

Pass data back to previous fragment using Android Navigation

元气小坏坏 提交于 2019-12-10 13:35:17
问题 I've started using Android Architecture Components (Navigation and Safe Args, View Models) along with Koin library. Currently, I've got a problem with passing arguments between two fragments - I need to pass a string value from fragment A to fragment B, modify this value in fragment B and pass it back to fragment A. I've found one possible solution to my problem - shared view models. Unfortunately, this approach has one problem because I can pass and modify values between screens, but when

Room TypeConverter for map

雨燕双飞 提交于 2019-12-10 11:03:46
问题 How would you write TypeConverter for Map? My approach was to do it by Moshi class Converters() { val moshi = Moshi .Builder() .add(KotlinJsonAdapterFactory()) .build() val mapOfStringsType = Types.newParameterizedType(Map::class.java, String::class.java, String::class.java) val mapOfStringsAdapter = moshi.adapter<Map<String, String>>(mapOfStringsType) @TypeConverter fun stringToMap(data: String): Map<String, String> { return mapOfStringsAdapter.fromJson(data).orEmpty() } @TypeConverter fun

Note: Failed to read get kotlin metadata for …etc, and type converter

孤街醉人 提交于 2019-12-10 03:26:46
问题 after add room db dependencies and configuring it with my app, I got several errors, most of it is Failed to read get kotlin metadata for... although I do not use kotlin in my project, the second error is about TypeConverter for the variable private List<String> labels; I doing some search for how to add List or ArrayList as a TypeConverter but I didn't found soultion for that > Task :app:processDebugAnnotationsWithJavac D:\Courses\Java\Android Projects\ProCSIS\app\src\main\java\www\pro_cs_is

How to convert a List<Object> to PagedList<Object> and vice-versa?

非 Y 不嫁゛ 提交于 2019-12-10 01:02:35
问题 PagedList<Object> is used for Android's cool paging library. To make the question as minimal as possible : If i have a list of strings like List<String> stringList; // it consists of 200 strings I want to convert stringList to type PagedList<String> like PagedList<String> pagedStringList; And also if i have a PagedList<Object> how can convert it to a List<Object> ? I went through this for reference If i try the other way round .... How can I convert List<Object> into DataSource.Factory

Android Jetpack Navigation library and onActivityResult

天涯浪子 提交于 2019-12-09 15:44:28
问题 I'm trying to migrate an app to the new Navigation Architecture Component that was announced at GoogleIO'18 Suppose I need to use an activity that is normally started with startActivityForResult . This activity comes either from a library or a system activity, so I can't modify it. Is there any way to include this activity as a destination in the navigation graph and get results from it? 回答1: The only solution I have so far is to wrap that activity behind a fragment that catches the result

Shared ViewModel to help communication between fragments and parent activity

我的梦境 提交于 2019-12-09 06:29:20
问题 While Navigation component of JetPack looks pretty promising I got to a place where I could not find a way to implement something I wanted. Let's take a look at a sample app screen: The app has one main activity, a top toolbar, a bottom toolbar with fab attached. There are 2 challenges that I am facing and I want to make them the right way. 1. I need to implement fragment transactions in order to allow replacing the fragment on the screen, based on the user interaction. There are three ways I