Xamarin Forms Map - Polyline background thread? - multithreading

I'm attempting to plot 90,000+ GPS LAT/LONGs on a Xamarin Forms Map.
Using basically the following to highlight my Polyline:
https://developer.xamarin.com/recipes/cross-platform/xamarin-forms/maps/map-overlay/polyline/
I want to ensure all the points are plotted/drawn in the background so it allows the UI to still be responsive. Currently its taking 5-10 seconds for UI to become responsive.
I've attempted code similar to the following but I don't believe it's correct.
Task.Factory.StartNew(() =>
{
var plist = (from p in totalPoints
select new Position(p.Latitude, p.Longitude)).ToList();
Device.BeginInvokeOnMainThread(() => {
map.RouteCoordinates = plist;
map.MoveToRegion(GeoHelper.FromPositions(plist));
});
});
What's the best way to do this?

Related

How to grid updated and refresh data with KendoUI for Angular2?

I am using the Kendo UI grid to edit records.
I have a load data function:
private loadData(): void {
this.gridView = {
data: this.data.slice(this.skip, this.skip + this.pageSize),
total: this.data.length
};
}
and I have a service that updates the data and stores it in this.data content:
this.dataservice.update().then(res => this.loadData());
However, the UI does not update. How should I update the grid UI?
If the grid is not updated, I suppose that changes in the loadData() method are not detected.
A simple test in a plunker shows that such simplified approach works just fine:
Plunker Demo
As a side note, if you are not seeing changes in the a specific row template, then this is a known issue logged here:
Kendo Grid for Angular 2 Issue

Selecting a UI element not on the screen of native android app using Appium, Selenium web driver, Node js, Mocha etc

I'm testing a native Android app and need to click on a button that is off the bottom of the screen. I've seen tons of examples of this using Java and Javascript but I'm using Node.js and nothing seems to work. I'm pretty new to this stuff and have wasted far too much time on something so simple.
For example to click on an onscreen element this works:
it("Select Button Test",function(){
return driver
.setImplicitWaitTimeout(timeoutWait)
.elementByXPath('//android.widget.TextView[#text=\'My Button\']').click();
});
Also the full xpath works for onscreen elements - in this case:
var myButton ='//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.view.View[1]/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]/android.widget.ScrollView[1]/android.widget.LinearLayout[1]/android.widget.TableLayout[1]/android.widget.TableRow[10]');
it("Select Button Test",function(){
return driver
.setImplicitWaitTimeout(timeoutWait)
.elementByXPath(myButton).click();
});
I found the full xpath for this button by scrolling to it while the test was running and firing up the screen in appium inspector. I've tried various scroll, touch, and swipe methods from the webdriver docs but nothing is available so apparently I've wandered off the ponderosa...
So how can I access a button that is not on the screen?
I'm sure its some mundane detail. Thanks!
try the below scroll function to scroll using dimensions
public void scroll() throws IOException {
Dimension dimensions = driver.manage().window().getSize();
System.out.println("Size of Window= " +dimensions);
int scrollStart = (int) (dimensions.getHeight() * 0.5);
System.out.println("Size of scrollStart= " +scrollStart);
int scrollEnd = (int) (dimensions.getHeight() * 0.2);
System.out.println("Size of scrollEnd= " + scrollEnd);
driver.swipe(0,scrollStart,0,scrollEnd,1000); }
and then use your locator strategy to find the element
I'm use node.js to test react native app solve this problem .
The appium node.js sample code have scroll feature.First,you need import all what sample imported.Then there's the codeļ¼š
it("should scroll", function () {
return driver
.elementByXPath('//android.widget.TextView[#text=\'Animation\']')//change your element which doesn't cover it.
.elementsByXPath('//android.widget.TextView')
.then(function (els) {
return Q.all([
els[7].getLocation(),
els[3].getLocation()
]).then(function (locs) {
console.log('locs -->', locs);
return driver.swipe({
startX: locs[0].x, startY: locs[0].y,
endX: locs[1].x, endY: locs[1].y,
duration: 800
});
});
});
});
good luck !!

Multithreading in flex web application

