Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Companion App Android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andy B-S
Companion App Android
Commits
7cff04ec
Commit
7cff04ec
authored
5 years ago
by
Anon
Browse files
Options
Downloads
Patches
Plain Diff
FileTransferFragment: Add error handling.
parent
be9f3535
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/de/ccc/events/badge/card10/filetransfer/FileTransferFragment.kt
+29
-2
29 additions, 2 deletions
.../events/badge/card10/filetransfer/FileTransferFragment.kt
with
29 additions
and
2 deletions
app/src/main/java/de/ccc/events/badge/card10/filetransfer/FileTransferFragment.kt
+
29
−
2
View file @
7cff04ec
...
@@ -34,11 +34,14 @@ import android.widget.EditText
...
@@ -34,11 +34,14 @@ import android.widget.EditText
import
android.widget.ProgressBar
import
android.widget.ProgressBar
import
android.widget.TextView
import
android.widget.TextView
import
androidx.annotation.UiThread
import
androidx.annotation.UiThread
import
androidx.appcompat.app.AlertDialog
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.Fragment
import
de.ccc.events.badge.card10.CARD10_BLUETOOTH_MAC_PREFIX
import
de.ccc.events.badge.card10.CARD10_BLUETOOTH_MAC_PREFIX
import
de.ccc.events.badge.card10.R
import
de.ccc.events.badge.card10.R
import
de.ccc.events.badge.card10.common.ConnectionException
import
de.ccc.events.badge.card10.common.ConnectionService
import
de.ccc.events.badge.card10.common.ConnectionService
import
de.ccc.events.badge.card10.common.GattListener
import
de.ccc.events.badge.card10.common.GattListener
import
de.ccc.events.badge.card10.main.MainFragment
import
java.lang.Exception
import
java.lang.Exception
import
java.lang.IllegalStateException
import
java.lang.IllegalStateException
...
@@ -76,8 +79,15 @@ class FileTransferFragment : Fragment(), GattListener, FileTransferListener{
...
@@ -76,8 +79,15 @@ class FileTransferFragment : Fragment(), GattListener, FileTransferListener{
buttonStartStop
=
view
.
findViewById
(
R
.
id
.
button_start_stop_transfer
)
buttonStartStop
=
view
.
findViewById
(
R
.
id
.
button_start_stop_transfer
)
try
{
initConnection
()
initConnection
()
toggleControls
()
toggleControls
()
}
catch
(
e
:
ConnectionException
)
{
showError
(
e
.
message
)
}
catch
(
e
:
Exception
)
{
showError
(
getString
(
R
.
string
.
connection_error_generic
))
}
}
}
private
fun
initConnection
()
{
private
fun
initConnection
()
{
...
@@ -160,4 +170,21 @@ class FileTransferFragment : Fragment(), GattListener, FileTransferListener{
...
@@ -160,4 +170,21 @@ class FileTransferFragment : Fragment(), GattListener, FileTransferListener{
}
}
toggleControls
()
toggleControls
()
}
}
private
fun
showError
(
message
:
String
?)
{
val
ctx
=
context
?:
throw
IllegalStateException
()
val
fm
=
fragmentManager
?:
throw
IllegalStateException
()
val
errorDialog
=
AlertDialog
.
Builder
(
ctx
)
.
setMessage
(
message
?:
getString
(
R
.
string
.
connection_error_generic
))
.
setPositiveButton
(
R
.
string
.
dialog_action_ok
)
{
dialog
,
_
->
dialog
.
dismiss
()
fm
.
beginTransaction
()
.
replace
(
R
.
id
.
fragment_container
,
MainFragment
())
.
addToBackStack
(
null
)
.
commit
()
}
.
show
()
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment