Skip to content

Commit

Permalink
初步完成
Browse files Browse the repository at this point in the history
  • Loading branch information
Dboy233 committed Nov 8, 2021
1 parent b65333b commit dedc0df
Show file tree
Hide file tree
Showing 46 changed files with 1,841 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
.externalNativeBuild
.cxx
local.properties

gradle.properties
5 changes: 4 additions & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.dboy.slotting'
}

android {
Expand Down Expand Up @@ -32,6 +33,9 @@ android {
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//引入Api
implementation 'io.github.dboy233:slotting-api:1.0.0'

implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
Expand All @@ -40,4 +44,14 @@ dependencies {
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

slotting{
//配置文件名,要包含扩展名.json , 默认名称:slotting.json
fileName "slotting.json"
//配置文件路径, 默认位置是app模块根目录
//simple: filePath = "slottingDir/"
filePath ""
//消息接受实现类,实现接口 [com.dboy.slotting.api.Slotting]
implementedClass "com.dboy.slotting.example.SimpleSlotting"
}
43 changes: 43 additions & 0 deletions app/slotting.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[
{
"classPath": "com.dboy.slotting.example.MainActivity",
"entryPoints": [
{
"methodName": "onCancel",
"event": "cancelLogin"
},
{
"methodName": "onLogin",
"event": "userLogin"
},
{
"methodName": "onCheckChange",
"event": "协议:,${agree},_check:,${isChecked}"
},
{
"methodName": "onDestroy",
"eventMap": {
"msg": "退出",
"business": "${this.businessName}"
}
}
]
},
{
"classPath": "com.dboy.slotting.example.InfoActivity",
"entryPoints": [
{
"methodName": "showInfo",
"eventMap": {
"msg": "用户信息",
"password": "${password}",
"name": "${name}"
}
},
{
"methodName": "closePager",
"event": "关闭详情页"
}
]
}
]
43 changes: 43 additions & 0 deletions app/slottingDir/slotting.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[
{
"classPath": "com.dboy.slotting.example.MainActivity",
"entryPoints": [
{
"methodName": "onCancel",
"event": "cancelLogin"
},
{
"methodName": "onLogin",
"event": "userLogin"
},
{
"methodName": "onCheckChange",
"event": "协议:,${agree},_check:,${isChecked}"
},
{
"methodName": "onDestroy",
"eventMap": {
"msg": "退出",
"business": "${this.businessName}"
}
}
]
},
{
"classPath": "com.dboy.slotting.example.InfoActivity",
"entryPoints": [
{
"methodName": "showInfo",
"eventMap": {
"msg": "用户信息",
"password": "${password}",
"name": "${name}"
}
},
{
"methodName": "closePager",
"event": "关闭详情页"
}
]
}
]
74 changes: 74 additions & 0 deletions app/src/main/java/com/dboy/slotting/example/EventDemo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.dboy.slotting.example;

import android.util.Log;

/**
* 用来编译查看字节码
*/
@SuppressWarnings({"unused", "FieldMayBeFinal"})
public class EventDemo {

private String globalString = "StringValue";

private int globalInt = 1;

/**
* 配置文件中的字段name=globalLong于这个不对应,所以在插入的时候会忽略fuckLong
*/
private long fuckLong = 1L;

private double globalDouble = 1.1;

private float globalFloat = 1.2f;

private char globalChar = '?';

private byte globalByte = 1;

private boolean globalBoolean = false;

public void event() {
String localString = "我是之前的代码,测试会不会影响其他操作";
Log.d("DBoy", localString);
}

public void eventLocal() {
int localInt = 100;
String localString = "局部变量的影响";
Log.d("Dboy", "局部变量插入测试-" + localString);
}

public String eventReturn(boolean check, boolean isThrow) {
if (isThrow) {
String localThrow = "异常";
throw new NullPointerException("throwReturn");
}
if (check) {
String localTrue = "true";
return "eventReturn true";
} else {
String localFalse = "false";
return "eventReturn false";
}
}

public void eventMap() {
String localString = "我是之前的代码,测试会不会影响其他操作";
Log.d("DBoy", localString);
}

public String eventMapReturn(boolean check, boolean isThrow) {
if (isThrow) {
boolean localThrow = false;
Log.d("DJC", "eventMapReturn: " + localThrow);
throw new NullPointerException("throwReturn");
}
if (check) {
boolean localTrue = true;
return "eventMapReturn true";
} else {
String localFalse = "false";
return "eventMapReturn false";
}
}
}
2 changes: 2 additions & 0 deletions app/src/main/java/com/dboy/slotting/example/InfoActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ class InfoActivity : AppCompatActivity(R.layout.info_activity) {
val password = bundle.getString("user_password", "Null")
userNameTv.text = "Name: $name"
userPasswordTv.text = "Password: $password"
//这里会插入
}

fun closePager(view: android.view.View) {
onBackPressed()
//这里会插入
}

}
33 changes: 27 additions & 6 deletions app/src/main/java/com/dboy/slotting/example/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.dboy.slotting.example

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.CompoundButton
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.AppCompatCheckBox
import androidx.appcompat.widget.AppCompatEditText
import com.dboy.slotting.R
Expand All @@ -14,41 +16,60 @@ import com.dboy.slotting.R
* @since 2021/11/3 16:13
*/
class MainActivity : AppCompatActivity() {

private val businessName = "Login"

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val checkBox = findViewById<AppCompatCheckBox>(R.id.agree_cb)
checkBox.setOnCheckedChangeListener { buttonView, isChecked ->
val agree = if (isChecked) "agree" else "deny"
showToast(agree)
}
checkBox.setOnCheckedChangeListener(this::onCheckChange)
}

private fun onCheckChange(btn: CompoundButton, isChecked: Boolean) {
val agree = if (isChecked) "agree" else "deny"
showToast(agree)
//这里会插入
}

fun onCancel(view: android.view.View) {
showToast("cancel login")
//这里会插入
}

fun onLogin(view: android.view.View) {
val bundle = Bundle()
val name = findViewById<AppCompatEditText>(R.id.user_name_edt).text?.toString()
if (name.isNullOrEmpty()) {
showToast("name = null")
//这里会插入
return
}
val password = findViewById<AppCompatEditText>(R.id.user_password_edt).text?.toString()
if (password.isNullOrEmpty()) {
showToast("password = null")
//这里会插入
return
}
val bundle = Bundle()
bundle.putString("user_name", name)
bundle.putString("user_password", password)
val intent = Intent(this, InfoActivity::class.java)
intent.putExtras(bundle)
startActivity(intent)
finish()
//这里会插入
}

private fun showToast(msg: String) {
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
}

/**
* 例如: 如果给这个父类方法插入代码,需要重写这个方法。
*/
override fun onDestroy() {
super.onDestroy()
//这里会插入
}

}
Loading

0 comments on commit dedc0df

Please sign in to comment.