Unable to find TrackSelectionView .getDialog class in exoplayer2 on AndroidX - chromecast

Unable to find TrackSelectionView .getDialog class on AndroidX.
But v7Support Libraries normal working.
error: cannot find symbol method getDialog(Activity,CharSequence,DefaultTrackSelector,int)
MappingTrackSelector.MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
if (mappedTrackInfo != null)
{
CharSequence title = string;
int rendererIndex = index;
int rendererType = mappedTrackInfo.getRendererType(rendererIndex);
boolean allowAdaptiveSelections =
rendererType == C.TRACK_TYPE_VIDEO || (rendererType == C.TRACK_TYPE_AUDIO &&
mappedTrackInfo.getTypeSupport(C.TRACK_TYPE_VIDEO) == MappingTrackSelector.MappedTrackInfo.RENDERER_SUPPORT_NO_TRACKS);
Pair<AlertDialog, TrackSelectionView> dialogPair = TrackSelectionView.getDialog((Activity) context, title, trackSelector, rendererIndex);
dialogPair.second.setShowDisableOption(non);
//dialogPair.second.setAllowAdaptiveSelections(allowAdaptiveSelections);
//Set the dialog to not focusable (makes navigation ignore us adding the window)
dialogPair.first.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
dialogPair.first.show();
dialogPair.first.getWindow().getDecorView().setSystemUiVisibility(((Activity) context).getWindow().getDecorView().getSystemUiVisibility());
//Clear the not focusable flag from the window
dialogPair.first.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
}
Find exoplayer dialog track in the TrackSelectionView .getDialog

Related

How to solve, Keyboard hide automatically when we work with multiple view?

We have two search textbox that will dynamically showing. One for portrait view and second for landscape view. We handled input text using flag in ViewDidLayoutSubviews() method. We have written a keyboard hide notification method as KeyboardWillHide(NSNotification notification) for text value handling.
We are getting these issue. Please have a look
1. When we start typing ViewDidLayoutSubviews() method every time call on key press and reload textbox. So my keyboard unable to up. We have fixe this with checking a flag if keyboard will then return.
2. Now we are getting same issue that keyboard hide automatic when we press on mic for speak to write. KeyboardWillHide(NSNotification notification) method every time call and hide keyboard. Its also call when we touch on tableview. 
How to solve these issue ,Please help
private void KeyboardWillHide(NSNotification notification)
{
string orientation = this.InterfaceOrientation.ToString();
if ((orientation.ToString() == "Portrait" || orientation.ToString() == "PortraitUpsideDown") && KeyboardHideSameView == false )
{
SearchText= txtSearchKeywordLS.Text;
txtSearchKeyword.Text = txtSearchKeywordLS.Text;
}
else if ((orientation.ToString() == "LandscapeRight" || orientation.ToString() == "LandscapeLeft") && KeyboardHideSameView == false )
{
SearchText = txtSearchKeyword.Text;
txtSearchKeywordLS.Text = txtSearchKeyword.Text;
}
txtSearchKeyword.ResignFirstResponder();
txtSearchKeywordLS.ResignFirstResponder();
isKeyboardApear = false;
KeyboardHideSameView = false;
}
public override void ViewDidLayoutSubviews()
{
base.ViewDidLayoutSubviews();
if (isKeyboardApear == true) return;
applyViewGradient();
var orientation = this.InterfaceOrientation;
if (orientation.ToString() == "Portrait" || orientation.ToString() == "PortraitUpsideDown")
{
PortraitConst(this.View.Bounds.Height, this.View.Bounds.Width);
this.vwLandscapeHead.Hidden = true;
this.vwPortraitHead.Hidden = false;
this.txtSearchKeyword.Text = SearchText;
txtSearchKeyword.ResignFirstResponder();
txtSearchKeywordLS.ResignFirstResponder();
}
else if (orientation.ToString() == "LandscapeRight" || orientation.ToString() == "LandscapeLeft")
{
//Console.WriteLine("Landscape Mode");
// this.addSubview(landscapeView, containerView);
LandscapeConst(UIScreen.MainScreen.Bounds.Height, UIScreen.MainScreen.Bounds.Width);
applyViewGradient();
this.vwPortraitHead.Hidden = true;
this.vwLandscapeHead.Hidden = false;
this.txtSearchKeywordLS.Text = SearchText;
txtSearchKeyword.ResignFirstResponder();
txtSearchKeywordLS.ResignFirstResponder();
}
// this.containerView.NeedsUpdateConstraints();
}
We have solved it logically by using flags.
We have declare a boolean flag isKeyboardAppear=false when view appear first. When keyboard appear we set this flag to true And we noticed ViewDidLayoutSubviews() method are calling on every key press, so we write this code
public override void ViewDidLayoutSubviews()
{
base.ViewDidLayoutSubviews();
if (isKeyboardAppear == true)
{
return;
}
}
When we hide keyboard manually we reset flag isKeyboardAppear=false .

