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 23:50:15 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
393077cf82e42a93dfa64be352893e0bc156648b
393077cf
1 parent
d2623346
원격 잠금해제 기록 API 연동2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletions
app/src/main/java/com/sunnni/smartdoorlock/api/Api.java
app/src/main/java/com/sunnni/smartdoorlock/ui/RemoteControlRecordActivity.java
app/src/main/java/com/sunnni/smartdoorlock/api/Api.java
View file @
393077c
...
...
@@ -8,6 +8,7 @@ import com.google.gson.JsonElement;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonParser
;
import
com.sunnni.smartdoorlock.data.Auth
;
import
com.sunnni.smartdoorlock.data.RemoteRecord
;
import
com.sunnni.smartdoorlock.data.Setting
;
import
java.io.BufferedReader
;
...
...
@@ -16,6 +17,7 @@ import java.io.InputStreamReader;
import
java.io.OutputStream
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.Set
;
...
...
@@ -174,4 +176,29 @@ public class Api {
}
});
}
static
public
void
getRemotes
(
final
Callback
callback
)
{
callApi
(
"GET"
,
"/api/remote"
,
null
,
new
Callback
()
{
@Override
public
void
callbackMethod
(
Object
obj
)
{
ApiResult
apiResult
=
(
ApiResult
)
obj
;
if
(
apiResult
.
isSuccess
())
{
JsonObject
resp
=
(
JsonObject
)
apiResult
.
getData
();
if
(
resp
.
has
(
"remoteHistoryList"
))
{
ArrayList
<
RemoteRecord
>
remoteRecords
=
new
ArrayList
<
RemoteRecord
>();
Iterator
it
=
resp
.
getAsJsonArray
(
"remoteHistoryList"
).
iterator
();
while
(
it
.
hasNext
())
{
JsonObject
jsonObject
=
(
JsonObject
)
it
.
next
();
remoteRecords
.
add
(
new
RemoteRecord
(
jsonObject
.
get
(
"device_name"
).
getAsString
(),
jsonObject
.
get
(
"created"
).
getAsString
()));
}
callback
.
callbackMethod
(
remoteRecords
);
}
else
{
callback
.
callbackMethod
(
null
);
}
}
else
{
callback
.
callbackMethod
(
null
);
}
}
});
}
}
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/RemoteControlRecordActivity.java
View file @
393077c
...
...
@@ -37,7 +37,7 @@ public class RemoteControlRecordActivity extends AppCompatActivity {
setToolbar
(
mToolbar
);
setRecyclerView
();
Api
.
getRemote
(
new
Api
.
Callback
()
{
Api
.
getRemote
s
(
new
Api
.
Callback
()
{
@Override
public
void
callbackMethod
(
Object
obj
)
{
if
(
obj
==
null
)
{
...
...
Please
register
or
login
to post a comment