完善访客预约布局

0515
panqihua 5 years ago
parent 819b010f4c
commit aa20cb47d5
  1. 17
      app/src/main/java/com/community/pocket/data/main/visitor/VisitorMyRequest.java
  2. 18
      app/src/main/java/com/community/pocket/data/main/visitor/VisitorReservationRequest.java
  3. 20
      app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorMyVisitor.java
  4. 10
      app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorAppointmentFragment.java
  5. 9
      app/src/main/java/com/community/pocket/ui/main/ui/visitor/my/VisitorMyFragment.java
  6. 4
      app/src/main/java/com/community/pocket/ui/main/ui/visitor/my/VisitorMyViewModel.java
  7. 9
      app/src/main/java/com/community/pocket/ui/main/ui/visitor/reservation/VisitorReservationFragment.java
  8. 5
      app/src/main/java/com/community/pocket/ui/main/ui/visitor/reservation/VisitorReservationViewModel.java
  9. 20
      app/src/main/res/layout/main/layout/visitor/layout/visitor_my_fragment.xml

@ -30,12 +30,17 @@ public class VisitorMyRequest {
* 加载我的访客
*/
@HttpRequest("/visitor/my")
public void loadMy(MutableLiveData<VisitorMyResponse> liveData) {
public void loadMy(MutableLiveData<VisitorMyResponse> liveData, String startDate, String endDate) {
FormBody.Builder builder = new FormBody.Builder()
.add("username", LocalToken.getUsername())
.add("token", LocalToken.getToken());
if (startDate != null && !startDate.isEmpty()) {
builder.add("startDate", startDate);
}
if (endDate != null && !endDate.isEmpty()) {
builder.add("endDate", endDate);
}
HttpUtil.getRequest(HttpUtil.Method.GET,
new SimpleHttpParse<VisitorMyResponse>(liveData).getInterface(VisitorMyResponse.class),
new FormBody.Builder()
.add("username", LocalToken.getUsername())
.add("token", LocalToken.getToken())
.build());
new SimpleHttpParse<VisitorMyResponse>(liveData).getInterface(VisitorMyResponse.class), builder.build());
}
}

@ -30,13 +30,17 @@ public class VisitorReservationRequest {
* 我的预约
*/
@HttpRequest("/visitor/reservation")
public void loadReservation(MutableLiveData<VisitorReservationResponse> liveData) {
public void loadReservation(MutableLiveData<VisitorReservationResponse> liveData, String startDate, String endDate) {
FormBody.Builder builder = new FormBody.Builder()
.add("username", LocalToken.getUsername())
.add("token", LocalToken.getToken());
if (startDate != null && !startDate.isEmpty()) {
builder.add("startDate", startDate);
}
if (endDate != null && !endDate.isEmpty()) {
builder.add("endDate", endDate);
}
HttpUtil.getRequest(HttpUtil.Method.GET,
new SimpleHttpParse<VisitorReservationResponse>(liveData).getInterface(VisitorReservationResponse.class),
new FormBody.Builder()
.add("username", LocalToken.getUsername())
.add("token", LocalToken.getToken())
.build());
new SimpleHttpParse<VisitorReservationResponse>(liveData).getInterface(VisitorReservationResponse.class), builder.build());
}
}

@ -1,6 +1,7 @@
package com.community.pocket.ui.main.ui.visitor;
import android.os.Build;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.view.Gravity;
import android.view.View;
@ -8,6 +9,8 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AlertDialog;
@ -16,6 +19,7 @@ import androidx.gridlayout.widget.GridLayout;
import com.community.pocket.R;
import com.community.pocket.data.model.Visitor;
import com.community.pocket.ui.BaseFragment;
import com.community.pocket.util.PropertiesUtil;
import org.xutils.view.annotation.ViewInject;
@ -45,15 +49,25 @@ public abstract class VisitorMyVisitor extends BaseFragment {
@ViewInject(R.id.time)
protected TextView time;
@ViewInject(R.id.tip)
private TextView tip;
/**
* 显示备注最大长度
*/
private static final int maxLength = 5;
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
this.initTip();
}
/**
* 初始化数据
*/
protected <T extends Visitor> void loadData(List<T> visitors) {
gridLayout.removeAllViews();
for (final Visitor visitor : visitors) {
createTextView(visitor.getName());
createTextView(DateFormat.format(getString(R.string.dateformat), visitor.getTime()));
@ -138,4 +152,10 @@ public abstract class VisitorMyVisitor extends BaseFragment {
});
alertDialog.show();
}
//初始化日期提示
private void initTip() {
String format = PropertiesUtil.getValue("date.pattern");
tip.setText(getString(R.string.dateformat_tip, format, DateFormat.format(format, System.currentTimeMillis())));
}
}

