Bottomsheetdialogfragment with recycler view either half open or closed - android-fragments

I have a fragment and inside it there is a tablayout with view pager as here.
Each tab opens a bottom sheet fragment, each has a recycler view inside them. I want to make them half open and disable scroll so that once they are opened, their position is fixed and if the user scrolls down they are closed. So they are either half open or closed.
I make them half opened as follows. I tried disabling the scrolling but it was not enough. How can I solve the problem?
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return BottomSheetDialog(requireContext(), theme).apply {
behavior.state = BottomSheetBehavior.STATE_HALF_EXPANDED
}
}

Related

Floating QDockWidget appears not on the same screen as the main window when dragged

I'm completely stuck with the following problem. When I drag a dock widget out of the main window, which is placed on the second screen, the floating dock appears on the first screen. When I click on the float button, it appears undocked correctly, i.e. near the main window, but only if I didn't drag it out before. If I did, docked it after and then clicked the float button, it appears detached on the first screen as well.
When I do all this on the first screen, it works fine.
First I thought I could force the dock widget to appear where I want it to by using something like this:
connect(dock, &QDockWidget::topLevelChanged, [this, dock](bool) {
dock->setGeometry(this->x(), this->y(), 200, 500);
});
It solved buggy floating button behavior, but didn't help with dragging, so my dock widget appears 200x500 px on the first screen again.
I also don't see any possibility to subclass and override anything here.
Is there a way to make the dock widget appear on the screen where the main window is, when it's detached by dragging?

Prevent JavaFX TabPane from switching tabs on swipe

When I use a TabPane with a touchscreen, the tabs are switching when I swipe left or right, which I want to prevent.
I fixed part of the problem by consuming the swipe events on the child panes, but the tabs still switch when I swipe in the area where the tabs are displayed.
I tried to consume the events that the TabPane generates, such as the swipe and scroll events, but the tabs are still switching. How do I prevent this from happening?
I add the same problem. I solved adding the following filter to the tabPane:
tabPane.addEventFilter(SwipeEvent.ANY, new EventHandler<SwipeEvent>() {
#Override
public void handle(SwipeEvent event) {
event.consume();
}
});

ScrollPance moving with node Javafx

I have a scroll Pane with a rectangle inside the scroll Pane.The rectangle can only move left or right . The scroll pane has a with of 800,when the windows gets to small the scrollbar becomes enabled and you can scroll. My problem is when i try to move the rectangle when the scrollbar is on , the scroll bar will also move either left or right.Is the a way to temporary disable the scroll feature when i am moving the node >
I think what you might be looking for is
public final void setPannable(boolean value)
Sets the value of the property pannable.
Property description:
Specifies whether the user should be able to pan the viewport by using the mouse. If mouse events reach the ScrollPane (that is, if mouse events are not blocked by the contained node or one of its children) then pannable is consulted to determine if the events should be used for panning.
https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/ScrollPane.html#setPannable-boolean-
I'm not sure if this works, but sounds like it.
You also could use https://docs.oracle.com/javase/8/javafx/api/javafx/scene/Node.html#onMouseClickedProperty
or a similar MouseProperty, set up a Listener and make it so that when you click on the ScrollPane, it will set https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/ScrollPane.ScrollBarPolicy.html
to NEVER
public static final ScrollPane.ScrollBarPolicy NEVER
Indicates that a scroll bar should never be shown.
then back to your original setting for ScrollPane.onMouseReleased();
Good luck!

Bootstrap 3 button group Drop UP or DOWN, base on position in table container

I have problem with bootstrap drop up/down button.
Button Menu doesn't fit well on page.
I am looking for way to dynamically detect position on page of that button.
Base on location button should automatically drop up instead of drop down.
Here is problem:
on "SHOW" and "Action" button. Menu doesn't fit on page (It extends container).
https://jsfiddle.net/yz0ex8c5/
https://jsfiddle.net/3ro502q5/4/
The same happens when the button is on top. It opens Dropping up Instead of drop Down.
This is very important. Couse I use this buttons with drop down and drop up in table that can be sorted. I use Bootstrap-table library to sort rows in table.
You could check the scrollTop position for the page, then switch between .dropup or .dropdown according to what is most suitable.
$(window).scroll(function() {
var scrollTop = $("body").scrollTop();
if (scrollTop<50) {
$("#showBtnGroup").removeClass('dropdown').addClass('dropup');
} else {
$("#showBtnGroup").removeClass('dropup').addClass('dropdown');
}
});
forked fiddle -> https://jsfiddle.net/wenz3v5r/
Have given the btn-group an id for easy access. The evaluation value of 50 is completely arbitrary, have just added a lot of <br>'s to the bottom and the top of the page - that must depend on how your site looks like IRL. You should do the same (or rather the opposit) with the Action dropdown at the bottom.

jquery mobile sidebar not expected drag

I'm working on a phonegap app that has a fixed sidebar behind the page and I found an behavior issue.
The sidebar is hidden, the user can see it with a tap on a menu icon. When the user tap on he icon the page go to the right and it shows the sidebar that is in a minor z-index.
If the user want to close the menu he have to drag the visible part of the page to the left.
My problem was that in the sidebar I have a block that is vertically scrollable. It works fine but the thing is, if I put the .scroll (overflow-y: scroll; -webkit-overflow-scrolling: touch;) class in this element and the user swipe horizontally from right to left over it the sidebar and the page start a drag.
We're using snap.js for the sidebar interaction.
I want to disable this drag. I tried with CSS and preventing horizontal scroll but it doesn't work.
I attach a pic for more visual details.
Use iScroll5 for scrolling.
Then hook into the onScrollStart event:
myScroll.on('beforeScrollStart', function(event)
{
if (isPanelOpen){
myScroll.disable();
}
else{
myScroll.enable();
}
});
Or - if you not wanna use iScroll5, you can set a global bool, which indicates, if a panel is open (you've gotta do this anyway).
If a Panel is open (meaning, you're showing the sidebar) set the bool to true in snap.js - this subsequently means, you've gotta tweak snap.js.
Then, on touchmove, check the bool if it is true. Then you know, a panel is open, and you can do a event.stopPropagation on touchmove in order to prevent the event bubbling up to get recognized by snap.js and avoid the panels closes too early.
Woop! We found it!
The problem was that we're catching the touchmove event for each element with .scroll class and we're stoping the propagation of it.
We had notice that when we tried to start a horizontal scroll all page was moving like a drag so we added this CSS property:
html, body, .ui-mobile .ui-page-active { overflow-x: hidden; }
And...it works fine!
P.S. we don't actually need the horizontal scroll in any element, so, this is fine for us.

Resources