Xamarin Android: Resource.designer Id does not match Android component Id

I am trying to find an ImageView within the SearchView widget, the ImageView's Id name is search_close_btn. I'm looking it up with this line of code however it returns null.
closeButton = searchView.FindViewById(Resource.Id.search_close_btn);
I investigated the children of the search view and found the ImageView and discovered that the Id of the child did not match the one from the designer.
I'm curious to where the correct Id is stored as I have to search the view manually in order to find it.
Is java's R.Id the equivalent to Xamarin's Resource.Id
Try the following once you have a reference to your SearchView:
int searchPlateId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null);
View searchPlate = searchView.FindViewById(searchPlateId);
if (searchPlate != null)
{
int imgViewId = searchPlate.Context.Resources.GetIdentifier("android:id/search_close_btn", null, null);
ImageView imgView = (ImageView)searchPlate.FindViewById(imgViewId);
if (imgView != null)
{
Console.WriteLine("Found you image view: {0}", imgView);
}
}

How can I get an IVsDropdownBar out of an EnvDTE.Window?

I get notified whenever a new window is opened by this method:
private void OnWindowActivated(EnvDTE.Window GotFocus, EnvDTE.Window LostFocus)
What I want to do now is to get the selected method in the object IVsDropdownBar, whenever this is changed.
So how can I get a reference to this object?
I haven´t tried that, so this answer is just an idea...
In accordance to MSDN you can obtain an IVsDropdownBar instance through the IVsDropdownBarManager service; the GetDropdownBar method returns the drop-down bar associated with the code window (might be the case that there isn´t a drop-down bar, since this addornment is language service specific and can be turned of via the options).
The documentation states that the IVsDropdownBarManager can be obtained from an IVsCodeWindow; I guess you can get such an instance from the active document window, somehow...
Once you have the IVsDropdownBar object, the GetClient and GetCurrentSelection methods might be of your interest; GetCurrentSelection allows you to query the selection for a certain drop-down; for instance...
IVsDropdownBar bar;
int hr = manager.GetDropdownBar(out bar);
if (hr == VSConstants.S_OK && bar != null)
{
IVsDropdownBarClient barClient;
hr = bar.GetClient(out barClient);
if (hr == VSConstants.S_OK && barClient != null)
{
// const int TypesDropdown = 0;
const int MembersDropdown = 1;
int curSelection;
hr = bar.GetCurrentSelection(MembersDropdown, out curSelection);
if (hr == VSConstants.S_OK && curSelection >= 0)
{
hr = barClient.GetEntryText(MembersDropdown, curSelection, out text);
if (hr == VSConstants.S_OK)
{
...
}
}
}
}
Not sure, if the obtained information is useful...
The documentation states, it can be
[...] plain or fancy text [...] and the drop-down code makes no assumption about their semantics.

How to programmatically move a tab to another window in a firefox Addon-SDK extension?

