|
|
@@ -15,6 +15,9 @@ import android.widget.BaseAdapter;
|
|
|
import android.widget.Button;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshGridView;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
|
@@ -26,6 +29,7 @@ import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.net.ViewUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.Constants;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.view.EmptyLayout;
|
|
|
import com.xzjmyk.pm.activity.util.DateFormatUtil;
|
|
|
import com.xzjmyk.pm.activity.util.ToastUtil;
|
|
|
import com.xzjmyk.pm.activity.view.wheel.DatePicker;
|
|
|
@@ -45,8 +49,12 @@ import java.util.Map;
|
|
|
*/
|
|
|
public class SalesRankingActivity extends BaseActivity {
|
|
|
private BussinessDetailAdapter mAdapter;
|
|
|
+ @ViewInject(R.id.tv_date_title)
|
|
|
+ private TextView tv_date_title;
|
|
|
@ViewInject(R.id.list_business)
|
|
|
private PullToRefreshGridView mlist;
|
|
|
+ @ViewInject(R.id.tv_msg)
|
|
|
+ private TextView tv_msg;
|
|
|
private ArrayList<Business> mData = new ArrayList<Business>();
|
|
|
private Context ct;
|
|
|
@Override
|
|
|
@@ -62,7 +70,7 @@ public class SalesRankingActivity extends BaseActivity {
|
|
|
private void initListener() {
|
|
|
mlist.setEnabled(false);
|
|
|
mlist.setMode(PullToRefreshBase.Mode.DISABLED);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void initData() {
|
|
|
@@ -78,13 +86,15 @@ public class SalesRankingActivity extends BaseActivity {
|
|
|
model.setSource("####" + i);
|
|
|
mData.add(model);
|
|
|
}
|
|
|
- mAdapter = new BussinessDetailAdapter(this, mData);
|
|
|
- mlist.setAdapter(mAdapter);
|
|
|
+// mAdapter = new BussinessDetailAdapter(this, mData);
|
|
|
+// mlist.setAdapter(mAdapter);
|
|
|
}
|
|
|
|
|
|
private void initView() {
|
|
|
ct = this;
|
|
|
ViewUtils.inject(this);
|
|
|
+ tv_date_title.setText(DateFormatUtil.getStrDate4Date(new Date(),"yyyy年MM月")+"荣誉墙");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -105,6 +115,7 @@ public class SalesRankingActivity extends BaseActivity {
|
|
|
case R.id.sale_date_select:
|
|
|
DatePicker picker = new DatePicker(this);
|
|
|
picker.setRange(1950, 2030);
|
|
|
+ picker.setAnimationStyle(R.style.Animation_CustomPopup);
|
|
|
picker.setSelectedItem(
|
|
|
calendar.get(Calendar.YEAR),
|
|
|
calendar.get(Calendar.MONTH) + 1,
|
|
|
@@ -113,6 +124,7 @@ public class SalesRankingActivity extends BaseActivity {
|
|
|
@Override
|
|
|
public void onDatePicked(String year, String month, String day) {
|
|
|
sendHttpResquest(Constants.HTTP_SUCCESS_INIT,year+month);
|
|
|
+ tv_date_title.setText(year+"年"+month+"月荣誉墙");
|
|
|
}
|
|
|
});
|
|
|
picker.show();
|
|
|
@@ -126,10 +138,10 @@ public class SalesRankingActivity extends BaseActivity {
|
|
|
|
|
|
private class BussinessDetailAdapter extends BaseAdapter {
|
|
|
private Context ct;
|
|
|
- private ArrayList<Business> mdata = new ArrayList<>();
|
|
|
+ private JSONArray mdata = new JSONArray();
|
|
|
private LayoutInflater inflater;
|
|
|
|
|
|
- public BussinessDetailAdapter(Context ct, ArrayList<Business> data) {
|
|
|
+ public BussinessDetailAdapter(Context ct, JSONArray data) {
|
|
|
this.ct = ct;
|
|
|
this.mdata = data;
|
|
|
this.inflater = LayoutInflater.from(ct);
|
|
|
@@ -137,7 +149,7 @@ public class SalesRankingActivity extends BaseActivity {
|
|
|
|
|
|
@Override
|
|
|
public int getCount() {
|
|
|
- return mdata.size();
|
|
|
+ return mdata==null?0:mdata.size();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -156,25 +168,27 @@ public class SalesRankingActivity extends BaseActivity {
|
|
|
if (convertView == null) {
|
|
|
convertView = inflater.inflate(R.layout.item_sale_ranking, null);
|
|
|
holder = new ViewHolder();
|
|
|
+ holder.tv_money= (TextView) convertView.findViewById(R.id.tv_sale_num);
|
|
|
+ holder.tv_name= (TextView) convertView.findViewById(R.id.tv_sale_name);
|
|
|
+ holder.tv_depart= (TextView) convertView.findViewById(R.id.tv_sale_dep);
|
|
|
+
|
|
|
convertView.setTag(holder);
|
|
|
} else {
|
|
|
holder = (ViewHolder) convertView.getTag();
|
|
|
}
|
|
|
-
|
|
|
+ holder.tv_name.setText(mdata.getJSONObject(position).getString("name"));
|
|
|
+ holder.tv_money.setText(mdata.getJSONObject(position).getString("id"));
|
|
|
+ holder.tv_depart.setText(mdata.getJSONObject(position).getString("position")
|
|
|
+ +"\n"+mdata.getJSONObject(position).getString("depart"));
|
|
|
return convertView;
|
|
|
}
|
|
|
|
|
|
|
|
|
class ViewHolder {
|
|
|
- TextView tv_num;
|
|
|
TextView tv_name;
|
|
|
- TextView tv_leader;
|
|
|
- TextView tv_source;
|
|
|
- TextView tv_phone;
|
|
|
- TextView tv_note;
|
|
|
- TextView tv_datetv;
|
|
|
- TextView tv_date;
|
|
|
- Button bt_event;
|
|
|
+ TextView tv_depart;
|
|
|
+ TextView tv_money;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -187,7 +201,52 @@ public class SalesRankingActivity extends BaseActivity {
|
|
|
case Constants.HTTP_SUCCESS_INIT:
|
|
|
progressDialog.dismiss();
|
|
|
Log.i(TAG, "handleMessage:" + msg.getData().getString("result"));
|
|
|
+ JSONObject ranklist= JSON.parseObject(msg.getData().getString("result")).getJSONObject("ranklist");
|
|
|
+ JSONArray sales =ranklist.getJSONArray("sales");
|
|
|
+ JSONArray profits =ranklist.getJSONArray("profits");
|
|
|
+ if (sales!=null&&profits!=null){
|
|
|
+ JSONArray rootArray=new JSONArray();
|
|
|
+ JSONObject s=new JSONObject();
|
|
|
+ JSONObject p=new JSONObject();
|
|
|
+
|
|
|
+ int s_id=sales.getIntValue(0);
|
|
|
+ String s_name=sales.getString(1);
|
|
|
+ String s_position=sales.getString(2);
|
|
|
+ String s_depart=sales.getString(3);
|
|
|
+ int s_imid=sales.getIntValue(4);
|
|
|
+ s.put("id",s_id);
|
|
|
+ s.put("name",s_name);
|
|
|
+ s.put("position",s_position);
|
|
|
+ s.put("depart",s_depart);
|
|
|
+ s.put("imId",s_imid);
|
|
|
+
|
|
|
+ int p_id=profits.getIntValue(0);
|
|
|
+ String p_name=profits.getString(1);
|
|
|
+ String p_position=profits.getString(2);
|
|
|
+ String p_depart=profits.getString(3);
|
|
|
+ int p_imid=profits.getIntValue(4);
|
|
|
+ p.put("id",p_id);
|
|
|
+ p.put("name",p_name);
|
|
|
+ p.put("position",p_position);
|
|
|
+ p.put("depart",p_depart);
|
|
|
+ p.put("imid", p_imid);
|
|
|
+ rootArray.add(0, s);
|
|
|
+ rootArray.add(1, p);
|
|
|
|
|
|
+ mAdapter = new BussinessDetailAdapter(ct, rootArray);
|
|
|
+ mlist.setAdapter(mAdapter);
|
|
|
+ mlist.setVisibility(View.VISIBLE);
|
|
|
+ tv_msg.setVisibility(View.GONE);
|
|
|
+ }else{
|
|
|
+ //空数据处理
|
|
|
+ JSONArray rootArray=new JSONArray();
|
|
|
+ mAdapter = new BussinessDetailAdapter(ct, rootArray);
|
|
|
+ mlist.setAdapter(mAdapter);
|
|
|
+
|
|
|
+ mlist.setVisibility(View.GONE);
|
|
|
+ tv_msg.setText("暂无数据");
|
|
|
+ tv_msg.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
break;
|
|
|
case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
progressDialog.dismiss();
|