In Android TV leanback UI BrowseFragment how could I find when HeadersFragment is put away? - android

I'm writing a POC Android TV app for my company based on our existing mobile OTT product and backend.
I'm modifying the PageAndListRowFragment example from Google's Leanback Showcase code.
When a header option is selected (with OK or right arrow) I want the RowsFragment side to popup an AlertDialog to let me filter the content displayed ('all', 'latest', etc).
My problem is that I have the AlertDialog in the RowsFragment onCreate So, It displays as soon as the HeadersFragment is highlighted. This stops the user from scrolling down the header smoothly and is confusing because you still have to select the header item after the dialog.
Most advice on the web seems to point to overriding the OnItemViewClickedListener function on the HeadersFragment but I can't find a way to do this. (The leanback showcase uses the deprecated BrowseFragement code, Not BrowseSupportFragment and if I try to change up I get into FragmentFactory errors I'm not experienced enough to resolve).
I've also tried implementing isShowingHeaders() in the RowsFragment.
I've tried to find a stage of the fragment lifecycle in either HeadersFragment or RowsFragment that will let me popup the dialog when the RowsFragment is full screen without success.
I'm already using the PageRowFragmentFactory code in the leanback showcase code to send an EventBus message containing the header option chosen and was hoping to send a similar message to trigger the dialog.
I've tried setting up a setOnHeaderViewSelectedListener on the BrowseFragment but can't seem to successfully get it invoked.
I'm new to Android programming so apologies for my ignorance, but I'm determined to make this work somehow.
Any suggestions on the approach would be very much appreciated, thanks.

Related

Android, Material Design, RecyclerView doesn't show elements

I have a question related to Material Design introduced in Android 5. I'm very new with UX interfaces. Now I'm trying to implement simple music player with fragment for choosing songs from storage. Actually, that fragment contains RecyclerView. But RecyclerView doesn't show any element (it contains views with one TextView), even simple "..". I checked it with log-tracking and found that function "onBindViewHolder" was called correctly. To be honest, I have no idea what is wrong with my code. Obviously, I provide link to my project: UX
I will be gratefull for any suggestion, advice or may be pointer to the mistake.

In Android how can I design a view like the attached image?

I am new in android and I have a view which is in the attach image. I have to open this view after clicking on list item, but I am not finding any proper way to solve this please suggest me how can i open a dialog like in Image.
Check PopupWindow control in android developers, does exactly what you want. There are numerous tutorials on the web on how to customize, animate, have functionality etc. It has an onCreate method and in simple words it works just like an Activity with specific bounds. It can be attached and shown anywhere and anytime. It's actually quite useful. When you don't want to use dialogs this is the best option.

WebView Text Selection

I want to achieve something like this -- text selection plus custom actions ..
http://www.youtube.com/watch?feature=player_embedded&v=iwmG43D0vD4
I have done sufficient research on this topic and concluded that webview text selection and overriding it functionality is not possible ..
Seems that webview's functionality is very limited atleast in the case of text manipulation.
I had decent success by accessing webview's private nativeGetSelection method ( i was able to get selected text ).. but still i was unable to suppress the default dialog box .. and using private methods dosen't seem to be a safe action tooo ..
I was about to scrap my thought of doing that project .. then i came to see that default web browser provides good text selection capability and further provides custom quick action to manipulate the text .. I am really confused at this point ....
can anyone .. with all their expertise ... point out how to achieve that behavior .. ?
what view does google docs app use to achieve that behavior .. ?
I got something similar working in 2.2 - 4.0.3. I used a javascript interface and passed all touches to it. Of course to do that you'll need enough control over the web content to include the javascript file. I have this solution in an app in production and I've put an example project on github. The github project includes the necessary js in the assets folder as well as a test page and web view that loads the test page and implements all necessary methods to handle the selection. The link to the github project is https://github.com/btate/BTAndroidWebViewSelection. Have at it.

android 4.0 spinner usage

I want to be able to do what is on the picture, provided by this link, under the "Allow cutting through hierarchies" section. I thought that I could do that using a spinner, but from the android documentation I realized that a spinner can show one child at a time and lets the user pick among them. In my case, (and from the example I provided), you have some other text displayed, and then you can choose from some other options provided in sth that looks like a popup, list that contains the things that i want to choose from. I don't know how this is implemented, but it's used in the google music app for android 4.0. If someone has an idea, have implemented sth like this, please give me some advice.
It is not a spinner. Its just a view (in the Mail app a relative layout) See here
On click this View opens a popupmenu.
Therefore it is looking like a spinner but you can add you custom behaviour.

How to implement Android 4.0 like swipe to dismiss functionality in ListView?

I'm working on an app in which I would like to implement swipe-to-dismiss functionality in the ListView - similar to what we see in Android 4.0's notification bar, recent apps list or browser tabs. I want to run the app on the devices running Android 2.2+. See the following image. I also want to change the transparency of the item being swiped-away - just like in ICS.
I checked the source of the ICS web browser on http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.0.1_r1/com/android/browser/TabScrollView.java?av=f but couldn't figure out which class is particularly responsible for implementing this functionality.
Can anyone point me in the right direction here? Can we do this using Android Compatibility Library? Please let me know. Many thanks.
I've thought about implementing such a feature as well, but I haven't done it yet. So the only thing I can provide are some ideas on how I would approach that problem. If I've eventually written some code I will post it here.
The main class needed is a custom Adapter which extends a ListAdapter (ArrayAdapter, SimpleCursorAdapter etc.).
The adapter applies a View.OnTouchListener to all of its Views.
Whenever that listener detects a horizontal scroll dx, it calls concernedView.offsetLeftAndRight(dx) (which will make the view draggable). Of course the adapter has to save the current horizontal offset for the view. If the user was dragging a view and removes his/her finger from the screen, the touchListener will detect this as well and start a slide back animation. Using the current offset we can also calculate an alpha value, so the view will fade out when it approaches the screen borders.
If one list entry is eventually dismissed by the user, it becomes a bit tricky, and I'm still not sure how I would implement the following action: The list content has to be updated (or the adapter has to ignore the dismissed entries) and the views that were below the one that was dismissed must hover upwards in order to fill the gap. I think it might work to let the ListView load the new content, but that would fill the gap instantly. In order to avoid that, I would then start an animation that lets all the concerned views hover from their old position (where we still had the gap) back to their current position (where the gap is filled).
These are just some of my thoughts on the issue that might help some people getting started on working on the problem. Like I said, I'm probably going to implement that sometime in the future and of course I will post the code here.
I would appreciate any feedback in the comments, but I don't want to thorougly explain every single aspect of my idea, that would take me too much time ;)
I know this is quite an old question, but for anyone still searching for this, you can have a look at Roman Nurik's library here: https://github.com/romannurik/Android-SwipeToDismiss
This shows how to create the required behavior for list-view as well as for normal views.

Categories

Resources