Jump to content

Featured Replies

Posted

Hi, I'm testing a CollectionView to display a large number of data rows (literally 100,000) with images. The images will be loaded from the web.
How can I achieve this using FGX? I apologize for asking, but there’s no documentation available.

Thank you

function TFormMain.cvGetItemCount(Sender: TObject): Integer;
begin
  result := 10;
end;

procedure TFormMain.cvGetItemId(Sender: TObject;
  const AIndex: Integer; var AId: Int64);
begin
  lHeader.Text := 'Header '+AIndex.ToString+','+AId.ToString;
  im.ImageName := 'https://picsum.photos/id/'+AId.ToString+'/200/300';
end;

image.thumb.png.4f6aa7b3244a26e78c4b9d1909927ba6.png

Hi. The ImageName property maps to a file on the local device. Accordingly, you need to download it additionally, for example using TfgAssetManager, and you can specify the name of the local file even if AssetManager has not downloaded it yet. As soon as the download is finished, the image will be displayed.

  • Administrators

Hello,

10 hours ago, barshad said:

im.ImageName := 'https://picsum.photos/id/'+AId.ToString+'/200/300';

ImageName is just a reference on asset with name in TfgAssetsManager. It cannot be URL. 

There are at least 2 ways how to download image:

  1. Automatically via FGX Native. Look at the followed demo samples: Assets -> Images -> "Asynchronous image loading by URL". It demonstrates how to load image with Assets manager by URL via the Internet. TfgAssetsManager can download image.
  2. Manually. You can manually download all required images via the THttpClient component for example, than add images to TfgAssetsManager via Add method and         

Also keep in mind, the device has limited memory, so if you try to downoad 10K images to memory, application will crashed with OutOfMemory exception. However, AssetsManager has special mechanizm for it. Look at the demo "Assets" -> "Images" -> "Releasing image from memory"

Quote

procedure TFormMain.cvGetItemId(Sender: TObject;
  const AIndex: Integer; var AId: Int64);
begin
  lHeader.Text := 'Header '+AIndex.ToString+','+AId.ToString;
  im.ImageName := 'https://picsum.photos/id/'+AId.ToString+'/200/300';
end;

It's completly wrong code. You need to study the demo projects. Components -> TfgCollectionView.

PS. All demo projects are available from the main menu File -> New -> FGX Sample

If you have questions after trying our demo samples, feel free to ask here.

Thank you

  • Author

Thank you Yaroslav,
I have one more question please, where are OnGetFocused like event? I want to highlight, scale up and shadow to the focused item in CollectionView

 

Thank you 

 

  • Administrators

Hello,

What do you mean about OnGetFocused? Item in collection view doesn't have focus in general. If you are talking about selection, so you should have a look at the: OnItemSelectionChangedOnSelectionChanged

Also if you would like to add custom selection behavior, look at the sample in Components -> TfgCollectionView -> Manual displaying selection

  • Administrators

Unfortunately I have never tried to debug on Android TV. As far as I remember, the difference between a TV and a tablet or phone is that it is controlled by setting the focus. But I don't think that's how it will work for collection view by default. You may need to specify separately that the element can be focusable. But this can only be done directly through the Android API. But the benefit of FGX Native allows you to get direct access to the naive representation of each control.

  • Author

Forget that it's a TV app — it's not specifically a TV app. I just want to run it on Android TV or other non-Android TV boxes. It's a normal app.

Even in Java (Android Studio), I use code to check whether an item is focused or has lost focus.

Do you have any sample Android API code for that? Even a simple app with two Card Panels or Buttons would work. I only need to detect the focus event (not click) when the user uses the keyboard or arrow keys to move focus between components.

  • Author

Thank you, button are already focusable I want to know how to get the focus event.

  • Author

Also can you please publish the Interface sections of your library? that would be great help

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.