Skip to content
This repository has been archived by the owner on Aug 15, 2021. It is now read-only.

Commit

Permalink
2020-03-06 Version 1.3.1: Refactored project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
fartem committed Mar 6, 2020
1 parent b12e7fa commit e046f79
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName '1.3.0'
versionName '1.3.1'

buildConfigField 'String', 'API_IMPL', "\"\""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class MainActivity : AppCompatActivity() {
}

private fun handleOnPause() {
val currentFragment = supportFragmentManager.findFragmentByTag(CURRENT_FRAGMENT_TAG)
val currentFragment = supportFragmentManager.findFragmentByTag(
CURRENT_FRAGMENT_TAG
)
if (currentFragment != null && currentFragment is BtPauseTarget) {
currentFragment.btOnPause()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class BtDevicesBottomSheet : BaseBottomSheet() {
this.btDevices.addAll(btDevices)
}

fun setBtDeviceSelectCallback(btConnectTarget: BtConnectTarget) {
fun setBtDeviceSelectCallback(
btConnectTarget: BtConnectTarget
) {
this.btConnectTarget = btConnectTarget
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ class BtDevicesAdapter(
private var selectedDeviceMacAddress: String = ""
private var selectedDeviceName: String = ""

override fun onBindViewHolder(holderBt: BtDeviceHolder, position: Int) {
override fun onBindViewHolder(
holderBt: BtDeviceHolder,
position: Int
) {
holderBt.bind(btDevices[position])
}

Expand All @@ -32,8 +35,10 @@ class BtDevicesAdapter(

fun getSelectedDeviceMacAddress() = selectedDeviceMacAddress

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
BtDeviceHolder(
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
) = BtDeviceHolder(
LayoutInflater.from(parent.context)
.inflate(R.layout.item_bt_device, parent, false),
this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import com.smlnskgmail.jaman.remotetemperaturecontrol.logic.settings.SettingsBot
import kotlinx.android.synthetic.main.fragment_monitor.*

@SuppressWarnings("TooManyFunctions")
class MonitorFragment : BaseFragment(), BtMonitorTarget {
class MonitorFragment : BaseFragment(), BtMonitorTarget, BtDisconnectTarget {

private var monitorBtConnection: BtConnection? = null
private var btAdapter: BluetoothAdapter? = null
Expand Down Expand Up @@ -201,14 +201,12 @@ class MonitorFragment : BaseFragment(), BtMonitorTarget {

private fun showSettings() {
val settingsBottomSheet = SettingsBottomSheet()
settingsBottomSheet.setBtDisconnectListener(object : BtDisconnectTarget {
override fun btDisconnect() {
monitorBtConnection!!.disconnect()
resetRequired()
}
})
showBottomSheet(settingsBottomSheet)
}
override fun btDisconnect() {
monitorBtConnection!!.disconnect()
resetRequired()
}

override fun btOnPause() {
monitorBtConnection!!.handleOnResume()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ class DebugBtConnection(
)
}

override fun send(btMonitorSignalType: BtMonitorSignalType) {
override fun send(
btMonitorSignalType: BtMonitorSignalType
) {
writeLog(
"Debug Monitor: send(${btMonitorSignalType})"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import kotlinx.android.synthetic.main.bottom_sheet_settings.*

class SettingsBottomSheet : BaseBottomSheet() {

private var disconnectTarget: BtDisconnectTarget? = null

override fun initialize() {
settings_disconnect.setOnClickListener {
actionAndDismiss {
disconnectTarget?.btDisconnect()
(activity as BtDisconnectTarget).btDisconnect()
}
}
}
Expand All @@ -22,10 +20,6 @@ class SettingsBottomSheet : BaseBottomSheet() {
action()
}

fun setBtDisconnectListener(disconnectTarget: BtDisconnectTarget) {
this.disconnectTarget = disconnectTarget
}

override fun getLayoutResId() = R.layout.bottom_sheet_settings

}

0 comments on commit e046f79

Please sign in to comment.