sunnnl

비디오 뷰 퍼블리싱 완료, api 추가 연결 및 video 객체 점검 필요

......@@ -42,4 +42,7 @@ dependencies {
//gson: https://github.com/google/gson
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.squareup.retrofit2:converter-gson:2.6.2'
// 이미지 url 출력
implementation 'com.github.bumptech.glide:glide:4.10.0'
}
......
......@@ -9,17 +9,18 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity android:name=".ui.VideoCheckActivity"></activity>
<activity android:name=".ui.DeviceManagerActivity" />
<activity android:name=".ui.RemoteControlRecordActivity" />
<activity
android:name=".ui.SplashActivity"
android:noHistory="true"
android:screenOrientation="fullSensor" >
android:screenOrientation="fullSensor">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......
......@@ -215,7 +215,7 @@ public class Api {
Iterator it = resp.getAsJsonArray("videoList").iterator();
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()));
videos.add(new Video(jsonObject.get("vid_name").getAsString(), jsonObject.get("thumb").getAsString(), jsonObject.get("created").getAsString(), "01:14"));
}
callback.callbackMethod(videos);
} else {
......
......@@ -5,11 +5,13 @@ public class Video {
private String thumb;
private String created;
private String s3link;
private String playTime;
public Video(String vidName, String thumb, String created) {
public Video(String vidName, String thumb, String created, String playTime) {
this.vidName = vidName;
this.thumb = thumb;
this.created = created;
this.playTime = playTime;
}
public void setS3link(String s3link) {
......@@ -31,4 +33,8 @@ public class Video {
public String getVidName() {
return vidName;
}
public String getPlayTime() {
return playTime;
}
}
......
......@@ -19,16 +19,16 @@ public class RemoteRecordRvAdapter extends RecyclerView.Adapter<RemoteRecordRvAd
ArrayList<RemoteRecord> recordList;
static class RemoteRecordViewHolder extends RecyclerView.ViewHolder{
static class RemoteRecordViewHolder extends RecyclerView.ViewHolder {
TextView mTvDeviceName, mTvRemoteDate;
RemoteRecordViewHolder(View v){
RemoteRecordViewHolder(View v) {
super(v);
this.mTvDeviceName = v.findViewById(R.id.tv_device_name);
this.mTvRemoteDate = v.findViewById(R.id.tv_remote_date);
}
void bind(RemoteRecord record){
void bind(RemoteRecord record) {
mTvDeviceName.setText(record.getDeviceName());
mTvRemoteDate.setText(record.getCreated());
}
......
......@@ -2,6 +2,10 @@ package com.sunnni.smartdoorlock.ui;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.widget.NestedScrollView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent;
import android.os.Bundle;
......@@ -20,6 +24,9 @@ import java.util.Objects;
public class VideoCheckActivity extends AppCompatActivity {
ArrayList<Video> mVideoList = new ArrayList<Video>();
RecyclerView mRecyclerView;
VideoRvAdapter mAdapter;
Button mBtnRemoveVideo;
Button mBtnViewVideo;
......@@ -35,6 +42,8 @@ public class VideoCheckActivity extends AppCompatActivity {
mBtnViewVideo = (Button) findViewById(R.id.btn_view_video);
getVideos();
init();
setRecyclerView();
mBtnRemoveVideo.setOnClickListener(new View.OnClickListener() {
@Override
......@@ -114,9 +123,22 @@ public class VideoCheckActivity extends AppCompatActivity {
} else {
mVideoList.clear();
mVideoList.addAll(0, (ArrayList<Video>) obj);
//mAdapter.notifyDataSetChanged();
mAdapter.notifyDataSetChanged();
}
}
});
}
private void init(){
NestedScrollView nestedScrollView = findViewById(R.id.scroll_video_check);
nestedScrollView.getParent().requestChildFocus(nestedScrollView, nestedScrollView);
}
private void setRecyclerView(){
mRecyclerView = findViewById(R.id.rv_video_list);
GridLayoutManager manager = new GridLayoutManager(this, 2);
mAdapter = new VideoRvAdapter(mVideoList);
mRecyclerView.setLayoutManager(manager);
mRecyclerView.setAdapter(mAdapter);
}
}
......
package com.sunnni.smartdoorlock.ui;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.constraintlayout.widget.ConstraintLayout;
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.data.RemoteRecord;
import com.sunnni.smartdoorlock.data.Video;
import java.util.ArrayList;
public class VideoRvAdapter extends RecyclerView.Adapter<VideoRvAdapter.VideoViewHolder> {
ArrayList<Video> videoList;
static class VideoViewHolder extends RecyclerView.ViewHolder {
TextView mTvDate, mTvPlayTime;
ImageView mImgThumbnail, mImgDelete;
ConstraintLayout mCtnItem;
VideoViewHolder(View v) {
super(v);
this.mCtnItem = v.findViewById(R.id.cl_item_video);
this.mTvDate = v.findViewById(R.id.tv_date);
this.mTvPlayTime = v.findViewById(R.id.tv_play_time);
this.mImgThumbnail = v.findViewById(R.id.img_thumbnail);
this.mImgDelete = v.findViewById(R.id.img_delete);
}
void bind(final Video video) {
mTvDate.setText(video.getCreated());
mTvPlayTime.setText(video.getPlayTime());
Glide.with(itemView.getContext())
.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));
// TODO: finish 하거나 or intent flag 설정하기
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) {
if (video.getS3link() == null){
Api.getVideo(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 {
String s3link = (String) obj;
video.setS3link(s3link);
// TODO : 비디오 재생 코드 구현 (video.setS3link를 통해)
}
}
});
}
}
});
}
}
public VideoRvAdapter(ArrayList<Video> list) {
this.videoList = list;
}
@NonNull
@Override
public VideoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.rv_item_video, parent, false);
return new VideoViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull VideoViewHolder holder, int position) {
holder.bind(videoList.get(position));
}
@Override
public int getItemCount() {
return videoList.size();
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#455a64">
<path
android:fillColor="@android:color/white"
android:pathData="M9,11L7,11v2h2v-2zM13,11h-2v2h2v-2zM17,11h-2v2h2v-2zM19,4h-1L18,2h-2v2L8,4L8,2L6,2v2L5,4c-1.11,0 -1.99,0.9 -1.99,2L3,20c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,6c0,-1.1 -0.9,-2 -2,-2zM19,20L5,20L5,9h14v11z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#607d8b"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M21,3L3,3c-1.11,0 -2,0.89 -2,2v12c0,1.1 0.89,2 2,2h5v2h8v-2h5c1.1,0 1.99,-0.9 1.99,-2L23,5c0,-1.11 -0.9,-2 -2,-2zM21,17L3,17L3,5h18v12zM16,11l-7,4L9,7z" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="@color/colorAccent">
<path
android:fillColor="@android:color/white"
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V9c0,-1.1 -0.9,-2 -2,-2H8c-1.1,0 -2,0.9 -2,2v10zM18,4h-2.5l-0.71,-0.71c-0.18,-0.18 -0.44,-0.29 -0.7,-0.29H9.91c-0.26,0 -0.52,0.11 -0.7,0.29L8.5,4H6c-0.55,0 -1,0.45 -1,1s0.45,1 1,1h12c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#ff5252">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2z"/>
</vector>
......@@ -62,10 +62,10 @@
app:layout_constraintTop_toBottomOf="@+id/toolbar_remote_control_record" />
<TextView
android:includeFontPadding="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:layout_marginTop="2dp"
android:fontFamily="@font/g_market_sans_ttf_medium"
android:text="@string/menu_remote_control_record"
android:textColor="#111111"
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll_video_check"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.VideoCheckActivity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar_video_check"
android:layout_width="0dp"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorBackground"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:elevation="7dp"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/g_market_sans_ttf_medium"
android:text="@string/menu_video_check"
android:textColor="@color/colorMainText"
android:textSize="15sp" />
</androidx.appcompat.widget.Toolbar>
<Button
android:id="@+id/btn_remove_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="563dp"
android:layout_marginStart="100dp"
android:text="btn_remove_video"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar_video_check" />
<Button
android:id="@+id/btn_view_video"
android:background="@color/colorAccent">
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.VideoCheckActivity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar_video_check"
android:layout_width="0dp"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorBackground"
android:elevation="7dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="504dp"
android:layout_marginStart="6dp"
android:text="btn_view_video"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@+id/btn_remove_video"
app:layout_constraintTop_toBottomOf="@+id/toolbar_video_check" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
android:fontFamily="@font/g_market_sans_ttf_medium"
android:text="@string/menu_video_check"
android:textColor="@color/colorMainText"
android:textSize="15sp" />
</androidx.appcompat.widget.Toolbar>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/gl_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintGuide_percent="0.05"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/gl_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintGuide_percent="0.95"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/img_icon_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:src="@drawable/round_format_list_bulleted_24"
app:layout_constraintStart_toStartOf="@id/gl_start"
app:layout_constraintTop_toBottomOf="@+id/toolbar_video_check" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:fontFamily="@font/g_market_sans_ttf_medium"
android:includeFontPadding="false"
android:text="@string/video_list"
android:textColor="#111111"
android:textSize="17sp"
app:layout_constraintBottom_toBottomOf="@id/img_icon_list"
app:layout_constraintStart_toEndOf="@id/img_icon_list"
app:layout_constraintTop_toTopOf="@+id/img_icon_list" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_video_list"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:layout_constraintEnd_toEndOf="@id/gl_end"
app:layout_constraintStart_toStartOf="@id/gl_start"
app:layout_constraintTop_toBottomOf="@+id/img_icon_list" />
<Button
android:id="@+id/btn_remove_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn_remove_video"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/btn_view_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn_view_video"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
\ No newline at end of file
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginHorizontal="5dp"
app:cardCornerRadius="2dp">
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/cl_item_video"
android:background="@color/colorAccent">
<ImageView
android:id="@+id/img_thumbnail"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/colorPrimary"
app:layout_constraintDimensionRatio="7:3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/img_date"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginStart="15dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="2dp"
android:src="@drawable/baseline_date_range_24"
app:layout_constraintBottom_toTopOf="@+id/img_video"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/img_thumbnail"
app:layout_constraintVertical_chainStyle="packed" />
<TextView
android:id="@+id/tv_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:fontFamily="@font/g_market_sans_ttf_medium"
android:includeFontPadding="false"
android:text="@string/sample_date"
android:textColor="#455a64"
android:textSize="11sp"
app:layout_constraintBottom_toBottomOf="@id/img_date"
app:layout_constraintStart_toEndOf="@+id/img_date"
app:layout_constraintTop_toTopOf="@id/img_date" />
<ImageView
android:id="@+id/img_video"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="20dp"
android:src="@drawable/baseline_ondemand_video_small_24"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@id/img_date"
app:layout_constraintTop_toBottomOf="@id/img_date"
app:layout_constraintVertical_chainStyle="packed" />
<TextView
android:id="@+id/tv_play_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:fontFamily="@font/g_market_sans_ttf_medium"
android:includeFontPadding="false"
android:text="@string/sample_play_time"
android:textColor="#607d8b"
android:textSize="11sp"
app:layout_constraintBottom_toBottomOf="@id/img_video"
app:layout_constraintStart_toEndOf="@+id/img_video"
app:layout_constraintTop_toTopOf="@id/img_video" />
<Button
android:id="@+id/btn_back"
style="?android:attr/borderlessButtonStyle"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginEnd="10dp"
android:background="@drawable/round_lens_delete_24"
app:layout_constraintBottom_toBottomOf="@id/img_thumbnail"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/img_thumbnail" />
<ImageView
android:id="@+id/img_delete"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/round_delete_white_24"
app:layout_constraintBottom_toBottomOf="@id/btn_back"
app:layout_constraintEnd_toEndOf="@id/btn_back"
app:layout_constraintStart_toStartOf="@+id/btn_back"
app:layout_constraintTop_toTopOf="@id/btn_back" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
\ No newline at end of file
......@@ -27,9 +27,11 @@
<string name="sample_device_name">Galaxy Note 10</string>
<string name="sample_remote_date">2020.10.07(수) 17:50:00</string>
<string name="sample_play_time">01:41</string>
<string name="video_settings">비디오 설정</string>
<string name="video_auto_record">비디오 자동 녹화</string>
<string name="video_list">비디오 목록</string>
<string name="logout">로그아웃</string>
......