[TOC]


# WebSocket

``````kotlin
WebSocketHandler.getInstance("ws://192.168.3.20:8765")
``````

# 线程

## UI线程执行

````kotlin
runOnUiThread { "提示信息".showMessage() }
````

````kotlin
App.getInstance().runOnUiThread() {}
````

## 延时执行

```kotlin
App.getInstance().runOnUiThreadDelay({},1100) 
```

# 常用工具

## Toast

````kotlin
"连接完成".showMessage()
````

````kotlin
ToolsHelper.showMessage("")
````

## Log

````kotlin
"".loge()
````

````kotlin
"".log()
````

````kotlin
LogHelper.d("")
````



# 常用方法

## 双击退出

```kotlin

    private var oldTime = 0L
    override fun onBackPressed() {
        val newTime = System.currentTimeMillis()
        if (newTime - oldTime < 1500 && oldTime != 0L)
            AppManager.getInstance().exit()
        else {
            oldTime = newTime
            ToolsHelper.showMessage("双击退出")
        }
    }
```






# 界面

> 所有界面继承`BaseFragment`,`BaseActivity`,`BaseListActivity`等
>
> 页面`layout`跟节点必须为`layout`

```xml
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
</layout>
```

## 列表页面

### 纯列表

> `BaseListActivity`

### 自定义布局列表

> `BaseListFormLayoutActivity` 
>
> 布局列表部分必须使用下面的方法和id

```xml
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
    android:id="@+id/baseRefreshLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.xuqm.base.view.EmptyView
        android:id="@+id/baseEmptyView"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/baseRecyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:overScrollMode="never" />

    </com.xuqm.base.view.EmptyView>

</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
```

## 界面控件使用

```kotlin
binding.btn1.setOnClickListener {
    
}
```

## 导航栏

> 使用base自带导航栏的情况下，可以操控对应控件

```kotlin
baseBinding.baseToolbar.backBtn.setOnClickListener {}
```













































