Showing
7 changed files
with
49 additions
and
15 deletions
... | @@ -17,6 +17,7 @@ import android.widget.Toast; | ... | @@ -17,6 +17,7 @@ import android.widget.Toast; |
17 | 17 | ||
18 | import com.sunnni.smartdoorlock.R; | 18 | import com.sunnni.smartdoorlock.R; |
19 | import com.sunnni.smartdoorlock.api.Api; | 19 | import com.sunnni.smartdoorlock.api.Api; |
20 | +import com.sunnni.smartdoorlock.api.OnItemClick; | ||
20 | import com.sunnni.smartdoorlock.data.Device; | 21 | import com.sunnni.smartdoorlock.data.Device; |
21 | import com.sunnni.smartdoorlock.data.RemoteRecord; | 22 | import com.sunnni.smartdoorlock.data.RemoteRecord; |
22 | 23 | ||
... | @@ -25,7 +26,7 @@ import java.util.Objects; | ... | @@ -25,7 +26,7 @@ import java.util.Objects; |
25 | 26 | ||
26 | import static android.view.InputDevice.getDevice; | 27 | import static android.view.InputDevice.getDevice; |
27 | 28 | ||
28 | -public class DeviceManagerActivity extends AppCompatActivity { | 29 | +public class DeviceManagerActivity extends AppCompatActivity implements OnItemClick { |
29 | 30 | ||
30 | ArrayList<Device> mList = new ArrayList<Device>(); | 31 | ArrayList<Device> mList = new ArrayList<Device>(); |
31 | RecyclerView mRecyclerView; | 32 | RecyclerView mRecyclerView; |
... | @@ -78,7 +79,7 @@ public class DeviceManagerActivity extends AppCompatActivity { | ... | @@ -78,7 +79,7 @@ public class DeviceManagerActivity extends AppCompatActivity { |
78 | private void setRecyclerView(){ | 79 | private void setRecyclerView(){ |
79 | mRecyclerView = findViewById(R.id.rv_device_list); | 80 | mRecyclerView = findViewById(R.id.rv_device_list); |
80 | LinearLayoutManager manager = new LinearLayoutManager(this); | 81 | LinearLayoutManager manager = new LinearLayoutManager(this); |
81 | - mAdapter = new DeviceRecyclerViewAdapter(mList); | 82 | + mAdapter = new DeviceRecyclerViewAdapter(mList, this); |
82 | mRecyclerView.setLayoutManager(manager); | 83 | mRecyclerView.setLayoutManager(manager); |
83 | mRecyclerView.setAdapter(mAdapter); | 84 | mRecyclerView.setAdapter(mAdapter); |
84 | } | 85 | } |
... | @@ -130,4 +131,10 @@ public class DeviceManagerActivity extends AppCompatActivity { | ... | @@ -130,4 +131,10 @@ public class DeviceManagerActivity extends AppCompatActivity { |
130 | alertDialog = builder.create(); | 131 | alertDialog = builder.create(); |
131 | alertDialog.show(); | 132 | alertDialog.show(); |
132 | } | 133 | } |
134 | + | ||
135 | + @Override | ||
136 | + public void onItemClick() { | ||
137 | + getDevice(); | ||
138 | + Toast.makeText(this, "호출 테스트", Toast.LENGTH_LONG).show(); | ||
139 | + } | ||
133 | } | 140 | } | ... | ... |
... | @@ -16,6 +16,7 @@ import androidx.recyclerview.widget.RecyclerView; | ... | @@ -16,6 +16,7 @@ import androidx.recyclerview.widget.RecyclerView; |
16 | 16 | ||
17 | import com.sunnni.smartdoorlock.R; | 17 | import com.sunnni.smartdoorlock.R; |
18 | import com.sunnni.smartdoorlock.api.Api; | 18 | import com.sunnni.smartdoorlock.api.Api; |
19 | +import com.sunnni.smartdoorlock.api.OnItemClick; | ||
19 | import com.sunnni.smartdoorlock.data.Device; | 20 | import com.sunnni.smartdoorlock.data.Device; |
20 | 21 | ||
21 | import java.util.ArrayList; | 22 | import java.util.ArrayList; |
... | @@ -23,6 +24,7 @@ import java.util.ArrayList; | ... | @@ -23,6 +24,7 @@ import java.util.ArrayList; |
23 | public class DeviceRecyclerViewAdapter extends RecyclerView.Adapter<DeviceRecyclerViewAdapter.DeviceViewHolder> { | 24 | public class DeviceRecyclerViewAdapter extends RecyclerView.Adapter<DeviceRecyclerViewAdapter.DeviceViewHolder> { |
24 | 25 | ||
25 | ArrayList<Device> mList; | 26 | ArrayList<Device> mList; |
27 | + OnItemClick mCallback; | ||
26 | 28 | ||
27 | static class DeviceViewHolder extends RecyclerView.ViewHolder { | 29 | static class DeviceViewHolder extends RecyclerView.ViewHolder { |
28 | TextView mTvDeviceNum, mTvRegisterDate; | 30 | TextView mTvDeviceNum, mTvRegisterDate; |
... | @@ -58,6 +60,7 @@ public class DeviceRecyclerViewAdapter extends RecyclerView.Adapter<DeviceRecycl | ... | @@ -58,6 +60,7 @@ public class DeviceRecyclerViewAdapter extends RecyclerView.Adapter<DeviceRecycl |
58 | Toast.makeText(itemView.getContext(), "삭제되었습니다.", Toast.LENGTH_LONG).show(); | 60 | Toast.makeText(itemView.getContext(), "삭제되었습니다.", Toast.LENGTH_LONG).show(); |
59 | // TODO : 목록 refresh | 61 | // TODO : 목록 refresh |
60 | // DeviceManagerActivity.getDevices 를 호출하거나 DeviceManagerActivity.mList에서 device 제거 | 62 | // DeviceManagerActivity.getDevices 를 호출하거나 DeviceManagerActivity.mList에서 device 제거 |
63 | + this.notifyAll(); | ||
61 | } | 64 | } |
62 | } | 65 | } |
63 | }); | 66 | }); |
... | @@ -76,8 +79,9 @@ public class DeviceRecyclerViewAdapter extends RecyclerView.Adapter<DeviceRecycl | ... | @@ -76,8 +79,9 @@ public class DeviceRecyclerViewAdapter extends RecyclerView.Adapter<DeviceRecycl |
76 | } | 79 | } |
77 | } | 80 | } |
78 | 81 | ||
79 | - public DeviceRecyclerViewAdapter(ArrayList<Device> list) { | 82 | + public DeviceRecyclerViewAdapter(ArrayList<Device> list, OnItemClick listener) { |
80 | this.mList = list; | 83 | this.mList = list; |
84 | + this.mCallback = listener; | ||
81 | } | 85 | } |
82 | 86 | ||
83 | @NonNull | 87 | @NonNull |
... | @@ -91,6 +95,12 @@ public class DeviceRecyclerViewAdapter extends RecyclerView.Adapter<DeviceRecycl | ... | @@ -91,6 +95,12 @@ public class DeviceRecyclerViewAdapter extends RecyclerView.Adapter<DeviceRecycl |
91 | @Override | 95 | @Override |
92 | public void onBindViewHolder(@NonNull DeviceViewHolder holder, int position) { | 96 | public void onBindViewHolder(@NonNull DeviceViewHolder holder, int position) { |
93 | holder.bind(mList.get(position)); | 97 | holder.bind(mList.get(position)); |
98 | + holder.mTrashcan.setOnClickListener(new View.OnClickListener() { | ||
99 | + @Override | ||
100 | + public void onClick(View v) { | ||
101 | + mCallback.onItemClick(); | ||
102 | + } | ||
103 | + }); | ||
94 | } | 104 | } |
95 | 105 | ||
96 | @Override | 106 | @Override | ... | ... |
... | @@ -82,8 +82,4 @@ public class RemoteControlRecordActivity extends AppCompatActivity { | ... | @@ -82,8 +82,4 @@ public class RemoteControlRecordActivity extends AppCompatActivity { |
82 | mRecyclerView.setLayoutManager(manager); | 82 | mRecyclerView.setLayoutManager(manager); |
83 | mRecyclerView.setAdapter(mAdapter); | 83 | mRecyclerView.setAdapter(mAdapter); |
84 | } | 84 | } |
85 | - | ||
86 | - private void dummy(){ | ||
87 | - | ||
88 | - } | ||
89 | } | 85 | } | ... | ... |
... | @@ -15,13 +15,14 @@ import android.widget.Toast; | ... | @@ -15,13 +15,14 @@ import android.widget.Toast; |
15 | 15 | ||
16 | import com.sunnni.smartdoorlock.R; | 16 | import com.sunnni.smartdoorlock.R; |
17 | import com.sunnni.smartdoorlock.api.Api; | 17 | import com.sunnni.smartdoorlock.api.Api; |
18 | +import com.sunnni.smartdoorlock.api.OnItemClick; | ||
18 | import com.sunnni.smartdoorlock.data.RemoteRecord; | 19 | import com.sunnni.smartdoorlock.data.RemoteRecord; |
19 | import com.sunnni.smartdoorlock.data.Video; | 20 | import com.sunnni.smartdoorlock.data.Video; |
20 | 21 | ||
21 | import java.util.ArrayList; | 22 | import java.util.ArrayList; |
22 | import java.util.Objects; | 23 | import java.util.Objects; |
23 | 24 | ||
24 | -public class VideoCheckActivity extends AppCompatActivity { | 25 | +public class VideoCheckActivity extends AppCompatActivity implements OnItemClick { |
25 | 26 | ||
26 | ArrayList<Video> mVideoList = new ArrayList<Video>(); | 27 | ArrayList<Video> mVideoList = new ArrayList<Video>(); |
27 | RecyclerView mRecyclerView; | 28 | RecyclerView mRecyclerView; |
... | @@ -137,8 +138,15 @@ public class VideoCheckActivity extends AppCompatActivity { | ... | @@ -137,8 +138,15 @@ public class VideoCheckActivity extends AppCompatActivity { |
137 | private void setRecyclerView() { | 138 | private void setRecyclerView() { |
138 | mRecyclerView = findViewById(R.id.rv_video_list); | 139 | mRecyclerView = findViewById(R.id.rv_video_list); |
139 | GridLayoutManager manager = new GridLayoutManager(this, 2); | 140 | GridLayoutManager manager = new GridLayoutManager(this, 2); |
140 | - mAdapter = new VideoRvAdapter(mVideoList); | 141 | + mAdapter = new VideoRvAdapter(mVideoList, this); |
141 | mRecyclerView.setLayoutManager(manager); | 142 | mRecyclerView.setLayoutManager(manager); |
142 | mRecyclerView.setAdapter(mAdapter); | 143 | mRecyclerView.setAdapter(mAdapter); |
143 | } | 144 | } |
145 | + | ||
146 | + @Override | ||
147 | + public void onItemClick() { | ||
148 | + // 삭제했을 때 여기서 다시 비디오 리스트 불러오기 | ||
149 | + getVideos(); | ||
150 | + Toast.makeText(this, "호출 테스트", Toast.LENGTH_LONG).show(); | ||
151 | + } | ||
144 | } | 152 | } | ... | ... |
... | @@ -10,6 +10,7 @@ import android.widget.Toast; | ... | @@ -10,6 +10,7 @@ import android.widget.Toast; |
10 | import android.widget.VideoView; | 10 | import android.widget.VideoView; |
11 | 11 | ||
12 | import com.sunnni.smartdoorlock.R; | 12 | import com.sunnni.smartdoorlock.R; |
13 | +import com.sunnni.smartdoorlock.api.OnItemClick; | ||
13 | 14 | ||
14 | public class VideoPlayerActivity extends AppCompatActivity { | 15 | public class VideoPlayerActivity extends AppCompatActivity { |
15 | 16 | ... | ... |
... | @@ -17,6 +17,7 @@ import androidx.recyclerview.widget.RecyclerView; | ... | @@ -17,6 +17,7 @@ import androidx.recyclerview.widget.RecyclerView; |
17 | import com.bumptech.glide.Glide; | 17 | import com.bumptech.glide.Glide; |
18 | import com.sunnni.smartdoorlock.R; | 18 | import com.sunnni.smartdoorlock.R; |
19 | import com.sunnni.smartdoorlock.api.Api; | 19 | import com.sunnni.smartdoorlock.api.Api; |
20 | +import com.sunnni.smartdoorlock.api.OnItemClick; | ||
20 | import com.sunnni.smartdoorlock.data.RemoteRecord; | 21 | import com.sunnni.smartdoorlock.data.RemoteRecord; |
21 | import com.sunnni.smartdoorlock.data.Video; | 22 | import com.sunnni.smartdoorlock.data.Video; |
22 | 23 | ||
... | @@ -25,6 +26,7 @@ import java.util.ArrayList; | ... | @@ -25,6 +26,7 @@ import java.util.ArrayList; |
25 | public class VideoRvAdapter extends RecyclerView.Adapter<VideoRvAdapter.VideoViewHolder> { | 26 | public class VideoRvAdapter extends RecyclerView.Adapter<VideoRvAdapter.VideoViewHolder> { |
26 | 27 | ||
27 | ArrayList<Video> videoList; | 28 | ArrayList<Video> videoList; |
29 | + OnItemClick mCallback; | ||
28 | 30 | ||
29 | static class VideoViewHolder extends RecyclerView.ViewHolder { | 31 | static class VideoViewHolder extends RecyclerView.ViewHolder { |
30 | TextView mTvDate, mTvPlayTime; | 32 | TextView mTvDate, mTvPlayTime; |
... | @@ -62,13 +64,11 @@ public class VideoRvAdapter extends RecyclerView.Adapter<VideoRvAdapter.VideoVie | ... | @@ -62,13 +64,11 @@ public class VideoRvAdapter extends RecyclerView.Adapter<VideoRvAdapter.VideoVie |
62 | public void callbackMethod(Object obj) { | 64 | public void callbackMethod(Object obj) { |
63 | if(obj==null){ | 65 | if(obj==null){ |
64 | Toast.makeText(itemView.getContext(), "연결 상태가 불안정합니다.", Toast.LENGTH_SHORT).show(); | 66 | Toast.makeText(itemView.getContext(), "연결 상태가 불안정합니다.", Toast.LENGTH_SHORT).show(); |
65 | - itemView.getContext().startActivity(new Intent(itemView.getContext(), MainActivity.class)); | 67 | + // itemView.getContext().startActivity(new Intent(itemView.getContext(), MainActivity.class)); |
66 | - // TODO: finish 하거나 or intent flag 설정하기 | ||
67 | return; | 68 | return; |
68 | 69 | ||
69 | } else { | 70 | } else { |
70 | - Toast.makeText(itemView.getContext(), "삭제되었습니다.", Toast.LENGTH_LONG).show(); | 71 | + // Toast.makeText(itemView.getContext(), "삭제되었습니다.", Toast.LENGTH_LONG).show(); |
71 | - // 삭제 구현 | ||
72 | } | 72 | } |
73 | } | 73 | } |
74 | }); | 74 | }); |
... | @@ -94,7 +94,7 @@ public class VideoRvAdapter extends RecyclerView.Adapter<VideoRvAdapter.VideoVie | ... | @@ -94,7 +94,7 @@ public class VideoRvAdapter extends RecyclerView.Adapter<VideoRvAdapter.VideoVie |
94 | public void callbackMethod(Object obj) { | 94 | public void callbackMethod(Object obj) { |
95 | if (obj == null) { | 95 | if (obj == null) { |
96 | Toast.makeText(itemView.getContext(), "연결 상태가 불안정합니다.", Toast.LENGTH_SHORT).show(); | 96 | Toast.makeText(itemView.getContext(), "연결 상태가 불안정합니다.", Toast.LENGTH_SHORT).show(); |
97 | - itemView.getContext().startActivity(new Intent(itemView.getContext(), MainActivity.class)); | 97 | + // itemView.getContext().startActivity(new Intent(itemView.getContext(), MainActivity.class)); |
98 | return; | 98 | return; |
99 | } else { | 99 | } else { |
100 | String s3link = (String) obj; | 100 | String s3link = (String) obj; |
... | @@ -112,8 +112,9 @@ public class VideoRvAdapter extends RecyclerView.Adapter<VideoRvAdapter.VideoVie | ... | @@ -112,8 +112,9 @@ public class VideoRvAdapter extends RecyclerView.Adapter<VideoRvAdapter.VideoVie |
112 | } | 112 | } |
113 | } | 113 | } |
114 | 114 | ||
115 | - public VideoRvAdapter(ArrayList<Video> list) { | 115 | + public VideoRvAdapter(ArrayList<Video> list, OnItemClick listener) { |
116 | this.videoList = list; | 116 | this.videoList = list; |
117 | + this.mCallback = listener; | ||
117 | } | 118 | } |
118 | 119 | ||
119 | @NonNull | 120 | @NonNull |
... | @@ -126,6 +127,12 @@ public class VideoRvAdapter extends RecyclerView.Adapter<VideoRvAdapter.VideoVie | ... | @@ -126,6 +127,12 @@ public class VideoRvAdapter extends RecyclerView.Adapter<VideoRvAdapter.VideoVie |
126 | @Override | 127 | @Override |
127 | public void onBindViewHolder(@NonNull VideoViewHolder holder, int position) { | 128 | public void onBindViewHolder(@NonNull VideoViewHolder holder, int position) { |
128 | holder.bind(videoList.get(position)); | 129 | holder.bind(videoList.get(position)); |
130 | + holder.mImgDelete.setOnClickListener(new View.OnClickListener() { | ||
131 | + @Override | ||
132 | + public void onClick(View v) { | ||
133 | + mCallback.onItemClick(); | ||
134 | + } | ||
135 | + }); | ||
129 | } | 136 | } |
130 | 137 | ||
131 | @Override | 138 | @Override | ... | ... |
-
Please register or login to post a comment