Category : kotlin

I’m a beginner tiring to develop a app in kotlin using laravel/sanctum api. Right now i stock in login, because all time that i try to call LARAVEL_URL ="http://10.0.2.2/venturiAPI/public/api/login" MainActivity.kt mServiceV.login(email,password,deviceName).enqueue(object : Callback<String>{ override fun onResponse(call: Call<String>, response: Response<String>) { Log.d("ErrorBody response", response.errorBody().toString()) Log.d("Body response", response.body().toString()) Log.d("Raw response", response.raw().toString()) Log.d("message response", response.message()) Log.d("Headers response", response.headers().toString()) ..

Read more

I’m creating an audiobook player, and I’m using MediaSessionCompat related classes to handle notifications. My code is heavily inspired by the android-MediaBrowserService samples ( https://github.com/googlearchive/android-MediaBrowserService ), and i’m not quite understanding it all for the moment ( the createContentIntent espicially ) Here is my simple class in charge of building notifications from a bookPlayer providing ..

Read more

What is the difference between OnConflictStrategy.ABORT and OnConflictStrategy.IGNORE in Room Database? ABORT: roll back the transaction on conflict IGNORE: keep the existing rows I know both of them won’t add a new row when there is an existed row. what is really the difference between these? In What case we must use them? Source: Android ..

Read more

In my app i have one activity with two fragment, the app has a toolbar with search action, that search action must be visible only in the second fragment. So how could i hide the search button and show it only when i’m in fragment2? My menu.xml looks like this: <menu 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" tools:context="it.gabtamagnini.visualstock.MainActivity"> ..

Read more

I wanna remove item from viewpager2 adapter but when notify adapter(FragmentStateAdapter) activity crashed and give bellow error: java.lang.IndexOutOfBoundsException: Index: 36, Size: 36 at java.util.ArrayList.get(ArrayList.java:437) at com.libramee.ui.category.adapter.CategoryPagerAdapter.remove(CategoryPagerAdapter.kt:61) at com.libramee.ui.home.fragment.HomeFragment$observe$2.onChanged(HomeFragment.kt:218) at com.libramee.ui.home.fragment.HomeFragment$observe$2.onChanged(HomeFragment.kt:45) HomeFragment.kx: deleteCategoryLiveData?.observe(viewLifecycleOwner, Observer { if (it.status == Response.Status.SUCCESS){ adapter?.remove(it.message ?:"") } }) CategoryPagerAdapter.kx class CategoryPagerAdapter(fragment: Fragment, var categoryFragments: ArrayList<Fragment>) : FragmentStateAdapter(fragment) { override fun getItemCount(): ..

Read more