delphi android ProgressDialog

来源:互联网 发布:安卓深度优化 编辑:程序博客网 时间:2024/05/09 09:07

好像不是特别好用....但能将就着

{***************************************************************************}{                                                                           }{       功能:Android ProgressDialog封装                                    }{       名称:Androidapi.JNI.App.ProgressDialog.pas                         }{       版本:1.0                                                           }{       环境:Win7 Sp1 32bit                                                }{       工具:Delphi XE5                                                    }{       日期:2013-11-02 12:26:11                                           }{       作者:ying32                                                        }{       QQ  :1444386932                                                     }{       E-mail:1444386932@qq.com                                      }{       版权所有 (C) 2013-2013 ying32.tk All Rights Reserved                }{                                                                           }{---------------------------------------------------------------------------}{                                                                           }{       备注:Android ProgressDialog封装                                    }{                                                                           }{                                                                           }{                                                                           }{***************************************************************************}{procedure TForm1.Button1Click(Sender: TObject);var  Dialog: JProgressDialog;begin CallInUIThread( procedure begin  Dialog := TJProgressDialog.JavaClass.init(SharedActivityContext);  Dialog.setTitle(StrToJCharSequence('标题'));  Dialog.setMessage(StrToJCharSequence('正在加载中...'));  Dialog.setIndeterminate(True);  Dialog.setCancelable(True);  Dialog.show;  end);end;procedure TForm1.Button2Click(Sender: TObject);var  Dialog: JProgressDialog;begin CallInUIThread( procedure begin  Dialog := TJProgressDialog.JavaClass.init(SharedActivityContext);  Dialog.setMessage(StrToJCharSequence('Please wait while loading...'));  Dialog.setIndeterminate(True);  Dialog.setCancelable(True);  Dialog.show;  end);end;}unit Androidapi.JNI.App.ProgressDialog;interfaceuses  Androidapi.JNIBridge,  Androidapi.JNI.JavaTypes,  Androidapi.JNI.App,  Androidapi.JNI.Os,  Androidapi.JNI.GraphicsContentViewText;type  JProgressDialog = interface; // android.app.ProgressDialog  JProgressDialogClass = interface(JAlertDialogClass)  ['{44D764E0-4244-4682-BDC4-D2A80D43BBB1}']    function _GetSTYLE_HORIZONTAL: Integer;    function _GetSTYLE_SPINNER: Integer;    // ProgressDialog android.app.ProgressDialog.show(Context context, CharSequence title, CharSequence message)    function show(context: JContext; title, messages: JCharSequence): JProgressDialog; cdecl; overload;    // ProgressDialog android.app.ProgressDialog.show(Context context, CharSequence title, CharSequence message, boolean indeterminate)    function show(context: JContext; title, messages: JCharSequence; indeterminate: Boolean): JProgressDialog; cdecl; overload;    // ProgressDialog android.app.ProgressDialog.show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable)    function show(context: JContext; title, messages: JCharSequence; indeterminate, cancelable: Boolean): JProgressDialog; cdecl; overload;    // ProgressDialog android.app.ProgressDialog.show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable, OnCancelListener cancelListener)    function show(context: JContext; title, messages: JCharSequence; indeterminate, cancelable: Boolean; cancelListener: JDialogInterface_OnCancelListener): JProgressDialog; cdecl; overload;    // android.app.ProgressDialog.ProgressDialog(Context context)    function init(context: JContext): JProgressDialog; cdecl; overload;    // android.app.ProgressDialog.ProgressDialog(Context context, int theme)    function init(context: JContext; theme: Integer): JProgressDialog; cdecl; overload;    property STYLE_HORIZONTAL: Integer read _GetSTYLE_HORIZONTAL;    property STYLE_SPINNER: Integer read _GetSTYLE_SPINNER;  end;  [JavaSignature('android/app/ProgressDialog')]  JProgressDialog = interface(JAlertDialog)  ['{25EAD706-AB02-481C-8D81-C0C39BCA19C8}']    // int android.app.ProgressDialog.getMax()    function getMax: Integer; cdecl;    // int android.app.ProgressDialog.getProgress()    function getProgress: Integer; cdecl;    // int android.app.ProgressDialog.getSecondaryProgress()    function getSecondaryProgress: Integer; cdecl;    // void android.app.ProgressDialog.incrementProgressBy(int diff)    procedure incrementProgressBy(diff: Integer); cdecl;    // void android.app.ProgressDialog.incrementSecondaryProgressBy(int diff)    procedure incrementSecondaryProgressBy(diff: Integer); cdecl;    // boolean android.app.ProgressDialog.isIndeterminate()    function isIndeterminate: Boolean; cdecl;    // void android.app.ProgressDialog.onCreate(Bundle savedInstanceState)    procedure onCreate(savedInstanceState: JBundle); cdecl;    // void android.app.ProgressDialog.onStart()    procedure onStart; cdecl;    // void android.app.ProgressDialog.onStop()    procedure onStop; cdecl;    // void android.app.ProgressDialog.setIndeterminate(boolean indeterminate)    procedure setIndeterminate(indeterminate: Boolean); cdecl;    // void android.app.ProgressDialog.setIndeterminateDrawable(Drawable d)    procedure setIndeterminateDrawable(d: JDrawable); cdecl;    // void android.app.ProgressDialog.setMax(int max)    procedure setMax(max: Integer); cdecl;    // void android.app.ProgressDialog.setMessage(CharSequence message)    procedure setMessage(messages: JCharSequence); cdecl;    // void android.app.ProgressDialog.setProgress(int value)    procedure setProgress(value: Integer); cdecl;    // void android.app.ProgressDialog.setProgressDrawable(Drawable d)    procedure setProgressDrawable(d: JDrawable); cdecl;    // void android.app.ProgressDialog.setProgressStyle(int style)    procedure setProgressStyle(style: Integer); cdecl;    // void android.app.ProgressDialog.setSecondaryProgress(int secondaryProgress)    procedure setSecondaryProgress(secondaryProgress: Integer); cdecl;  end;  TJProgressDialog = class(TJavaGenericImport<JProgressDialogClass, JProgressDialog>) end;  { TProcessDialog }  TProcessDialog = class  private class var    FDialog: JProgressDialog;  public    class procedure Show(AText: string); overload;    class procedure Show(AText, ACaption: string); overload;    class procedure Close;  end;implementationuses  FMX.Helpers.Android;{ TProcessDialog }class procedure TProcessDialog.Close;begin  CallInUIThread(    procedure    begin      FDialog.cancel;      FDialog := nil;    end);end;class procedure TProcessDialog.Show(AText: string);begin  CallInUIThread(    procedure    begin      FDialog := TJProgressDialog.JavaClass.show(         SharedActivityContext,         StrToJCharSequence(''),         StrToJCharSequence(AText),         True,         True        );    end);end;class procedure TProcessDialog.Show(AText, ACaption: string);begin  CallInUIThread(    procedure    begin      FDialog := TJProgressDialog.JavaClass.show(         SharedActivityContext,         StrToJCharSequence(ACaption),         StrToJCharSequence(AText),         True,         True        );    end);end;end.

0 0
原创粉丝点击