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-07 05:58:39 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
35ecc375150a6df546cf0a39a315d6a74febfca0
35ecc375
1 parent
be670e3f
auth api 연결
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
app/src/main/java/com/sunnni/smartdoorlock/api/Api.java
app/src/main/java/com/sunnni/smartdoorlock/ui/SplashActivity.java
app/src/main/java/com/sunnni/smartdoorlock/api/Api.java
View file @
35ecc37
...
...
@@ -95,4 +95,22 @@ public class Api {
}
}.
start
();
}
static
public
void
auth
(
String
doorId
,
final
Callback
callback
)
{
JsonObject
params
=
new
JsonObject
();
params
.
addProperty
(
"door_id"
,
doorId
);
callApi
(
"GET"
,
"/api/auth"
,
params
,
new
Callback
()
{
@Override
public
void
callbackMethod
(
Object
obj
)
{
ApiResult
apiResult
=
(
ApiResult
)
obj
;
if
(
apiResult
.
isSuccess
())
{
JsonObject
resp
=
(
JsonObject
)
apiResult
.
getData
();
if
(
resp
.
get
(
"is_available"
).
getAsBoolean
())
{
callback
.
callbackMethod
(
true
);
}
}
callback
.
callbackMethod
(
false
);
}
});
}
}
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/SplashActivity.java
View file @
35ecc37
...
...
@@ -18,6 +18,7 @@ import android.widget.Toast;
import
com.google.android.material.textfield.TextInputEditText
;
import
com.google.android.material.textfield.TextInputLayout
;
import
com.sunnni.smartdoorlock.R
;
import
com.sunnni.smartdoorlock.api.Api
;
public
class
SplashActivity
extends
AppCompatActivity
{
...
...
@@ -67,13 +68,18 @@ public class SplashActivity extends AppCompatActivity {
if
(
""
.
equals
(
text
)){
Toast
.
makeText
(
getApplicationContext
(),
"고유번호를 입력해주세요."
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
// TODO : API 연결
if
(
"123456"
.
equals
(
text
))
{
Api
.
auth
(
text
,
new
Api
.
Callback
()
{
@Override
public
void
callbackMethod
(
Object
obj
)
{
Boolean
success
=
(
Boolean
)
obj
;
if
(
success
)
{
startActivity
(
new
Intent
(
SplashActivity
.
this
,
MainActivity
.
class
));
}
else
{
Toast
.
makeText
(
getApplicationContext
(),
"고유번호를 확인해주세요."
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
});
}
}
});
}
...
...
Please
register
or
login
to post a comment