Exemplo n.º 1
0
 public HttpModel getHttpModel() {
   if (finalDb.findAll(TerminalModel.class).size() > 0) {
     mobileConfigModel = finalDb.findAll(TerminalModel.class).get(0);
     mIp = mobileConfigModel.getTerminalIP();
     mPort = mobileConfigModel.getTerminalCount();
   }
   mSessionId = VikiccUtils.ReadString(this, VikiccUtils.KEY_SESSIONID);
   mUserId = "Admin";
   try {
     mPassword = Utils.hashPassword("1");
   } catch (UnsupportedEncodingException e) {
     e.printStackTrace();
   } catch (NoSuchAlgorithmException e) {
     e.printStackTrace();
   }
   // mIp = VikiccUtils.ReadString(this, KeyModel.KEY_IP);
   // mPort = VikiccUtils.ReadString(this, KeyModel.KEY_PORT);
   if (!VikiccUtils.isEmptyString(mSessionId)) {
     httpModel.setSessionId(mSessionId);
   }
   if (!VikiccUtils.isEmptyString(mUserId)) {
     httpModel.setUserId(mUserId);
   }
   if (!VikiccUtils.isEmptyString(mPassword)) {
     httpModel.setPassword(mPassword);
   }
   if (!VikiccUtils.isEmptyString(mIp)) {
     if (!VikiccUtils.isEmptyString(mPort)) {
       httpModel.setURL("http://" + mIp + ":" + mPort + "/Service/Index.aspx");
     } else {
       httpModel.setURL(mIp);
     }
   }
   return httpModel;
 }
Exemplo n.º 2
0
 private void saveNote() {
   view.hideKeyBoard();
   if (TextUtils.isEmpty(view.getLabelText())) {
     note.setLabel(mContext.getString(R.string.default_label));
   } else {
     note.setLabel(view.getLabelText());
   }
   note.setContent(view.getContentText());
   note.setLastOprTime(TimeUtils.getCurrentTimeInLong());
   note.setStatus(SNote.Status.NEED_PUSH.getValue());
   event = new MainPresenter.NotifyEvent<>();
   switch (operateMode) {
     case CREATE_NOTE_MODE:
       note.setCreateTime(TimeUtils.getCurrentTimeInLong());
       event.setType(MainPresenter.NotifyEvent.CREATE_NOTE);
       mFinalDb.saveBindId(note);
       break;
     default:
       event.setType(MainPresenter.NotifyEvent.UPDATE_NOTE);
       mFinalDb.update(note);
       break;
   }
   event.setData(note);
   view.finishView();
 }
Exemplo n.º 3
0
  private void addCar(FBProduct p, TextView tv) {
    String mPid = p.getFb_product_id();

    int count = 1;
    FinalDb db = AppContext.mDb;
    // 先判断数据库是否有数据
    List<Car> c = db.findAllByWhere(Car.class, "productId=" + "'" + mPid + "'");
    if (c != null) {
      // 如果存在数据
      if (c.size() > 0) {
        // 将已经存在的数据叠加
        count = count + c.get(0).getNum();
        // 删除已经存在的数据
        db.deleteByWhere(Car.class, "productId=" + "'" + mPid + "'");
      }
    }
    Car car = new Car();
    car.setProductId(mPid);
    car.setPrice(p.getPrice() + "");
    car.setNum(count);
    car.setIs_norm(Constants.PRODUCT_TYPE2);
    tv.setVisibility(View.VISIBLE);
    tv.setText(count + "");
    // 保存数据
    AppContext.mDb.save(car);

    MainActivity a = (MainActivity) mContext;
    a.onShopping();
  }
