示例#1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    if ((getIntent() != null)
        && (getIntent().getExtras() != null)
        && (getIntent().getExtras().get("user") != null)) {
      userName = getIntent().getExtras().get("user").toString();
    }
    Log.d("wang", "Profile user name is " + userName);
    if (!userName.equals("")) {

      HashMap<String, String> locationParams = new HashMap<String, String>();
      locationParams.put("user", userName);
      doTaskAsync(C.task.getCustomer, C.api.getCustomer, locationParams);
    } else if ((userName.equals(""))
        && (getIntent() != null)
        && (getIntent().getExtras() != null)
        && (getIntent().getExtras().get("user") != null)) {
      uselessView();
    } else if (app.isLogin()) {
      if ((getIntent() != null)
          && (getIntent().getExtras() != null)
          && (getIntent().getExtras().get("newsCount") != null)) {
        newsCount = getIntent().getExtras().get("newsCount").toString();
        loginView();
      } else {
        unLoginView();
      }
    } else {
      unLoginView();
    }
  }
示例#2
0
 @Override
 public void onBackPressed() {
   // TODO Auto-generated method stub
   Intent intent = new Intent();
   intent.putExtra("result", "ok1");
   setResult(RESULT_OK, intent);
   super.onBackPressed();
 }
示例#3
0
  public void onTaskComplete(int taskId, BaseMessage message) {
    super.onTaskComplete(taskId, message);
    switch (taskId) {
      case C.task.replyCreate:
        toast("回复成功!");
        replyContent.setText("");
        if ((listItem.get(0).get("empty") != null) && (listItem.get(0).get("empty").equals("1"))) {
          listItem.remove(0);
          adapter.notifyDataSetChanged();
        }
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("comment", content);
        map.put("user", name);
        map.put("time", time);
        listItem.add(0, map);
        adapter.notifyDataSetChanged();

        HashMap<String, String> commentParams = new HashMap<String, String>();
        commentParams.put("commentId", commentId);
        count = count + 1;
        commentParams.put("count", String.valueOf(count));
        doTaskAsync(C.task.commentCount, C.api.commentCount, commentParams);
        break;
      case C.task.commentCount:
        Log.d("wang", "comment count successfully");
        break;
      case C.task.replyList:
        Log.d("wang", "entry commentList");

        try {
          if (message.getCode().equals("10000")) {
            ArrayList<Reply> replyList;
            replyList = (ArrayList<Reply>) message.getResultList("Reply");
            getData(replyList);
            adapter.notifyDataSetChanged();
          } else {
            Map<String, Object> map1 = new HashMap<String, Object>();
            map1.put("empty", "1");
            map1.put("comment", "目前没有任何评论!");
            listItem.add(map1);
            adapter.notifyDataSetChanged();
          }
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }

        break;
    }
  }
