@Override public void handleMessage(Message msg) { if (msg.what == 2) { // 已达最低层 adapter = new ReadReportAdapter(ReadReportFL.this, findData, flList); flList.setAdapter(adapter); if (findData.size() < 20) moreText.setVisibility(View.GONE); } else if (msg.what == 404) { // Toast.makeText(ReadReportFL.this, "分类下没有数据!", 2).show(); MyTools.exitShow( ReadReportFL.this, ReadReportFL.this.getWindow().getDecorView(), "分类下没有数据!"); } else if (msg.what == 3) { if (msg.arg1 < 20) { moreText.setVisibility(View.GONE); } if (adapter != null) adapter.notifyDataSetChanged(); } else { click(rootElement, 1); if (firstData.size() > 0) { click(firstData.get(0), 2); if (secondData.size() > 0) { // 加载默认数据 nowId = secondData.get(0).getId(); if (((CeiApplication) getApplication()).isNet()) { String reportData = Service.queryAllClassTypeReport(nowId, pageindex + ""); try { findData = XmlUtil.parseReport(reportData); // 保存数据库 for (Report report : findData) { report.setPartitiontID(nowId); dataHelper.saveAllReport(report); } findHandler.sendEmptyMessage(2); } catch (Exception e) { MyTools.showPushXml(getApplicationContext()); e.printStackTrace(); } } } else if (!firstData.get(0).isMhasChild()) { nowId = firstData.get(0).getId(); if (((CeiApplication) getApplication()).isNet()) { String reportData = Service.queryAllClassTypeReport(nowId, pageindex + ""); try { findData = XmlUtil.parseReport(reportData); // 保存数据库 for (Report report : findData) { report.setPartitiontID(nowId); dataHelper.saveAllReport(report); } findHandler.sendEmptyMessage(2); } catch (Exception e) { MyTools.showPushXml(getApplicationContext()); e.printStackTrace(); } } } } FlTableAdapter adapter = new FlTableAdapter(ReadReportFL.this, firstData, 0); FlTableAdapter adapter1 = new FlTableAdapter(ReadReportFL.this, secondData, 0); flGridView1.setAdapter(adapter); flGridView2.setAdapter(adapter1); flGridView1.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // findData.clear(); // 换点击item背景 for (int i = 0; i < arg0.getChildCount(); i++) { RelativeLayout rl = (RelativeLayout) arg0.getChildAt(i); if (i == arg2) { ((ImageView) (rl.getChildAt(0))) .setImageResource(R.drawable.phone_study_menu_select); ((TextView) rl.getChildAt(1)).setTextColor(Color.WHITE); } else { ((ImageView) (rl.getChildAt(0))).setImageResource(R.drawable.menu_transbg); ((TextView) rl.getChildAt(1)).setTextColor(Color.BLUE); } } // 第二层的数据集合 ReportpaitElement element = (ReportpaitElement) arg0.getAdapter().getItem(arg2); click(element, 2); if (secondData != null) { // // 加载下一层数据 /* * findViewById(R.id.read_report_fltable1).setVisibility * (View.VISIBLE); * flGridView2.setVisibility(View.VISIBLE); */ FlTableAdapter adapter = new FlTableAdapter(ReadReportFL.this, secondData, -1); flGridView2.setAdapter(adapter); } } }); flGridView2.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { findData.clear(); // 换点击item背景 for (int i = 0; i < arg0.getChildCount(); i++) { RelativeLayout rl = (RelativeLayout) arg0.getChildAt(i); if (i == arg2) { ((ImageView) (rl.getChildAt(0))) .setImageResource(R.drawable.phone_study_menu_select); ((TextView) rl.getChildAt(1)).setTextColor(Color.WHITE); } else { ((ImageView) (rl.getChildAt(0))).setImageResource(R.drawable.menu_transbg); ((TextView) rl.getChildAt(1)).setTextColor(Color.BLUE); } } ReportpaitElement element = (ReportpaitElement) arg0.getAdapter().getItem(arg2); click(element, 3); } }); } }
@Override protected void onResume() { if (adapter != null) adapter.notifyDataSetChanged(); super.onResume(); }