Jun 18 | 9:50 AM |
Mark M. | has entered the room |
Jun 18 | 9:55 AM |
Mark M. | turned on guest access |
Guy W. | has entered the room |
Guy W. |
Hey
|
Mark M. |
hello, Guy!
|
Mark M. |
how can I help you today?
|
Guy W. |
how are you doing?
|
Mark M. |
busy busy busy
|
Guy W. |
:-)
|
Guy W. | |
Guy W. | |
Jun 18 | 10:00 AM |
Guy W. |
REST
|
EGHDK | has entered the room |
Mark M. |
(EGHDK: hi! I'll be with you shortly!)
|
Mark M. |
Guy: OK... but what's your question?
|
Guy W. |
could you recommend a tutorial to implement this?
|
Mark M. |
off the cuff, no, because I have never used it
|
Guy W. |
OK thanks
|
Mark M. |
sorry
|
Mark M. |
EGHDK: do you have a question?
|
EGHDK |
okay so back to my last question from Monday. You said that "signed integers" means that they can be negative. But why is a byte in Java range from -128 to 127? Wouldn't it make sense if it was the other way around -127 to 128?
|
Mark M. |
you would have to ask the people who wrote Java
|
Jun 18 | 10:05 AM |
Mark M. |
Guy: do you have another question?
|
EGHDK |
Hm. Okay, thought that there may be a specific reason for that.
|
Mark M. |
EGHDK: there may be, but I do not know what it is. I can confidently state that in this chat, I have thought more about this issue than in the rest of my life combined. :-)
|
Guy W. |
at the moment just the "Digest access authentication"
|
Mark M. |
what HTTP client API are you using? HttpUrlConnection? HttpClient? a third-party HTTP library?
|
Guy W. |
HttpClient
|
Mark M. | |
Mark M. | |
Mark M. |
though personally HttpClient is your worst choice for client API, simply because Google is not maintaining it anymore
|
Jun 18 | 10:10 AM |
Mark M. |
(on Android -- Apache is maintaining their own copy, but Android's is much older)
|
Mark M. |
if either of you have more questions, go right ahead
|
EGHDK |
Yep. Got my list ready.
|
Guy W. |
so I should use HttpsURLConnection instead
|
Mark M. |
Guy: or a third-party library layered atop of HttpsUrlConnection, yes
|
EGHDK | |
Mark M. |
because you are casting a float value from 0 to 1 (Math.random()) to an int
|
Mark M. |
and that cast does not round IIRC
|
Jun 18 | 10:15 AM |
EGHDK |
When reading about jars trying to figure out what they "really" are... "You can put your application files into a Java Archive - .jar file - thats based on the pkzip format. The jar file can include a simple text file formatted as something called the manifest that defines which class in the jar holds the main method that should run." Does this mean an Android project is just a jar file? Because isn't an android project zipped up with a manifest?
|
Mark M. |
"Does this mean an Android project is just a jar file?" -- no, just as a Word document in a ZIP file is not a JAR file
|
Mark M. |
JARs, APKs, and Word-docs-in-ZIP-files are all ZIP files
|
Mark M. |
their contents differ
|
Mark M. |
APKs *resemble* JARs more than Word-docs-in-ZIP-files do
|
Mark M. |
but they are not the same
|
EGHDK |
So out of the Android world over here... if I wanted to make a java program and send it to someone, and the program used 5 classes... I could just package it as a jar?
|
Mark M. |
yes
|
Jun 18 | 10:20 AM |
EGHDK |
So a lot of the libraries you make are simply jar files. Like mergeadapter and stuff. So are just compressed classes?
|
Mark M. |
compiled classes
|
Mark M. |
off the cuff, I forget whether JARs use actual ZIP compression or not
|
EGHDK |
Got it. So there are compiled... so you get the .class and not the .java?
|
Jun 18 | 10:25 AM |
Mark M. |
correct
|
EGHDK |
So if I downloaded a .jar file I'm not able to actually edit the code in there?
|
Mark M. |
not directly
|
EGHDK |
But I can see the code... right?
|
EGHDK |
So I can edit it... indirectly by just copying it into a different file?
|
Mark M. |
"But I can see the code... right?" -- no, because it is compiled, not the raw source code
|
EGHDK |
Hmm... got it. So how would you edit it "indirectly" like you said?
|
Mark M. |
reverse engineering is way out of scope for this chat
|
EGHDK |
Okay. I just had to know if it was reverse engineering or some other way. Thanks
|
Jun 18 | 10:30 AM |
Mark M. |
Guy: if you have other questions, feel free to chime in
|
EGHDK |
View paste
|
Mark M. |
the ones for your parent container
|
Mark M. |
if you are adjusting the LayoutParams for a widget in a RelativeLayout, you will be using RelativeLayout.LayoutParams
|
Jun 18 | 10:35 AM |
EGHDK |
Hmm... okay that makes sense. Why does anyone have to ever use LayoutParams itself?
|
Mark M. |
there is no "LayoutParams" itself
|
Mark M. |
RelativeLayout.LayoutParams, for example, inherits from ViewGroup.MarginLayoutParams, which inherits from ViewGroup.LayoutParams
|
Mark M. |
some container classes can get by with using one of those inner classes of ViewGroup, because they did not need any extra rules
|
EGHDK |
Gotcha. Okay. sounds good.
|
Jun 18 | 10:40 AM |
EGHDK |
View paste
|
EGHDK |
Looking at it... logically I would feel like the Saving dialog would show for half a second... but it doesn't. The dialog shows afterwards. I don't understand how thats possible.
|
Mark M. |
because show() is asynchronous
|
Mark M. |
your dialog will not show until sometime after you return control to the main application thread
|
Jun 18 | 10:45 AM |
EGHDK |
show is async? But, it's on the main thread... no?
|
Mark M. |
you are *calling* show() on the main application thread
|
Mark M. |
all this does is schedule work to be done later
|
EGHDK |
Sorry... this is going to take some explaining because this blows my mind.
|
Mark M. |
just like startActivity() is asynchronous
|
EGHDK |
isn't every method "scheduled"? Isn't that what the stack is?
|
Mark M. |
no and no
|
Mark M. |
let's draw an analogy
|
Mark M. |
IIRC, you are college
|
Mark M. |
sorry, you are in college
|
Mark M. |
when a professor assigns you a term paper, or some other sort of project, does the professor expect you to hand in the result in the next few seconds?
|
Mark M. |
or does the professor give you a submission date in the future?
|
Mark M. |
most professors will give you a submission date in the future, so you have time to actually do the work
|
Mark M. |
however, if the professor asks you a *question*, they expect an immediate answer
|
Mark M. |
not everything that a professor tells you to do, therefore, is stuff that is done immediately -- only some things are
|
Mark M. |
this is no different in computer programming
|
Jun 18 | 10:50 AM |
Mark M. |
some things your program asks to have done will be done immediately
|
Mark M. |
some things will be arranged to happen in the future
|
Mark M. |
sometimes, "the future" is a scheduled point in time (see AlarmManager in Android)
|
Mark M. |
sometimes, "the future" is in the form of a work queue (see the main application thread in Android)
|
Mark M. |
and there are other patterns
|
Mark M. |
in this case, the constructor creates the object immediately
|
Mark M. |
and setMessage() configures the object immediately
|
Mark M. |
and show() puts the request to display the dialog onto a work queue
|
Mark M. |
the main application thread's primary role is process requests on that work queue
|
Mark M. |
which is why we need to spend as little time as possible in our own code on the main application thread
|
Mark M. |
and a side effect is that if you call some method that simply puts work on the work queue, that work will not even *begin* until you return control of the main application thread to the framework (by returning from whatever callback that you are in), so the framework code can return to processing work off of that queue
|
Jun 18 | 10:55 AM |
EGHDK |
Okay. So how would I figure out that a method like show() or startActivity() are methods that get put on the work queue? I don't see anything in the docs about it.
|
Mark M. |
experience
|
Mark M. |
the documentation does not cover everything
|
EGHDK |
Not the answer I was looking for -_- Hmm.. Yeah I guess. It's just like the show method says "Start the dialog and display it on screen." so it makes it seem like it will drop everything and do that now.
|
EGHDK |
So now for a solution... how would I rewrite that progress dialog so that The dialog shows for 5 seconds with thread.sleep()?
|
EGHDK |
Put it into an async task?
|
EGHDK |
onpreExecute create the dialog and show it, onBackground Thread.Sleep, onPostExecute hide progress dialog?
|
Mark M. |
you could use postDelayed() on some View to schedule a Runnable to run in five seconds, where the Runnable cancels the dialog
|
EGHDK |
postDelayed() on a view? Never heard of that before... Heard of a runnable... but haven't looked into what it is yet.
|
Mark M. |
it's covered in my book
|
Mark M. |
in a few places, actually
|
Jun 18 | 11:00 AM |
EGHDK |
Okay, I put your book onPause() for now because of your update. I'm still trying to brush up on my java fundamentals.
|
EGHDK |
Alright, well it looks like your scheduled for 7:30 so I'll be there tonight with more questions... Thanks mark!
|
Mark M. |
yes, the next chat is in a bit over 8 hours
|
Mark M. |
this chat's transcript will be posted to http://commonsware.com/office-hours/ shortly
|
Mark M. |
have a pleasant day, all!
|
Guy W. | has left the room |
EGHDK | has left the room |
Mark M. | turned off guest access |