|
|
|
@ -12,12 +12,16 @@ import com.qhclh.ytzh.bean.TablePBean; |
|
|
|
import com.qhclh.ytzh.home.RpcUrl; |
|
|
|
import com.qhclh.ytzh.tasks.ViewOnClickTask; |
|
|
|
import com.qhclh.ytzh.utils.DateTimeUtil; |
|
|
|
import com.qhclh.ytzh.work.tablepoultry.ChoseEvent; |
|
|
|
import com.qhclh.ytzh.work.tablepoultry.ReportActivity; |
|
|
|
import com.qhclh.ytzh.work.tablepoultry.XFactryAdapter; |
|
|
|
|
|
|
|
import org.forks.jsonrpc.JsonRpcResult; |
|
|
|
import org.forks.jsonrpc.RpcFacade; |
|
|
|
import org.forks.jsonrpc.RpcObject; |
|
|
|
import org.greenrobot.eventbus.EventBus; |
|
|
|
import org.greenrobot.eventbus.Subscribe; |
|
|
|
import org.greenrobot.eventbus.ThreadMode; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
@ -38,21 +42,17 @@ public class ChangleFragment extends BaseFragment { |
|
|
|
private XFactryAdapter adapter; |
|
|
|
|
|
|
|
private static final String ARG_TIMELINE_TYPE = "ARG_TIMELINE_TYPE"; |
|
|
|
public static ChangleFragment newInstance(long type) { |
|
|
|
public static ChangleFragment newInstance(long type,long choseTime) { |
|
|
|
Bundle args = new Bundle(); |
|
|
|
args.putLong(ARG_TIMELINE_TYPE, type); |
|
|
|
args.putLong("time",choseTime); |
|
|
|
ChangleFragment fragment = new ChangleFragment(); |
|
|
|
fragment.setArguments(args); |
|
|
|
return fragment; |
|
|
|
} |
|
|
|
|
|
|
|
private long mType; |
|
|
|
|
|
|
|
//Fragment的View加载完毕的标记 |
|
|
|
private boolean isViewCreated; |
|
|
|
|
|
|
|
//Fragment对用户可见的标记 |
|
|
|
private boolean isUIVisible; |
|
|
|
private long choseDate; |
|
|
|
|
|
|
|
@Override |
|
|
|
protected int setLayout() { |
|
|
|
@ -61,12 +61,16 @@ public class ChangleFragment extends BaseFragment { |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void initView() { |
|
|
|
isViewCreated = true; |
|
|
|
if (!EventBus.getDefault().isRegistered(this)) { |
|
|
|
EventBus.getDefault().register(this); |
|
|
|
} |
|
|
|
list = new ArrayList<>(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void initData() { |
|
|
|
mType = getArguments().getLong(ARG_TIMELINE_TYPE); |
|
|
|
choseDate = getArguments().getLong("time"); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -79,33 +83,22 @@ public class ChangleFragment extends BaseFragment { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void setUserVisibleHint(boolean isVisibleToUser) { |
|
|
|
super.setUserVisibleHint(isVisibleToUser); |
|
|
|
if (isVisibleToUser) { |
|
|
|
isUIVisible = true; |
|
|
|
lazyLoad(); |
|
|
|
} else { |
|
|
|
isUIVisible = false; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void lazyLoad() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onResume() { |
|
|
|
super.onResume(); |
|
|
|
// BreedFactoryReportListView(choseDate); |
|
|
|
} |
|
|
|
|
|
|
|
private void BreedFactoryReportListView(final long time) { |
|
|
|
ViewOnClickTask listTask = new ViewOnClickTask(getActivity(),"加载中...") { |
|
|
|
List<RpcObject> rpcList; |
|
|
|
@Override |
|
|
|
protected void successUI() { |
|
|
|
list = new ArrayList<>(); |
|
|
|
System.out.println("aaa++++++++"+rpcList); |
|
|
|
list.clear(); |
|
|
|
System.out.println("aaa++++"+rpcList); |
|
|
|
for (int i=0;i<rpcList.size();i++){ |
|
|
|
// list.add(new TablePBean(i,i+1,"aaaa"+i,"22"+i,"333"+i,"5555"+i)); |
|
|
|
list.add(new TablePBean(mType,rpcList.get(i).getLong("ID"),rpcList.get(i).getString("Name"),"22b"+mType,"333c"+mType,"5555d"+mType)); |
|
|
|
} |
|
|
|
|
|
|
|
adapter = new XFactryAdapter(getActivity(),list); |
|
|
|
@ -114,11 +107,26 @@ public class ChangleFragment extends BaseFragment { |
|
|
|
|
|
|
|
@Override |
|
|
|
public Object call() throws Exception { |
|
|
|
JsonRpcResult result = RpcFacade.rpcCall(RpcUrl.BreedFactoryReportListView,mType,new SimpleDateFormat("yyyy-MM-dd").parse(DateTimeUtil.getYMD(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24)))); |
|
|
|
JsonRpcResult result = RpcFacade.rpcCall(RpcUrl.BreedFactoryReportListView,mType,new SimpleDateFormat("yyyy-MM-dd").parse(DateTimeUtil.getYMD(new Date(time)))); |
|
|
|
rpcList = result.getRpcObjectList(RpcUrl.BreedFactoryReportListView_fanhui); |
|
|
|
return null; |
|
|
|
} |
|
|
|
}; |
|
|
|
listTask.execute(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN,sticky = true) |
|
|
|
public void onEvent(ChoseEvent event){ |
|
|
|
System.out.println("aaa++++bus+++"+event.getTime()); |
|
|
|
BreedFactoryReportListView(event.getTime()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onDestroy() { |
|
|
|
super.onDestroy(); |
|
|
|
if (EventBus.getDefault().isRegistered(this)) { |
|
|
|
EventBus.getDefault().unregister(this); |
|
|
|
} |
|
|
|
} |
|
|
|
} |