오윤석

원격 잠금해제 기록 API 연동

package com.sunnni.smartdoorlock.data;
public class RemoteRecord {
public String deviceName;
public String remoteDate;
private String deviceName;
private String remoteDate;
public RemoteRecord(String name, String date){
this.deviceName = name;
this.remoteDate = date;
}
public String getDeviceName() {
return deviceName;
}
public String getRemoteDate() {
return remoteDate;
}
}
......
......@@ -7,12 +7,15 @@ import androidx.core.widget.NestedScrollView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent;
import android.os.Bundle;
import android.telecom.Call;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.sunnni.smartdoorlock.R;
import com.sunnni.smartdoorlock.api.Api;
import com.sunnni.smartdoorlock.data.Device;
import com.sunnni.smartdoorlock.data.RemoteRecord;
......@@ -34,7 +37,20 @@ public class RemoteControlRecordActivity extends AppCompatActivity {
setToolbar(mToolbar);
setRecyclerView();
setRecordList();
Api.getRemote(new Api.Callback() {
@Override
public void callbackMethod(Object obj) {
if(obj == null) {
Toast.makeText(getApplicationContext(), "연결 상태가 불안정합니다.", Toast.LENGTH_SHORT).show();
startActivity(new Intent(RemoteControlRecordActivity.this, MainActivity.class));
return;
} else {
mRecordList.clear();
mRecordList.addAll(0, (ArrayList<RemoteRecord>) obj);
mAdapter.notifyDataSetChanged();
}
}
});
init();
}
......@@ -66,24 +82,4 @@ public class RemoteControlRecordActivity extends AppCompatActivity {
mRecyclerView.setLayoutManager(manager);
mRecyclerView.setAdapter(mAdapter);
}
private void setRecordList(){
RemoteRecord temp;
mRecordList.add(temp = new RemoteRecord("Galaxy Note 10", "2020.10.07(수) 17:50:00"));
mRecordList.add(temp = new RemoteRecord("Galaxy Note 10", "2020.10.07(수) 17:50:00"));
mRecordList.add(temp = new RemoteRecord("Galaxy Note 10", "2020.10.07(수) 17:50:00"));
mRecordList.add(temp = new RemoteRecord("Galaxy Note 10", "2020.10.07(수) 17:50:00"));
mRecordList.add(temp = new RemoteRecord("Galaxy Note 10", "2020.10.07(수) 17:50:00"));
mRecordList.add(temp = new RemoteRecord("Galaxy Note 10", "2020.10.07(수) 17:50:00"));
mRecordList.add(temp = new RemoteRecord("Galaxy Note 10", "2020.10.07(수) 17:50:00"));
mRecordList.add(temp = new RemoteRecord("Galaxy Note 10", "2020.10.07(수) 17:50:00"));
mRecordList.add(temp = new RemoteRecord("Galaxy Note 10", "2020.10.07(수) 17:50:00"));
mRecordList.add(temp = new RemoteRecord("Galaxy Note 10", "2020.10.07(수) 17:50:00"));
mRecordList.add(temp = new RemoteRecord("Galaxy Note 10", "2020.10.07(수) 17:50:00"));
mRecordList.add(temp = new RemoteRecord("Galaxy Note 10", "2020.10.07(수) 17:50:00"));
mRecordList.add(temp = new RemoteRecord("Galaxy Note 10", "2020.10.07(수) 17:50:00"));
mRecordList.add(temp = new RemoteRecord("Galaxy Note 10", "2020.10.07(수) 17:50:00"));
mAdapter.notifyDataSetChanged();
}
}
......
......@@ -29,8 +29,8 @@ public class RemoteRecordRvAdapter extends RecyclerView.Adapter<RemoteRecordRvAd
}
void bind(RemoteRecord record){
mTvDeviceName.setText(record.deviceName);
mTvRemoteDate.setText(record.remoteDate);
mTvDeviceName.setText(record.getDeviceName());
mTvRemoteDate.setText(record.getRemoteDate());
}
}
......