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 01:50:51 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
45f55e88ff8f0f8db88cb4a645ef8b14680d9df5
45f55e88
1 parent
9a898610
삭제 시 리스트 갱신 구현, 동작 확인 필요
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
49 additions
and
15 deletions
app/src/main/java/com/sunnni/smartdoorlock/api/OnItemClick.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/RemoteControlRecordActivity.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/OnItemClick.java
0 → 100644
View file @
45f55e8
package
com
.
sunnni
.
smartdoorlock
.
api
;
public
interface
OnItemClick
{
void
onItemClick
();
}
app/src/main/java/com/sunnni/smartdoorlock/ui/DeviceManagerActivity.java
View file @
45f55e8
...
...
@@ -17,6 +17,7 @@ import android.widget.Toast;
import
com.sunnni.smartdoorlock.R
;
import
com.sunnni.smartdoorlock.api.Api
;
import
com.sunnni.smartdoorlock.api.OnItemClick
;
import
com.sunnni.smartdoorlock.data.Device
;
import
com.sunnni.smartdoorlock.data.RemoteRecord
;
...
...
@@ -25,7 +26,7 @@ import java.util.Objects;
import
static
android
.
view
.
InputDevice
.
getDevice
;
public
class
DeviceManagerActivity
extends
AppCompatActivity
{
public
class
DeviceManagerActivity
extends
AppCompatActivity
implements
OnItemClick
{
ArrayList
<
Device
>
mList
=
new
ArrayList
<
Device
>();
RecyclerView
mRecyclerView
;
...
...
@@ -78,7 +79,7 @@ public class DeviceManagerActivity extends AppCompatActivity {
private
void
setRecyclerView
(){
mRecyclerView
=
findViewById
(
R
.
id
.
rv_device_list
);
LinearLayoutManager
manager
=
new
LinearLayoutManager
(
this
);
mAdapter
=
new
DeviceRecyclerViewAdapter
(
mList
);
mAdapter
=
new
DeviceRecyclerViewAdapter
(
mList
,
this
);
mRecyclerView
.
setLayoutManager
(
manager
);
mRecyclerView
.
setAdapter
(
mAdapter
);
}
...
...
@@ -130,4 +131,10 @@ public class DeviceManagerActivity extends AppCompatActivity {
alertDialog
=
builder
.
create
();
alertDialog
.
show
();
}
@Override
public
void
onItemClick
()
{
getDevice
();
Toast
.
makeText
(
this
,
"호출 테스트"
,
Toast
.
LENGTH_LONG
).
show
();
}
}
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/DeviceRecyclerViewAdapter.java
View file @
45f55e8
...
...
@@ -16,6 +16,7 @@ import androidx.recyclerview.widget.RecyclerView;
import
com.sunnni.smartdoorlock.R
;
import
com.sunnni.smartdoorlock.api.Api
;
import
com.sunnni.smartdoorlock.api.OnItemClick
;
import
com.sunnni.smartdoorlock.data.Device
;
import
java.util.ArrayList
;
...
...
@@ -23,6 +24,7 @@ import java.util.ArrayList;
public
class
DeviceRecyclerViewAdapter
extends
RecyclerView
.
Adapter
<
DeviceRecyclerViewAdapter
.
DeviceViewHolder
>
{
ArrayList
<
Device
>
mList
;
OnItemClick
mCallback
;
static
class
DeviceViewHolder
extends
RecyclerView
.
ViewHolder
{
TextView
mTvDeviceNum
,
mTvRegisterDate
;
...
...
@@ -58,6 +60,7 @@ public class DeviceRecyclerViewAdapter extends RecyclerView.Adapter<DeviceRecycl
Toast
.
makeText
(
itemView
.
getContext
(),
"삭제되었습니다."
,
Toast
.
LENGTH_LONG
).
show
();
// TODO : 목록 refresh
// DeviceManagerActivity.getDevices 를 호출하거나 DeviceManagerActivity.mList에서 device 제거
this
.
notifyAll
();
}
}
});
...
...
@@ -76,8 +79,9 @@ public class DeviceRecyclerViewAdapter extends RecyclerView.Adapter<DeviceRecycl
}
}
public
DeviceRecyclerViewAdapter
(
ArrayList
<
Device
>
list
)
{
public
DeviceRecyclerViewAdapter
(
ArrayList
<
Device
>
list
,
OnItemClick
listener
)
{
this
.
mList
=
list
;
this
.
mCallback
=
listener
;
}
@NonNull
...
...
@@ -91,6 +95,12 @@ public class DeviceRecyclerViewAdapter extends RecyclerView.Adapter<DeviceRecycl
@Override
public
void
onBindViewHolder
(
@NonNull
DeviceViewHolder
holder
,
int
position
)
{
holder
.
bind
(
mList
.
get
(
position
));
holder
.
mTrashcan
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
mCallback
.
onItemClick
();
}
});
}
@Override
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/RemoteControlRecordActivity.java
View file @
45f55e8
...
...
@@ -82,8 +82,4 @@ 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 @
45f55e8
...
...
@@ -15,13 +15,14 @@ import android.widget.Toast;
import
com.sunnni.smartdoorlock.R
;
import
com.sunnni.smartdoorlock.api.Api
;
import
com.sunnni.smartdoorlock.api.OnItemClick
;
import
com.sunnni.smartdoorlock.data.RemoteRecord
;
import
com.sunnni.smartdoorlock.data.Video
;
import
java.util.ArrayList
;
import
java.util.Objects
;
public
class
VideoCheckActivity
extends
AppCompatActivity
{
public
class
VideoCheckActivity
extends
AppCompatActivity
implements
OnItemClick
{
ArrayList
<
Video
>
mVideoList
=
new
ArrayList
<
Video
>();
RecyclerView
mRecyclerView
;
...
...
@@ -137,8 +138,15 @@ public class VideoCheckActivity extends AppCompatActivity {
private
void
setRecyclerView
()
{
mRecyclerView
=
findViewById
(
R
.
id
.
rv_video_list
);
GridLayoutManager
manager
=
new
GridLayoutManager
(
this
,
2
);
mAdapter
=
new
VideoRvAdapter
(
mVideoList
);
mAdapter
=
new
VideoRvAdapter
(
mVideoList
,
this
);
mRecyclerView
.
setLayoutManager
(
manager
);
mRecyclerView
.
setAdapter
(
mAdapter
);
}
@Override
public
void
onItemClick
()
{
// 삭제했을 때 여기서 다시 비디오 리스트 불러오기
getVideos
();
Toast
.
makeText
(
this
,
"호출 테스트"
,
Toast
.
LENGTH_LONG
).
show
();
}
}
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/VideoPlayerActivity.java
View file @
45f55e8
...
...
@@ -10,6 +10,7 @@ import android.widget.Toast;
import
android.widget.VideoView
;
import
com.sunnni.smartdoorlock.R
;
import
com.sunnni.smartdoorlock.api.OnItemClick
;
public
class
VideoPlayerActivity
extends
AppCompatActivity
{
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/VideoRvAdapter.java
View file @
45f55e8
...
...
@@ -17,6 +17,7 @@ import androidx.recyclerview.widget.RecyclerView;
import
com.bumptech.glide.Glide
;
import
com.sunnni.smartdoorlock.R
;
import
com.sunnni.smartdoorlock.api.Api
;
import
com.sunnni.smartdoorlock.api.OnItemClick
;
import
com.sunnni.smartdoorlock.data.RemoteRecord
;
import
com.sunnni.smartdoorlock.data.Video
;
...
...
@@ -25,6 +26,7 @@ import java.util.ArrayList;
public
class
VideoRvAdapter
extends
RecyclerView
.
Adapter
<
VideoRvAdapter
.
VideoViewHolder
>
{
ArrayList
<
Video
>
videoList
;
OnItemClick
mCallback
;
static
class
VideoViewHolder
extends
RecyclerView
.
ViewHolder
{
TextView
mTvDate
,
mTvPlayTime
;
...
...
@@ -62,13 +64,11 @@ public class VideoRvAdapter extends RecyclerView.Adapter<VideoRvAdapter.VideoVie
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
));
// TODO: finish 하거나 or intent flag 설정하기
// itemView.getContext().startActivity(new Intent(itemView.getContext(), MainActivity.class));
return
;
}
else
{
Toast
.
makeText
(
itemView
.
getContext
(),
"삭제되었습니다."
,
Toast
.
LENGTH_LONG
).
show
();
// 삭제 구현
// Toast.makeText(itemView.getContext(), "삭제되었습니다.", Toast.LENGTH_LONG).show();
}
}
});
...
...
@@ -94,7 +94,7 @@ public class VideoRvAdapter extends RecyclerView.Adapter<VideoRvAdapter.VideoVie
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
));
//
itemView.getContext().startActivity(new Intent(itemView.getContext(), MainActivity.class));
return
;
}
else
{
String
s3link
=
(
String
)
obj
;
...
...
@@ -112,8 +112,9 @@ public class VideoRvAdapter extends RecyclerView.Adapter<VideoRvAdapter.VideoVie
}
}
public
VideoRvAdapter
(
ArrayList
<
Video
>
list
)
{
public
VideoRvAdapter
(
ArrayList
<
Video
>
list
,
OnItemClick
listener
)
{
this
.
videoList
=
list
;
this
.
mCallback
=
listener
;
}
@NonNull
...
...
@@ -126,6 +127,12 @@ public class VideoRvAdapter extends RecyclerView.Adapter<VideoRvAdapter.VideoVie
@Override
public
void
onBindViewHolder
(
@NonNull
VideoViewHolder
holder
,
int
position
)
{
holder
.
bind
(
videoList
.
get
(
position
));
holder
.
mImgDelete
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
mCallback
.
onItemClick
();
}
});
}
@Override
...
...
Please
register
or
login
to post a comment