示例#1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    ViewUtils.inject(this);

    init();
  }
示例#2
0
  @Override
  public void callback(String jsonString, int flag) {
    super.callback(jsonString, flag);
    Intent intent;
    switch (flag) {
      case login:
        try {
          JSONObject jsonObject = new JSONObject(jsonString);
          MyApplication.getInstance().setCreationtime(jsonObject.getString("creationtime"));
          MyApplication.getInstance().setPhone(jsonObject.getString("phone"));
          MyApplication.getInstance().setDeliveryaddress(jsonObject.getString("deliveryaddress"));
          MyApplication.getInstance().setExamine(jsonObject.getString("examine"));
          MyApplication.getInstance()
              .setIdNumber(Integer.parseInt(jsonObject.getString("idNumber")));
          MyApplication.getInstance().setStallsname(jsonObject.getString("stallsname"));
          MyApplication.getInstance().setTlr_name(jsonObject.getString("tlr_name"));
          MyApplication.getInstance().setTlr_pwd(jsonObject.getString("tlr_pwd"));
          MyApplication.getInstance().setTlr_type(jsonObject.getString("tlr_type"));
          MyApplication.getInstance().setUserlogo(jsonObject.getString("userlogo"));
          MyApplication.getInstance().setIsSetpassword(jsonObject.getString("isSetPayPwd"));
          MyApplication.getInstance().setIdStore(jsonObject.getString("idStore"));
          MyApplication.getInstance().setBalance(jsonObject.getString("balance"));
          MyApplication.getInstance().setToKen(jsonObject.getString("toKen"));
          LogUtils.i("toKen:" + MyApplication.getInstance().getToKen());
          putSp(MyConst.isLogin, true);
          putSp(MyConst.userName, getStr(ed_user_name));
          putSp(MyConst.userPwd, getStr(ed_user_password));
          if (!TextUtils.isEmpty(MyApplication.getInstance().getToKen())) {
            messageList();
          } else {
            showToast("登录异常,请稍后重试!");
          }

        } catch (JSONException e) {
          e.printStackTrace();
        }

        break;

      case messageList:
        List<MessageBean> list = new ArrayList<MessageBean>();
        list = new Gson().fromJson(jsonString, new TypeToken<List<MessageBean>>() {}.getType());
        String spFileName = MyApplication.getInstance().getIdNumber() + "sysIdMessage";
        SharedPreferences sharedPreferences =
            getSharedPreferences(
                spFileName, Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
        Iterator it;
        String str = "";
        //			list.get(0).setIdMessage(1222211111);
        // 后台不能够判断系统消息是否已读     ---把保存在SharedPreferences里面的已读的系统消息id跟消息列表接口的系统消息id想对比
        if (list.size() != 0) {

          for (int i = 0; i < list.size(); i++) {
            if ("0".equals(list.get(i).getMsgtype()) || "1".equals(list.get(i).getMsgtype())) {
              it = sharedPreferences.getStringSet("idMessage", new HashSet<String>()).iterator();
              while (it.hasNext()) {
                str = (String) it.next();
                if ((list.get(i).getIdMessage() + "").equals(str)) {
                  list.get(i).setIsRead("Y");
                }
              }
            }
          }
          MyApplication.getInstance().setMessage(list);
        }
        if (MyApplication.getInstance().getTlr_type().equals("0")) { // 0买家
          intent = new Intent(LoginActivity.this, MainActivity.class);
          startActivity(intent);
          finish();
        } else if (MyApplication.getInstance().getTlr_type().equals("1")) { // 1卖家
          intent = new Intent(LoginActivity.this, MainActivityMerchant.class);
          startActivity(intent);
          finish();
        }
        break;

      default:
        break;
    }
  }