コード例 #1
0
  private void isAuthen() {
    User user = User.getInstance();
    if (user.isLogin()) {
      DhNet mDhNet =
          new DhNet(API.availableSeat + user.getUserId() + "/seats?token=" + user.getToken());
      mDhNet.doGet(
          new NetTask(self) {

            @Override
            public void doInUI(Response response, Integer transfer) {
              // TODO Auto-generated method stub
              if (response.isSuccess()) {
                JSONObject json = response.jSONFrom("data");
                try {
                  User user = User.getInstance();
                  user.setIsAuthenticated(json.getInt("isAuthenticated"));
                  // 认证车主
                } catch (JSONException e) {
                  e.printStackTrace();
                }
              }
            }
          });
    }
  }
コード例 #2
0
  private void deleteMessage() {
    List<String> delList = mJsonAdapter.getCheckMessage();
    if (delList.size() == 0) {
      showToast("请选择需要删除的消息!");
      return;
    }
    JSONArray jsa = new JSONArray(delList);
    User user = User.getInstance();
    DhNet net =
        new DhNet(
            API.CWBaseurl
                + "/message/remove?userId="
                + user.getUserId()
                + "&token="
                + user.getToken());
    net.addParam("messages", jsa);
    net.doPostInDialog(
        "删除中...",
        new NetTask(self) {

          @Override
          public void doInUI(Response response, Integer transfer) {
            if (response.isSuccess()) {
              showToast("删除成功!");
              leftTitleT.setVisibility(View.GONE);
              leftTitleT.setText("全选");
              backI.setVisibility(View.VISIBLE);
              delB.setVisibility(View.GONE);
              mJsonAdapter.showCheck(false);
              rightTitleT.setVisibility(View.GONE);
              mJsonAdapter.refresh();
            }
          }
        });
  }
コード例 #3
0
  private void uploadPic(String path) {
    Bitmap bmp = PhotoUtil.getLocalImage(new File(path));
    picI.setImageBitmap(bmp);
    DhNet net =
        new DhNet(
            API.CWBaseurl
                + "/user/"
                + user.getUserId()
                + "/license/upload?token="
                + user.getToken());
    net.upload(
        new FileInfo("attach", new File(path)),
        new NetTask(self) {

          @Override
          public void doInUI(Response response, Integer transfer) {
            hidenProgressDialog();
            if (response.isSuccess()) {
              JSONObject jo = response.jSONFromData();
              picUid = JSONUtil.getString(jo, "photoId");
            } else {
              showToast("上传失败,请重新上传");
              picUid = "";
            }
          }
        });
  }
コード例 #4
0
  private void authtion() {
    if (TextUtils.isEmpty(picUid)) {
      showToast("请上传驾驶证!");
      return;
    }

    if (TextUtils.isEmpty(drivingExperienceE.getText().toString())) {
      showToast("请输入驾龄!");
      return;
    }

    if (Integer.parseInt(drivingExperienceE.getText().toString()) > 20
        || Integer.parseInt(drivingExperienceE.getText().toString()) <= 0) {
      showToast("驾龄为1~20数字");
      return;
    }

    if (TextUtils.isEmpty(brandName)) {
      showToast("请选择车型品牌!");
      return;
    }

    DhNet net =
        new DhNet(
            API.CWBaseurl
                + "/user/"
                + user.getUserId()
                + "/authentication?token="
                + user.getToken());
    net.addParam("drivingExperience", drivingExperienceE.getText().toString());
    net.addParam("carBrand", brandName);
    net.addParam("carBrandLogo", brandLogo);
    net.addParam("carModel", modelName);
    net.addParam("slug", modelSlug);
    net.doPostInDialog(
        new NetTask(self) {

          @Override
          public void doInUI(Response response, Integer transfer) {
            if (response.isSuccess()) {
              showToast("认证车主申请成功,请等待审核!");
              Intent it = getIntent();
              setResult(Activity.RESULT_OK, it);
              finish();
            }
          }
        });
  }
