ATDownloadClient.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using UnityEngine;
  2. using AnyThinkAds.Common;
  3. using AnyThinkAds.Api;
  4. namespace AnyThinkAds.Android
  5. {
  6. public class ATDownloadClient : AndroidJavaProxy,IATDownloadClient
  7. {
  8. private AndroidJavaObject downloadHelper;
  9. private ATDownloadAdListener anyThinkListener;
  10. public ATDownloadClient() : base("com.anythink.unitybridge.download.DownloadListener")
  11. {
  12. }
  13. public void setListener(ATDownloadAdListener listener)
  14. {
  15. Debug.Log("ATDownloadClient : setListener");
  16. anyThinkListener = listener;
  17. if (downloadHelper == null)
  18. {
  19. downloadHelper = new AndroidJavaObject(
  20. "com.anythink.unitybridge.download.DownloadHelper", this);
  21. }
  22. }
  23. public void onDownloadStart(string placementId, string callbackJson, long totalBytes, long currBytes, string fileName, string appName)
  24. {
  25. Debug.Log("onDownloadStart...unity3d.");
  26. if(anyThinkListener != null){
  27. anyThinkListener.onDownloadStart(placementId, new ATCallbackInfo(callbackJson), totalBytes, currBytes, fileName, appName);
  28. }
  29. }
  30. public void onDownloadUpdate(string placementId, string callbackJson, long totalBytes, long currBytes, string fileName, string appName)
  31. {
  32. Debug.Log("onDownloadUpdate...unity3d.");
  33. if (anyThinkListener != null)
  34. {
  35. anyThinkListener.onDownloadUpdate(placementId, new ATCallbackInfo(callbackJson), totalBytes, currBytes, fileName, appName);
  36. }
  37. }
  38. public void onDownloadPause(string placementId, string callbackJson, long totalBytes, long currBytes, string fileName, string appName)
  39. {
  40. Debug.Log("onDownloadPause...unity3d.");
  41. if (anyThinkListener != null)
  42. {
  43. anyThinkListener.onDownloadPause(placementId, new ATCallbackInfo(callbackJson), totalBytes, currBytes, fileName, appName);
  44. }
  45. }
  46. public void onDownloadFinish(string placementId, string callbackJson, long totalBytes, string fileName, string appName)
  47. {
  48. Debug.Log("onDownloadFinish...unity3d.");
  49. if (anyThinkListener != null)
  50. {
  51. anyThinkListener.onDownloadFinish(placementId, new ATCallbackInfo(callbackJson), totalBytes, fileName, appName);
  52. }
  53. }
  54. public void onDownloadFail(string placementId, string callbackJson, long totalBytes, long currBytes, string fileName, string appName)
  55. {
  56. Debug.Log("onDownloadFail...unity3d.");
  57. if (anyThinkListener != null)
  58. {
  59. anyThinkListener.onDownloadFail(placementId, new ATCallbackInfo(callbackJson), totalBytes, currBytes, fileName, appName);
  60. }
  61. }
  62. public void onInstalled(string placementId, string callbackJson, string fileName, string appName)
  63. {
  64. Debug.Log("onInstalled...unity3d.");
  65. if (anyThinkListener != null)
  66. {
  67. anyThinkListener.onInstalled(placementId, new ATCallbackInfo(callbackJson), fileName, appName);
  68. }
  69. }
  70. }
  71. }