Exemplo n.º 4
0
  /**
   * 保存好友列表. 请在后台操作。
   *
   * @param customerVos
   * @return 作者:fighter <br>
   *     创建时间:2013-5-31<br>
   *     修改时间:<br>
   */
  public boolean saveFriendList(List<CustomerVo> customerVos) {
    Log.d(TAG, "saveFriendList()");
    try {
      friendListVo = new FriendListVo();
      friendListVo.setUid(userInfoVo.getUid());
      friendListVo.setUpdateTime(System.currentTimeMillis() + "");

      StringBuffer buffer = new StringBuffer();
      int index = customerVos.size();
      for (int i = 0; i < index; i++) {
        CustomerVo customerVo = customerVos.get(i);
        customerVo.setFriend("1");
        buffer.append("'").append(customerVo.getUid()).append("'");
        if (i == (index - 1)) {
          continue;
        }
        buffer.append(",");
      }
      String friends = buffer.toString();

      friendListVo.setFriends(friends);
      finalDb.delete(friendListVo);
      finalDb.save(friendListVo);
      finalDb.deleteByWhere(CustomerVo.class, "uid in (" + friends + ")");
      finalDb.saveList(customerVos);
      return true;
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
  }
Exemplo n.º 5
0
 /**
  * 失败返回-1
  *
  * @param context Context
  * @param entity ErrorHelpLog
  * @return int
  */
 public static int Insert(Context context, ErrorHelpLog entity) {
   FinalDb db = FinalDb.create(context, ApplicationConfig.DATABASE_NAME, DEBUG);
   if (db.saveBindId(entity)) {
     return entity.getId();
   }
   return -1;
 }
Exemplo n.º 6
0
 public static List<ErrorHelpLog> findAll(Context context) {
   FinalDb db = FinalDb.create(context, ApplicationConfig.DATABASE_NAME, DEBUG);
   List<ErrorHelpLog> result = db.findAll(ErrorHelpLog.class);
   if (result != null) {
     for (ErrorHelpLog lg : result) {
       lg.setCtx(context);
     }
   }
   return result;
 }
Exemplo n.º 7
0
  /**
   * 更新好友列表.
   *
   * @param customerVos
   * @return 作者:fighter <br>
   *     创建时间:2013-5-31<br>
   *     修改时间:<br>
   */
  public boolean updateFriendList(List<CustomerVo> customerVos) {
    Log.d(TAG, "updateFriendList()");
    String friends = JSON.toJSONString(customerVos);
    try {
      finalDb.deleteByWhere(CustomerVo.class, "uid != '" + userInfoVo.getUid() + "'");
      finalDb.saveList(customerVos);
    } catch (Exception e) {
      return false;
    }

    return saveFriendListDb(friends);
  }
Exemplo n.º 8
0
 @Override
 public void init() {
   db = FinalDb.create(ctx);
   initHelper();
   initView();
   initData();
 }
Exemplo n.º 9
0
  public List<?> FindAllModel(Object model) {

    return db.findAll(model.getClass());
    //        db.deleteAll(model.getClass());
    //        db.dropTable(model.getClass());
    //        db.update(model.getClass());
  }
Exemplo n.º 10
0
        @Override
        public void run() {
          Looper.prepare();
          while (bool_thread) {
            try {
              Log.i("check_time", check_time);
              Thread.sleep(Integer.parseInt(check_time) * 60000);
              if (Utils.isNetworkAvailable(BaseActivity.this)) {
                List<ExpressModel> list =
                    finalDb.findAllByWhere(ExpressModel.class, "IsDownLoad=0");
                list.size();
                for (ExpressModel e : list) {
                  ImageObject[] imgs = new ImageObject[3];

                  ImageObject imageObject1 = new ImageObject();
                  imageObject1.setImageId("ConsignIdentityImageId");
                  if (!VikiccUtils.isEmptyString(e.getConsignIdentityImageId())) {
                    imageObject1.setImageData(
                        Utils.getBitmapFromByte(
                            Base64.decode(e.getConsignIdentityImageId(), Base64.DEFAULT)));
                  }
                  ImageObject imageObject2 = new ImageObject();
                  imageObject2.setImageId("GoodsImageId");
                  imageObject2.setImageData(
                      Utils.getBitmapFromByte(Base64.decode(e.getGoodsImageId(), Base64.DEFAULT)));
                  ImageObject imageObject3 = new ImageObject();
                  imageObject3.setImageId("OrderImageId");
                  imageObject3.setImageData(
                      Utils.getBitmapFromByte(Base64.decode(e.getOrderImageId(), Base64.DEFAULT)));
                  //                            if
                  // (!VikiccUtils.isEmptyString(e.getConsignIdentityImageId())) {
                  //
                  // imageObject1.setImageData(Utils.getBitmapFromByte(e.getConsignIdentityImageId().getBytes()));
                  //                            }
                  //
                  // imageObject2.setImageData(Utils.getBitmapFromByte(e.getGoodsImageId().getBytes()));
                  //
                  // imageObject3.setImageData(Utils.getBitmapFromByte(e.getOrderImageId().getBytes()));
                  imgs[0] = imageObject1;
                  imgs[1] = imageObject2;
                  imgs[2] = imageObject3;
                  e.setImages(imgs);
                  AddExpress(e);
                }
              }
              Message message = new Message();
              message.what = 1;
              handler.sendMessage(message); // 发送消息
            } catch (InterruptedException e) {
              e.printStackTrace();
            }
          }
          Looper.loop();
        }
Exemplo n.º 11
0
  @Override
  public View initView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
      convertView = mInflater.inflate(R.layout.item_product, null);
    }
    TextView name = (TextView) ViewHolder.get(convertView, R.id.name);
    final TextView num = (TextView) ViewHolder.get(convertView, R.id.n);
    TextView price = (TextView) ViewHolder.get(convertView, R.id.price);
    ImageView img = (ImageView) ViewHolder.get(convertView, R.id.img);
    final TextView ePay = (TextView) ViewHolder.get(convertView, R.id.e);
    final LinearLayout mView = (LinearLayout) ViewHolder.get(convertView, R.id.view_e);
    final ImageView imgCar = (ImageView) ViewHolder.get(convertView, R.id.img_car);

    final FBProduct g = mList.get(position);

    int eCash = g.getCash_pay();
    if (eCash == 0) {
      mView.setBackgroundResource(R.color.cash_0);
    } else {
      mView.setBackgroundResource(R.color.red);
    }
    ePay.setText(PriceUtil.floatToString(eCash));

    g.getTitle();
    name.setText(g.getName());
    price.setText("¥" + PriceUtil.floatToString(g.getPrice()));
    AppContext.displayImage(img, g.getCover_img());
    String mPid = g.getFb_product_id();

    // 先判断数据库是否有数据
    List<Car> c = db.findAllByWhere(Car.class, "productId=" + "'" + mPid + "'");

    if (c != null) {
      // 如果存在数据
      if (c.size() > 0) {
        // 将已经存在的数据叠加
        num.setVisibility(View.VISIBLE);
        num.setText(c.get(0).getNum() + "");
      }
    }

    imgCar.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            //				AnimationUtil.translateAnim(imgCar);
            addCar(g, num);
          }
        });

    return convertView;
  }
