Office Hours — Today, August 10

Tuesday, August 3

Aug 10
7:55 PM
Mark M.
has entered the room
Mark M.
turned on guest access
8:00 PM
Julius
has entered the room
Mark M.
howdy, Julius
Julius
Greetings amrk
Mark
(sorry bout that)
Mark M.
no problem
how can I help you today?
Julius
I have a question regarding hte SQLiteDatabase and errors I sem to have from time to time
I am using the methods from your books
to open the database and set it up
View paste
eg. mDb = new SDIDbHelper(this).getWritableDatabase();
and from time to time I get errors such as:
java.lang.IllegalStateException: database not open
I'm wondering have I somehow closed the database unknowingly?
Mark M.
where are you closing the database?
Julius
in onDestroy()
(pretty much in each Activity)
Mark M.
one thing I have changed in my books is that I am now holding onto the SQLiteOpenHelper object
calling getReadableDatabase() and getWriteableDatabase() as needed
and closing the helper
Julius
ah ok I might check that out
thank you for the pointer
I also have a general Java question probably
I am downloading a file and I would like to be able to stop or pause that process
8:05 PM
Julius
(it is in an Androi app)
and I use:
View paste
			while ((!shouldStop.get())&&((ByteRead = is.read(buf)) != -1)) {
I'm trying to figure out a nice way of stopping the download
Mark M.
what's wrong with what you're using?
Julius
um it doesn't appear to stop :)
I'll get a bit more code to describe it better
Mark M.
I assume shouldStop is an AtomicBoolean -- when are you setting it to true?
Julius
yes
View paste
	// --------------------------------
	
	public void setShouldStopFlag(boolean state) {
		shouldStopFlag.set(state);
	}
I probably need to breakpoint to check when it's being set
Mark M.
shouldStopFlag is not shouldStop
Julius
oh son of a ... :) <blush>
8:10 PM
Julius
thank you
sorry for using up your time.
Mark M.
not a problem
Julius
is the approach right?
for stopping the download?
(one day it would be nice to have it litterally pause and then carry on)
Mark M.
in the abstract, it seems ok
Julius
great thank you
have a nice day/evening
Mark M.
you too!
Julius
has left the room
Mike R.
has entered the room
Mark M.
howdy, Mike R
Mike R.
Hi Mark
8:15 PM
Mike R.
Just us?
Mark M.
Julius just left
Mike R.
ok. 2 questions
Mark M.
fire away
Mike R.
first one is a hard one. I have an EditText widget on a view. when the widget gets the focus, the soft keyboard appears and I have a listener that makes some instructions visible and covers up other parts of the view.
When the user presses the Search key on the keyboard, I have a listener that removes the instructions, clears the focus from the widget and does some processing.
Problem is when the user presses the Back key, the soft keyboard disappears, but I'm not getting any kind of notification that this is happening. So I can't remove the instructions and clear focus on the widget.
Mark M.
the theory is you're not supposed to be reacting to the soft keyboard coming and going
Mike R.
That's a nice theory, but it's not very helpful.
Mark M.
well, what are you doing when the user doesn't have a soft keyboard?
8:20 PM
Mike R.
Haven't gotten that far yet. Trying to figure out the soft keyboard scenario first.
Mark M.
my point is that you're not supposed to be doing anything in either case
Mike R.
That's a nice theory, but I need to provide guidance for the user to understand the requirements of the data entry task they are doing.
Mark M.
then provide the guidance, but don't try to play games with the guidance based on the existence of a soft keyboard
just have it always be there
after all, people with physical keyboards aren't going to magically not need the guidance
for instance, use android:hint
Mike R.
The view is too cluttered already and the instructions could easily take up more than half of the view.
already using hint
Mark M.
then split it into multiple activities
or a wizard
Mike R.
for people with keyboards, I can detect the EditText getting and losing focus
8:25 PM
Mark M.
I don't know how to help you
Google (mostly Ms. Hackborn) has stated repeatedly that you're not supposed to do what you're trying to do
I personally know of no reliable workarounds
Mike R.
argh!!!!!
have to get my laptop for my other question. be right back
8:30 PM
Mike R.
ok. On my main view, I use the system progress bar to indicate the progress of some start up activities. Works great.
Mark M.
"system progress bar" meaning the one in the title bar?
Mike R.
When the start-up activities have finished, I sent position to 10000 which fills the progress bars, pauses for a few seconds and then clears the progress bar. works great.
yes. that's the one.
Problem is, I have a secondary, user-initiated activity for which I'd like to show progess.
The first step in this activity sets the position to 1000 (10%)
The progress bar shows a deep yellow bar at 10%, but a more faded yellow at about 50%.
I've got an example I can email you.
8:35 PM
Mark M.
what's the question?
Mike R.
How do I clear that faded yellow out of the progress bar?
Mark M.
don't set it to 50%, apparently
is it that you want a different color, or that you don't want 50%, or something else?
Mike R.
I don't set it to 50%. I set it to 10%. The screen shot should be in our email
Mark M.
that's the secondary progress
Mike R.
what's secondary progress?
Mark M.
On a ProgressBar, there are two progress levels, primary and secondary
think "progress of copying the current file" and "progress in copying the whole set of files"
call setSecondaryProgress(0)
and that should get rid of it
Gwindor
has entered the room
Mike R.
excellent. thanks.
Mark M.
howdy, Gwindor
Mike R.
that's all for me.
Mark M.
ok
Gwindor, do you have a question?
8:50 PM
Gwindor
has left the room
8:55 PM
Mark M.
OK, any last questions?
9:00 PM
Mike R.
has left the room
Mark M.
turned off guest access

Tuesday, August 3

 

Office Hours

People in this transcript

  • Gwindor
  • Julius
  • Mark Murphy
  • Mike Renda