Office Hours — Today, February 6

Saturday, February 3

Feb 6
3:50 PM
Mark M.
has entered the room
Mark M.
turned on guest access
4:00 PM
Ed T.
has entered the room
Mark M.
hello, Ed!
how can I help you today?
Ed T.
can we start with a beer? it's been a long week already... lol
this might be more like therapy...
:-)
Mark M.
look on the bright side
you could have been sitting in a certain Tesla Roadster just a little bit ago
Ed T.
I've been tasked to port an iPhone app to android...
ripped thru the 1,000 plus BigNerd ranch book in 2 weeks
pretty good book
then was in a Ken Kousten class and he recommended your book
the problem I'm having
Android Studio 3.0
seems a little odd to me
trying to get annotations to work correctly
Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project.
Mark M.
custom annotations of yours? stock annotations? annotations from a library?
Ed T.
I got this error a little while back.. after rolling back..
4:05 PM
Ed T.
let me post the gradle files...
trying to use a few things at the same time
Mark M.
bear in mind that these chat transcripts are archived
so, don't post anything here that you don't want others to see
Ed T.
thanks for the heads up
this might help someone else down the road
Mark M.
OK
Ed T.
View paste (14 more lines)
android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.seapineva.android.servicelancevsc"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath = true
            }
        }
    }