Exemplo n.º 12
0
  private boolean saveFriendListDb(String cvos) {
    Log.d(TAG, "saveFriendListDb()");
    try {
      friendListVo = new FriendListVo();
      friendListVo.setUid(userInfoVo.getUid());
      friendListVo.setUpdateTime(System.currentTimeMillis() + "");

      friendListVo.setFriends(cvos);
      finalDb.update(friendListVo);
      return true;
    } catch (Exception e) {
      return false;
    }
  }
Exemplo n.º 13
0
  /**
   * 判断本地是否有好友列表信息
   *
   * @return true 有, false 没有 作者:fighter <br>
   *     创建时间:2013-5-31<br>
   *     修改时间:<br>
   */
  public synchronized boolean isLocalFriendInfo() {
    Log.d(TAG, "isLocalFriendInfo()");
    if (localState) {
      return true;
    }
    friendListVo = finalDb.findById(userInfoVo.getUid(), FriendListVo.class);
    if (friendListVo == null) {
      localState = false;
    } else {
      localState = true;
    }

    return localState;
  }
Exemplo n.º 14
0
  /**
   * 获取没有缩略图的地址
   *
   * @param sourcePath
   * @return
   */
  private String getCurrentThumPath(String sourcePath) {
    String thumbnailPath = null;
    MyAlbumThumBean bean = db.findById(sourcePath, MyAlbumThumBean.class);
    if (bean != null) {
      // 已经在数据库中有的 就读取
      // System.out.println("-- 读取 -- ");
      thumbnailPath = bean.getThumPath() + "/" + bean.getPhotoName() + ".png";
    } else {
      // 新建 存数据库
      // System.out.println("-- 新建 -- ");
      thumbnailPath = createImgBitmapThum(sourcePath);
    }

    return thumbnailPath;
  }
