• Breaking News

    Saturday, October 16, 2021

    Android Dev - Jetpack Compose: Drag-and-drop reorder for lists

    Android Dev - Jetpack Compose: Drag-and-drop reorder for lists


    Jetpack Compose: Drag-and-drop reorder for lists

    Posted: 16 Oct 2021 05:29 AM PDT

    Do I understand "withContext" correctly?

    Posted: 16 Oct 2021 12:37 AM PDT

    Say I have a LoginActivity, and calls 2 APIs (login and get current news) inside that. Here's the rough code:

    ApiInterface.kt

    interface ApiInterface { // Login u/POST("/v1/user/login") suspend fun login(@Body requestBody: RequestBody): Response<ResponseBody> // Get current news u/GET("/v1/news/list") suspend fun getNewsList(): Response<ResponseBody> } 

    ApiUtil.kt

    class ApiUtil { companion object { var API_BASE_URL = "https://localhost:8084/testApi" fun createService() : ApiInterface { val retrofit = Retrofit.Builder() .addConverterFactory(GsonConverterFactory.create()) .baseUrl(API_BASE_URL) .build() return retrofit.create(ApiInterface::class.java) } } suspend fun login(userParam: UserParam): String? { val gson = Gson() val json = gson.toJson(userParam) val requestBody = json.toString().toRequestBody("application/json".toMediaTypeOrNull()) val response = createService().login(requestBody) return if (response.isSuccessful){ val gson = GsonBuilder().setPrettyPrinting().create() gson.toJson( JsonParser.parseString( response.body() ?.string() ) ) } else { Log.e("RETROFIT_ERROR", response.code().toString()) return "err" } } suspend fun getNews(): List<News>{ var newsList = listOf<News>() val response = createService().getNewsList() if (response.isSuccessful){ val gson = GsonBuilder().create() remittanceList = gson.fromJson(response.body()?.string(),Array<RemittanceItem>::class.java).toList() } return remittanceList } } 

    LoginActivity.kt

    btnLogin.setOnClickListener { val api = ApiUtil() val userParam = UserParam(edtUserName.text.toString(), edtPassword.text.toString()) lifecycleScope.launch(Dispatchers.IO) { // hit login API val loginResponse = JSONObject(api.login(userParam)) // hit get news API val getNewsResponse = api.getNewsList() withContext(Dispatchers.Main) { if (loginResponse.getString("message").equals("OK")) val ii = Intent(this@LoginActivity, HomeActivity::class.java) startActivity(ii) } } } } 

    The `startActivity` is called inside `withContext` block. So, that means wait for both APIs to be completed first, and after that execute `startActivity` ?

    submitted by /u/anta40
    [link] [comments]

    Spazes : [Since you can't search for spaces on the Twitter app, I made an app to do that!] Spazes is an android application that allows users to search twitter spaces and join in.

    Posted: 16 Oct 2021 04:17 AM PDT

    How to use sealed interfaces in Android?

    Posted: 16 Oct 2021 08:03 AM PDT

    Hello,

    Basically the title. I have upgraded kotlin to 1.5.30, then grade to 7, then tried to use JDK 17, and then I broke my code and can't compile at all. I have tried for whole day other stuff on internet, but couldn't manage.

    Perhaps someone can help me? Thanks a lot!

    submitted by /u/developroper
    [link] [comments]

    Did anyone else notice a sudden drop in downloads around June 21 this year?

    Posted: 16 Oct 2021 07:45 AM PDT

    All of our apps have seen massive drops in downloads on June 21 this year, and we struggle to find any reason for that: no algorithm change anyone talks about, and no other developer I know seems to be impacted... no posts on this sub either around that date (or I have missed them). Surely we can't be the only ones?

    What's really weird is that our ranking on App Annie is still fairly good. From the top 100 of our category, 3 of the apps are ours. Yet their downloads have dropped to less than 100 per day (used to be 4k+). It doesn't make much sense. Does anyone have any ideas?

    submitted by /u/Daiymas
    [link] [comments]

    DataBinding generated classes

    Posted: 16 Oct 2021 07:16 AM PDT

    I wondering why DataBinding still generating classes in Java, not Kotlin! Could I configure DataBining to generate Kotlin classes instead?

    submitted by /u/sh3lan93
    [link] [comments]

    Insults apparently don't violate the Google Play Comment posting policy

    Posted: 15 Oct 2021 01:19 PM PDT

    Here is the user comment:

    Very bad, it does not work. When I finish the document, lines and spaces are skipped. As well as asking you to download an Acrobat add-on. Honestly, IT'S A DISGUSTING APP. The creator should be admitted to a mental institution ...

    I reported the review and received the following:

    Your request to remove this review was unsuccessful because it doesn't violate the Google Play Comment posting policy

    The gloves are off.

    submitted by /u/Present-Effective-52
    [link] [comments]

    Stressing memory on any android device

    Posted: 15 Oct 2021 03:43 PM PDT

    Hey folks, just published an article on how in android you can create/reproduce memory pressure situations on any device and some interesting things which I noted while this analysis. Have a read here: https://www.amanjeet.me/stressing-memory-on-android/

    Let me know about your suggestions, reviews, feedback around this.

    submitted by /u/amanjeetsingh150
    [link] [comments]

    Jetpack Compose - Learn with code

    Posted: 16 Oct 2021 01:59 AM PDT

    https://proandroiddev.com/learn-with-code-jetpack-compose-playing-media-part-3-3792bdfbe1ea

    Hi guys, if you want to explore Jetpack Compose - checkout my latest article in the compose series! Would love to get your feedback on the same. Last but not the least, if you liked the article don't forget to clap and follow me :)

    submitted by /u/rubenquadros95
    [link] [comments]

    Google Admob account got unrightfully suspended

    Posted: 15 Oct 2021 10:17 AM PDT

    10 days ago I published my first game on Google play. In it I used Google admob for ads. 3 days ago I got an e-mail, stating that my admob account got suspended. In the email i got cited this as the reason for suspention: We do not allow content that:

    helps users to mislead others.

    promotes any form of hacking or cracking and/or provides users with instructions or equipment that tampers with or provides unauthorised access to software, servers or websites.

    I was very confused, since I only use my account for my at that time a week old game. My game does not in any way do any of the things it's accused of. It is a small casual game, where you destroy meteors before they hit your planet. It's the same as if a game like 2048 got accused of the same thing. In the email I recieved no proff or explanation of what I'm supposed to fix to get my account unsuspended. Mind that my game was still up and running on Play store and even had in app purchases enabled, which I assumee means that Google has no problem with it, since if it would break the same policy that my admob account broke, it would at least get a warning. Another thing that was weird was that I never got a warning for breaking this admob policy. On their official website it states that for this violation you get a 7 day warning before you get suspended. I never got that, just a sudden suspention.

    That same day that my account got suspended I made an appeal, since I was sure that it was a mistake. Well, today I got a response, stating that my account got canceled. I am even more confused then before. They said that the appeal got reviewed by their policy specialist, but if that were true, they would see that I did not do anything that breaks the policy. Note that my game is still up on store and runs like it should, besides getting no ads. I got no explanation or proff that I did anything wrong, beside the 2 points I have cited above.

    What am I supposed to do? I can appeal again in 90 days, but thats far away and I still don't know what I did wrong. I also assume that that appeal would be the final decision and I don't want to mess it up. Any help would be appreciated.

    submitted by /u/sickboi12
    [link] [comments]

    How to "highlight to make the user aware of an action and show a description of it" in XML/Kotlin?

    Posted: 15 Oct 2021 05:06 PM PDT

    How to "highlight to make the user aware of an action and show a description of it" in XML/Kotlin?

    Hello everyone. This is my first post here, so apologies in advance for any mistakes. I don't know to describe exactly this kind of pattern in UI, so I just show a image of it that I found in an app.

    https://preview.redd.it/4tttxq5sdpt71.jpg?width=720&format=pjpg&auto=webp&s=f26abee869ad181e7b931194043d167386846ef4

    In this app, there is a kind of in-app tutorial where buttons have that orange highlight around them and it has a description of what the buttons do when clicked. I want to know how to do that, and in such case what is the name for it. Is there any library that makes it easy to develop something like that?

    submitted by /u/Xammm
    [link] [comments]

    Any idea how to clear room databases located in multiple feature modules?

    Posted: 15 Oct 2021 01:03 PM PDT

    I have a feature-based project, and each module contains its own database and daos and entities, one of the modules (account) will allow to logout and then I'm gonna need to clear all the databases, but I can't seem to figure out how to do that since modules are independent of each other.

    I thought about having an extra module that has dependency on all of them do that, but then it needs to be triggered somehow and that always would result in a circular dependency since account would also need to depend on it to trigger the deletion

    I need some idea if anyone has done that before, or is the idea of having independent room data does not work for this. thanks

    submitted by /u/dotcomslashwhatever
    [link] [comments]

    Does anyone encounter wrong File.getCanonicalPath from Android 11 device?

    Posted: 15 Oct 2021 12:09 PM PDT

    Hi all,

    I was wondering, have anyone of you, encounter wrong File.getCanonicalPath from Android 11 device?

    I am not able to reproduce the problem. But from the crash report and logging at live app, I am pretty confirm File.getCanonicalPath doesn't behave correctly, in Android 11 device, sometimes.

    final String destDirectory = "/storage/emulated/0/Android/data/org.yccheok.jstock.gui/files/1.0.7/"; final String name = "Austria/database/stock-info-database.csv"; final File destination = new File(destDirectory, name); /* canonicalPath is /storage/emulated/0/android/data/org.yccheok.jstock.gui/files/1.0.7/Austria/database/stock-info-database.csv */ final String canonicalPath = destination.getCanonicalPath(); 

    For the above case, the correct expected canonicalPath suppose to be

    /storage/emulated/0/Android/data/org.yccheok.jstock.gui/files/1.0.7/Austria/database/stock-info-database.csv 

    However, for unknown reason, some Android 11 devices are returning (Take note on the lower case "android")

    /storage/emulated/0/android/data/org.yccheok.jstock.gui/files/1.0.7/Austria/database/stock-info-database.csv 

    I was wondering, do you encounter some behaviour too? Do you have any workaround to resolve such issues?

    I have filed a bug report https://issuetracker.google.com/issues/203115488 . Kindly feel free to upvote it, if that impacts you.

    Thank you.

    submitted by /u/yccheok
    [link] [comments]

    how can i make this chart? xml&java

    Posted: 15 Oct 2021 03:03 PM PDT

    Hosting my app admin panel on a server?

    Posted: 15 Oct 2021 05:48 PM PDT

    I'm working with an app developer who is creating my app on Android and iOS, and have made an admin panel where data is stored and also so that I can make updates to the app (adding new features and categories, etc).

    I will be given login credentials that I can change, but what should I look out for? Simply changing the password means it is now mine and only I can access it?

    Also, the app currently is kinda slow because apparently they are using a free server, so once they hand it over, I will need to host the admin panel on a new server? How do I go about doing this?

    Would be great if someone can explain this because as you can tell I'm kinda confused, or point me in the right direction - I'm keen to get a better understanding here.

    submitted by /u/Langlu
    [link] [comments]

    How do we change the Button color, text dynamically with Jetpack compose

    Posted: 15 Oct 2021 08:40 PM PDT

    My app pulls data from my website api. How can I get the language translated data when someone has a language other than English in their device?

    Posted: 15 Oct 2021 11:54 AM PDT

    My app pulls certain data like descriptions from my website api. My website can be localized but I'm wondering how I can get my app to pull in the right language from the website side. Even something simple like a privacy policy for example? TYIA

    submitted by /u/Necessary1OK
    [link] [comments]

    Second display

    Posted: 15 Oct 2021 05:37 PM PDT

    Is there any way to use a phone as a second display for a school chrome book without installing any app on the chrome book. Is it possible to just use something like adb to send display data. (Hp 11 g8 we) I can access adb on the chrome book

    submitted by /u/calebgameryt
    [link] [comments]

    How can I make custom options for each sub category like Amazon in Firestore?

    Posted: 15 Oct 2021 10:45 AM PDT

    This is my data structure

    categories (collection) | --- mainCategoryId (document) | --- mainCategoryName (field -> string) (value -> Cars) --- image (field -> string) (value -> https://...) --- numberOfPosts (field -> number) (value -> 281) --- subCategories (sub-collection) | --- subCategoryId (document) | --- subCategoryName (field -> string) (value -> Cars For Sale) --- image (field -> string) (value -> https://...) --- numberOfPosts (field -> number) (value -> 81) --- subCategoryId (document) | --- subCategoryName (field -> string) (value -> Car Rental) --- image (field -> string) (value -> https://...) --- numberOfPosts (field -> number) (value -> 200) 

    The custom options for this sub category (Cars For Sale)

    01- Car Make (Audi) (BMW) (Toyota) (Ford) (etc...) 02- Model -> Depending on car make for example Ford company (E-350) (F-150) (F-250) (F-350) (etc...) 03- Year (From) (To) 04- Price (From) (To) 05- Condition (Used) (New) 06- Kilometers (1 - 9,999) (10,000 - 19,999) (20,000 - 29,999) (30,000 - 39,999) (etc...) 07- Transmission (Automatic) (Manual) 08- Fuel (Gasoline) (Diesel) (Hybrid) (Electric) (etc...) 09- Car Options (Sunroof) (Electric Mirrors) (Touch Screen) (Keyless Entry) (etc...) 10- Car License (Licensed) (No Licensed) 11- Insurance (Compulsory Insurance) (Comprehensive Insurance) (Not Insured) 12- Color (Red) (Blue) (Yellow) (Green) (etc...) 13- Payment Method (Cash Only) (Installments Only) (Cash or Installments) 

    The custom options for this sub category (Car Rental)

    01- Car Make (Audi) (BMW) (Toyota) (Ford) (etc...) 02- Model -> Depending on car make for example Ford company (E-350) (F-150) (F-250) (F-350) (etc...) 03- Year (From) (To) 04- Price (From) (To) 05- Transmission (Automatic) (Manual) 06- Fuel (Gasoline) (Diesel) (Hybrid) (Electric) (etc...) 07- Rental period (Daily) (Weekly) (Monthly) (Yearly) 08- Color (Red) (Blue) (Yellow) (Green) (etc...) 

    I have a search box but it's not advanced, I want to improve it and make it working with customization so I want to show options depending on sub category but the problem is how can I make these options in Firestore, What is the best data structure to do this?

    submitted by /u/DismalCall5534
    [link] [comments]

    Help with Android Studio creating asset folder

    Posted: 15 Oct 2021 10:16 AM PDT

    I'm going nuts here I cannot seem to do something that is seemingly easy and straight forward...

    when I'm trying to create an asset folder I go to the " new " " folder " but ALL the options are totally grayed out, I have no idea what-so-ever I'm doing wrong here and It's driving me bananas I looked this up online and evidently I'm the only one who has faced this issue

    submitted by /u/Roger_Smith93
    [link] [comments]

    Can not start any side project because of fear of imperfection

    Posted: 15 Oct 2021 09:36 AM PDT

    I feel bad because I look sample codes on github. Then I look at my code. After that my codebase looks terrible. How do people on github learn to code like this. Skydoves is one of these people. I dont know where to start. Thanks for any help or suggestion.

    submitted by /u/mobile_deve
    [link] [comments]

    No comments:

    Post a Comment