Перейти к содержанию
Fire Monkey от А до Я

Лидеры

  1. Alex7wrt

    Alex7wrt

    Пользователи


    • Баллы

      5

    • Постов

      508


  2. #WAMACO

    #WAMACO

    Пользователи


    • Баллы

      1

    • Постов

      776


  3. Евгений Корепов

    Евгений Корепов

    Пользователи


    • Баллы

      1

    • Постов

      738


  4. Slym

    Slym

    Пользователи


    • Баллы

      1

    • Постов

      180


Популярный контент

Показан контент с высокой репутацией 26.07.2019 во всех областях

  1. странное заключение.... поясните пожалуйста....
    1 балл
  2. аяяй! Совсем разленились try юзать, все на RefCounting надеетесь... ну-ну... а под вендой мемлики плодятся (если файла нет - Surf куда?) не-не... переделать! а то студенты накопипастят... procedure TBitmapAsyncLoader.LoadImageAsync(const AFilePath:string; Callback: TProc); begin TTask.Run( procedure var ABitmapSurface : TBitmapSurface; begin ABitmapSurface:=TBitmapSurface.Create; try if TBitmapCodecManager.LoadFromFile(AFilePath, ABitmapSurface, CanvasClass.GetAttribute(TCanvasAttribute.MaxBitmapSize)) and assigned(Callback) then TThread.Synchronize(nil, Callback); finally ABitmapSurface.Free; end; end); end;
    1 балл
  3. По результатам проб и тестов - не пытыйтесь использовать мой хелпер на длинных ListView или ListView содержимое которого может неожиданно изменится - нарветесь на AV. Я не нашел простого способа проверить существование самого себя и родителей. По Bitmap.LoadFromFile(ImagePath+Name) - загляните в исходники Эмбаркадеро, там все делается через TBitmapSurface : procedure TBitmap.LoadFromFile(const AFileName: string); var Surf: TBitmapSurface; begin TMonitor.Enter(Self); try Surf := TBitmapSurface.Create; try if TBitmapCodecManager.LoadFromFile(AFileName, Surf, CanvasClass.GetAttribute(TCanvasAttribute.MaxBitmapSize)) then Assign(Surf) else raise EBitmapLoadingFailed.CreateFMT(SBitmapLoadingFailedNamed, [AFileName]); finally Surf.Free; end; finally TMonitor.Exit(Self); end; end; Добавил к хелперу procedure LoadFromFileAsync(const AFilePath : String; const ASize : TControlSize = nil); overload; procedure LoadFromFileAsync(const AFilePath : String; const AListItemImage : TListItemImage); overload; constructor CreateFromFileAsync(const AFilePath : String; const AListItemImage : TListItemImage = nil); overload; Сам хелпер и и архив с демо-проектом (загружает 1000 картинок в ListView, параллельно изменяя их размер, картинки в комплекте) : unit BitmapAsyncLoader; interface uses System.Net.HttpClient, System.Net.URLClient, System.SysUtils, System.Types, System.Classes, System.Threading, FMX.Graphics, FMX.Surfaces, FMX.Types, FMX.ListView.Types; type TBitmapAsyncLoader = class helper for TBitmap private function ResizeBitmapSurface(const ABitmapSurface : TBitmapSurface; const AWidth, AHeight : Integer) : TBitmapSurface; procedure SynchronizeAssignFromBitmapSurface(const ABitmapSurface : TBitmapSurface; const AListItemImage : TListItemImage = nil); procedure StartHTTPThread(const AURL : String; const AWidth, AHeight : Integer; const AListItemImage : TListItemImage = nil); procedure StartLoadFromFileThread(const AFilePath : String; const AWidth, AHeight : Integer; const AListItemImage : TListItemImage = nil); public procedure LoadFromURLAsync(const AURL : String; const ASize : TControlSize = nil); overload; procedure LoadFromURLAsync(const AURL : String; const AListItemImage : TListItemImage); overload; constructor CreateFromUrlAsync(const AURL : String; const AListItemImage : TListItemImage = nil); overload; procedure LoadFromFileAsync(const AFilePath : String; const ASize : TControlSize = nil); overload; procedure LoadFromFileAsync(const AFilePath : String; const AListItemImage : TListItemImage); overload; constructor CreateFromFileAsync(const AFilePath : String; const AListItemImage : TListItemImage = nil); overload; end; implementation type THTTPClientListener = class class procedure HTTPClientValidateServerCertificate(const Sender: TObject; const ARequest: TURLRequest; const Certificate: TCertificate; var Accepted: Boolean); end; var AHTTPClient : THTTPClient; procedure TBitmapAsyncLoader.LoadFromFileAsync(const AFilePath : String; const ASize : TControlSize = nil); var AWidth, AHeight : Integer; begin if Assigned(ASize) then begin AWidth:=Round(ASize.Width); AHeight:=Round(ASize.Height); end else begin AWidth:=-1; AHeight:=-1; end; StartLoadFromFileThread(AFilePath, AWidth, AHeight); end; procedure TBitmapAsyncLoader.LoadFromFileAsync(const AFilePath : String; const AListItemImage : TListItemImage); var AWidth, AHeight : Integer; begin if Assigned(AListItemImage) then begin AWidth:=Round(AListItemImage.Width); AHeight:=Round(AListItemImage.Height); end else begin AWidth:=-1; AHeight:=-1; end; StartLoadFromFileThread(AFilePath, AWidth, AHeight, AListItemImage); end; constructor TBitmapAsyncLoader.CreateFromFileAsync(const AFilePath : String; const AListItemImage : TListItemImage = nil); begin Create; LoadFromFileAsync(AFilePath, AListItemImage); end; constructor TBitmapAsyncLoader.CreateFromUrlAsync(const AURL : String; const AListItemImage : TListItemImage = nil); begin Create; LoadFromURLAsync(AURL, AListItemImage); end; procedure TBitmapAsyncLoader.LoadFromURLAsync(const AURL : String; const AListItemImage : TListItemImage); var AWidth, AHeight : Integer; begin if Assigned(AListItemImage) then begin AWidth:=Round(AListItemImage.Width); AHeight:=Round(AListItemImage.Height); end else begin AWidth:=-1; AHeight:=-1; end; StartHTTPThread(AURL, AWidth, AHeight, AListItemImage); end; procedure TBitmapAsyncLoader.LoadFromURLAsync(const AURL : String; const ASize : TControlSize = nil); var AWidth, AHeight : Integer; begin if Assigned(ASize) then begin AWidth:=Round(ASize.Width); AHeight:=Round(ASize.Height); end else begin AWidth:=-1; AHeight:=-1; end; StartHTTPThread(AURL, AWidth, AHeight); end; function TBitmapAsyncLoader.ResizeBitmapSurface(const ABitmapSurface : TBitmapSurface; const AWidth, AHeight : Integer) : TBitmapSurface; begin if (AWidth <> -1) and (AHeight <> -1) then begin try Result:=TBitmapSurface.Create; Result.StretchFrom(ABitmapSurface, AWidth, AHeight, ABitmapSurface.PixelFormat); finally ABitmapSurface.Free; end; end else Result:=ABitmapSurface; end; procedure TBitmapAsyncLoader.SynchronizeAssignFromBitmapSurface(const ABitmapSurface : TBitmapSurface; const AListItemImage : TListItemImage = nil); begin TThread.Synchronize(Nil, procedure begin Assign(ABitmapSurface); ABitmapSurface.Free; if Assigned(AListItemImage) then AListItemImage.Invalidate; end ); end; procedure TBitmapAsyncLoader.StartHTTPThread(const AURL : String; const AWidth, AHeight : Integer; const AListItemImage : TListItemImage = nil); begin AHTTPClient.BeginGet( procedure (const ASyncResult: IAsyncResult) var AHTTPResponse : IHTTPResponse; ABitmapSurface : TBitmapSurface; begin if Not ASyncResult.IsCompleted then exit; try AHTTPResponse:=THTTPClient.EndAsyncHTTP(ASyncResult); except exit; end; if Assigned(AHTTPResponse) and (AHTTPResponse.StatusCode = 200) then begin ABitmapSurface:=TBitmapSurface.Create; if TBitmapCodecManager.LoadFromStream(AHTTPResponse.ContentStream, ABitmapSurface, CanvasClass.GetAttribute(TCanvasAttribute.MaxBitmapSize)) then begin ABitmapSurface:=ResizeBitmapSurface(ABitmapSurface, AWidth, AHeight); SynchronizeAssignFromBitmapSurface(ABitmapSurface, AListItemImage); end; end; end, AURL ); end; procedure TBitmapAsyncLoader.StartLoadFromFileThread(const AFilePath : String; const AWidth, AHeight : Integer; const AListItemImage : TListItemImage = nil); begin TTask.Run( procedure var ABitmapSurface : TBitmapSurface; begin ABitmapSurface:=TBitmapSurface.Create; if TBitmapCodecManager.LoadFromFile(AFilePath, ABitmapSurface, CanvasClass.GetAttribute(TCanvasAttribute.MaxBitmapSize)) then begin ABitmapSurface:=ResizeBitmapSurface(ABitmapSurface, AWidth, AHeight); SynchronizeAssignFromBitmapSurface(ABitmapSurface, AListItemImage); end; end ); end; class procedure THTTPClientListener.HTTPClientValidateServerCertificate(const Sender: TObject; const ARequest: TURLRequest; const Certificate: TCertificate; var Accepted: Boolean); begin Accepted:=True; end; initialization AHTTPClient:=THTTPClient.Create; AHTTPClient.OnValidateServerCertificate:=THTTPClientListener.HTTPClientValidateServerCertificate; finalization if Assigned(AHTTPClient) then AHTTPClient.DisposeOf; end. BitmapAsyncLoader.7z
    1 балл
  4. Google USB Driver входит в состав Android SDK. Кроме него вам ничего не нужно. При подключении по USB достаточно, чтобы телефон был в режиме "Зарядка".
    1 балл
  5. Alex7wrt

    android:minSdkVersion после 1 августа

    Манифест нужно редактировать только в одном месте - в файле AndroidManifest.template.xml, который лежит непосредственно в папке вашего проекта На основе этого файла генерируется файл манифеста, который добавляется к приложению.
    1 балл
  6. Alex7wrt

    android:minSdkVersion после 1 августа

    Так как с 1 августа Google требует указывать targetSdkVersion 28 и выше, то логично будет использовать 28-ю версию.29-я это Android 10, который еще не вышел официально. Думаю, проблем с ней не должно быть, но я бы повременил с ее использованием. Обратите внимание, что использование все более новых targetSdkVersion может приводить к некоторым ограничениям, которые вводит Google в новых версиях андроида. Например, при переходе на targetSdkVersion 28 вы обнаружите, что ссылки, начинающиеся на "http" считаются небезопасными и по умолчанию не обрабатываются. Рекомендуется повсеместно переходить на "https". Так что, если вы в каком-нибудь THTTPClient или где-либо еще выполняли запрос на "http", а после перехода на targetSdkVersion 28 обнаружили, что ваш код перестал работать, то либо переходите на "https", либо, если все же необходимо выполнять запрос на "http", внесите изменения в файле манифеста: в разделе application нужно добавить строку android:usesCleartextTraffic="true".
    1 балл
  7. Alex7wrt

    android:minSdkVersion после 1 августа

    Название SDK Version в FMX остается таким каким было при первой установке и не меняется при обновлении Android SDK. Если вы исправно обновляете Android SDK, то в SDK менеджере вы можете указать последние версии ZipAlign Location и Aapt Location, в частности 28.
    1 балл
  8. Alex7wrt

    android:minSdkVersion после 1 августа

    В справке Google говорится исключительно о targetSdkVersion, а не о minSdkVersion. И targetSdkVersion="26" - это условие для прошлого года. В этом году нужно писать targetSdkVersion="28"
    1 балл
  9. Всем спасибо, разобрался procedure UpdateListSubSection;varid, Subsection : string;begin F_General.LV_SubSection.BeginUpdate; if F_General.LV_SubSection.Items.Count <> 0 then F_General.LV_SubSection.Items.Clear; While not F_General.Qry.Eof do begin SubSection := F_General.Qry.FieldByName('N_subsection').AsString; FCanUpdate := False; LItem := F_General.LV_SubSection.Items.Add; LItem.Data['SubSection'] := SubSection; FCanUpdate := True; F_General.LV_SubSection.Adapter.ResetView(LItem); F_General.Qry.Next; end; F_General.LV_SubSection.EndUpdate; F_General.Qry.Close;end;
    1 балл
Эта таблица лидеров рассчитана в Москва/GMT+03:00
×
×
  • Создать...