示例#4
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.reply);
    HashMap<String, String> commentParams = new HashMap<String, String>();

    lv = (ListView) findViewById(R.id.list);
    lv.setPadding(0, 0, 0, 0);
    View v = View.inflate(ReplyActivity.this, R.layout.reply_header, null);
    content_tv = (TextView) v.findViewById(R.id.content);
    time_tv = (TextView) v.findViewById(R.id.time);
    private_cus = (LinearLayout) v.findViewById(R.id.private_cus);
    username = (TextView) v.findViewById(R.id.userName);
    reply = (LinearLayout) v.findViewById(R.id.reply);
    replyContent = (EditText) findViewById(R.id.add_reply);
    replySubmit = (TextView) findViewById(R.id.reply_submit);
    TextView v_return = (TextView) findViewById(R.id.tv_return);
    v_return.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            finish();
          }
        });

    username.setText(getIntent().getExtras().get("user").toString());
    time_tv.setText(getIntent().getExtras().get("time").toString());
    content_tv.setText(getIntent().getExtras().get("comment").toString());
    commentId = getIntent().getExtras().get("commentId").toString();
    count = Integer.valueOf(getIntent().getExtras().get("count").toString());
    replySubmit.setOnClickListener(
        new OnClickListener() {

          @SuppressLint("NewApi")
          @Override
          public void onClick(View arg0) {
            // TODO Auto-generated method stub
            HashMap<String, String> commentParams = new HashMap<String, String>();
            content = ReplyActivity.this.replyContent.getText().toString();
            String sign = app.getSign();
            String user = app.getUser();
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 璁剧疆鏃ユ湡鏍煎紡
            time = df.format(new Date()); // new Date()涓鸿幏鍙栧綋鍓嶇郴缁熸椂闂�
            commentParams.put("commentId", commentId);
            commentParams.put("content", content);
            // if(sign.isEmpty()) {
            name = user;
            commentParams.put("name", user);
            /*} else {
            	name = sign;
            	commentParams.put("name", sign);
            }*/
            doTaskAsync(C.task.replyCreate, C.api.replyCreate, commentParams);
          }
        });

    private_cus.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            // TODO Auto-generated method stub
            Intent user = new Intent();
            String user_name = getIntent().getExtras().get("user").toString();
            if (user_name == null) {
              user_name = "";
            }
            user.putExtra("user", user_name);
            user.setClass(ReplyActivity.this, ProfileActivity.class);
            ReplyActivity.this.startActivity(user);
          }
        });

    lv.addHeaderView(v);
    listItem = new ArrayList<Map<String, Object>>();
    /*adapter = new SimpleAdapter(this,listItem,R.layout.comment,
    new String[]{"user","time","comment"},
    new int[]{R.id.userName,R.id.time,R.id.content});*/
    adapter = new ReplyAdapter(ReplyActivity.this, listItem);
    lv.setAdapter(adapter);
    commentParams.put("commentId", commentId);
    doTaskAsync(C.task.replyList, C.api.replyList, commentParams);
  }
示例#5
0
  public void onTaskComplete(int taskId, BaseMessage message) {
    super.onTaskComplete(taskId, message);
    if ((message.getCode().equals("10000")) && (taskId == C.task.login)) {
      Customer customer;
      toast(message.getMessage());
      try {
        customer = (Customer) message.getResult("Customer");
        Log.d(
            "wang",
            "id: "
                + customer.getId()
                + " name: "
                + customer.getName()
                + " pass: "******" qq: "
                + customer.getQq()
                + " email: "
                + customer.getEmail()
                + " sign: "
                + customer.getSign());
        SharedPreferences share = getSharedPreferences("customer", MODE_PRIVATE);
        SharedPreferences.Editor edit = share.edit();
        edit.putString("customerId", customer.getId());
        edit.putString("user", customer.getName());
        edit.putString("sign", customer.getSign());
        edit.putString("aa", customer.getQq());
        edit.putString("email", customer.getEmail());
        edit.commit();
        app.setUser(customer.getName());
        app.setSign(customer.getSign());
        app.setCustomerid(Integer.valueOf(customer.getId()));
        app.setQQ(customer.getQq());
        app.setEmail(customer.getEmail());
        dialog.dismiss();

        // build.
        loginView();
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

    } else if (taskId == (C.task.getCustomer)) {
      if ((message.getCode().equals("10000"))) {
        Customer customer;
        try {
          customer = (Customer) message.getResult("Customer");
          Log.d(
              "wang",
              "getCustomer id: "
                  + customer.getId()
                  + " name: "
                  + customer.getName()
                  + " pass: "******" qq: "
                  + customer.getQq()
                  + " email: "
                  + customer.getEmail()
                  + " sign: "
                  + customer.getSign());
          user = customer.getName();
          sign = customer.getSign();
          mQq = customer.getQq();
          mEmail = customer.getEmail();
          userView();
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      } else {
        uselessView();
      }

    } else {
      toast(message.getMessage());
    }
  }