Aug 14 | 8:55 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Aryan | has entered the room |
Aryan |
Hi
|
Aug 14 | 9:00 AM |
Mark M. |
hello, Aryan!
|
Mark M. |
how can I help you today?
|
Aryan |
I contacted you few weeks ago on mail. let me show you our chat (a glimpse) so that you can get the idea.
|
Aryan |
Leave that !. I had to search
|
Aryan |
Well I am a huge fan of yours. And you are the best guy I can ever find in Android.
|
Mark M. |
um, thanks! I try to be useful
|
Aryan |
So, today I am going to ask you some questions which are not related to the Android Development but you.
|
Aryan |
How do you remember the names of all methods and classes in Android?
|
Mark M. |
I don't -- there are far too many
|
Aryan |
Ok. But I see your answers on SO, and seems like there is no field in Android that you are unaware of.
|
Mark M. |
well, there are lots of things in Android that I haven't touched
|
Aryan |
Did you get the screenshot I attached ?
|
Aryan |
I can't see that.
|
Mark M. |
I do not know what screenshot it is that you are referring to
|
Aryan | |
Mark M. |
ah, there it is!
|
Aryan |
Just sent that
|
Aryan |
Please read it once
|
Mark M. |
I did
|
Aryan |
OK. I think you got me.
|
Aug 14 | 9:05 AM |
Mark M. |
so I am happy to help you here with Android app development questions
|
Aryan |
Well, my next question is: how to master Android Development just like you? How did you do that?
|
Aryan |
Ok. Coming to bit technical stuffs here then.
|
Mark M. |
um, well, it's taken 10 years to get where I am now
|
Aryan |
Hopefully I can also reach at that place.
|
Aryan |
Ok. I want to know how to obfuscate your app code just like big apps (Facebook, Google etc) does.
|
Mark M. |
I don't obfuscate code, so I have little practical experience in the area
|
Aryan |
I did proguard but it seems to change only the names of variables.
|
Mark M. |
it will change the names of classes and methods that it is allowed to change
|
Aryan |
View paste
|
Mark M. |
ProGuard only changes what it is allowed to change, based on the ProGuard configuration files
|
Mark M. |
so, for example, it will tend to leave activities alone
|
Aryan |
OK. I got that. Do you also know anything more to obfuscate the code bit more?
|
Mark M. |
adjust the ProGuard configuration files
|
Mark M. |
buy a copy of DexGuard, perhaps
|
Mark M. |
again, I don't obfuscate code, so I have little practical experience in the area
|
Aryan |
Thanks for the tip. I can see there are various apps like Whatsapp (moded ones), how anyone can do that? They literally can play with the app code, by adding their names, their own screens in the app and change the functionality of the app. Do you know how do they do that?
|
Aug 14 | 9:10 AM |
Mark M. |
since I do not engage in distributing pirated or hacked apps, I have little practical experience in this area
|
Aryan |
Ok.
|
Aryan |
I can also see some apps like Snaptube which allows you to download youtube videos, what kind of library or anything else do they use? Do you have some ideas?
|
Mark M. |
I have no idea, though you might hunt up the code to the youtube-dl Linux app and see what they do
|
Aryan |
Alright.
|
Hazi c. | has entered the room |
Mark M. |
let me take a question from Hazi, and I'll return to you shortly
|
Mark M. |
Hazi: welcome to the chat! do you have a question?
|
Aryan |
Recently I was trying to make an TextView to take up entire height as much as possible, but I failed. I have seen Google Maps does that. But I can't achieve it.
|
Aryan |
OK. I can wait
|
Mark M. |
Hazi: how can I help you today?
|
Hazi c. |
Hey mark, you can continue with Aryan, in the meanwhile i'll be going through several questions i have and choose one of them
|
Mark M. |
um, OK
|
Aryan | |
Aryan |
Mark this is my question. Please help me.
|
Mark M. |
so, you want the font size to grow to allow the text to fill the area?
|
Aryan |
Yes.
|
Aug 14 | 9:15 AM |
Aryan |
Google Maps does something with scaleY
|
Aryan |
I think.
|
Mark M. |
autosize supported natively on Android 8.0, and it should be supported via appcompat for older devices
|
Aryan |
I did that also
|
Aryan |
But it maintains the same aspect ratio.
|
Aryan |
Between width and height of the textview.
|
Aryan |
Google maps makes the text looks long
|
Mark M. |
that may just be the particular font that they chose
|
Aryan |
So, basically it shrinks the TextView in width and keeps the same height.
|
Aryan |
Yes, that might be the case. But is there any way to allow the width shrink and keep the height constant?
|
Mark M. |
my guess is that you would need to look at how existing autosize implementations work, then create your own that shrinks the font (for X effect) and scales the Y (to keep the height constant)
|
Aryan |
Thanks for the tip.
|
Mark M. |
there are auto-sizing TextView implementations on the Android Arsenal, in addition to the official stuff
|
Mark M. |
with luck, one of the implementations will make sense :-)
|
Aryan |
How many hours do you work in a week? I am sorry but I am a huge fan of yours. I am dying to know about you. It's like a dream to talk to your role model live
|
Mark M. |
I work too many hours
|
Aryan |
Like?
|
Mark M. |
(Hazi: if you have a question, chime in!)
|
Mark M. |
I don't keep count, sorry
|
Aryan |
any rough figure?
|
Aryan |
OK
|
Aryan |
Can I also have a chat with on coming days or is this just one time stuff?
|
Mark M. |
for as long as you are a subscriber, you're welcome to join these office hours chats and ask questions on Android app development
|
Aug 14 | 9:20 AM |
Mark M. |
I try to hold 3 hours of chats per week
|
Aryan |
Awesome!
|
Mark M. |
at various times of the day, to try to offer times that are reasonably convenient for all time zones
|
Aryan |
yes, I saw the Calendar, you offer chats at differnt time.
|
Aryan |
Hazi, if you got your questions then please ask. I am thinking more questions till then.
|
Hazi c. |
My question is more about architecture and decoupling UI from business logic.. Lets say I have a list, displaying in some fragment, and I want the fragment to not be aware of the type of objects it is actually displaying (e.g. a fragment displaying a list of items, that each has a title, subtitle and image). At one point i might want to use the fragment to display 'cars', and at somewhere else, perhaps 'televisions'. Also i must say, im using a basic MVVM approach as introduced by the Google architecture components. Here comes the tricky part.... I want each item in the list to be clickable, in a way the fragment receives a click on some item, forwards it to the viewmodel, and the viewmodel should decide what to do with the item clicked, and which item was clicked. My small issue is, im a bit afraid that the data set in the ViewModel might been changed in between, and the item clicked, might no longer be in the given index. (my View is observing a data set from the ViewModel.... theres a slight chance that between the click and until i figure what item has been clicked, the data set was changed by some repository or something)
|
Mark M. |
ideally, your click listener has access to some primary key or other immutable identifier of what it was that the listener was associated with, so it can supply that information along with the click event
|
Aug 14 | 9:25 AM |
Mark M. |
you can achieve this with final variables in Java, or lambda expressions in Java/Kotlin
|
Mark M. |
or, you can use data binding and have the binding expression tied to android:onClick pass along some other data-bound data
|
Aryan |
What about having a static variable. This way you have more control.
|
Hazi c. |
so, in case I am displaying some view entity that contains two strings (title + subtitle for example) , should i also generate some unique ID to trace back to the original item standing behind this entity? to locate the actual 'car' or 'whatever' clicked?
|
Mark M. |
statics are a last resort, and IMHO are unlikely to help here
|
Mark M. |
yes -- presumably, there is a unique ID already, from your database, Web service, or wherever the data is coming from
|
Mark M. |
there is still always the chance that you update the UI right as the user is touching the screen, but that sort of "human race condition" is unavoidable
|
Hazi c. |
unfortunately not all our data objects contain an ID provided by our data sources. You can correct about that situation of the human race condition, but this ins exactly what im trying to avoid. So in the worst case, if I pass the unique ID from my item clicked, to the data set, and it doesnt exist anymore in the dataset, should i just ignore the click? would that be an okay behavior?
|
Hazi c. |
you are correct*
|
Mark M. |
I would display some sort of message to the user acknowledging the click but saying that the data is gone
|
Mark M. |
Toast, Snackbar, some message in the core of your UI, etc.
|
Aug 14 | 9:30 AM |
Hazi c. |
Alright that seems fair enough. Possible to ask one more question regarding MVVM architecture?
|
Mark M. |
sure, though I am not a GUI architecture expert
|
Aryan |
How to get effects of iOS type ripple effects in Android?
|
Mark M. |
I don't use iOS, so I cannot speak in terms of their ripple effects
|
Mark M. |
Android has RippleDrawable as of Android 5.0
|
Aryan |
I have worked on Ripple (almost all type) in Android. But I can't find iOS type.
|
Mark M. |
¯\_(ツ)_/¯
|
Aug 14 | 9:35 AM |
Aryan |
Mark, do you also have your apps on the Google Play Store?
|
Mark M. |
I have no apps in the Play Store under the CommonsWare brand
|
Mark M. |
I have contributed to apps that are in the Play Store, but they are under my clients' brands
|
Aryan |
Thanks for telling me.
|
Aryan |
Thanks Mark for all your answers. My few questions might sound stupid to you. But they were important for me. I really appreciate. Thanks again for your time. I will see you later. Have a great day :)
|
Mark M. |
your questions were far from stupid, though I will admit that I preferred the ones about Android app development (as opposed to the ones about me)
|
Aug 14 | 9:40 AM |
Mark M. |
if either of you have another question, go right ahead!
|
Aryan |
The technical questions can be found on SO (with people like you who contributed a lot there), but I just wanted to ask about you. That's all. Anyways, I don't have any question as of now.
|
Hazi c. |
Im using the MVVM architecture in cases where i have a single activity with multiple fragments. The activity has its own viewmodel where I can store data or expose data relevant to all other fragments, also, each of the fragments have their own viewmodel. Each click on a view is being delegated to the ViewModel to actually decide what to do with it (in order of keeping the business logic out of the view). At some cases, a click on some button should pass data to a view model, which is relevant to all other fragments too. So, what happens is, I am currently in the fragment's viewmodel, but want to store some data in the activity's viewmodel (again, so it will be available to all other fragments later on).. What I am doing right now is passing the data back to the fragment, so it can provide the activity viewmodel with it. i just feels bad to do thise entire 'circle'..
|
Hazi c. |
Can a fragment's viewmodel be aware and hold a reference to the activity's viewmodel? I assume that wouldn't be a great way of solving the problem, might also break some things..
|
Mark M. |
in terms of memory leaks or similar problems, what you are describing (fragment VM holding a reference to activity VM) should be OK
|
Mark M. |
the reverse (activity VM holding a reference to a fragment VM) could be more of a problem
|
Aug 14 | 9:45 AM |
Hazi c. |
I have through of working with a single viewmodel, that implements the interfaces of all the fragment viewmodels. but it just creates an enormous class handling too many things. Is there perhaps a way you know of that is considered best practice? or whether one solution is better than the other?
|
Hazi c. |
through*
|
Hazi c. |
thought** :)
|
Mark M. |
I cannot really answer that, sorry
|
Hazi c. |
Okay, no problem.. I might just check this solution regarding a fragment's VM knowing of it's activity's VM!
|
Hazi c. |
Thank you very much for your time.. and if I may ask, what is your comfort zone regarding this chat? would pure Android questions fit more than architecture questions?
|
Mark M. |
you are welcome to ask architecture questions, so long as you understand that I can only help so much
|
Aug 14 | 9:50 AM |
Mark M. |
IMHO architecture has lots of nuance, and so it is difficult to address in this sort of a chat environment
|
Hazi c. |
of course, I can see why it would be complicated. it is even hard for me to try and explain those question and what really stands behind them in here
|
Hazi c. |
Thank you very much for your time, much appreciated!
|
Mark M. |
I am happy to be useful!
|
Hazi c. | has left the room |
Aug 14 | 10:00 AM |
Aryan | has left the room |