I am working on web application. In which i am stuck with some issue.
When i call some server function it will take time to get response. When response have high number of data. It will get data, process on that data and update GUI in background.
Upto that my application GUI freeze. I can not click on any part. I see some where that ActionScript support multithreading. I found some tutorial for that which is here. But, it is for desktop application only.
Is there any way i can handle this freezing of application/GUI in web application. It will decrease my application performance and looks very bad.
Example:
If i have list of data with checkbox and on checkbox click there is some process. Now, there is one button called "Select All". Now, if i click on "select all" then all check box selected and process on check selection is going and freeze the application upto process done.
like: I have following list
<s:List id="tempList" itemRenderer="CustomItemRenderer"
dataProvider="{someList}" useVirtualLayout="false"/>
ItemRenderer have label and checkbox as following.
<s:CheckBox id="cCheckId" selected="{data.selected}"
change="onChangeHandler(event)" />
<s:Label id="lblTest" />
protected function onChangeHandler(event:Event):void
{
data.selected = !data.selected;
}
Now, on button Select all will select all check box.
<s:Button id="btnSelectAll" label="Select All" click="selectAllHandler(event)" />
protected function selectAllHandler(event:MouseEvent):void
{
for(var i:int = 0;i<someList.length;i++)
{
someList[i].selected = true;
}
}
Now, if someList have lots of data then it will freeze the screen.
Any help is greatly appreciated.
The main idea behind the list and itemrenderers that you have a list (or datagrid) that displays like 30 items and then you can scroll to see the rest. Then you will only have 30 Itemrenderers that would be updated at once.
If you don't want to scroll you will need to distribute your item selection over several frames, something like that (untested, but you get the idea)
private static const ITEMS_AT_ONCE:int = 5000;
private var _currentIndex:int;
protected function selectAllHandler(event:MouseEvent):void
{
_currentIndex = 0;
addEventListener(Event.ENTER_FRAME, onEnterFrame); // this will call the onEnterFrame method on each frame rendered
}
private function onEnterFrame(e:Event):void
{
// make sure we don't run out of bounds of the dataprovider's length
var maxIndex:int = Math.min(_currentIndex + ITEMS_AT_ONCE, someList.length);
// set selection for the current bunch
for (var i:int = _currentIndex; i < maxIndex; i++)
{
someList[i].selected = true;
}
if (maxIndex == someList.length)
{
// We are done, remove enterframe listener
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
// I'm not sure but don't you need to refresh the dataprovider to reflect the changes in the ItemRenderers ?
// (someList.dataProvider as ArrayCollection).refresh();
}
else
{
// update the _currentindex so we continue after this item on the next frame
_currentIndex = maxIndex;
}
Another possible solution - if you display all of them anyways - you might try to switch to a VGroup that will hold custom UIComponents (without MXML) for the items - this should speed up the rendering.

Transition is lost when using PRISM in UWP

I am making my first steps in Universal Windows Platform (Windows 10 store apps technology). I have an application with 2 pages and use the navigation service to navigate between them. I am used to having a transition applied when navigating between pages, but now I don't see any transition.
I tried to set the content transition manually but that does not work as well:
protected override Task OnLaunchApplicationAsync(LaunchActivatedEventArgs args)
{
var shell = Shell as Frame;
shell.ContentTransitions = new TransitionCollection();
shell.ContentTransitions.Clear();
shell.ContentTransitions.Add(new ContentThemeTransition { HorizontalOffset = 300 });
this.NavigationService.Navigate(Experiences.Main, null);
return Task.FromResult<object>(null);
}
Is there any other way to configure the navigation service to apply a transition?
I found the solution for the problem. I ended up using the **EntranceThemeTransition** and it seemed to work:
shell.ContentTransitions.Add(new EntranceThemeTransition {
FromHorizontalOffset = 400,
FromVerticalOffset = 0,
IsStaggeringEnabled = true});

Telerik MVC Grid submitChanges with no grid changes

I'm using Telerik's MVC grid, and I would like to submit batch edit mode changes with some out of grid values. According to this telerik forum I can call the grid's submitChanges function and supply non-grid values inside the OnSubmitChanges event. This function only gets called if the grid has changes. There can be a case when values are changed outside of the grid but grid values are not saved. Is it possible to force the submission so that non-grid values can be submitted?
Good thing Telerik MVC Extensions are open source. I figured out the answer the following way:
function SaveCriteriaChanges() {
var grid = $("#MyGridId").data("tGrid");
//don't submit if grid fails validation
if (!grid.validate())
return false;
if (grid.hasChanges()) {
grid.submitChanges();
} else { //no grid changes to process so force submission
var additionalValues = {};
if(!$.telerik.trigger(grid.element, 'submitChanges', { values: additionalValues })) {
grid.sendValues($.extend({}, additionalValues), 'updateUrl', 'submitChanges');
}
}
return true;
}

Resources