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-26 02:49:02 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bd0750985f1d32870c3cd61c8667f68347e042c4
bd075098
1 parent
45f55e88
기기, 비디오 삭제 오류 수정
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
77 additions
and
54 deletions
app/src/main/java/com/sunnni/smartdoorlock/api/Api.java
app/src/main/java/com/sunnni/smartdoorlock/data/Device.java
app/src/main/java/com/sunnni/smartdoorlock/data/RemoteRecord.java
app/src/main/java/com/sunnni/smartdoorlock/data/Video.java
app/src/main/java/com/sunnni/smartdoorlock/ui/DeviceManagerActivity.java
app/src/main/java/com/sunnni/smartdoorlock/ui/DeviceRecyclerViewAdapter.java
app/src/main/java/com/sunnni/smartdoorlock/ui/RemoteRecordRvAdapter.java
app/src/main/java/com/sunnni/smartdoorlock/ui/SettingActivity.java
app/src/main/java/com/sunnni/smartdoorlock/ui/VideoCheckActivity.java
app/src/main/java/com/sunnni/smartdoorlock/ui/VideoPlayerActivity.java
app/src/main/java/com/sunnni/smartdoorlock/ui/VideoRvAdapter.java
app/src/main/java/com/sunnni/smartdoorlock/api/Api.java
View file @
bd07509
...
...
@@ -53,7 +53,7 @@ public class Api {
conn
.
setRequestMethod
(
method
);
if
(
accessToken
!=
null
)
{
conn
.
setRequestProperty
(
"
access_token"
,
accessToken
);
conn
.
setRequestProperty
(
"
Authorization"
,
"Token "
+
accessToken
);
}
if
(
"POST"
.
equals
(
method
)
||
"PUT"
.
equals
(
method
))
{
...
...
@@ -254,6 +254,7 @@ public class Api {
ApiResult
apiResult
=
(
ApiResult
)
obj
;
if
(
apiResult
.
isSuccess
())
{
callback
.
callbackMethod
(
new
Boolean
(
true
));
Log
.
d
(
"삭제 테스트"
,
apiResult
.
toString
());
}
else
{
callback
.
callbackMethod
(
null
);
}
...
...
@@ -293,6 +294,7 @@ public class Api {
ApiResult
apiResult
=
(
ApiResult
)
obj
;
if
(
apiResult
.
isSuccess
())
{
callback
.
callbackMethod
(
new
Boolean
(
true
));
Log
.
d
(
"삭제 테스트"
,
apiResult
.
toString
());
}
else
{
callback
.
callbackMethod
(
null
);
}
...
...
@@ -301,7 +303,7 @@ public class Api {
}
static
public
void
requestAddDevice
(
final
Callback
callback
)
{
callApi
(
"P
OS
T"
,
"/api/device/request"
,
null
,
new
Callback
()
{
callApi
(
"P
U
T"
,
"/api/device/request"
,
null
,
new
Callback
()
{
@Override
public
void
callbackMethod
(
Object
obj
)
{
ApiResult
apiResult
=
(
ApiResult
)
obj
;
...
...
app/src/main/java/com/sunnni/smartdoorlock/data/Device.java
View file @
bd07509
...
...
@@ -12,7 +12,7 @@ public class Device {
}
public
String
getCreated
()
{
return
created
;
return
created
.
substring
(
0
,
10
)
+
" "
+
created
.
substring
(
11
,
19
)
;
}
public
int
getDeviceId
()
{
...
...
app/src/main/java/com/sunnni/smartdoorlock/data/RemoteRecord.java
View file @
bd07509
...
...
@@ -4,7 +4,7 @@ public class RemoteRecord {
private
String
deviceName
;
private
String
created
;
public
RemoteRecord
(
String
deviceName
,
String
created
){
public
RemoteRecord
(
String
deviceName
,
String
created
)
{
this
.
deviceName
=
deviceName
;
this
.
created
=
created
;
}
...
...
@@ -14,6 +14,6 @@ public class RemoteRecord {
}
public
String
getCreated
()
{
return
created
;
return
created
.
substring
(
0
,
10
)
+
" "
+
created
.
substring
(
11
,
19
)
;
}
}
...
...
app/src/main/java/com/sunnni/smartdoorlock/data/Video.java
View file @
bd07509
...
...
@@ -19,7 +19,7 @@ public class Video {
}
public
String
getCreated
()
{
return
created
;
return
created
.
substring
(
0
,
10
)
+
" "
+
created
.
substring
(
11
,
19
)
;
}
public
String
getS3link
()
{
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/DeviceManagerActivity.java
View file @
bd07509
...
...
@@ -135,6 +135,7 @@ public class DeviceManagerActivity extends AppCompatActivity implements OnItemCl
@Override
public
void
onItemClick
()
{
getDevice
();
Toast
.
makeText
(
this
,
"호출 테스트"
,
Toast
.
LENGTH_LONG
).
show
();
mAdapter
.
notifyDataSetChanged
();
Toast
.
makeText
(
this
,
"기기가 삭제되었습니다."
,
Toast
.
LENGTH_LONG
).
show
();
}
}
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/DeviceRecyclerViewAdapter.java
View file @
bd07509
...
...
@@ -93,12 +93,38 @@ public class DeviceRecyclerViewAdapter extends RecyclerView.Adapter<DeviceRecycl
}
@Override
public
void
onBindViewHolder
(
@NonNull
DeviceViewHolder
holder
,
int
position
)
{
public
void
onBindViewHolder
(
@NonNull
final
DeviceViewHolder
holder
,
final
int
position
)
{
holder
.
bind
(
mList
.
get
(
position
));
holder
.
mTrashcan
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
mCallback
.
onItemClick
();
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
holder
.
mTrashcan
.
getContext
(),
R
.
style
.
AlertDialogTheme
);
builder
.
setTitle
(
"확인"
)
.
setMessage
(
R
.
string
.
alert_message_delete
);
builder
.
setPositiveButton
(
"삭제"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
Api
.
removeDevice
(
mList
.
get
(
position
),
new
Api
.
Callback
()
{
@Override
public
void
callbackMethod
(
Object
obj
)
{
if
(
obj
==
null
)
{
Toast
.
makeText
(
holder
.
mTrashcan
.
getContext
(),
"연결 상태가 불안정합니다."
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
else
{
mCallback
.
onItemClick
();
}
}
});
}
});
builder
.
setNegativeButton
(
"취소"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
}
});
AlertDialog
alertDialog
=
builder
.
create
();
alertDialog
.
show
();
}
});
}
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/RemoteRecordRvAdapter.java
View file @
bd07509
...
...
@@ -9,6 +9,7 @@ import androidx.annotation.NonNull;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.sunnni.smartdoorlock.R
;
import
com.sunnni.smartdoorlock.api.OnItemClick
;
import
com.sunnni.smartdoorlock.data.Device
;
import
com.sunnni.smartdoorlock.data.RemoteRecord
;
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/SettingActivity.java
View file @
bd07509
...
...
@@ -46,7 +46,7 @@ public class SettingActivity extends AppCompatActivity {
swcRecording
.
setOnCheckedChangeListener
(
new
CompoundButton
.
OnCheckedChangeListener
()
{
@Override
public
void
onCheckedChanged
(
CompoundButton
compoundButton
,
boolean
b
)
{
Api
.
setSetting
(
new
Setting
(
true
),
new
Api
.
Callback
()
{
Api
.
setSetting
(
new
Setting
(
b
),
new
Api
.
Callback
()
{
@Override
public
void
callbackMethod
(
Object
obj
)
{
if
(
obj
==
null
)
{
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/VideoCheckActivity.java
View file @
bd07509
...
...
@@ -147,6 +147,7 @@ public class VideoCheckActivity extends AppCompatActivity implements OnItemClick
public
void
onItemClick
()
{
// 삭제했을 때 여기서 다시 비디오 리스트 불러오기
getVideos
();
Toast
.
makeText
(
this
,
"호출 테스트"
,
Toast
.
LENGTH_LONG
).
show
();
mAdapter
.
notifyDataSetChanged
();
Toast
.
makeText
(
this
,
"비디오가 삭제되었습니다."
,
Toast
.
LENGTH_LONG
).
show
();
}
}
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/VideoPlayerActivity.java
View file @
bd07509
...
...
@@ -24,11 +24,11 @@ public class VideoPlayerActivity extends AppCompatActivity {
mVideoView
=
findViewById
(
R
.
id
.
vv
);
if
(
getIntent
().
getStringExtra
(
"video_url"
).
isEmpty
()){
if
(
getIntent
().
getStringExtra
(
"video_url"
).
isEmpty
())
{
Toast
.
makeText
(
this
,
"링크 null"
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
}
else
{
String
url
=
getIntent
().
getStringExtra
(
"video_url"
);
videoUri
=
Uri
.
parse
(
"android.resource://"
+
getPackageName
()
+
"/"
+
url
);
videoUri
=
Uri
.
parse
(
url
);
playVideo
();
}
}
...
...
@@ -36,16 +36,16 @@ public class VideoPlayerActivity extends AppCompatActivity {
@Override
protected
void
onPause
()
{
super
.
onPause
();
if
(
mVideoView
!=
null
&&
mVideoView
.
isPlaying
())
mVideoView
.
pause
();
if
(
mVideoView
!=
null
&&
mVideoView
.
isPlaying
())
mVideoView
.
pause
();
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
if
(
mVideoView
!=
null
)
mVideoView
.
stopPlayback
();
if
(
mVideoView
!=
null
)
mVideoView
.
stopPlayback
();
}
private
void
playVideo
(){
private
void
playVideo
()
{
mVideoView
.
setMediaController
(
new
MediaController
(
this
));
mVideoView
.
setVideoURI
(
videoUri
);
mVideoView
.
setOnPreparedListener
(
new
MediaPlayer
.
OnPreparedListener
()
{
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/VideoRvAdapter.java
View file @
bd07509
...
...
@@ -50,41 +50,6 @@ public class VideoRvAdapter extends RecyclerView.Adapter<VideoRvAdapter.VideoVie
.
load
(
video
.
getThumb
())
.
into
(
mImgThumbnail
);
mImgDelete
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
itemView
.
getContext
(),
R
.
style
.
AlertDialogTheme
);
builder
.
setTitle
(
"확인"
)
.
setMessage
(
R
.
string
.
alert_message_delete
);
builder
.
setPositiveButton
(
"삭제"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
Api
.
removeVideo
(
video
,
new
Api
.
Callback
()
{
@Override
public
void
callbackMethod
(
Object
obj
)
{
if
(
obj
==
null
){
Toast
.
makeText
(
itemView
.
getContext
(),
"연결 상태가 불안정합니다."
,
Toast
.
LENGTH_SHORT
).
show
();
// itemView.getContext().startActivity(new Intent(itemView.getContext(), MainActivity.class));
return
;
}
else
{
// Toast.makeText(itemView.getContext(), "삭제되었습니다.", Toast.LENGTH_LONG).show();
}
}
});
}
});
builder
.
setNegativeButton
(
"취소"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
}
});
AlertDialog
alertDialog
=
builder
.
create
();
alertDialog
.
show
();
}
});
mCtnItem
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
...
...
@@ -125,12 +90,39 @@ public class VideoRvAdapter extends RecyclerView.Adapter<VideoRvAdapter.VideoVie
}
@Override
public
void
onBindViewHolder
(
@NonNull
VideoViewHolder
holder
,
int
position
)
{
public
void
onBindViewHolder
(
@NonNull
final
VideoViewHolder
holder
,
final
int
position
)
{
holder
.
bind
(
videoList
.
get
(
position
));
holder
.
mImgDelete
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
mCallback
.
onItemClick
();
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
holder
.
mImgDelete
.
getContext
(),
R
.
style
.
AlertDialogTheme
);
builder
.
setTitle
(
"확인"
)
.
setMessage
(
R
.
string
.
alert_message_delete
);
builder
.
setPositiveButton
(
"삭제"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
Api
.
removeVideo
(
videoList
.
get
(
position
),
new
Api
.
Callback
()
{
@Override
public
void
callbackMethod
(
Object
obj
)
{
if
(
obj
==
null
){
Toast
.
makeText
(
holder
.
mImgDelete
.
getContext
(),
"연결 상태가 불안정합니다."
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
else
{
mCallback
.
onItemClick
();
}
}
});
}
});
builder
.
setNegativeButton
(
"취소"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
}
});
AlertDialog
alertDialog
=
builder
.
create
();
alertDialog
.
show
();
}
});
}
...
...
Please
register
or
login
to post a comment