コード例 #5
0
  private void upLoadPic(String path) {
    User user = User.getInstance();
    DhNet net =
        new DhNet(API.uploadAlbum + user.getUserId() + "/album/upload?token=" + user.getToken());
    Log.e("url", net.getUrl());
    net.upload(
        new FileInfo("attach", new File(path)),
        new NetTask(self) {

          @Override
          public void doInUI(Response response, Integer transfer) {
            if (response.isSuccess()) {
              IocContainer.getShare().get(IDialog.class).showToastShort(self, "图片上传成功!");
              Intent it = new Intent(MainActivity.this, ManageAlbumActivity.class);
              it.putExtra("tempPath", tempPath);
              startActivity(it);
            }
          }
        });
  }
コード例 #6
0
  @Override
  public void initView() {
    type = getIntent().getStringExtra("type");
    per = IocContainer.getShare().get(CarPlayPerference.class);
    per.load();
    if (per.isShowMessageGuilde == 0) {
      findViewById(R.id.guide).setVisibility(View.VISIBLE);
    }

    findViewById(R.id.know)
        .setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                per.load();
                per.isShowMessageGuilde = 1;
                per.commit();
                findViewById(R.id.guide).setVisibility(View.GONE);
              }
            });
    backI = (ImageView) findViewById(R.id.back);
    if (type.equals("comment")) {
      setTitle("新的留言");
    } else {
      setTitle("活动消息");
    }
    leftTitleT = (TextView) findViewById(R.id.left_text);
    leftTitleT.setText("全选");
    leftTitleT.setPadding(DhUtil.dip2px(self, 12), 0, 0, 0);
    leftTitleT.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (leftTitleT.getText().toString().equals("全选")) {
              mJsonAdapter.checkAll(true);
              leftTitleT.setText("取消全选");
            } else {
              leftTitleT.setText("全选");
              mJsonAdapter.checkAll(false);
            }
            mJsonAdapter.notifyDataSetChanged();
          }
        });
    rightTitleT = (TextView) findViewById(R.id.right_text);
    rightTitleT.setText("取消");
    rightTitleT.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            mJsonAdapter.showCheck(false);
            leftTitleT.setText("全选");
            rightTitleT.setVisibility(View.GONE);
            delB.setVisibility(View.GONE);
            mJsonAdapter.cleanCheck();
            backI.setVisibility(View.VISIBLE);
            mJsonAdapter.showCheck(false);
            leftTitleT.setVisibility(View.GONE);
          }
        });

    delB = (Button) findViewById(R.id.del);
    delB.setOnClickListener(this);
    listView = (NetRefreshAndMoreListView) findViewById(R.id.listview);
    listView.setOnItemLongClickListener(
        new OnItemLongClickListener() {

          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            mJsonAdapter.showCheck(true);
            rightTitleT.setVisibility(View.VISIBLE);
            leftTitleT.setVisibility(View.VISIBLE);
            delB.setVisibility(View.VISIBLE);
            backI.setVisibility(View.GONE);
            return true;
          }
        });
    listView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent it = null;
            JSONObject jo = (JSONObject) mJsonAdapter.getItem(position - 1);
            if (type.equals("comment")) {

              it = new Intent(self, ActiveDetailsActivity.class);
              it.putExtra("activityId", JSONUtil.getString(jo, "activityId"));
              startActivity(it);
            } else {
              String activityId = JSONUtil.getString(jo, "activityId");
              String type = JSONUtil.getString(jo, "type").trim();
              if (!TextUtils.isEmpty(activityId)) {

                it = new Intent(self, ActiveDetailsActivity.class);
                it.putExtra("activityId", activityId);
                startActivity(it);
              }
              if (type.equals("车主认证")) {
                String carModel = JSONUtil.getString(jo, "carModel");
                String remarks = JSONUtil.getString(jo, "remarks");
                String rs = "";
                if (JSONUtil.getString(jo, "remarks").equals("")) {
                  rs = "0";
                } else {
                  rs = "1";
                }
                it = new Intent(self, AttestationNotifyActivity.class);
                it.putExtra("carModel", carModel);
                it.putExtra("result", rs);
                it.putExtra("remarks", remarks);
                startActivity(it);
              }
            }
          }
        });

    listView.setOnEmptyDataListener(
        new OnEmptyDataListener() {

          @Override
          public void onEmpty(boolean showeEptyView) {
            ViewUtil.bindView(findViewById(R.id.msg), "暂无留言");
            findViewById(R.id.empty).setVisibility(showeEptyView ? View.VISIBLE : View.GONE);
          }
        });
    User user = User.getInstance();
    String url =
        API.CWBaseurl
            + "/user/"
            + user.getUserId()
            + "/message/list?token="
            + user.getToken()
            + "&type="
            + type;
    mJsonAdapter = new MessageAdapter(url, self, R.layout.item_message_list, type);
    mJsonAdapter.fromWhat("data");
    listView.setAdapter(mJsonAdapter);
    // getData();
    mJsonAdapter.showNextInDialog();
  }
