-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
136 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
app/src/main/java/me/andreww7985/connectplus/ui/FragmentName.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package me.andreww7985.connectplus.ui | ||
|
||
interface FragmentName { | ||
fun getName(): String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
app/src/main/java/me/andreww7985/connectplus/ui/fragments/ConnectFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package me.andreww7985.connectplus.ui.fragments | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import kotlinx.android.synthetic.main.fragment_connect.* | ||
import me.andreww7985.connectplus.R | ||
import me.andreww7985.connectplus.manager.BleScanManager | ||
import me.andreww7985.connectplus.manager.SpeakerManager | ||
import me.andreww7985.connectplus.ui.FragmentName | ||
import me.andreww7985.connectplus.ui.SpeakersAdapter | ||
|
||
class ConnectFragment : Fragment(), FragmentName { | ||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
return inflater.inflate(R.layout.fragment_connect, container, false) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
connect_list.layoutManager = LinearLayoutManager(context) | ||
connect_list.adapter = SpeakersAdapter(context!!, SpeakerManager.speakerList) | ||
|
||
SpeakerManager.linkUpdatedEvent.subscribe { | ||
this@ConnectFragment.activity?.runOnUiThread { | ||
connect_list.adapter?.notifyDataSetChanged() | ||
} | ||
} | ||
|
||
connect_scan_button.setOnClickListener { | ||
if (BleScanManager.isScanning) { | ||
BleScanManager.stopScan() | ||
} else { | ||
BleScanManager.startScan() | ||
} | ||
|
||
updateUi() | ||
} | ||
|
||
updateUi() | ||
} | ||
|
||
fun updateUi() { | ||
if (BleScanManager.isScanning) { | ||
connect_scan_progressbar.visibility = View.VISIBLE | ||
connect_scan_value.text = getString(R.string.connect_searching_on) | ||
connect_scan_button.text = getString(R.string.connect_button_stop) | ||
} else { | ||
connect_scan_progressbar.visibility = View.GONE | ||
connect_scan_value.text = getString(R.string.connect_searching_off) | ||
connect_scan_button.text = getString(R.string.connect_button_search) | ||
} | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
SpeakerManager.speakerFoundEvent.unsubscribe() | ||
} | ||
|
||
override fun getName() = "Connect" | ||
} |
34 changes: 0 additions & 34 deletions
34
app/src/main/java/me/andreww7985/connectplus/ui/fragments/ConnectPlusFragment.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters