Office Hours — Today, November 20

Yesterday, November 19

Mark M.
has entered the room
Mark M.
turned on guest access
Gabriele
has entered the room
Mark M.
howdy, Gabriele!
Gabriele
Hello
Mark M.
how can I help you today?
Gabriele
today I'm here with the ide! I'm still confused with the webviewfragment not showed hm
you told me to check if with the hierarchy tool I can see the webview, right?
Mark M.
yes
Gabriele
What do you mean exactly? I see Fragment -> WebViewFragment -> WikiFragment
Mark M.
you will not see any of those in Hierarchy View
Hierarchy View only shows widgets and containers, not fragments
Hierarchy View is a separate perspective in Eclipse, or a standalone tool
Gabriele
Ah maybe because I'm in intellij
Mark M.
yes, I do not know if they have Hierarchy View integrated or not
Nov 20
4:00 PM
Mark M.
(though the instructions there are a bit out of date -- run the monitor command, not hierarchyviewer)
Gabriele
oh nice
no, here I don't see any webview :/
maybe the problem is I didn't loaded it then hm
Mark M.
do you see whatever container your fragment is in?
Gabriele
load*
no I don't see any of my fragments
Mark M.
do you see the, um, ViewPager, or whatever the container was?
Gabriele
yes I see the viewpager
but no fragments inside it
Mark M.
does that correspond with what you see live, that you cannot swipe between pages?
4:05 PM
Gabriele
I can swipe between pages, but I can't see the webview
should I use getSupportFragmentManager().beginTransaction().add() to load the webview?
Mark M.
OK, that means that there must be some children of the ViewPager in Hierarchy View
Gabriele
yes I have two textview
Wikipedia (which should contain the webview) and Bookmarks
Mark M.
does your ViewPager use an indicator, like PagerTitleStrip?
Gabriele
yes
Mark M.
OK, so the TextViews then are your title strip
are there any other children of the ViewPager?
Gabriele
pagertabstrip
no, there aren't
Mark M.
that means that neither of your fragments are being loaded properly, then, for some reason
there should be the view from one of those two as a child of the ViewPager, I would expect
Gabriele
hm I think I didn't load them then, should I load them with getSupportFragmentManager().beginTransaction().add()?
Mark M.
no, because FragmentPagerAdapter does that
Gabriele
ah :(
Mark M.
I have a few samples of fragments in ViewPagers in the book
Gabriele
my getItem is ok? (do you still have the github access?)
the file is MyPagerAdapter.java
Mark M.
hold on
4:10 PM
Mark M.
I suggest that you delete isViewFromObject()
you should not need that, and it might be interfering
otherwise, what you have there should work
the fact that you are getting your page titles indicates that you are successfully putting the adapter in the ViewPager
so, other than isViewFromObject(), I cannot explain why you would not see either of your fragments' contents
Gabriele
hm I've removed it
Ok, something better, it seems
I can see the listview inside bookmarks now
but no webview, still!
Mark M.
swipe over to the WebView, then refresh your Hierarchy View for your activity
Gabriele
hm still no webview
4:15 PM
Mark M.
set some breakpoints in onCreateView() of WikiFragment and walk through it, I guess
Gabriele
I've put it inside onCreateView, but it never get called (on getWebView().setWebViewClient(new MyWebViewClient());)
Mark M.
is the WikiFragment actually being created and returned by MyPagerAdapter, then?
Gabriele
let's see, f = WikiFragment.newInstance(); is reached
4:20 PM
Mark M.
hmmm, there's no assignment in your code on GitHub, it's just return WikiFragment.newInstance();
Gabriele
ah yes, I've changed it, but it's the same, now it is Fragment f = WikiFragment.newInstance(); and then after the switch return f;
I will change back in a moment
Mark M.
what you have there sounds fine -- I was just pointing out that it wasn't what I'm seeing
Gabriele
oh no!
now it's working
so my new assignment did a new damage!
View paste
Fragment f = null;

		switch (i) {
			case 0:
				f = WikiFragment.newInstance();
			case 1:
				f = BookmarkFragment.newInstance();
		}

		if (f == null) {
			//getSupportFragmentManager().beginTransaction().add(R.id.pager, f).commit();
		}

		return f;
shouldn't it be the same?
Mark M.
it looks like it should be OK
OTOH, it is difficult to argue with working code
Gabriele
what does otoh means? :P
Mark M.
on the other hand
Gabriele
ah, thank you
Mark M.
it is YAIA (yet another Internet acronym)
Gabriele
it seems that the problem on my switch
is that I didn't use the break after case 0
but I can't understand why
Mark M.
ah!
good catch
4:25 PM
Gabriele
why case 1 is always executed? hm
Mark M.
well, case 0 falls through to case 1
because of the missing break
Gabriele
ah, true
Mark M.
and, since you are assigning the value now, the case 1 assignment wipes out the case 0 assignment
whereas before, you were returning immediately from the case 0
Gabriele
yes
so the old problem was the one you find
and the new one the break
and why isViewFromObject made this problem?
Mark M.
that is something you do not need to override on FragmentPagerAdapter or FragmentStatePagerAdapter
you do need to implement it on your own custom PagerAdapter
Gabriele
ah
another question, a thing I don't understand
the support library... I thought it was for back-compatibility projects
Mark M.
some things in the Android Support package are backports, yes
not everything
Gabriele
so I thought "I can try to build a new project without back compatibily" but then I've noticed that there is not viepwager ect.
Mark M.
such as ViewPager
Gabriele
exaclty!
why this decision?
Mark M.
the Android Support package is "code that Google is giving us and is supporting but is in no Android OS"
Gabriele
ah, I see
4:30 PM
Mark M.
partly, they can update the Android Support package without OTA updates to hundreds of millions of devices
partly, it helps keep the firmware size down, which helps keep the cost of Android devices down
Gabriele
how do they update it?
Mark M.
through the SDK Manager
developers opt into using newer versions as part of building their apps
for example, they just shipped a new version when they shipped Android 4.2 and the R21 tools release a week ago
Gabriele
Ah, so when I'm developing with the new version and I publish the app on the playstore, it will packed inside my app?
Mark M.
yes
Gabriele
because it's a library, nice
Mark M.
just like any other JAR
Gabriele
the name was confusing me, probably
Mark M.
it used to be called the Android Compatibility Library (ACL) and only had backports
they then added ViewPager to it
I grumbled about the name then, and some time later, they renamed it to the Android Support packager
er, package
(though I doubt my grumbling had much to do with their decision to change it)
Gabriele
eheh, maybe it did!
ok, thank you very much, I don't have question anymore, at least for today :P
Mark M.
OK
5:00 PM
Gabriele
See you the next time, thank you again.
5:00 PM
Gabriele
has left the room
Mark M.
turned off guest access

Yesterday, November 19

 

Office Hours

People in this transcript

  • Gabriele
  • Mark Murphy