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
sunnnl
2020-11-19 00:18:11 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
38a8c368f7d4e862f4175e150dae81a65346a554
38a8c368
1 parent
e8de58a9
뷰 스플래싱 완료, api 동작 확인 필요
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
35 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/ui/VideoCheckActivity.java
app/src/main/res/layout/rv_item_video.xml
app/src/main/java/com/sunnni/smartdoorlock/api/Api.java
View file @
38a8c36
...
...
@@ -38,10 +38,10 @@ public class Api {
ApiResult
apiResult
;
try
{
String
queryString
=
""
;
if
((
"GET"
.
equals
(
method
)
||
"DELETE"
.
equals
(
method
))
&&
params
!=
null
)
{
if
((
"GET"
.
equals
(
method
)
||
"DELETE"
.
equals
(
method
))
&&
params
!=
null
)
{
Set
<
String
>
keys
=
params
.
keySet
();
Iterator
<
String
>
iter
=
keys
.
iterator
();
while
(
iter
.
hasNext
())
{
while
(
iter
.
hasNext
())
{
String
key
=
iter
.
next
();
queryString
+=
"&"
+
key
+
"="
+
params
.
get
(
key
).
getAsString
();
}
...
...
@@ -52,12 +52,12 @@ public class Api {
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
conn
.
setRequestMethod
(
method
);
if
(
accessToken
!=
null
)
{
if
(
accessToken
!=
null
)
{
conn
.
setRequestProperty
(
"access_token"
,
accessToken
);
}
if
(
"POST"
.
equals
(
method
)
||
"PUT"
.
equals
(
method
))
{
if
(
params
!=
null
)
{
if
(
"POST"
.
equals
(
method
)
||
"PUT"
.
equals
(
method
))
{
if
(
params
!=
null
)
{
OutputStream
os
=
conn
.
getOutputStream
();
os
.
write
(
params
.
toString
().
getBytes
());
os
.
flush
();
...
...
@@ -68,13 +68,13 @@ public class Api {
int
status
=
conn
.
getResponseCode
();
Log
.
d
(
"status"
,
String
.
valueOf
(
status
));
InputStream
is
=
conn
.
getErrorStream
();
if
(
is
==
null
)
if
(
is
==
null
)
is
=
conn
.
getInputStream
();
StringBuilder
builder
=
new
StringBuilder
();
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
is
,
"UTF-8"
));
String
line
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
while
((
line
=
reader
.
readLine
())
!=
null
)
{
builder
.
append
(
line
);
}
...
...
@@ -103,7 +103,7 @@ public class Api {
}
static
public
void
auth
(
String
doorId
,
final
Callback
callback
)
{
if
(
"123123123"
.
equals
(
doorId
))
{
if
(
"123123123"
.
equals
(
doorId
))
{
// 테스트를 위한 super pass
callback
.
callbackMethod
(
new
Auth
(
true
,
"superpass"
));
return
;
...
...
@@ -115,9 +115,9 @@ public class Api {
@Override
public
void
callbackMethod
(
Object
obj
)
{
ApiResult
apiResult
=
(
ApiResult
)
obj
;
if
(
apiResult
.
isSuccess
())
{
if
(
apiResult
.
isSuccess
())
{
JsonObject
resp
=
(
JsonObject
)
apiResult
.
getData
();
if
(
resp
.
get
(
"is_available"
).
getAsBoolean
())
{
if
(
resp
.
get
(
"is_available"
).
getAsBoolean
())
{
callback
.
callbackMethod
(
new
Auth
(
true
,
resp
.
get
(
"access_token"
).
getAsString
()));
}
else
{
callback
.
callbackMethod
(
new
Auth
(
false
));
...
...
@@ -134,7 +134,7 @@ public class Api {
@Override
public
void
callbackMethod
(
Object
obj
)
{
ApiResult
apiResult
=
(
ApiResult
)
obj
;
if
(
apiResult
.
isSuccess
())
{
if
(
apiResult
.
isSuccess
())
{
JsonObject
resp
=
(
JsonObject
)
apiResult
.
getData
();
callback
.
callbackMethod
(
new
Setting
(
resp
.
get
(
"recording"
).
getAsBoolean
()));
}
else
{
...
...
@@ -152,7 +152,7 @@ public class Api {
@Override
public
void
callbackMethod
(
Object
obj
)
{
ApiResult
apiResult
=
(
ApiResult
)
obj
;
if
(
apiResult
.
isSuccess
())
{
if
(
apiResult
.
isSuccess
())
{
callback
.
callbackMethod
(
true
);
}
else
{
callback
.
callbackMethod
(
null
);
...
...
@@ -169,7 +169,7 @@ public class Api {
@Override
public
void
callbackMethod
(
Object
obj
)
{
ApiResult
apiResult
=
(
ApiResult
)
obj
;
if
(
apiResult
.
isSuccess
())
{
if
(
apiResult
.
isSuccess
())
{
callback
.
callbackMethod
(
new
Boolean
(
true
));
}
else
{
callback
.
callbackMethod
(
null
);
...
...
@@ -183,12 +183,12 @@ public class Api {
@Override
public
void
callbackMethod
(
Object
obj
)
{
ApiResult
apiResult
=
(
ApiResult
)
obj
;
if
(
apiResult
.
isSuccess
())
{
if
(
apiResult
.
isSuccess
())
{
JsonObject
resp
=
(
JsonObject
)
apiResult
.
getData
();
if
(
resp
.
has
(
"remoteHistoryList"
))
{
if
(
resp
.
has
(
"remoteHistoryList"
))
{
ArrayList
<
RemoteRecord
>
remoteRecords
=
new
ArrayList
<
RemoteRecord
>();
Iterator
it
=
resp
.
getAsJsonArray
(
"remoteHistoryList"
).
iterator
();
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
JsonObject
jsonObject
=
(
JsonObject
)
it
.
next
();
remoteRecords
.
add
(
new
RemoteRecord
(
jsonObject
.
get
(
"device_name"
).
getAsString
(),
jsonObject
.
get
(
"created"
).
getAsString
()));
}
...
...
@@ -208,14 +208,14 @@ public class Api {
@Override
public
void
callbackMethod
(
Object
obj
)
{
ApiResult
apiResult
=
(
ApiResult
)
obj
;
if
(
apiResult
.
isSuccess
())
{
if
(
apiResult
.
isSuccess
())
{
JsonObject
resp
=
(
JsonObject
)
apiResult
.
getData
();
if
(
resp
.
has
(
"videoList"
))
{
if
(
resp
.
has
(
"videoList"
))
{
ArrayList
<
Video
>
videos
=
new
ArrayList
<
Video
>();
Iterator
it
=
resp
.
getAsJsonArray
(
"videoList"
).
iterator
();
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
JsonObject
jsonObject
=
(
JsonObject
)
it
.
next
();
videos
.
add
(
new
Video
(
jsonObject
.
get
(
"vid_name"
).
getAsString
(),
jsonObject
.
get
(
"thumb"
).
getAsString
(),
jsonObject
.
get
(
"created"
).
getAsString
(),
"01:14"
));
videos
.
add
(
new
Video
(
jsonObject
.
get
(
"vid_name"
).
getAsString
(),
jsonObject
.
get
(
"thumb"
).
getAsString
(),
jsonObject
.
get
(
"created"
).
getAsString
(),
jsonObject
.
get
(
"vid_time"
).
getAsString
()
));
}
callback
.
callbackMethod
(
videos
);
}
else
{
...
...
@@ -233,9 +233,9 @@ public class Api {
@Override
public
void
callbackMethod
(
Object
obj
)
{
ApiResult
apiResult
=
(
ApiResult
)
obj
;
if
(
apiResult
.
isSuccess
())
{
if
(
apiResult
.
isSuccess
())
{
JsonObject
resp
=
(
JsonObject
)
apiResult
.
getData
();
if
(
resp
.
has
(
"s3link"
))
{
if
(
resp
.
has
(
"s3link"
))
{
callback
.
callbackMethod
(
resp
.
get
(
"s3link"
).
getAsString
());
}
else
{
callback
.
callbackMethod
(
null
);
...
...
@@ -252,7 +252,7 @@ public class Api {
@Override
public
void
callbackMethod
(
Object
obj
)
{
ApiResult
apiResult
=
(
ApiResult
)
obj
;
if
(
apiResult
.
isSuccess
())
{
if
(
apiResult
.
isSuccess
())
{
callback
.
callbackMethod
(
new
Boolean
(
true
));
}
else
{
callback
.
callbackMethod
(
null
);
...
...
@@ -266,12 +266,12 @@ public class Api {
@Override
public
void
callbackMethod
(
Object
obj
)
{
ApiResult
apiResult
=
(
ApiResult
)
obj
;
if
(
apiResult
.
isSuccess
())
{
if
(
apiResult
.
isSuccess
())
{
JsonObject
resp
=
(
JsonObject
)
apiResult
.
getData
();
if
(
resp
.
has
(
"deviceList"
))
{
if
(
resp
.
has
(
"deviceList"
))
{
ArrayList
<
Device
>
videos
=
new
ArrayList
<
Device
>();
Iterator
it
=
resp
.
getAsJsonArray
(
"deviceList"
).
iterator
();
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
JsonObject
jsonObject
=
(
JsonObject
)
it
.
next
();
videos
.
add
(
new
Device
(
jsonObject
.
get
(
"device_id"
).
getAsInt
(),
jsonObject
.
get
(
"rfid_id"
).
getAsString
(),
jsonObject
.
get
(
"created"
).
getAsString
()));
}
...
...
@@ -291,7 +291,7 @@ public class Api {
@Override
public
void
callbackMethod
(
Object
obj
)
{
ApiResult
apiResult
=
(
ApiResult
)
obj
;
if
(
apiResult
.
isSuccess
())
{
if
(
apiResult
.
isSuccess
())
{
callback
.
callbackMethod
(
new
Boolean
(
true
));
}
else
{
callback
.
callbackMethod
(
null
);
...
...
@@ -305,7 +305,7 @@ public class Api {
@Override
public
void
callbackMethod
(
Object
obj
)
{
ApiResult
apiResult
=
(
ApiResult
)
obj
;
if
(
apiResult
.
isSuccess
())
{
if
(
apiResult
.
isSuccess
())
{
callback
.
callbackMethod
(
new
Boolean
(
true
));
}
else
{
callback
.
callbackMethod
(
null
);
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/RemoteControlRecordActivity.java
View file @
38a8c36
...
...
@@ -82,4 +82,8 @@ public class RemoteControlRecordActivity extends AppCompatActivity {
mRecyclerView
.
setLayoutManager
(
manager
);
mRecyclerView
.
setAdapter
(
mAdapter
);
}
private
void
dummy
(){
}
}
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/VideoCheckActivity.java
View file @
38a8c36
...
...
@@ -53,7 +53,7 @@ public class VideoCheckActivity extends AppCompatActivity {
Api
.
removeVideo
(
mVideoList
.
get
(
0
),
new
Api
.
Callback
()
{
@Override
public
void
callbackMethod
(
Object
obj
)
{
if
(
obj
==
null
)
{
if
(
obj
==
null
)
{
Toast
.
makeText
(
getApplicationContext
(),
"연결 상태가 불안정합니다."
,
Toast
.
LENGTH_SHORT
).
show
();
startActivity
(
new
Intent
(
VideoCheckActivity
.
this
,
MainActivity
.
class
));
return
;
...
...
@@ -74,7 +74,7 @@ public class VideoCheckActivity extends AppCompatActivity {
// 원래는 각 비디오에 대해서 동작해야 함. 코드 의미 전달을 위해 video[0]에 대해 재생하는 코드만 구현
final
Video
video
=
mVideoList
.
get
(
0
);
// s3 링크를 받아오지 못한 경우에만 조회. 이미 받아온 경우 바로 해당 링크로 재생
if
(
video
.
getS3link
()
==
null
)
{
if
(
video
.
getS3link
()
==
null
)
{
Api
.
getVideo
(
mVideoList
.
get
(
0
),
new
Api
.
Callback
()
{
@Override
public
void
callbackMethod
(
Object
obj
)
{
...
...
@@ -96,7 +96,7 @@ public class VideoCheckActivity extends AppCompatActivity {
});
}
private
void
setToolbar
(
Toolbar
toolbar
){
private
void
setToolbar
(
Toolbar
toolbar
)
{
setSupportActionBar
(
toolbar
);
Objects
.
requireNonNull
(
getSupportActionBar
()).
setDisplayShowCustomEnabled
(
true
);
getSupportActionBar
().
setDisplayShowTitleEnabled
(
false
);
...
...
@@ -116,7 +116,7 @@ public class VideoCheckActivity extends AppCompatActivity {
@Override
public
void
callbackMethod
(
Object
obj
)
{
// TODO : 비디오 리스트가 로드되었을 때
if
(
obj
==
null
)
{
if
(
obj
==
null
)
{
Toast
.
makeText
(
getApplicationContext
(),
"연결 상태가 불안정합니다."
,
Toast
.
LENGTH_SHORT
).
show
();
startActivity
(
new
Intent
(
VideoCheckActivity
.
this
,
MainActivity
.
class
));
return
;
...
...
@@ -129,12 +129,12 @@ public class VideoCheckActivity extends AppCompatActivity {
});
}
private
void
init
(){
private
void
init
()
{
NestedScrollView
nestedScrollView
=
findViewById
(
R
.
id
.
scroll_video_check
);
nestedScrollView
.
getParent
().
requestChildFocus
(
nestedScrollView
,
nestedScrollView
);
}
private
void
setRecyclerView
(){
private
void
setRecyclerView
()
{
mRecyclerView
=
findViewById
(
R
.
id
.
rv_video_list
);
GridLayoutManager
manager
=
new
GridLayoutManager
(
this
,
2
);
mAdapter
=
new
VideoRvAdapter
(
mVideoList
);
...
...
app/src/main/res/layout/rv_item_video.xml
View file @
38a8c36
...
...
@@ -18,7 +18,7 @@
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:background=
"@color/colorPrimary"
app:layout_constraintDimensionRatio=
"
7:3
"
app:layout_constraintDimensionRatio=
"
3:2
"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
...
...
Please
register
or
login
to post a comment