Exemplo n.º 15
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initTitleBar();
    setAbContentView(R.layout.activity_fanslist);
    FinalActivity.initInjectedView(this);

    page = getIntent().getIntExtra("page", 0);
    fromUid = getIntent().getStringExtra("uid");

    db = FinalDb.create(this);
    gson = new Gson();

    initView();
  }
Exemplo n.º 16
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i("----------------", "onCreate");
    finalDb = FinalDb.create(BaseActivity.this);
    vUtils = new VikiccUtils();
    httpUtil = new HttpUtil();
    httpModel = new HttpModel();

    cvrManager = new CvrManager();
    check_time = VikiccUtils.ReadString(getBaseContext(), VikiccUtils.CHECK_UPLOAD_TIME);
    if (check_time == "") {
      check_time = "5";
    } else {
      check_time = check_time.replaceAll("分", "");
    }
    initViews();
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
    initEvents();
  }
Exemplo n.º 17
0
  private void initView() {
    // TODO Auto-generated method stub
    if (page == 0) {
      mTitleBar.setTitleText(R.string.title_fans);
    } else {
      mTitleBar.setTitleText(R.string.title_attention);
    }
    mTitleBar.setLogo(R.drawable.selector_back_btn);

    adapter = new ListAdapter();
    listview.setAdapter(adapter);
    listview.setOnRefreshListener(
        new OnRefreshListener() {

          @Override
          public void onRefresh() {
            // TODO Auto-generated method stub
            isRefresh = true;
            requestGetContact();
          }
        });

    if (StringUtils.isEmpty(fromUid)) {
      List<FansDao> list = db.findAllByWhere(FansDao.class, "type=" + page + " and uid =" + uid);
      if (list != null && list.size() > 0) {
        for (FansDao item : list) {
          FansData data = gson.fromJson(item.getJson(), FansData.class);
          adapter.add(data);
        }
        if (list.size() < 10) {
          listview.setIsLoadFull(true);
        } else {
          listview.setIsLoadFull(false);
        }
        adapter.notifyDataSetChanged();
      }
    }
    listview.refresh();
  }
Exemplo n.º 18
0
 /**
  * 获取好友列表信息
  *
  * @return 作者:fighter <br>
  *     创建时间:2013-5-31<br>
  *     修改时间:<br>
  */
 public synchronized List<CustomerVo> getFriendList() {
   Log.d(TAG, "getFriendList()");
   if (customerVos != null) {
     return customerVos;
   }
   if (friendListVo != null) {
     try {
       List<CustomerVo> cVos =
           finalDb.findAllByWhere(CustomerVo.class, "uid in(" + friendListVo.getFriends() + ")");
       if (cVos != null) {
         Collections.sort(cVos, pinyinComparator);
       } else {
         cVos = new ArrayList<CustomerVo>();
       }
       checkFriendListIsUpdate();
       this.customerVos = cVos;
       return this.customerVos;
     } catch (Exception e) {
       return null;
     }
   } else {
     return null;
   }
 }
Exemplo n.º 19
0
  /**
   * 新建图片的缩略图 并存数据库
   *
   * @param sourcePath
   * @return
   */
  private String createImgBitmapThum(String sourcePath) {
    if (!isFileExist(sourcePath)) {
      System.out.println(sourcePath + "-----------not exsit");
      return null;
    }
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    Bitmap bitmap = BitmapFactory.decodeFile(sourcePath, options); //
    System.out.println("bitmap -- " + bitmap);
    options.inJustDecodeBounds = false;
    int be = (int) (options.outHeight / (float) 200); // 原图 压缩成 128*128的缩略图
    if (be <= 0) {
      be = 1;
    }
    options.inSampleSize = be;

    bitmap = BitmapFactory.decodeFile(sourcePath, options);
    // int w = bitmap.getWidth();
    // int h = bitmap.getHeight();
    // System.out.println(w + " " + h);
    String path = getSDPath();
    System.out.println("path --------- " + path);
    if (path == null) {
      app().showMsg("没有找到sd卡");
      return null;
    }
    String photoName = System.currentTimeMillis() + "";
    ImageTools.savePhotoToSDCard(bitmap, path, photoName);
    MyAlbumThumBean bean = new MyAlbumThumBean();
    bean.setSourthPath(sourcePath);
    bean.setPhotoName(photoName);
    bean.setThumPath(path);
    db.save(bean);

    return path + "/" + photoName + ".png";
  }
