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.
60 lines
1.9 KiB
60 lines
1.9 KiB
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();
|
|
}
|
|
}
|
|
|