android-jetpack

Replace Navigation View Item Ripple Effect

佐手、 提交于 2019-12-25 01:46:37
问题 I am attempting to replace what I thought was the default item background of the NavigationView . So I created a drawable to replace the background and applied it using the itemBackground attribute. background_navigation_view_item.xml <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/navigation_item_background_tint"> <item android:id="@android:id/mask" android:top="4dp" android:bottom="4dp" android:left="8dp" android:right="8dp"> <shape android:shape=

Android JetPack Navigation : How to open a fragment from an activity not associated with it?

岁酱吖の 提交于 2019-12-25 01:06:46
问题 scenario : MainActivity.kt : activity_main.xml contains my_nav_host_fragment in mobile_navigation.xml first_frag_dest is the startDestination and there is second_frag_dest also, with respective classes FirstFragment.kt and SecondFragment.kt . I have setup bottom navigation for switch between two fragments using the Android Jetpack Navigation components. When the Second Fragment is opened for the first time if FirbaseUser is null, A Welcome Activity is launched which is configured for

How to perform custom navigation?

我们两清 提交于 2019-12-24 12:13:15
问题 I try to using new architecture component called navigation. It's very thrilling and make lesser code than using FragmentManager . Now, I ended up in a case where I have 5 fragments with navigation looks like this: A -> B -> C -> D -> E Sometime I have to move user from fragment A directly to E and if back button pressed, I want something like this: E -> D -> C -> B -> A But what I got now is: E -> A Is there any approachable way to make it happen? 回答1: OK! if you want to go from E -> A then

Unable to initiate WorkManager from a separate process

落爺英雄遲暮 提交于 2019-12-24 11:21:55
问题 I'm using the WorkManager library(version: 1.0.0-alpha12). In my app I'm creating a new process using the below xml line in AndroidManifest. android:process=":myprocess" This is how I use the WorkManager: public static void startCheckStatusWorker() { WorkManager manager = WorkManager.getInstance(); String uniqueName = "check_status_worker"; PeriodicWorkRequest.Builder builder = new PeriodicWorkRequest.Builder(CheckStatusWorker.class, 1, TimeUnit.DAYS); builder.setConstraints(new Constraints

Toolbars Back button not working when using with navigation drawer

你说的曾经没有我的故事 提交于 2019-12-24 10:05:07
问题 Below is the code I have defined all my top level destinations with AppbarConfiguraion. class MainActivity : DaggerAppCompatActivity(), NavigationView.OnNavigationItemSelectedListener { lateinit var navController: NavController lateinit var binding: MainActivityBinding lateinit var appBarConfiguration: AppBarConfiguration override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = DataBindingUtil.setContentView(this, R.layout.activity_main) navController

How to change label attribute of a destination in navigation controller?

陌路散爱 提交于 2019-12-24 04:28:12
问题 I am trying to use navigation controller in Android as you can see in the image above, I set the label attribute of my destination to be 'Home'. and this label, will show like title in my toolbar. can I change that label programatically ? because I want to set my toolbar title dynamically. I have tried to change the toolbar title using toolbar.title = "some title here" but it will always be overlapped the title from that label. so how to solve this ? 回答1: Do it in your activity like below it

Android Jetpack Navigation - Custom Action with Drawer Item

可紊 提交于 2019-12-23 09:07:39
问题 I am using the new Jetpack Android Navigation in combination with a Drawer Layout. Everything is working as expected when using the same IDs in the Drawer XML in combination with Fragments in the Navigation Graph. I set everything up with: override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val navController = findNavController(R.id.navigation_host_fragment) setupActionBarWithNavController(navController, find(R.id.drawer_layout)) val navigationView =

Check if WorkRequest has been previously enquequed by WorkManager Android

笑着哭i 提交于 2019-12-22 03:43:55
问题 I am using PeriodicWorkRequest to perform a task for me every 15 minutes. I would like to check, if this periodic work request has been previously scheduled. If not, schedule it. if (!PreviouslyScheduled) { PeriodicWorkRequest dataupdate = new PeriodicWorkRequest.Builder( DataUpdateWorker.class , 15 , TimeUnit.MINUTES).build(); WorkManager.getInstance().enqueue(dataupdate); } Previously when I was performing task using JobScheduler, I used to use public static boolean isJobServiceScheduled

Manifest marge error after migrating to androidX

南楼画角 提交于 2019-12-22 00:13:14
问题 Recently I have dived into learning new andoirdX artefacts including Android Architecture Components. After reading through the officials docs and a google code samples I have successfully added the necessary dependencies in both my project and app level Gradle files. They are as follows dependencies { classpath 'com.android.tools.build:gradle:3.2.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:

How to make retrofit API call using ViewModel and LiveData

两盒软妹~` 提交于 2019-12-20 10:28:25
问题 this is the first time I'm trying to implement MVVM architecture, and I'm a bit confused about the correct way to make an API call. Currently, I'm just trying to make a simple query from the IGDB API, and output the name of the first item in a log. My activity is setup as follow: public class PopularGamesActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_popular_games);