Exemplo n.º 20
0
  private void initView() {

    db = FinalDb.create(act);
    gson = new Gson();

    page = getArguments().getInt("page");

    listview.setOnRefreshListener(
        new OnRefreshListener() {

          @Override
          public void onRefresh() {
            // TODO Auto-generated method stub
            getData(true);
          }
        });
    listview.setOnLoadMoreListener(
        new OnLoadMoreListener() {

          @Override
          public void onLoadMore() {
            // TODO Auto-generated method stub
            getData(false);
          }
        });

    adapter = new WeiboListAdapter(0);
    adapter.setmFragment(this);
    adapter.setOnPictureClickListener(new OnPictureClickListener());
    adapter.setOnMultiPictureClickListener(new OnMultiPictureClickListener());

    adapter.setOnAvatarClickListener(
        new OnAvatarClickListener() {

          @Override
          public void onAvatarClick(int position) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(act, FriendInfoActivity.class);
            intent.putExtra("uid", adapter.getItem(position).uid);
            startActivity(intent);
          }
        });
    adapter.setOnZanClickListener(
        new OnZanClickListener() {

          @Override
          public void OnZanClick(int position) {
            // TODO Auto-generated method stub
            if ("1".equals(adapter.getItem(position).is_digg)) {
              delDigg(position);
            } else {
              addDigg(position);
            }
          }
        });
    adapter.setOnShoucangClickListener(
        new OnShoucangClickListener() {

          @Override
          public void OnShoucangClick(int position) {
            // TODO Auto-generated method stub
            if ("1".equals(adapter.getItem(position).iscoll.colled)) {
              doUnFavorite(position);
            } else {
              doFavorite(position);
            }
          }
        });
    adapter.setOnPinglunClickListener(
        new OnPinglunClickListener() {

          @Override
          public void OnPinglunClick(int position) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(act, WriteCommentActivity.class);
            intent.putExtra("weiboListItem", adapter.getItem(position));
            startActivity(intent);
          }
        });
    adapter.setOnZhuanfaClickListener(
        new OnZhuanfaClickListener() {

          @Override
          public void OnZhuanfaClick(int position) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(act, WriteCommentActivity.class);
            intent.putExtra("weiboListItem", adapter.getItem(position));
            intent.putExtra("isZhuanfa", true);
            startActivity(intent);
          }
        });
    listview.setAdapter(adapter);
    listview.setOnScrollListener(new OnListScrollListener());
    listview.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(act, WeiboDetailActivity.class);
            intent.putExtra("weiboListItem", adapter.getItem(arg2 - 1));
            startActivity(intent);
          }
        });

    if (StringUtils.isEmpty(fromUid)) {
      List<WeiboDao> list = db.findAllByWhere(WeiboDao.class, "type=" + page + " and uid=" + uid);
      if (list != null && list.size() > 0) {
        for (WeiboDao item : list) {
          WeiboListItem data = gson.fromJson(item.getJson(), WeiboListItem.class);
          adapter.add(data);
        }
        if (list.size() < 10) {
          listview.setIsLoadFull(true);
        } else {
          listview.setIsLoadFull(false);
        }
        adapter.notifyDataSetChanged();
      }
    }
    listview.refresh();
  }
Exemplo n.º 21
0
 public AfinalDataHelper(Context context) {
   mContext = context;
   db = FinalDb.create(mContext, "mytest.db", false);
 }
Exemplo n.º 22
0
 /**
  * 保存数据
  *
  * @param model
  */
 public void SaveModel(Object model) {
   db.save(model);
 }
Exemplo n.º 23
0
 public void UpateModel(Object model) {
   db.update(model);
 }
Exemplo n.º 24
0
 public void dropTable(Object model) {
   db.dropTable(model.getClass());
 }
Exemplo n.º 25
0
 public static FinalDb createFinalDb(Context context, UserInfoVo info) {
   return FinalDb.create(context, info.getPhone(), false);
 }
Exemplo n.º 26
0
 public static ErrorHelp findErrorHelp(Context context, int id) {
   FinalDb db = FinalDb.create(context, ApplicationConfig.DATABASE_NAME, DEBUG);
   return db.findById(id, ErrorHelp.class);
 }