2.余弦相似度
5.URL 编解码
6.连续点击事件
1.AudioRecord / MediaPlayer 录音播放
3.MediaRecorder / MediaPlayer 录像播放
1.手机摇一摇
2.USB设备列表
3.位置信息获取
4.指纹识别
1.Wifi列表获取
2.蓝牙列表获取
2.梯度下降线性拟合
1.腾讯开屏广告
2.腾讯激励广告
3.腾讯插屏广告
1.时间戳转换
2.Json 格式化
3.生成二维码
4.发送短信
1.简单样式日历
2.范围选择日历
3.多选日历
package com.lujianfei.module_plugin_base.base
import android.content.Intent
import android.content.res.ColorStateList
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.Window
import androidx.appcompat.app.AppCompatActivity
import com.lujianfei.module_plugin_base.BaseApplication
import com.lujianfei.module_plugin_base.utils.ResUtils
/**
*@date 创建时间:2020/5/29
*@name 作者:陆键霏
*@describe 描述:
*/
abstract class BasePluginActivity: AppCompatActivity() {
companion object {
const val TAG = "BasePluginActivity"
}
var that: AppCompatActivity?= null
var from_host_activity = false
var thatContentView:View? = null
// 接收主应用Activity的上下文:setActivity
fun setActivity(paramActivity: AppCompatActivity) {
that = paramActivity
}
fun doOnCreate(savedInstanceState: Bundle?) {
onCreate(savedInstanceState)
}
override fun onCreate(savedInstanceState: Bundle?) {
if (savedInstanceState != null) {
from_host_activity = savedInstanceState.getBoolean("KEY_START_FROM_OTHER_ACTIVITY", false)
if (from_host_activity) {
Log.d(TAG,"MainActivity onCreate pluginResources = ${that?.resources}")
thatContentView = LayoutInflater.from(that).inflate(resouceId(),null, false)
ResUtils.pluginContext = thatContentView?.context
that?.setContentView(thatContentView)
}
}
if (!from_host_activity) {
that = this
super.onCreate(savedInstanceState)
thatContentView = LayoutInflater.from(that).inflate(resouceId(),null, false)
ResUtils.pluginContext = thatContentView?.context
setContentView(thatContentView)
}
initView()
initData()
initEvent()
}
abstract fun resouceId():Int
abstract fun initView()
abstract fun initData()
abstract fun initEvent()
override fun startActivity(intent: Intent?) {
if (from_host_activity) {
when(intent?.action) {
Intent.ACTION_VIEW-> {
(BaseApplication.INSTANCE as BaseApplication).openWebView(title = "", url = intent.data?.toString()?:"")
}
else-> {
that?.startActivity(intent)
}
}
} else {
super.startActivity(intent)
}
}
override fun <T : View?> findViewById(id: Int): T {
val findViewById = thatContentView?.findViewById<T>(id)
findViewById?.let {
return it
}
return super.findViewById<T>(id)
}
override fun getWindow(): Window {
if (from_host_activity) {
that?.window?.let {
return it
}
}
return super.getWindow()
}
fun getPluginString(resId:Int):String? {
return thatContentView?.context?.getString(resId)
}
fun getPluginColor(resId:Int):Int? {
return thatContentView?.context?.resources?.getColor(resId)
}
fun getPluginDrawable(resId:Int):Drawable? {
return thatContentView?.context?.resources?.getDrawable(resId)
}
fun getPluginColorStateList(resId:Int): ColorStateList? {
return thatContentView?.context?.resources?.getColorStateList(resId)
}
override fun finish() {
if (from_host_activity) {
that?.finish()
} else {
super.finish()
}
}
override fun onBackPressed() {
that?.finish()
}
open fun onPluginResume() {
}
open fun onPluginPause() {
}
open fun onPluginDestroy() {
}
open fun onPluginNewIntent(intent: Intent?) {
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。