Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class HttpNew:
- _client = None
- _gson = None
- _retrofit = None
- @staticmethod
- def _addCacheInterceptor(context):
- pass
- @staticmethod
- def _addHeaderInterceptor(context):
- pass
- @staticmethod
- def _addQueryParameterInterceptor(context):
- pass
- # @staticmethod
- # def buildGson():
- # if com.fans.common.net.HttpNew._gson is None:
- # com.fans.common.net.HttpNew._gson = (GsonBuilder()).registerTypeAdapter(String.class, StringNullAdapter()).create()
- # return com.fans.common.net.HttpNew._gson
- # @staticmethod
- # def _createSSLContext():
- # trustManagerArr = [HttpNew$4()]
- # try:
- # sSLContext = SSLContext.getInstance("SSL")
- # sSLContext.init(None, trustManagerArr, SecureRandom())
- # return sSLContext
- # except Exception as unused:
- # return None
- # @staticmethod
- # def getCurrentLanguage(context):
- # locale = context.getResources().getConfiguration().locale
- # if Build.VERSION.SDK_INT >= 21:
- # return locale.toLanguageTag()
- # sb = StringBuilder()
- # sb.append(locale.getLanguage())
- # if locale.getCountry() is not None:
- # sb.append("-")
- # sb.append(locale.getCountry())
- # return str(sb)
- # @staticmethod
- # def generateUrlNew(request, context):
- # str = None
- # str2 = None
- # httpUrl = str(request.url())
- # request.method().toLowerCase()
- # str3 = httpUrl.split("https://api.tiklikesapp.com/")[1].split("\\?")[0]
- # str4 = b.f(context) + ""
- # packageName = context.getPackageName()
- # e = j.e(context, "language", getCurrentLanguage(context))
- # c = b.c(context, "UMENG_CHANNEL")
- # c2 = b.c(context, "PAY_ENV")
- # e2 = j.e(context, "SP_AAID", "")
- # valueOf = str((Date()).getTime())
- # e3 = j.e(context, "SP_GP_REFER", b.c(context, "UMENG_CHANNEL"))
- # splitQuery = splitQuery(URL(httpUrl))
- # splitQuery["deviceId"] = str4
- # splitQuery["locale"] = e
- # splitQuery["vn"] = "1.6.1"
- # splitQuery["bundleId"] = packageName
- # splitQuery["ts"] = valueOf
- # splitQuery["bundleSource"] = c
- # splitQuery["aaid"] = e2
- # splitQuery["env"] = c2
- # str5 = "40"
- # splitQuery["versionCode"] = str5
- # splitQuery["adBundleSource"] = e3
- # if ( "POST" != request.method()) or request.body() is None:
- # str = e3
- # c2 = c2
- # str5 = str5
- # str2 = d.d(splitQuery, None)
- # else:
- # body = request.body()
- # buffer = Buffer()
- # if body is not None:
- # body.writeTo(buffer)
- # readUtf8 = buffer.readUtf8()
- # if "{" in readUtf8:
- # str = e3
- # elif "&" in readUtf8:
- # split = readUtf8.split("&")
- # length = len(split)
- # str = e3
- # i = 0
- # while i < length:
- # str6 = split[i]
- # indexOf = str6.find("=")
- # splitQuery[URLDecoder.decode(str6[0:indexOf], "UTF-8")] = URLDecoder.decode(str6[indexOf + 1:], "UTF-8")
- # i += 1
- # length = length
- # split = split
- # str5 = str5
- # c2 = c2
- # else:
- # str = e3
- # c2 = c2
- # str5 = str5
- # if "=" in readUtf8:
- # split2 = readUtf8.split("=")
- # splitQuery[split2[0]] = split2[1]
- # BufferedReader(StringReader(readUtf8))
- # str2 = d.d(splitQuery, None)
- # BufferedReader(StringReader(readUtf8))
- # str2 = d.d(splitQuery, None)
- # sb = StringBuilder()
- # sb.append(httpUrl)
- # if (httpUrl.contains("?")) {
- # sb.append("&deviceId=")
- # } else {
- # sb.append("?deviceId=")
- # }
- # sb.append(str4)
- # sb.append("&locale=")
- # sb.append(e)
- # sb.append("&vn=")
- # sb.append("1.6.1")
- # sb.append("&bundleId=")
- # sb.append(packageName)
- # sb.append("&ts=")
- # sb.append(valueOf)
- # sb.append("&bundleSource=")
- # sb.append(c)
- # sb.append("&aaid=")
- # sb.append(e2)
- # sb.append("&env=")
- # sb.append(c2)
- # sb.append("&versionCode=")
- # sb.append(str5)
- # sb.append("&adBundleSource=")
- # sb.append(URLEncoder.encode(str))
- # sb.append("&newSign=")
- # sb.append(str2)
- # return str(sb)
- # @staticmethod
- # def getRetrofit(context):
- # if com.fans.common.net.HttpNew._retrofit is None:
- # #JAVA TO PYTHON CONVERTER TODO TASK: Synchronized blocks are not converted by Java to Python Converter:
- # synchronized(HttpNew.class)
- # if com.fans.common.net.HttpNew._retrofit is None:
- # httpLoggingInterceptor = HttpLoggingInterceptor()
- # httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY)
- # cache = (OkHttpClient.Builder()).retryOnConnectionFailure(True).addInterceptor(com.fans.common.net.HttpNew._addQueryParameterInterceptor(context)).addInterceptor(com.fans.common.net.HttpNew._addHeaderInterceptor(context)).addInterceptor(httpLoggingInterceptor).cache(Cache(File(context.getCacheDir(), "cache"), 52428800))
- # timeUnit = TimeUnit.SECONDS
- # com.fans.common.net.HttpNew._client = cache.connectTimeout(30, timeUnit).readTimeout(60, timeUnit).writeTimeout(60, timeUnit).build()
- # bVar = n.b()
- # bVar.c("https://api.tiklikesapp.com/")
- # bVar.g(com.fans.common.net.HttpNew._client)
- # bVar.a(h.d())
- # bVar.b(a.d(com.fans.common.net.HttpNew.buildGson()))
- # com.fans.common.net.HttpNew._retrofit = bVar.e()
- # return com.fans.common.net.HttpNew._retrofit
- # @staticmethod
- # def getUserAgent(context):
- # e = k.e(context)
- # c = k.c()
- # d = k.d()
- # b = k.b()
- # return "Android-" + e + "-" + b + "-" + c + "-" + d
- # @staticmethod
- # def splitQuery(url):
- # split = []
- # hashMap = {}
- # query = url.getQuery()
- # if query is not None and not TextUtils.isEmpty(query):
- # if "&" in query:
- # for str in query.split("&"):
- # indexOf = str.find("=")
- # hashMap[URLDecoder.decode(str[0:indexOf], "UTF-8")] = URLDecoder.decode(str[indexOf + 1:], "UTF-8")
- # elif "=" in query:
- # indexOf2 = query.find("=")
- # hashMap[URLDecoder.decode(query[0:indexOf2], "UTF-8")] = URLDecoder.decode(query[indexOf2 + 1:], "UTF-8")
- # return hashMap
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement