TCUtil.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // TCUtil.h
  3. // TCLVBIMDemo
  4. //
  5. // Created by felixlin on 16/8/2.
  6. // Copyright © 2016年 tencent. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "TCLog.h"
  10. #import "TCConstants.h"
  11. // 日志
  12. #ifdef DEBUG
  13. #ifndef DebugLog
  14. //#define DebugLog(fmt, ...) NSLog((@"[%s Line %d]" fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
  15. #define DebugLog(fmt, ...) [[TCLog shareInstance] log:fmt, ##__VA_ARGS__]
  16. #endif
  17. #else
  18. #ifndef DebugLog
  19. #define DebugLog(fmt, ...) [[TCLog shareInstance] log:fmt, ##__VA_ARGS__]
  20. #endif
  21. #endif
  22. #ifndef TC_PROTECT_STR
  23. #define TC_PROTECT_STR(x) (x == nil ? @"" : x)
  24. #endif
  25. //report
  26. static NSString * const xiaoshipin_install = @"install";
  27. static NSString * const xiaoshipin_startup = @"startup";
  28. static NSString * const xiaoshipin_staytime = @"staytime";
  29. static NSString * const xiaoshipin_login = @"login";
  30. static NSString * const xiaoshipin_register = @"register";
  31. static NSString * const xiaoshipin_vodplay = @"vodplay";
  32. static NSString * const xiaoshipin_startrecord = @"startrecord";
  33. static NSString * const xiaoshipin_videorecord = @"videorecord";
  34. static NSString * const xiaoshipin_videosign = @"videosign";
  35. static NSString * const xiaoshipin_videouploadvod = @"videouploadvod";
  36. static NSString * const xiaoshipin_videouploadserver = @"videouploadserver";
  37. static NSString * const xiaoshipin_videoedit = @"videoedit";
  38. static NSString * const xiaoshipin_pictureedit = @"pictureedit";
  39. static NSString * const xiaoshipin_videojoiner = @"videojoiner";
  40. static NSString * const xiaoshipin_videochorus = @"videochorus";
  41. static NSString * const xiaoshipin_about_sdk = @"about_sdk";
  42. #ifndef NSStringCheck
  43. #define NSStringCheck(x)\
  44. ({\
  45. if(x == nil || ![x isKindOfClass:[NSString class]]){\
  46. x = @"";}\
  47. })
  48. #endif
  49. @interface TCUtil : NSObject
  50. + (void)asyncSendHttpRequest:(NSDictionary*)param handler:(void (^)(int resultCode, NSDictionary* resultDict))handler;
  51. + (void)asyncSendHttpRequest:(NSString*)command params:(NSDictionary*)params handler:(void (^)(int resultCode, NSString* message, NSDictionary* resultDict))handler;
  52. + (void)asyncSendHttpRequest:(NSString*)command token:(NSString*)token params:(NSDictionary*)params handler:(void (^)(int resultCode, NSString* message, NSDictionary* resultDict))handler;
  53. + (void)downloadVideo:(NSString *)videoUrl cachePath:(NSString *)cachePath process:(void(^)(CGFloat process))processHandler complete:(void(^)(NSString *videoPath))completeHandler;
  54. + (void)report:(NSString *)type userName:(NSString *)userName code:(UInt64)code msg:(NSString *)msg;
  55. + (NSData *)dictionary2JsonData:(NSDictionary *)dict;
  56. + (NSDictionary *)jsonData2Dictionary:(NSString *)jsonData;
  57. + (NSString *)getFileCachePath:(NSString *)fileName;
  58. + (void)removeCacheFile:(NSString*)filePath;
  59. + (NSUInteger)getContentLength:(NSString*)string;
  60. + (NSString *)transImageURL2HttpsURL:(NSString *)httpURL;
  61. + (NSString*) getStreamIDByStreamUrl:(NSString*) strStreamUrl;
  62. + (UIImage *)gsImage:(UIImage *)image withGsNumber:(CGFloat)blur;
  63. + (UIImage*)scaleImage:(UIImage *)image scaleToSize:(CGSize)size;
  64. + (UIImage *)clipImage:(UIImage *)image inRect:(CGRect)rect;
  65. + (void)toastTip:(NSString*)toastInfo parentView:(UIView *)parentView;
  66. + (float)heightForString:(UITextView *)textView andWidth:(float)width;
  67. + (BOOL)isSuitableMachine:(int)targetPlatNum;
  68. + (NSDate *)timeToDate:(NSString *)timeStr;
  69. + (NSString *)dateToTime:(NSDate *)date;
  70. + (UIViewController*)currentViewController;
  71. @end