...
did you have to add the javaCompileOptions
Mark M.
I haven't for any annotation processors that I have used
Ed T.
to get AndroidAnnontations to work ?
Mark M.
I haven't used AndroidAnnotations specifically
but I use annotations from libraries all the time
Ed T.
View paste (13 more lines)
dependencies {
    annotationProcessor "org.androidannotations:androidannotations:4.4.0"
    implementation 'org.androidannotations:androidannotations-api:4.4.0'

    implementation group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.1'
    annotationProcessor "org.projectlombok:lombok:1.16.10"
    implementation "org.projectlombok:lombok:1.16.10"

//    annotationProcessor group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.8.9'
    implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.8.9'

    implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.9'
    implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.9'

    implementation 'joda-time:joda-time:2.3'
...
AS 3.0 has a new gradle plugin
the 'listening bolt' feature seems to be putting annotation stuff into a weird place
Mark M.
if you mean "lightning bolt", that is Instant Run, and I always turn it off
Ed T.
I didn't know that was an option
thanks for that info!
Mark M.
search for "instant" in Settings
4:10 PM
Mark M.
in Build, Execution, Deployment > Instant Run, the top checkbox controls whether Instant Run is enabled ornot
4:10 PM
Mark M.
er, or not
Ed T.
found it! Instant Run under Build area
Mark M.
yup
the other thing that seems a bit odd in your Gradle is: implementation group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.1'
I haven't seen anyone use that in Android
it's quite possible that it is perfectly normal and I just haven't run across it
Ed T.
Lombok wouldn't compile
then the other issue I ran into is the Lombok generated code
Mark M.
I haven't tried using Project Lombok in an Android project
Ed T.
in IntelliJ if I ran it.. looked good
in AS it 'would' run OK but in the editor it would give red underlines
so the IDE didn't 'see it'
and I got weird compile errors down the road
Mark M.
if this is for a pure Java module, I have encountered the red-underlines problem: https://issuetracker.google.com/issues/71022016
I haven't run into compile errors related to that, though
Ed T.
it is a java module
4:15 PM
Ed T.
using Lombok but I made the decision to auto-generate the code... nothing major in there
for a REST / JSON interface to the server
server side had already built it out for testing
was going to put a UI up and use that as my data model
thanks Mark!
Mark M.
um, you're welcome!
Ed T.
I work remote... so it's nice to have a chat with someone
anything else you would advise me on AS 3.0 ?
3.1 is what I'm running actually
Mark M.
ah
I don't bother with their pre-release IDEs, usually
I spend enough time helping them debug their pre-release OS
Ed T.
3.2 is the pre-release
Mark M.
so is 3.1
Ed T.
lol
Mark M.
3.1 is beta
3.2 is canary
3.0.1 is the current production release
Ed T.
ahh , yes - you are correct
Mark M.
I have a rough enough time with their tools that are *supposed* to work, to spend time "chasing sensor ghosts" with tools that might not work
Ed T.
the confusing part for me... coming to Android...
is the 'sort of' support for Java 1.8
Mark M.
yes, well, to an extent, you have the Oracle v. Google lawsuit to blame for that
Ed T.
I did Java Swing for 10 years
and was in telecom
4:20 PM
Ed T.
Google poached the Java smart folks
Joshu Bloch
met him twice.. nice guy
Romain Guy
met him once
was a guru on the Swing team
Chet Hase left to Adobe... Fles team ... but is now at Google
Sun never gave away the JVM on the mobile handset
and it was terrible
no math.lang package for example... because most of them didn't have a math co-processor
Google should have paid for it in my humble opinion... because they have ton of money
but the bigger issue... is if it is no longer free... and you have a monopoly ... I think they call that 'dumping' to control a market... not sure
but the background is Oracle's CEO who sat on Apple Board... was best friends with Steve Jobs
those two took vacations together with their families
showdawn
has entered the room
Ed T.
so... expect Oracle to pay the lawyers forever ... it's very personal... my guess
ok... time to share
thanks Mark!
Mark M.
you're welcome
showdawn
hi Mark
Ed T.
I'll catch you another day.... this was great help
Mark M.
Ed: sounds good!
showdawn: hi! it's your turn -- do you have a question?
4:25 PM
showdawn
Yes. I am trying to implement a messenger kind of application and here is what I have thought of. Need your suggestion.
Steve S.
has entered the room
Mark M.
(Steve: hi! I'll be with you shortly, after showdawn's question)
Steve S.
Hi, Mark!. Sure thing
showdawn
I run a service which starts and listen on socket. When there are messages, update the database and use livedata to update the UI ?
Is that a good approach ? I would terminate the service when the app is closed.
Ed T.
has left the room
Mark M.
you only need a service if you are looking to process messages when your UI is not in the foreground
and then it would need to be a foreground service, to support Android 8.0+
in terms of the networking, I would recommend using established protocols rather than creating something yourself with bare sockets
otherwise, what you describe seems fine
showdawn
How can I do it, when I am in a different screen (not the chat screen) and still be notified of new messages
Mark M.
you just need some central object that is managing your network connection
it does not have to be a service
it could be some singleton
4:30 PM
showdawn
Ok got it.
But how would I update the databse when I get a new message? Do I do an async task in the singleton ?
Mark M.
use a background thread of some form, but probably not an AsyncTask, as you do not need to be doing work on the main application thread there
showdawn
Ok. I get the problem you mention with Services.
Especially with 8.
0+
Mark M.
let me take a question from Steve, and I will return to you shortly
showdawn
Sure
Mark M.
Steve: your turn! do you have a question?
Steve S.
I'll paste in my question:
I'm working on an implementation of the master-detail pattern. I think I can see why fragments are used for the details. But what is the rationale for using a fragment as the master?
Mark M.
as opposed to... what?
Steve S.
Just an actvity
Mark M.
OK, so you're proposing an activity that manages the master UI directly, and optionally shows a fragment for the detail if there is room?
Steve S.
Yes
Mark M.
I suppose that could work
4:35 PM
Mark M.
on smaller screens, you would have to hide your master UI at the View level (setVisibility()), since you would not be running a fragment transaction to replace that UI
Steve S.
ok
Mark M.
the original Google-recommended pattern was for two fragments, presumably for parallelism
Steve S.
right. that's what i've seen. i was curious why that was the pattern since it seems simpler to use just an activity for the mster
Mark M.
I'm not convinced it's that much simpler, though it could be -- I haven't tried that pattern
Steve S.
ok. i don't have any more questions today. than you so much, Mark!
Mark M.
you're welcome!
showdawn: back to you! do you have another question?
Steve S.
have a great rest of the day!
Mark M.
Steve: you too!
Steve S.
has left the room
showdawn
yes mark.
So if I am using a thread to update the DB and then use livedata to update the activity, dont you think there would be a delay ?
Mark M.
well, to some extent, there will be
4:40 PM
showdawn
Of-course these would be single line inserts into the database.
Mark M.
however, you already are on a background thread for the network I/O
you can't use that thread for the database I/O, as you cannot process more incoming messages that way
and you do not want to do disk I/O on the main application thread
so, another thread is unavoidable
you're certainly welcome to post data to the LiveData before you do the disk I/O, if you want
showdawn
Can I do that from a background thread that I create in singleton class ?
Mark M.
can you do what? post to the LiveData? sure, assuming that you have access to it
showdawn
Post to Activity from Background thread of Singleton class ?
Mark M.
well, that's what the LiveData is for
showdawn
Ok.
Mark M.
for example, if you have the latest copy of "Android's Architecture Components", I walk through an example of Model-View-Intent as a GUI architecture
there, I use background threads (via RxJava) for the database I/O, and the results of that work eventually trigger updates to LiveData to update the UI
it's not an exact match for your scenario, as all my data changes are driven by the UI, not by background events (incoming messages from the server)
but the flow of doing background work and using LiveData to stream the results to the UI would still hold
4:45 PM
showdawn
Ok. I will go through that book. havent read it.
4:45 PM
Mark M.
Version 0.8 of "Android's Architecture Components" has that material, and Version 0.9 should be out on Monday
showdawn
Thanks Mark.
Mark M.
no, wait, sorry -- 0.7 is the current version, and 0.8 is coming out on Monday
showdawn
So 0.7 already has it ?
Mark M.
the MVI sample? yes
I just had the version numbers wrong
showdawn
Ok
Thanks again mark. I will leave now.
Mark M.
OK
showdawn
has left the room
4:55 PM
Mark M.
turned off guest access

Saturday, February 3

 

Office Hours

People in this transcript

  • Ed Tidwell
  • Mark Murphy
  • showdawn
  • Steve S