While it looks like you can change the order of a tab within a window by updating the tab .index property, it doesn't look like the tabs api directly supports the move of a tab to another window.
Am I missing something? Is there a viable workaround?
It is possible through the low level module window/utils. The example below duplicates the active tab across every open window
const { getMostRecentBrowserWindow, windows: getWindows } = require("sdk/window/utils");
const { ActionButton } = require("sdk/ui/button/action");
var button = ActionButton({
id: "duplicatetab-button",
label: "Duplicate tab",
icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACUElEQVQ4jaWTTWtTURCGjzc33CCpbVKN4kexC9EUY1Hov+iqPyDrbgtuCrViKUERqsWVguBGQaW4UiKiaEVxoShFGgnuBMUqNW3zce49Z+ZxUWtwoRR8YXbzPswM7xj+JgVEiXGsYVknxgII4Ltt5p8AB8RArOAUVQfqQJNtAFA8QgvF6i9PR1Dt0KbVBTjncM4hIni/OZv3HsRB+wvefiP2LcQnJIkQe49FEJFNQLPZZHh4mEwmQyqVoqenh3K5TGvlK1dOlageH+HG4DFar1/S0A6Lr99xdN8QxWKRXC6HGR0dJZvNMjk5Sb1ep1gskk6nuTo/D+/ec7dvkBdhP9cKeX7UXxEZQ2/YRxRFLC8vY+bm5qhUKnjvsdYyPj5OFEWcnTnHujiS5TfcPDbAw50h9w7u5f7UadLZFLVaDRHBiGzuY61lbGyMXC5HoVBgrbGGWAW/TvvxHR7s7udFKs/1oyfZ+PSRTqeDqm7eoFqtEoYhmUyG2dlZVJU4iREfI/WP3Nt9iMUdu7jdf5Anly5i0oaVlRWazSZmYWGBIAiIoohyucz09DQTExPMnJli9dlT5vcM8Kh3gFsHDuNqb9mb7yXMRBhjWFpawpRKJVKpFMYYgiAgDEOCIOD81BkunBjh8pEhKqUhGkvP6bQ/U//wgUP5/YRhSDabxbTbbVQV5xyq2q0kgR8NdOM7JKuo/Y5qggqIdPvMlnkrQCKCquJFsOrxeHAJxA48eFU6Xv4EqOpv41YqnQirqliv4MEmQtN7RBSs7wL+/gvb038DfgJnyUabbHzUbQAAAABJRU5ErkJggg==",
onClick: function() {
var xulwindows = getWindows("navigator:browser");
var xulactivewindow = getMostRecentBrowserWindow();
var xulactivetab = xulactivewindow.gBrowser.selectedTab;
xulwindows.forEach(function(win){
if(win === xulactivewindow)
return;
var duplicatedtab = win.gBrowser.duplicateTab(xulactivetab);
win.gBrowser.moveTabTo(duplicatedtab, 0); // the second argument is the index
});
}
});
#paa's solution is nice but it doesn't move a tab. His is duplicating the tab. So flash movies will not retain their position etc. And its not a move its a duplicatio, like he explained.
I did a lot of research was real fun. The way they move tabs in Firefox is via docShell swapping. This will accomplish what you want. It's written for bootstrap though so needs touch up for addon sdk.
Pass second argument as string of tabbed or non-tabbed if you want to move it to a new window. Else pass second argument an existing window and it will be moved there. can copy paste and run this code from sratchpad.
this uses the gBrowser.swapBrowsersAndCloseOther function
function moveTabToWin(aTab, tDOMWin) {
//tDOMWin means target DOMWindow means the window you want the tab in
//if tDOMWin == 'tabbed' or == 'non-tabbed' it opens in a new window
//if aTopContWin is the last in its window, then its window is closed
if (tDOMWin == 'tabbed' || tDOMWin == 'non-tabbed') {
var sa = Cc["#mozilla.org/supports-array;1"].createInstance(Ci.nsISupportsArray);
var wuri = Cc["#mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
wuri.data = 'about:blank';
sa.AppendElement(wuri);
let features = "chrome,dialog=no";
if (tDOMWin == 'tabbed') {
features += ',all';
}
var sDOMWin = aTab.ownerGlobal; //source DOMWindow
if (PrivateBrowsingUtils.permanentPrivateBrowsing || PrivateBrowsingUtils.isWindowPrivate(sDOMWin)) {
features += ",private";
} else {
features += ",non-private";
}
var XULWindow = Services.ww.openWindow(null, 'chrome://browser/content/browser.xul', null, features, sa);
XULWindow.addEventListener('load', function() {
var DOMWindow = XULWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow);
DOMWindow.gBrowser.selectedTab.linkedBrowser.webNavigation.stop(Ci.nsIWebNavigation.STOP_ALL);
DOMWindow.gBrowser.swapBrowsersAndCloseOther(DOMWindow.gBrowser.selectedTab, aTab);
//DOMWindow.gBrowser.selectedTab = newTab;
}, false);
} else if (tDOMWin) {
//existing dom window
var newTab = tDOMWin.gBrowser.addTab('about:blank');
newTab.linkedBrowser.webNavigation.stop(Ci.nsIWebNavigation.STOP_ALL);
tDOMWin.gBrowser.swapBrowsersAndCloseOther(newTab, aTab);
tDOMWin.gBrowser.selectedTab = newTab;
}
}
moveTabToWin(gBrowser.selectedTab, 'tabbed');
I'v got inspired by #Noitidart's answer and came up with my solution.
I'm adding setWindow(window, index) method to Tab's prototype, so that any SDK tab can be moved to another window from anywhere in the addon with a simple call like this:
browserWindows[0].activeTab.setWindow(browserWindows.activeWindow, 0);
This will move active tab of window 0 to the beginning of active window.
And here is the method:
Update:
I've put together a module to do exactly this: jetpack-tab-setwindow
Old solution (breaks in FF43)
var Tab = require("sdk/tabs/tab").Tab;
Tab.prototype.setWindow = function (window, index) {
var tab = this;
var oldWindow = tab.window;
if ( oldWindow !== window ) {
// We have to use lower-level API here
var Ci = require('chrome').Ci;
var viewFor = require("sdk/view/core").viewFor;
var aTab = viewFor(tab);
var aWin = viewFor(window);
var gBrowser = aWin.gBrowser;
// Get tab properties
var isSelected = oldWindow.activeTab == tab;
var isPinned = aTab.pinned;
// Log for debugging:
var tabId = tab.id;
console.log('setWindow', {index, isSelected, isPinned, tab, tabId});
// Create a placeholder-tab on destination windows
var newTab = gBrowser.addTab('about:newtab');
newTab.linkedBrowser.webNavigation.stop(Ci.nsIWebNavigation.STOP_ALL); // we don't need this tab anyways
// If index specified, move placeholder-tab to desired index
if ( index != undefined ) {
var length = gBrowser.tabContainer.childElementCount;
if ( index < 0 ) index = length - index;
if( 0 <= index && index < length ) {
gBrowser.moveTabTo(newTab, index);
}
}
// Copy tab properties to placeholder-tab
if ( isPinned ) {
gBrowser.pinTab(newTab);
}
// For some reason this doesn't seem to work :-(
if ( isSelected ) {
gBrowser.selectedTab = newTab;
}
// Swap tabs and remove placeholder-tab
gBrowser.swapBrowsersAndCloseOther(newTab, aTab);
}
};

Check if behavior is attached to element

The question is: how to check if the d3 behavior, such as drag or zoom, is already called on the element? Seems to be this task is in relation to getting the events, which are attached to element? What is the common approach?
Thanks.
I know this is old, but I came across this post looking for the same thing, saw there wasn't an answer, so created the answer my self. This is for d3.js Version 4.
function hasD3EventOn(ele, eventName, eventType) {
if (!ele || typeof eventName == 'undefined') return !1;
if (ele._groups) ele = ele._groups[0][0]; // if d3.select()
var on = ele.__on; //d3.js(v4) function onRemove(typename)
if (!on || !on.length) return !1; var i = on.length, o;
while (--i >= 0) { if ((o = on[i]).name && o.name === eventName && (typeof eventType == 'undefined' || (o.type && o.type === eventType))) return !0; } return !1;
}
Just send in either a d3.select element (first in array only) or a native DOM Element along with the event name such as 'zoom', both are reqired. There is also the option for the event type such as 'wheel'. It also has some basic validation (maybe excessive) to help prevent crashing when called with trash or property name collison.

Resources