Toggle navigation
Toggle navigation
This project
Loading...
Sign in
cse437_e
/
smartdoorlock-frontend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
오윤석
2020-11-16 22:53:27 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6ce108b1f08ad406db5cd90349486e3011685d4b
6ce108b1
1 parent
8cd83fde
원격 잠금해제 연결
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletions
app/src/main/java/com/sunnni/smartdoorlock/api/Api.java
app/src/main/java/com/sunnni/smartdoorlock/ui/MainActivity.java
app/src/main/java/com/sunnni/smartdoorlock/api/Api.java
View file @
6ce108b
package
com
.
sunnni
.
smartdoorlock
.
api
;
import
android.os.Build
;
import
android.os.Handler
;
import
android.util.Log
;
...
...
@@ -156,4 +157,21 @@ public class Api {
}
});
}
static
public
void
requestRemote
(
final
Callback
callback
)
{
JsonObject
params
=
new
JsonObject
();
params
.
addProperty
(
"device_name"
,
Build
.
MODEL
);
callApi
(
"POST"
,
"/api/remote"
,
params
,
new
Callback
()
{
@Override
public
void
callbackMethod
(
Object
obj
)
{
ApiResult
apiResult
=
(
ApiResult
)
obj
;
if
(
apiResult
.
isSuccess
())
{
callback
.
callbackMethod
(
new
Boolean
(
true
));
}
else
{
callback
.
callbackMethod
(
null
);
}
}
});
}
}
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/MainActivity.java
View file @
6ce108b
...
...
@@ -22,6 +22,7 @@ import android.widget.Toast;
import
com.google.android.material.navigation.NavigationView
;
import
com.sunnni.smartdoorlock.R
;
import
com.sunnni.smartdoorlock.api.Api
;
import
java.util.Objects
;
...
...
@@ -220,9 +221,18 @@ public class MainActivity extends AppCompatActivity {
builder
.
setPositiveButton
(
"열기"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
// 원격 해제 구현 부분
Api
.
requestRemote
(
new
Api
.
Callback
()
{
@Override
public
void
callbackMethod
(
Object
obj
)
{
if
(
obj
==
null
)
{
Toast
.
makeText
(
getApplicationContext
(),
"연결 상태가 불안정합니다."
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
else
{
Toast
.
makeText
(
MainActivity
.
this
,
"도어락이 열렸습니다."
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
});
}
});
builder
.
setNegativeButton
(
"취소"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
...
...
Please
register
or
login
to post a comment