コード例 #7
0
  private void setTab(int index) {

    if (index == 1) {
      if (!User.getInstance().isLogin()) {
        UserInfoManage.getInstance()
            .checkLogin(
                self,
                new LoginCallBack() {

                  @Override
                  public void onisLogin() {
                    setTab(1);
                  }

                  @Override
                  public void onLoginFail() {}
                });
      }
    }

    if (index == 1 && !User.getInstance().isLogin()) {
      return;
    }

    for (int i = 0; i < tabV.getChildCount(); i++) {
      View childV = tabV.getChildAt(i);
      View imgLayout = childV.findViewById(R.id.img_layout);
      final ImageView img = (ImageView) imgLayout.findViewById(R.id.img);
      TextView text = (TextView) childV.findViewById(R.id.text);
      if (index == i) {
        text.setTextColor(getResources().getColor(R.color.text_blue_light));
        switch (index) {
          case 0:
            setTitle("同城");
            img.setImageResource(R.drawable.city_f);
            switchContent(ActiveListFragment.getInstance());
            setRightAction(
                "创建活动",
                -1,
                new OnClickListener() {

                  @Override
                  public void onClick(View arg0) {
                    UserInfoManage.getInstance()
                        .checkLogin(
                            self,
                            new LoginCallBack() {

                              @Override
                              public void onisLogin() {
                                Intent it =
                                    new Intent(MainActivity.this, CreateActiveActivity.class);
                                startActivity(it);
                              }

                              @Override
                              public void onLoginFail() {
                                // TODO Auto-generated method stub

                              }
                            });
                  }
                });
            setLeftAction(
                R.drawable.filtrate,
                "筛选",
                new OnClickListener() {

                  @Override
                  public void onClick(View arg0) {
                    activeFilterPop.show(titleBar);
                  }
                });
            break;

          case 1:
            setTitle("消息");
            setRightVISIBLEOrGone(View.GONE);
            switchContent(MsgFragment.getInstance(dataJo));

            img.setImageResource(R.drawable.msg_f);
            setLeftAction(
                -2,
                null,
                new OnClickListener() {

                  @Override
                  public void onClick(View arg0) {}
                });
            break;

          case 2:
            setTitle("我的");
            switchContent(MyFragment.getInstance());
            img.setImageResource(R.drawable.my_f);
            setLeftAction(
                R.drawable.icon_setting,
                null,
                new OnClickListener() {

                  @Override
                  public void onClick(View arg0) {
                    Intent it = new Intent(MainActivity.this, SettingActivity.class);
                    startActivity(it);
                  }
                });
            setRightAction(
                null,
                R.drawable.icon_camera,
                new OnClickListener() {

                  @Override
                  public void onClick(View arg0) {
                    UserInfoManage.getInstance()
                        .checkLogin(
                            self,
                            new LoginCallBack() {

                              @Override
                              public void onisLogin() {
                                // TODO Auto-generated
                                // method stub
                                mCacheDir = new File(getExternalCacheDir(), "CarPlay");
                                mCacheDir.mkdirs();
                                tempPath =
                                    new File(mCacheDir, System.currentTimeMillis() + ".jpg")
                                        .getAbsolutePath();
                                PhotoUtil.getPhoto(
                                    self,
                                    Constant.TAKE_PHOTO,
                                    Constant.PICK_PHOTO,
                                    new File(tempPath));
                              }

                              @Override
                              public void onLoginFail() {}
                            });
                  }
                });
            break;

          default:
            break;
        }
      } else {
        text.setTextColor(getResources().getColor(R.color.text_grey));
        switch (i) {
          case 0:
            img.setImageResource(R.drawable.city_n);
            break;

          case 1:
            img.setImageResource(R.drawable.msg_n);
            break;

          case 2:
            img.setImageResource(R.drawable.my_n);
            break;

          default:
            break;
        }
      }
    }
  }
