RDSocialManager.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import { RDPlatformManager } from "./RDPlatformManager";
  2. import { RDCommand } from "./RDCommand";
  3. import { RDAdsEntity } from "./RDAdsEntity";
  4. import { LOG_TAG, Log } from "../log/Log";
  5. export class RDSocialManager {
  6. public static readonly PAGE_COUNT: number = 100;
  7. private static _instance: RDSocialManager = new RDSocialManager();
  8. private lastRank: number = 0;
  9. private currentRank: number = 0;
  10. public static getInstance(): RDSocialManager {
  11. return this._instance;
  12. }
  13. public init(): void {
  14. Log.log(LOG_TAG.DEBUG,"[RDSocialManager] Init");
  15. this.updateRankInfo();
  16. }
  17. public setLastRank(rank: number): void {
  18. if(rank > 0){
  19. this.lastRank = rank;
  20. }
  21. }
  22. public setCurrentRank(rank: number): void {
  23. if (rank > 0) {
  24. this.currentRank = rank;
  25. }
  26. }
  27. public getRankUp(): number {
  28. if(this.lastRank <= 0){
  29. return this.currentRank;
  30. }
  31. return (this.lastRank - this.currentRank);
  32. }
  33. public getCurrentRank(): number {
  34. return this.currentRank;
  35. }
  36. public updateRankInfo(): void {
  37. RDPlatformManager.getInstance().sendData(RDCommand.CMD_GET_RANK, null);
  38. }
  39. public invite(completeCallback: (error: Error) => void): void {
  40. RDPlatformManager.getInstance().invite(completeCallback);
  41. }
  42. public submitScore(score: number, completeCallback: (error: Error) => void): void {
  43. if(score <= 0){
  44. return;
  45. }
  46. RDPlatformManager.getInstance().submitScore(score, completeCallback);
  47. }
  48. public share(score: number): void {
  49. RDPlatformManager.getInstance().sendData(RDCommand.CMD_SHARE, score);
  50. }
  51. /**
  52. * 开始录制视频
  53. * @param time 录制时间
  54. */
  55. public startRecordVideo(time){
  56. RDPlatformManager.getInstance().sendData(RDCommand.CMD_RECORDVIDEO,time);
  57. }
  58. public pauseRecordVideo(){
  59. RDPlatformManager.getInstance().sendData(RDCommand.CMD_STOPRECORDVIDEO,null);
  60. }
  61. public shareVideo(data: RDAdsEntity){
  62. RDPlatformManager.getInstance().sendData(RDCommand.CMD_SHAREVIDEO,data);
  63. }
  64. }