You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
2.0 KiB
61 lines
2.0 KiB
package com.community.pocket.ui.main.ui.visitor.reservation;
|
|
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.lifecycle.Observer;
|
|
import androidx.lifecycle.ViewModelProvider;
|
|
|
|
import com.community.pocket.R;
|
|
import com.community.pocket.ui.main.ui.share.Response;
|
|
import com.community.pocket.ui.main.ui.visitor.VisitorMyVisitor;
|
|
|
|
import org.xutils.view.annotation.ContentView;
|
|
import org.xutils.view.annotation.Event;
|
|
|
|
/**
|
|
* 我的预约界面
|
|
*/
|
|
@ContentView(R.layout.visitor_my_fragment)
|
|
public class VisitorReservationFragment extends VisitorMyVisitor {
|
|
|
|
private VisitorReservationViewModel viewModel;
|
|
|
|
@Override
|
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
|
super.onViewCreated(view, savedInstanceState);
|
|
name.setText(R.string.appointment_name);
|
|
time.setText(R.string.appointment_time);
|
|
|
|
viewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(VisitorReservationViewModel.class);
|
|
|
|
viewModel.loadReservation(null, null);
|
|
|
|
//监听我的预约请求状态
|
|
viewModel.getVisitorReservationResponse().observe(getViewLifecycleOwner(), new Observer<VisitorReservationResponse>() {
|
|
@Override
|
|
public void onChanged(VisitorReservationResponse visitorReservationResponse) {
|
|
if (visitorReservationResponse == null) {
|
|
return;
|
|
}
|
|
|
|
visitorReservationResponse.toast(getContext());
|
|
|
|
if (visitorReservationResponse.getResult() == Response.Result.OK) {
|
|
loadData(visitorReservationResponse.getVisitorList());
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
/**
|
|
* 查询预约数据
|
|
*/
|
|
@Event(value = R.id.query)
|
|
private void query(View view) {
|
|
viewModel.loadReservation(startTime.getText().toString(), endTime.getText().toString());
|
|
}
|
|
}
|
|
|