Example #1
0
 /**
  * @author yk
  * @date 2015年9月23日 下午5:58:59 @Title: dateSave @Description: 数据写入,更新progressbar
  * @param ls_o
  * @param t 设定文件
  * @return void 返回类型
  * @throws
  */
 private <T> void dateSave(List<Object> ls_o, T t) {
   if (ls_o != null) {
     SqlOperate<T> opetaterSim = new SqlOperate<T>(mContext, t.getClass());
     for (int i = 0; i < ls_o.size(); i++) {
       opetaterSim.saveContent((T) ls_o.get(i));
       cusdialogt.setProgress((int) Math.rint(minp * (i + basecount + 1)));
     }
     opetaterSim.close();
     basecount = basecount + ls_o.size();
   }
 }
Example #2
0
  public <T> void saveData(String jsonstr, Class<?> cla) {
    Field[] field = cla.getDeclaredFields();
    for (Field f : field) {
      f.setAccessible(true);
    }
    try {
      JSONObject jsonobject = new JSONObject(jsonstr);
      JSONArray jsonarray = jsonobject.getJSONArray("data");
      T T_stance = (T) cla.newInstance();
      for (int i = 0; i < jsonarray.length(); i++) {
        jsonobject = jsonarray.getJSONObject(i);
        for (Field f : field) {
          try {

            if (f.getGenericType().toString().equals("class java.lang.Integer")
                || f.getGenericType().toString().equals("int")) {
              f.set(T_stance, Integer.valueOf(jsonobject.get(f.getName()).toString()));
            } else {
              f.set(T_stance, jsonobject.get(f.getName()).toString());
            }
          } catch (Exception e) {
            f.set(T_stance, "");
          }
        }
        SqlOperate<T> opetaterSim = new SqlOperate<T>(mContext, cla);
        opetaterSim.saveContent(T_stance);
        cusdialogt.setProgress((int) Math.rint(minp * (i + basecount + 1)));
        opetaterSim.close();
      }
      basecount = basecount + jsonarray.length();
    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (InstantiationException e) {
      e.printStackTrace();
    } catch (IllegalAccessException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
  }
  private void initData() {
    SqlOperate<InformationRemind> opetaterDailyCheck =
        new SqlOperate<InformationRemind>(InformationRemindActivity.this, InformationRemind.class);
    mDatas = opetaterDailyCheck.SelectOffsetEntitysBySqlCondition(sqlStr, pangSize, pageCount);
    pageCount++;
    opetaterDailyCheck.close();
    mAdapter =
        new InformationRemindAdapter(
            InformationRemindActivity.this,
            mDatas,
            R.layout.list_item,
            mlistview.getRightViewWidth());

    if (mDatas.size() < pangSize) {
      mlistview.hindLoadView(false);
    }
    mlistview.setAdapter(mAdapter);

    // TODO Auto-generated method stub
    mlistview.setIClickLoadListListener(
        new IClickLoadListListener() {

          @Override
          public void onLoad(Handler handler) {
            // TODO Auto-generated method stub
            SqlOperate<InformationRemind> opetaterDailyCheck =
                new SqlOperate<InformationRemind>(
                    InformationRemindActivity.this, InformationRemind.class);
            final List<InformationRemind> data =
                opetaterDailyCheck.SelectOffsetEntitysBySqlCondition(sqlStr, pangSize, pageCount);
            pageCount++;
            opetaterDailyCheck.close();

            if (data != null && data.size() > 0) {
              handler.post(
                  new Runnable() {
                    public void run() {
                      mDatas.addAll(data);
                      mAdapter.notifyDataSetChanged();
                      if (data.size() < pangSize) {
                        mlistview.hindLoadView(true);
                      }
                    }
                  });
            } else {
              mlistview.hindLoadView(true);
            }
          }
        });

    mlistview.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, final int arg2, long arg3) {

            InformationRemind informationRemind = mDatas.get(arg2);
            if (informationRemind != null && informationRemind.getI_HaveLook().equals("0")) {
              informationRemind.setI_HaveLook("1");
              SqlOperate<InformationRemind> opetaterInformationRemind =
                  new SqlOperate<InformationRemind>(
                      InformationRemindActivity.this, InformationRemind.class);
              opetaterInformationRemind.upContent(informationRemind);
              opetaterInformationRemind.close();
              mAdapter.notifyDataSetChanged();
            }

            Intent intent;
            switch (mDatas.get(arg2).getI_Title()) {
              case "移动安监数据上传提醒":
                startActivity(
                    new Intent(InformationRemindActivity.this, SynchronousActivity.class));
                break;
              case "日常检查超期提醒":
                intent = new Intent(InformationRemindActivity.this, DailyReviewListActivity.class);
                intent.putExtra("remind", "remind");
                intent.putExtra("sql", DateChangeReceiver.mDailyExtendedStr);
                startActivity(intent);
                break;
              case "专项检查超期提醒":
                intent =
                    new Intent(InformationRemindActivity.this, SpecialReviewListActivity.class);
                intent.putExtra("remind", "remind");
                intent.putExtra("sql", DateChangeReceiver.mSpecialExtendedStr);
                startActivity(intent);
                break;
              case "对照标准检查超期提醒":
                intent =
                    new Intent(InformationRemindActivity.this, HiddenStandCheckListActivity.class);
                intent.putExtra("remind", "remind");
                intent.putExtra("sql", DateChangeReceiver.mStandExtendedStr);
                startActivity(intent);
                break;
              case "企业自查超期提醒":
                String mRectificationStr =
                    "select e_Id,e_companyName from SimpleEnterprise "
                        + " where e_Id in "
                        + "(select sc_companyId from SelfCheck"
                        + " where sc_deadline<date('now') and sc_state='ING' UNION "
                        + " select sc_companyId from SelfStandCheck "
                        + "where sc_deadline<date('now') and (sc_state='ing' or sc_state='noyet' ))";
                intent =
                    new Intent(InformationRemindActivity.this, HiddenTabSortDatilActivity.class);
                intent.putExtra("sql", mRectificationStr);
                intent.putExtra("remind", "remind");
                startActivity(intent);
                break;

              default:
                break;
            }
          }
        });

    mAdapter.setOnRightItemClickListener(
        new onRightItemClickListener() {

          @Override
          public void onRightItemClick(View v, final InformationRemind t) {
            AlertDialog.Builder builder =
                new AlertDialog.Builder(InformationRemindActivity.this); // 先得到构造器
            builder.setTitle("提示"); // 设置标题
            builder.setMessage("是否确认删除当前记录?"); // 设置内容
            builder.setPositiveButton(
                "确定",
                new DialogInterface.OnClickListener() { // 设置确定按钮
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    SqlOperate<InformationRemind> opetaterInformationRemind =
                        new SqlOperate<InformationRemind>(
                            InformationRemindActivity.this, InformationRemind.class);
                    opetaterInformationRemind.DeleteContent(t.getI_ID());
                    opetaterInformationRemind.close();

                    mDatas.remove(t);
                    mAdapter.notifyDataSetChanged();
                    dialog.dismiss(); // 关闭dialog
                  }
                });
            builder.setNegativeButton(
                "取消",
                new DialogInterface.OnClickListener() { // 设置取消按钮
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                  }
                });
            // 参数都设置完成了,创建并显示出来
            builder.create().show();
          }
        });
  }
Example #4
0
 /**
  * @author yk
  * @date 2015年9月23日 下午5:59:26 @Title: deleteTable @Description: 本地数据删除
  * @param t 设定文件
  * @return void 返回类型
  * @throws
  */
 private <T> void deleteTable(T t) {
   SqlOperate<T> opetater = new SqlOperate<T>(mContext, t.getClass());
   opetater.DeleteAllContent();
   opetater.close();
 }