Jul 14 | 8:50 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Jul 14 | 9:05 AM |
Johnny | has entered the room |
Mark M. |
hello, Johnny!
|
Mark M. |
how can I help you today?
|
Johnny |
Hi Mark
|
Johnny |
Currently in my activity layout I have the toolbar at the top, frameLayout for a fragment in the middle then an adView at the bottom.
|
Johnny |
View paste
(12 more lines)
|
Johnny |
How would I only show the adView when there is an Ad loaded? So if it fails I don't want the adView there.
|
Mark M. |
hmmmm...
|
Mark M. |
I have not tried setting visibility to GONE on a widget that is used as an anchor by something else in a RelativeLayout
|
Mark M. |
so, while I would try that first, it may not work
|
Johnny |
Yeah that crashes when I do that
|
Mark M. |
OK
|
Jul 14 | 9:10 AM |
Johnny |
Do I have to switch over to LinearLayout?
|
Mark M. |
that was what I was going to recommend trying next
|
Mark M. |
when you make the adView GONE, the recalculated weight should give all the space to the FrameLayout
|
Johnny |
Hmm yeah guess I got no choice. Thanks :)
|
Mark M. |
if you were desperate to stick with the RelativeLayout, you would need to change the RelativeLayout.LayoutParams for the FrameLayout, before you made the adView GONE
|
Mark M. |
basically, you'd change the FrameLayout to anchor at the bottom of the screen, as the adView does
|
Mark M. |
then, with no other anchoring rules dependent upon adView, I would expect that making it be GONE (or removing it via removeChild()) would work
|
Johnny |
Ah that makes sense. I'll try that also
|
Jul 14 | 9:15 AM |
Johnny |
I have another problem I am hoping that you could help me with
|
Mark M. |
go right ahead -- it's a quiet chat room today
|
Johnny |
I'm currently using the material theme at the moment
|
Johnny |
View paste
(1 more line)
|
Mark M. |
no, you are using Theme.AppCompat.Light.NoActionBar
|
Johnny |
Oh, should I have it there for pre-lollipop compatibility?
|
Mark M. |
I am not sure what "it" is
|
Mark M. |
you use Theme.AppCompat-based themes if you are using appcompat-v7
|
Mark M. |
inheriting from AppCompatActivity or ActionBarActivity, etc.
|
Jul 14 | 9:20 AM |
Tejas | has entered the room |
Mark M. |
hello, Tejas!
|
Johnny |
sorry, so I should be using something else for the parent?
|
Tejas |
Hi Mark. Good morning.
|
Mark M. |
Johnny: if you are not using appcompat-v7, using Theme.AppCompat-based themes will not work AFAIK
|
Mark M. |
Theme.Material only works on API Level 21+, so if your minSdkVersion is lower than that, you would need to either use something else consistently (e.g., Theme.Holo) or use Theme.Material only on the newer devices
|
Johnny |
Ah right, yeah I got min 15, and I have app-compat-v7
|
Mark M. |
this sample app from the book demonstrates an app that uses Theme.Holo-based themes on Android 4.x devices and Theme.Material-based themes on Android 5.x devices: https://github.com/commonsguy/cw-omnibus/tree/m...
|
Mark M. |
then you should stick with Theme.AppCompat-based themes
|
Johnny |
Thank you
|
Mark M. |
unless you like crashing :-)
|
Johnny |
haha
|
Mark M. |
let me take a question from Tejas, and I will be back with you in a bit
|
Mark M. |
Tejas: your turn! do you have a question?
|
Tejas |
Hi Mark. I need to flag a stack overflow question here. Can I give you a link?
|
Mark M. |
sure, though you're welcome to use the Stack Overflow "bump" feature in the Warescription account for that sort of thing too
|
Tejas |
Okay. Was not aware of that. Here the link http://stackoverflow.com/questions/30610216/and...
|
Mark M. |
mostly, via "bump", there is no need to wait for office hours
|
Jul 14 | 9:25 AM |
Mark M. |
OK, give me a moment...
|
Tejas |
Sure.
|
Mark M. |
in your case, I'd solve the issue in another way
|
Mark M. |
the fact that you get 30% after 40% is not a problem
|
Mark M. |
the fact that you *pay attention* to 30% after having paid attention to 40% is the problem
|
Mark M. |
so, have each event bus event include not only the percentage, but the time of the event
|
Mark M. |
and if you get an event that is older than the last-seen event, discard it
|
Tejas |
Okay. Perfect. I will do that. That's it from me.
|
Mark M. |
this way, you are independent of event bus characteristics
|
Tejas |
Thank you.
|
Mark M. |
happy to help
|
Mark M. |
Johnny: back to you! do you have another question?
|
Tejas | has left the room |
Johnny |
yep, so with the theme above I declared it in the manifest - android:theme="@style/AppTheme
|
Johnny |
But I was wondering how my preferenceFragment can have a different theme/style
|
Jul 14 | 9:30 AM |
Johnny |
because the text in the numberPicker is white
|
Mark M. |
it's more that you would need to figure out what to add to your theme to say "hey, number picker text should be this other color"
|
Mark M. |
or, since presumably this is your own custom Preference subclass, hack something in there
|
Mark M. |
(leastways, I don't recall a NumberPickerPreference in the Android SDK...)
|
Johnny |
Opps, yeah I actually extended DialogPreference
|
Johnny |
NumberPickerPreference extends DialogPreference
|
Johnny |
How can I separate or declare a new theme for my preference activity/fragment?
|
Mark M. |
so, you could either hard-code the coloring that you want as part of NumberPickerPreference, or add your own checks for theme attributes to allow you to set the colors in the theme
|
Mark M. |
you can't declare a theme for a fragment
|
Mark M. |
you're welcome to create another theme and have your PreferenceActivity use that theme via its manifest
|
Jul 14 | 9:35 AM |
Johnny |
View paste
|
Johnny |
I'll re-try though
|
Mark M. |
what is the nature of the crash?
|
Johnny |
ok sorry, it's working now
|
Johnny |
Must have been something else that was causing the crash before
|
Jul 14 | 9:40 AM |
Mark M. |
either that, or you were working on it yesterday, and the code was having a bad Monday :-)
|
Johnny |
lol got to love Android programming. Half the time my console doesn't show the crash report
|
Mark M. |
yeah, Android Studio's LogCat display has its issues, if that's what you are using
|
Johnny |
I was also wondering what's your opinion on ORMs?
|
Mark M. |
haven't played with any ORMs yet
|
Johnny |
yep I meant logcat
|
Johnny |
Ah ok. Reason I asked was because of all the boilerplate setting up content providers each time
|
Jul 14 | 9:45 AM |
Johnny |
Do you also know what's the difference between the SharePreference and Preference. I tried researching but I couldn't find much.
|
Mark M. |
Preference is a UI thing
|
Mark M. |
SharedPreferences are a data thing
|
Mark M. |
it's roughly analogous to the difference between a NumberPicker and a SQLite database
|
Johnny |
View paste
|
Jul 14 | 9:50 AM |
Mark M. |
"What do you mean by UI thing?" -- pretty much what I said. Preference objects are used by PreferenceScreens as part of PreferenceFragments (and, previously, PreferenceActivities)
|
Mark M. |
they present a specific SharedPreference value to the user and, usually, allow the user to update that value
|
Mark M. |
just as a NumberPicker might present a specific database value to the user and, usually, allow the user to update that value
|
Mark M. |
now, in truth, a Preference like DialogPreference is a bit closer to a controller than a view, in MVC semantics
|
Johnny |
Ah right.. understand. Thank you so much for all your help Mark!
|
Mark M. |
you are very welcome
|
Johnny |
Enjoy the rest of your day. Bye :)
|
Johnny | has left the room |
Jul 14 | 10:00 AM |
Mark M. | turned off guest access |