I have a ListView in my Xamarin Android app where I have over 100 list items. Each item has a Google Maps component showing a map of an area. I have realized that this causes the vertical scrolling of the ListView to lag (due to each component is pretty computational heavy I suppose). Each area is about Width x 128 pixels.
I am now thinking of how I can show the map of the area and still have good performance in the scrolling. One idea is to generate a small image of each area and bind it to the ListView item instead. However, as far as I understand, it is not technically possible to generate images from the Google Maps API (map + marker).
How would you recommended to solve this? Do you think I have some other bottleneck rather than the 100 instances? In my tests its pretty obvious it started to lag when I added the component. However, the component is hidden (IsVisible="False") unless you expand the List Item, but still its "there" and the lag persist. Is it normal to have so many components first of all?
My map is part of a Grid and looks like this:
<Frame Grid.Row="4" x:Name="expandArea" BackgroundColor="Transparent" IsVisible="False" Padding="0" Margin="0" HasShadow="True">
<maps:Map x:Name="userMap" MinimumHeightRequest="128" HeightRequest="128" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"/>
</Frame>
Related
Custom objects disappear on every orbit zoom or rotation for about one second, then reappear again when added to a aggregated view in combination with a large model. While the objects are hidden, I can see that there is some reloading/rerendering of the other unrelated model going on.
Overlays (meshes rendered directly into threejs) obviously don't show this behavior.
I'm using viewer version 7.85 and the sample code from here: https://aps.autodesk.com/blog/custom-models-forge-viewer
modelBuilder.addFragment(sphereGeometry, sphereMaterial, sphereTransform);
Is there any way I can prioritize rendering of my custom model or disconnect the rendering from other loaded models?
I am using full-calendar API for vertical resource view in my project. All is working fine for around 10 resources. But when I increase the number of resources in my project the view got screwed up.
SO how can I add a horizontal scrolling in this view.
in the viewRender callback function you can add something like
if(view.name === "agendaDay"){
$('.fc-view-container').css('overflow-x','auto');
$("#fullcalendar_container").css('min-width',$('.fc-resource-cell').length*slot_width_resource);
}
I have my slot_width_resource equal to 125. You can play around with that value so the spacing works better.
I am trying to display a GIF file stored in a Windows Phone 8.1 (RT) application's local folder. Until now, I have tried several approaches:
Load the GIF in a WebView control. This is not a solution since I want to display the images in a FlipView control (I cannot flip to another image). Also, it is quite slow.
Get the GIF frames using the BitmapDecoder class and animate them using a storyboard.
The code is as follows:
using (var stream = await storageFile.OpenReadAsync())
{
//I don't specify the type since I would like to load other type of images also
//It doesn't make any difference if I would use "BitmapDecoder.GifDecoderId"
var decoder = await BitmapDecoder.CreateAsync(stream);
uint frameCount = decoder.FrameCount;
for (uint frameIndex = 0; frameIndex < frameCount; frameIndex++)
{
var frame = await decoder.GetFrameAsync(frameIndex);
var writableBitmap = new WriteableBitmap((int)decoder.OrientedPixelWidth,
(int)decoder.OrientedPixelHeight);
var pixelDataProvider = await frame.GetPixelDataAsync
(BitmapPixelFormat.Bgra8,
decoder.BitmapAlphaMode, new BitmapTransform(),
ExifOrientationMode.IgnoreExifOrientation,
ColorManagementMode.DoNotColorManage);
var pixelData = pixelDataProvider.DetachPixelData();
using (var pixelStream = writableBitmap.PixelBuffer.AsStream())
{
pixelStream.Write(pixelData, 0, pixelData.Length);
}
_bitmapFrames.Add(writableBitmap);
}
}
The problem is that the frames I get from the GIF image are messed up
Am I doing something wrong in this approach? What should I modify in order to get good results?
I wouldn't like to use SharpDX since it seems to be very complicated and I am a beginner.
ImageTools is available only for Silverlight
I made a very basic GifImage control that you can start from. This is a starting point, you'll have to improve it to make it more usable as a reusable control. Check it out here.
EDIT
Do you have any idea how to improve the loading speed (parallelization, etc.)?
I assume you're referring to the process of preparing the frames. From what I tested, it seems to load instantly anyway, so there shouldn't be a need for drastic performance improvements. However, if perhaps the animation has hundreds of frames, then it could be a bottleneck maybe? More testing needs to be done to assess whether or not optimisations are necessary.
I also don't think it can be paralleled easily since each frame needs to be rendered in sequence from the previous frame. My only suggestion would be to run the loading code on a background thread so the UI thread doesn't block for large images.
If I have this control as a FlipViewItem, how can I release the memory after the item is flipped away?
I'm not sure whether or not you're using MVVM or not, but anyway, here's some suggestions:
Set the Source of the GifImage to null if it's not currently visible (inspect the SelectedIndex of the flip view). Note that currently the code in my repo doesn't handle setting Source to null. Like I said before, it needs lots of improvements. You'll have to make sure that the control doesn't hold any references to the frames so that the garbage collector can free them from memory (that is, call animation.KeyFrames.Clear() to clear all references to the frames).
Use a VirtualizingStackPanel inside the flip view. This will ensure that only the previous, current, and next flip view items are created in memory. You set it like this:
<FlipView>
<FlipView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</FlipView.ItemsPanel>
</FlipView>
I had a similar problem. I was trying to display an animated GIF loaded from an external source inside a ScrollViewer for Windows Phone 8.1 app. Since the web control takes over the events the scrolling did not work.
I used this trick: I placed the web control inside a grid and put another grid over the webcontrol. The grid over the web control was set to be the exact same size and I set the background to transparent. This way the grid receives the events and the scrolling works again.
<ScrollViewer Visibility="Visible" HorizontalAlignment="Left" VerticalAlignment="Top" Width="380">
<Grid>
<StackPanel>
<!--
Some items ...
-->
<Grid >
<WebView x:Name="animationWebView" HorizontalAlignment="Left" Height="315" Width="390" Visibility="Visible" />
<Grid Width="390" Height="315" Background="Transparent" />
</Grid>
<!--
Some other items ...
-->
</StackPanel>
</Grid>
</ScrollViewer>
I'm failrly new to LibGDX and I'm running into a problem.
I'm building a classically styled RPG/Adventure game in which I'm using a TiledMap(-Renderer) to create the map. I've followed different tutorials but can't get it to work. (last one was DPG's: Full working example link)
What I need, is a column of buttons on the right side of the screen (implemented that through ImageButtons). One of these buttons lead to a settings-kind of screen and another one should lead to the game map. Under a ClickListener of the button I've added DPK's code of
MapHelper map = new MapHelper();
map.setPackerDirectory("data/packer");
map.loadMap("data/world/level1/level.tmx");
map.prepareCamera((int)stage.getWidth(), (int)stage.getHeight());
map.getCamera().update();
map.render();
The MapHelper class is an exact copy of dpk's, only change above is the setting of the width and height of the camera. Any suggestion what I'm doing wrong here?
I don't think you want to invoke map.render() in the ClickListener callback. That would mean the map is only rendered when you click, and then not re-rendered (generally everything gets re-rendered on every screen re-fresh).
I think you need to track the map in your application class, and in the ClickListener callback you need to set a flag or somehow "enable" the map (perhaps setting it to something other than null). Then in the application's render() method you can check to see if the map should be rendered or not, and render it if so.
Specifically, move the calls to prepareCamera, getCamera and render out of the ClickListener.
I'm sure a lot of people need this, but so far I have not been able to find a good solution.
Environment: AIR app for iOS and Android created with Flash CS6.
What I'm trying to do: Display a table (5 columns, 200 rows). Nothing fancy, just text data. The table should be sortable and scroll smoothly in response to swipe gesture.
The DataGrid component is too "heavy" and not recommended for mobile. Is there a simple solution for this?
For table display (even fancy) I would use the StageWebView, of course if you can afford to not be able to overlay anything over it.
Quick Sample below:
webView = new StageWebView();
webView.viewPort = new Rectangle(0, 44, 480, 756);
webView.loadString('<html><head><style type="text/css">tr:nth-child(odd) { background-color:#eee; } tr:nth-child(even) { background-color:#fff; } .header_button { width:100%;}</style></head><body><table width="200" border="1"><tr><td><input name="Name" type="button" value="Name" class="header_button"></td><td>Id</td></tr><tr><td>Mark</td><td>0</td></tr><tr><td>Bob</td><td>1</td></tr></table></body></html>');
webView.stage = stage;
you should read through documentation as loadString is pretty limiting:) to see all possible ways of using this class, but the idea should by planted in you by now:) e.g. CSS, JQuery etc. can be used, and scrolling is really fast:)
I haven't tried them yet, but Mad Components (technically it's the Extended Mad Components lib) has a UIDataGrid class.
Other than that, since your grid/table is only intending to display text, you might want to give the components from Adobe a try. Their grids are flexible, and as a result can be "heavy".
Since you only want to render text, you won't pay the price of trying to render heavier objects (check boxes, buttons, etc) inside the grid. The performance (when only rendering text inside the grid) may be acceptable.
Forget the Flex DataGrid, even with static text you won't get acceptable scrolling performance (I got about 5fps for a real time data grid).
The way to go is a normal List with a custom LabelItemRenderer and a button group for the header. You can make the renderer look like a grid very easily.
I haven't tested Alex Harui's list based grid, but it should work out of the box. If not, you should get the idea. Just roll your own AS3 based renderer and performance should be over 25fps even with fast scrolling. I get around 30 on an iPad2.