@ -193,16 +193,6 @@ public class VisitorAppointmentFragment extends BaseFragment {
initTip();
}
//
// //是否外来人口
// @Event(value = R.id.button_group,type = RadioGroup.OnCheckedChangeListener.class)
// private void checkOutPeople(RadioGroup group, @IdRes int checkedId){
// if(R.id.is_outpeople==checkedId){
//
// }else{
//
// }
// }
/**
* 搜索框

@ -2,7 +2,6 @@ package com.community.pocket.ui.main.ui.visitor.my;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -22,15 +21,17 @@ import org.xutils.view.annotation.Event;
@ContentView(R.layout.visitor_my_fragment)
public class VisitorMyFragment extends VisitorMyVisitor {
private VisitorMyViewModel viewModel;
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
name.setText(R.string.visitor_name);
time.setText(R.string.visitor_time);
final VisitorMyViewModel viewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(VisitorMyViewModel.class);
viewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(VisitorMyViewModel.class);
viewModel.loadMy();
viewModel.loadMy(null, null);
//监听我的访客请求状态
viewModel.getVisitorMyResponse().observe(getViewLifecycleOwner(), new Observer<VisitorMyResponse>() {
@ -54,6 +55,6 @@ public class VisitorMyFragment extends VisitorMyVisitor {
*/
@Event(R.id.query)
private void query(View view) {
Toast.makeText(getContext(), "访客数据查询" + startTime.getText() + "|" + endTime.getText(), Toast.LENGTH_SHORT).show();
viewModel.loadMy(startTime.getText().toString(), endTime.getText().toString());
}
}

@ -20,8 +20,8 @@ public class VisitorMyViewModel extends BaseViewModel<VisitorMyRequest> {
/**
* 加载我的访客
*/
void loadMy() {
getRequest().loadMy(visitorMyResponse);
void loadMy(String startDate, String endDate) {
getRequest().loadMy(visitorMyResponse, startDate, endDate);
}
@Override

@ -2,7 +2,6 @@ package com.community.pocket.ui.main.ui.visitor.reservation;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -22,15 +21,17 @@ 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);
VisitorReservationViewModel viewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(VisitorReservationViewModel.class);
viewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(VisitorReservationViewModel.class);
viewModel.loadReservation();
viewModel.loadReservation(null, null);
//监听我的预约请求状态
viewModel.getVisitorReservationResponse().observe(getViewLifecycleOwner(), new Observer<VisitorReservationResponse>() {
@ -55,6 +56,6 @@ public class VisitorReservationFragment extends VisitorMyVisitor {
*/
@Event(value = R.id.query)
private void query(View view) {
Toast.makeText(getContext(), "预约数据查询" + startTime.getText() + "|" + endTime.getText(), Toast.LENGTH_SHORT).show();
viewModel.loadReservation(startTime.getText().toString(), endTime.getText().toString());
}
}

@ -17,8 +17,9 @@ public class VisitorReservationViewModel extends BaseViewModel<VisitorReservatio
return visitorReservationResponse;
}
void loadReservation() {
getRequest().loadReservation(visitorReservationResponse);
//我的预约
void loadReservation(String startDate, String endDate) {
getRequest().loadReservation(visitorReservationResponse, startDate, endDate);
}

@ -10,6 +10,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tip"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/query_layout"
android:layout_width="0dp"
@ -17,7 +27,7 @@
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
app:layout_constraintTop_toBottomOf="@id/tip">
<EditText
android:id="@+id/start_time"
@ -26,8 +36,8 @@
android:layout_weight="1"
android:ems="10"
android:hint="@string/start_time"
android:inputType="textPersonName"
android:importantForAutofill="no" />
android:importantForAutofill="no"
android:inputType="date" />
<EditText
android:id="@+id/end_time"
@ -36,8 +46,8 @@
android:layout_weight="1"
android:ems="10"
android:hint="@string/end_time"
android:inputType="textPersonName"
android:importantForAutofill="no" />
android:importantForAutofill="no"
android:inputType="date" />
</LinearLayout>

Loading…
Cancel
Save