parent
8bb27af826
commit
d56e41699c
@ -0,0 +1,41 @@ |
||||
package com.community.pocket.data.main.visitor; |
||||
|
||||
import com.community.pocket.R; |
||||
import com.community.pocket.data.model.Visitor; |
||||
import com.community.pocket.ui.main.ui.visitor.my.VisitorMyResponse; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 我的访客请求接口 |
||||
* TODO 完善逻辑 |
||||
*/ |
||||
public class VisitorMyRequest { |
||||
private static volatile VisitorMyRequest instance; |
||||
|
||||
private VisitorMyRequest() { |
||||
} |
||||
|
||||
public static VisitorMyRequest getInstance() { |
||||
if (instance == null) { |
||||
instance = new VisitorMyRequest(); |
||||
} |
||||
return instance; |
||||
} |
||||
|
||||
/** |
||||
* 加载我的访客 |
||||
*/ |
||||
public VisitorMyResponse loadMy() { |
||||
List<Visitor> visitors = new ArrayList<>(); |
||||
for (int i = 0; i < 30; i++) { |
||||
Visitor visitor = new Visitor("1231", System.currentTimeMillis(), "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); |
||||
visitors.add(visitor); |
||||
} |
||||
VisitorMyResponse response = new VisitorMyResponse(); |
||||
response.setSuccess(R.string.load_visitor_my_ok); |
||||
response.setBody(visitors); |
||||
return response; |
||||
} |
||||
} |
@ -0,0 +1,41 @@ |
||||
package com.community.pocket.data.main.visitor; |
||||
|
||||
import com.community.pocket.R; |
||||
import com.community.pocket.data.model.Visitor; |
||||
import com.community.pocket.ui.main.ui.visitor.reservation.VisitorReservationResponse; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 我的预约请求接口 |
||||
* TODO 完善逻辑 |
||||
*/ |
||||
public class VisitorReservationRequest { |
||||
private static volatile VisitorReservationRequest instance; |
||||
|
||||
private VisitorReservationRequest() { |
||||
} |
||||
|
||||
public static VisitorReservationRequest getInstance() { |
||||
if (instance == null) { |
||||
instance = new VisitorReservationRequest(); |
||||
} |
||||
return instance; |
||||
} |
||||
|
||||
/** |
||||
* @return 我的预约 |
||||
*/ |
||||
public VisitorReservationResponse loadReservation() { |
||||
List<Visitor> visitors = new ArrayList<>(); |
||||
for (int i = 0; i < 30; i++) { |
||||
Visitor visitor = new Visitor("1231", System.currentTimeMillis(), "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); |
||||
visitors.add(visitor); |
||||
} |
||||
VisitorReservationResponse response = new VisitorReservationResponse(); |
||||
response.setSuccess(R.string.load_visitor_my_ok); |
||||
response.setBody(visitors); |
||||
return response; |
||||
} |
||||
} |
@ -1,35 +0,0 @@ |
||||
package com.community.pocket.ui.main.ui.visitor; |
||||
|
||||
import android.os.Bundle; |
||||
import android.view.View; |
||||
import android.widget.Toast; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
|
||||
import com.community.pocket.R; |
||||
|
||||
import org.xutils.view.annotation.ContentView; |
||||
import org.xutils.view.annotation.Event; |
||||
|
||||
/** |
||||
* 我的访客界面 |
||||
*/ |
||||
@ContentView(R.layout.visitor_my_fragment) |
||||
public class VisitorMyFragment extends VisitorMyVisitor { |
||||
|
||||
@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); |
||||
} |
||||
|
||||
/** |
||||
* 查询访客数据 |
||||
*/ |
||||
@Event(R.id.query) |
||||
private void query(View view) { |
||||
Toast.makeText(getContext(), "访客数据查询" + startTime.getText() + "|" + endTime.getText(), Toast.LENGTH_SHORT).show(); |
||||
} |
||||
} |
@ -1,7 +0,0 @@ |
||||
package com.community.pocket.ui.main.ui.visitor; |
||||
|
||||
import androidx.lifecycle.ViewModel; |
||||
|
||||
public class VisitorMyViewModel extends ViewModel { |
||||
// TODO: Implement the ViewModel
|
||||
} |
@ -1,36 +0,0 @@ |
||||
package com.community.pocket.ui.main.ui.visitor; |
||||
|
||||
import android.os.Bundle; |
||||
import android.view.View; |
||||
import android.widget.Toast; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
|
||||
import com.community.pocket.R; |
||||
|
||||
import org.xutils.view.annotation.ContentView; |
||||
import org.xutils.view.annotation.Event; |
||||
|
||||
/** |
||||
* 我的预约界面 |
||||
*/ |
||||
@ContentView(R.layout.visitor_my_fragment) |
||||
public class VisitorReservationFragment extends VisitorMyVisitor { |
||||
|
||||
@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); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 查询预约数据 |
||||
*/ |
||||
@Event(value = R.id.query) |
||||
private void query(View view) { |
||||
Toast.makeText(getContext(), "预约数据查询" + startTime.getText() + "|" + endTime.getText(), Toast.LENGTH_SHORT).show(); |
||||
} |
||||
} |
@ -1,7 +0,0 @@ |
||||
package com.community.pocket.ui.main.ui.visitor; |
||||
|
||||
import androidx.lifecycle.ViewModel; |
||||
|
||||
public class VisitorReservationViewModel extends ViewModel { |
||||
// TODO: Implement the ViewModel
|
||||
} |
@ -1,4 +1,4 @@ |
||||
package com.community.pocket.ui.main.ui.visitor; |
||||
package com.community.pocket.ui.main.ui.visitor.appointment; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.lifecycle.ViewModel; |
@ -1,4 +1,4 @@ |
||||
package com.community.pocket.ui.main.ui.visitor; |
||||
package com.community.pocket.ui.main.ui.visitor.appointment; |
||||
|
||||
import androidx.annotation.Nullable; |
||||
|
@ -1,4 +1,4 @@ |
||||
package com.community.pocket.ui.main.ui.visitor; |
||||
package com.community.pocket.ui.main.ui.visitor.appointment; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
@ -1,4 +1,4 @@ |
||||
package com.community.pocket.ui.main.ui.visitor; |
||||
package com.community.pocket.ui.main.ui.visitor.appointment; |
||||
|
||||
import android.text.Editable; |
||||
|
@ -0,0 +1,60 @@ |
||||
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; |
||||
import androidx.lifecycle.Observer; |
||||
import androidx.lifecycle.ViewModelProvider; |
||||
|
||||
import com.community.pocket.R; |
||||
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 VisitorMyFragment extends VisitorMyVisitor { |
||||
|
||||
@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.loadMy(); |
||||
|
||||
//监听我的访客请求状态
|
||||
viewModel.getVisitorMyResponse().observe(getViewLifecycleOwner(), new Observer<VisitorMyResponse>() { |
||||
@Override |
||||
public void onChanged(VisitorMyResponse visitorMyResponse) { |
||||
if (visitorMyResponse == null) { |
||||
return; |
||||
} |
||||
|
||||
if (visitorMyResponse.getSuccess() != null) { |
||||
loadData(visitorMyResponse.getBody()); |
||||
} |
||||
|
||||
if (visitorMyResponse.getError() != null) { |
||||
Toast.makeText(getContext(), visitorMyResponse.getError(), Toast.LENGTH_SHORT).show(); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 查询访客数据 |
||||
*/ |
||||
@Event(R.id.query) |
||||
private void query(View view) { |
||||
Toast.makeText(getContext(), "访客数据查询" + startTime.getText() + "|" + endTime.getText(), Toast.LENGTH_SHORT).show(); |
||||
} |
||||
} |
@ -0,0 +1,9 @@ |
||||
package com.community.pocket.ui.main.ui.visitor.my; |
||||
|
||||
import com.community.pocket.data.model.Visitor; |
||||
import com.community.pocket.ui.main.ui.share.Response; |
||||
|
||||
import java.util.List; |
||||
|
||||
public class VisitorMyResponse extends Response<List<Visitor>> { |
||||
} |
@ -0,0 +1,32 @@ |
||||
package com.community.pocket.ui.main.ui.visitor.my; |
||||
|
||||
import androidx.lifecycle.MutableLiveData; |
||||
|
||||
import com.community.pocket.data.main.visitor.VisitorMyRequest; |
||||
import com.community.pocket.ui.main.ui.share.BaseViewModel; |
||||
|
||||
/** |
||||
* 我的访客UI数据管理 |
||||
*/ |
||||
public class VisitorMyViewModel extends BaseViewModel<VisitorMyRequest> { |
||||
|
||||
//我的访客数据请求状态
|
||||
private MutableLiveData<VisitorMyResponse> visitorMyResponse = new MutableLiveData<>(); |
||||
|
||||
MutableLiveData<VisitorMyResponse> getVisitorMyResponse() { |
||||
return visitorMyResponse; |
||||
} |
||||
|
||||
/** |
||||
* 加载我的访客 |
||||
*/ |
||||
void loadMy() { |
||||
VisitorMyResponse response = getRequest().loadMy(); |
||||
visitorMyResponse.setValue(response); |
||||
} |
||||
|
||||
@Override |
||||
protected VisitorMyRequest getRequest() { |
||||
return VisitorMyRequest.getInstance(); |
||||
} |
||||
} |
@ -0,0 +1,61 @@ |
||||
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; |
||||
import androidx.lifecycle.Observer; |
||||
import androidx.lifecycle.ViewModelProvider; |
||||
|
||||
import com.community.pocket.R; |
||||
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 { |
||||
|
||||
@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.loadReservation(); |
||||
|
||||
//监听我的预约请求状态
|
||||
viewModel.getVisitorReservationResponse().observe(getViewLifecycleOwner(), new Observer<VisitorReservationResponse>() { |
||||
@Override |
||||
public void onChanged(VisitorReservationResponse visitorReservationResponse) { |
||||
if (visitorReservationResponse == null) { |
||||
return; |
||||
} |
||||
|
||||
if (visitorReservationResponse.getSuccess() != null) { |
||||
loadData(visitorReservationResponse.getBody()); |
||||
} |
||||
|
||||
if (visitorReservationResponse.getError() != null) { |
||||
Toast.makeText(getContext(), visitorReservationResponse.getError(), Toast.LENGTH_SHORT).show(); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 查询预约数据 |
||||
*/ |
||||
@Event(value = R.id.query) |
||||
private void query(View view) { |
||||
Toast.makeText(getContext(), "预约数据查询" + startTime.getText() + "|" + endTime.getText(), Toast.LENGTH_SHORT).show(); |
||||
} |
||||
} |
@ -0,0 +1,9 @@ |
||||
package com.community.pocket.ui.main.ui.visitor.reservation; |
||||
|
||||
import com.community.pocket.data.model.Visitor; |
||||
import com.community.pocket.ui.main.ui.share.Response; |
||||
|
||||
import java.util.List; |
||||
|
||||
public class VisitorReservationResponse extends Response<List<Visitor>> { |
||||
} |
@ -0,0 +1,30 @@ |
||||
package com.community.pocket.ui.main.ui.visitor.reservation; |
||||
|
||||
import androidx.lifecycle.MutableLiveData; |
||||
|
||||
import com.community.pocket.data.main.visitor.VisitorReservationRequest; |
||||
import com.community.pocket.ui.main.ui.share.BaseViewModel; |
||||
|
||||
/** |
||||
* 我的预约UI数据管理 |
||||
*/ |
||||
public class VisitorReservationViewModel extends BaseViewModel<VisitorReservationRequest> { |
||||
|
||||
//我的预约请求状态
|
||||
private MutableLiveData<VisitorReservationResponse> visitorReservationResponse = new MutableLiveData<>(); |
||||
|
||||
MutableLiveData<VisitorReservationResponse> getVisitorReservationResponse() { |
||||
return visitorReservationResponse; |
||||
} |
||||
|
||||
void loadReservation() { |
||||
VisitorReservationResponse response = getRequest().loadReservation(); |
||||
visitorReservationResponse.setValue(response); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected VisitorReservationRequest getRequest() { |
||||
return VisitorReservationRequest.getInstance(); |
||||
} |
||||
} |
Loading…
Reference in new issue