Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 05/16/20 in all areas

  1. After a lot of Googling and experimenting, I managed to solve this myself. From what I could gather, and this may apply only to later versions of Android (I have Android 10 on my Pixel 3a), the method that FMX uses to "scan" the image file into the gallery, which is via an intent (source\rtl\androiddex\java\fmx\src\com\embarcadero\firemonkey\medialibrary\MediaImage.java): /** * Adds photo to Gallery application. */ public void addPhotoToGallery() { Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); intent.setData(getFileUri()); activity.sendBroadcast(intent); } Does not immediately update the media "database". I discovered that using the scanFile method of the MediaScannerConnection class: https://developer.android.com/reference/android/media/MediaScannerConnection Does cause an immediate update, so that requerying using ContentResolver now works. I used the code in this article: https://www.grokkingandroid.com/adding-files-to-androids-media-library-using-the-mediascanner/ To come up with the additional Delphi code required, which is in the attached test app. I've added some comments which should clarify the whys and hows. AndroidGetPhotoV2.zip
  2. FredS

    Rx10.4 new feature blogs

    I'm also Primary contact and there has never been another, the email hasn't changed from Godzilla, yet nada.. Not that I was interested but some bot shouldn't know that 🙂
  3. pyscripter

    Revisiting TThreadedQueue and TMonitor

    I am attaching a new version of the test code incorporating the suggestions of @Anders Melander in case anyone wants to try see attached iaStressTest.TThreadedQueue.PopItem that can be used with the original stress test of @Darian Miller). iaStressTest.TThreadedQueue.PopItem.pas
  4. Alexander Elagin

    Rx10.4 new feature blogs

    So if I am the Primary Contact (as I paid the bill myself) I still have to assign myself somewhere as an Authorized Contact? Damn, the Embarcadero's sales model does not change with years, they are targeting businesses, not developers. And don't remind me about all this reseller-only distribution and obligatory quote request for updates ☠️...
  5. If size was the only problem, I can imagine something like this ("human preprocessor"): type tRecordA = record of size 8; tRecordB = record ... function Test: tRecordA; end; tRecordA = record x, y: integer; end;
  6. Dave Nottage

    Rx10.4 new feature blogs

    As Bill said, it's a "we've been given permission" thing. This is not new, however - I think it has been a "thing" for at least a couple of major releases now. Also, you missed my post: https://www.delphiworlds.com/2020/05/its-time-to-get-excited/ 🙂
  7. Anders Melander

    Revisiting TThreadedQueue and TMonitor

    It's been raining so here you go (completely untested): type TEventStack = record Counter: int64; Head: PEventItemHolder; procedure Push(EventItem: PEventItemHolder); function Pop: PEventItemHolder; end; var EventCache: TEventStack; ... EventItemHolders: TEventStack; procedure TEventStack.Push(EventItem: PEventItemHolder); var Current, Next: TEventStack; begin repeat // We don't need to copy atomically since the test below will detect tearing // but since the members should be aligned tearing should not occur anyway. Current := Self; EventItem.Next := Current.Head; Next.Head := EventItem; Next.Counter := Current.Counter + 1; // I'm assuming TInterlocked.CompareExchange returns a boolean: True on success. until TInterlocked.CompareExchange(Self, Next, Current); end; function TEventStack.Pop: PEventItemHolder; var Current, Next: TEventStack; begin repeat Current := Self; if (Current.Head = nil) then Exit(nil); Next.Head := Current.Head.Next; Next.Counter := Current.Counter + 1; until TInterlocked.CompareExchange(Self, Next, Current); Result := Current.Head; end; I've made the two functions members of the record to get rid of the first parameter. What you (or someone else) need to do is provide an implementation of TInterlocked.CompareExchange, AtomicCmpExchange or CAS that handles 16 bytes and returns a boolean indicating success.
  8. I am very happy that FastMM5 is now available and also with the new licensing scheme. We plan to use it in our heavily threaded 64-bit http/socket servers. While I wouldn't have used it at all if it was GPL only, having a commercial offering at a reasonable price is actually more preferable because I like the idea of a properly maintained memory manager for our commercial products. There are plenty of free memory managers around for Delphi, that are barely maintained.
×