Пример #1
0
        @Override
        public void onClick(View v) {
          // TODO Auto-generated method stub
          switch (v.getId()) {
            case R.id.personIconIv:
              Intent it = new Intent(Intent.ACTION_GET_CONTENT);
              it.setType("*/*");
              it.addCategory(Intent.CATEGORY_OPENABLE);
              startActivityForResult(Intent.createChooser(it, "选择所需要的图片"), FILE_SELECT_CODE);
              break;
            case R.id.commitBtn:
              if (!HAVA_SET_ICON) {
                Toast.makeText(PersonalIconSettingActivity.this, "未做更改", Toast.LENGTH_SHORT).show();
              } else {

                params.add(new BasicNameValuePair("icon", Tools.iconBitmap2String(bitmap)));
                params.add(new BasicNameValuePair("userNow", sharePreferenceHelper.getStuCode()));
                loadingProgressBar.setVisibility(View.VISIBLE);
                new Thread(
                        new Runnable() {

                          @Override
                          public void run() {
                            // TODO Auto-generated method stub
                            String resultString = HttpConnect.setIcon(params);
                            if (resultString != null) {
                              try {
                                JSONObject jsonObject = new JSONObject(resultString);
                                errorString = jsonObject.getString("errorMsg");
                                if (jsonObject.getInt("state") == 0) {
                                  handler.sendEmptyMessage(0);
                                } else {
                                  handler.sendEmptyMessage(1);
                                }
                              } catch (Exception e) {
                                // TODO: handle exception
                                handler.sendEmptyMessage(2);
                              }
                            } else {
                              handler.sendEmptyMessage(3);
                            }
                          }
                        })
                    .start();
                ;
              }
              break;

            default:
              break;
          }
        }
Пример #2
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   this.requestWindowFeature(Window.FEATURE_NO_TITLE);
   setContentView(R.layout.activity_personal_icon_setting);
   personalIconIv = (ImageView) findViewById(R.id.personIconIv);
   commitBtn = (LinearLayout) findViewById(R.id.commitBtn);
   loadingProgressBar = (ProgressBar) findViewById(R.id.loading);
   personalIconIv.setOnClickListener(onClickListener);
   sharePreferenceHelper = new SharePreferenceHelper();
   commitBtn.setOnClickListener(onClickListener);
   params = new ArrayList<NameValuePair>();
   usrNow = sharePreferenceHelper.getStuCode();
 }