コード例 #8
0
  @Override
  public void initView() {
    mCacheDir = new File(getExternalCacheDir(), "CarPlay");
    mCacheDir.mkdirs();
    setTitle("车主认证");
    String type = getIntent().getStringExtra("type");
    if (TextUtils.isEmpty(type)) {
      setRightAction(
          "跳过",
          -1,
          new OnClickListener() {

            @Override
            public void onClick(View arg0) {
              Intent it = getIntent();
              setResult(Activity.RESULT_OK, it);
              finish();
            }
          });

      findViewById(R.id.backLayout)
          .setOnClickListener(
              new OnClickListener() {

                @Override
                public void onClick(View v) {
                  Intent it = getIntent();
                  setResult(Activity.RESULT_OK, it);
                  finish();
                }
              });
    }

    icon_tI = (ImageView) findViewById(R.id.icon_t);
    icon_bI = (ImageView) findViewById(R.id.icon_b);
    modelT = (TextView) findViewById(R.id.model);
    modelT.setOnClickListener(this);
    picI = (ImageView) findViewById(R.id.pic);
    picI.setOnClickListener(this);
    user = User.getInstance();

    drivingExperienceE = (EditText) findViewById(R.id.drivingExperience);
    submitB = (Button) findViewById(R.id.submit);
    submitB.setOnClickListener(this);

    Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
      isAuthenticated = bundle.getInt("isAuthenticated", 0);
      drivingyears = bundle.getInt("drivingyears", 0);
      carModel = bundle.getString("carModel");
      license = bundle.getString("license");
    }
    System.out.println("-----------------" + license);
    switch (isAuthenticated) {
        // 未认证
      case 0:
        drivingExperienceE.setText("");
        modelT.setText("");
        submitB.setText("认证车主");
        submitB.setEnabled(true);
        break;
        // 已认证
      case 1:
        drivingExperienceE.setText(drivingyears + "");
        modelT.setText(carModel);
        if (!TextUtils.isEmpty(license)) {
          ViewUtil.bindNetImage(picI, license, CarPlayValueFix.optionsDefault.toString());
        }
        submitB.setText("已认证");
        submitB.setEnabled(false);
        submitB.setBackgroundResource(R.drawable.btn_grey_bg);
        break;
        // 认证中
      case 2:
        drivingExperienceE.setText(drivingyears + "");
        modelT.setText(carModel);
        if (!TextUtils.isEmpty(license)) {
          ViewUtil.bindNetImage(picI, license, CarPlayValueFix.optionsDefault.toString());
        }
        submitB.setText("认证中");
        submitB.setEnabled(false);
        submitB.setBackgroundResource(R.drawable.btn_grey_bg);
        picI.setEnabled(false);
        drivingExperienceE.setEnabled(false);
        drivingExperienceE.setTextColor(self.getResources().getColor(R.color.text_grey));
        modelT.setTextColor(self.getResources().getColor(R.color.text_grey));
        modelT.setEnabled(false);

        icon_tI.setVisibility(View.INVISIBLE);
        icon_bI.setVisibility(View.INVISIBLE);
        break;

      default:
        break;
    }
  }