Exemplo n.º 1
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   switch (requestCode) {
     case REQUEST_CODE:
       if (resultCode == 0) return;
       Uri uri = data.getData();
       Bitmap bmp = null;
       ContentResolver cr = this.getContentResolver();
       try {
         bmp = BitmapFactory.decodeStream(cr.openInputStream(uri));
       } catch (FileNotFoundException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
       if (bmp != null) {
         Bitmap output = RoundImageUtil.toRoundCorner(RoundImageUtil.resizeImage(bmp, 100, 100));
         photoCh.setImageBitmap(output);
       }
       break;
   }
 }
Exemplo n.º 2
0
 void setJobs(String url, ArrayList<ListItem> itemArray) throws URISyntaxException {
   if (!NetWorkUtil.isNetworkConnected(this.getApplicationContext())) {
     ToastUtil.show(getApplicationContext(), "网络服务不可用,请检查网络状态!");
     return;
   }
   List<NameValuePair> list = new ArrayList<NameValuePair>();
   if (mBeMyself) list.add(new BasicNameValuePair("name", (String) mUserName.getText()));
   else list.add(new BasicNameValuePair("name", mOtherName));
   HttpResponse res = PostandGetConnectionUtil.getConnect(url, list);
   if (PostandGetConnectionUtil.responseCode(res) != 200) return;
   //		Toast.makeText(UserProfileActivity.this,
   //				 "setJobs", Toast.LENGTH_LONG).show();
   String json_str = PostandGetConnectionUtil.GetResponseMessage(res);
   if (json_str.length() != 0) {
     JsonPushRet o = new DecodeJson().jsonPush(json_str);
     itemArray.clear();
     if (o.getRet().equals("ok")) {
       int count = o.getCount();
       for (int i = 0; i < count; i++) {
         String theme = "主题:" + o.getList().get(i).getTheme();
         String details = "正文:" + o.getList().get(i).getDetails();
         String time = "时间:" + o.getList().get(i).getTime();
         String cnt = "人数:" + o.getList().get(i).getCount();
         String name = o.getList().get(i).getName();
         String img = o.getList().get(i).getImg();
         String id = o.getList().get(i).getId();
         Bitmap bitmap = mDefaultBit;
         String image_location = PostandGetConnectionUtil.mediaUrlBase + img;
         // get the image from the url
         try {
           ByteArrayOutputStream baos = new ByteArrayOutputStream();
           URL url_image = new URL(image_location);
           InputStream is = url_image.openStream();
           bitmap = RoundImageUtil.toRoundCorner(BitmapFactory.decodeStream(is));
           is.close();
         } catch (Exception e) {
           e.printStackTrace();
         }
         itemArray.add(new ListItem(name, theme, time, cnt, details, id, bitmap));
       }
     }
   }
 }
Exemplo n.º 3
0
 void setInfo_other() throws URISyntaxException {
   if (!NetWorkUtil.isNetworkConnected(this.getApplicationContext())) {
     ToastUtil.show(getApplicationContext(), "网络服务不可用,请检查网络状态!");
     return;
   }
   List<NameValuePair> list = new ArrayList<NameValuePair>();
   list.add(new BasicNameValuePair("name", mOtherName));
   list.add(new BasicNameValuePair("other", "y"));
   HttpResponse res =
       PostandGetConnectionUtil.getConnect(PostandGetConnectionUtil.getinfoUrl, list);
   if (PostandGetConnectionUtil.responseCode(res) != 200) return;
   String json_str = PostandGetConnectionUtil.GetResponseMessage(res);
   if (json_str.length() != 0) {
     JsonInfoResult o = new DecodeJson().jsonInfo(json_str);
     if (o.getRet().equals("ok")) {
       mUserName.setText(o.getUsername());
       mUserLabel.setText(o.getLabel());
       if (o.getSex().equals("F")) {
         mSexImage.setImageResource(R.drawable.girl);
       } else {
         mSexImage.setImageResource(R.drawable.boy);
       }
       String image_location = PostandGetConnectionUtil.mediaUrlBase + o.getUserimage();
       try {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         URL url_image = new URL(image_location);
         InputStream is = url_image.openStream();
         Bitmap bitmap = BitmapFactory.decodeStream(is);
         photoCh.setImageBitmap(RoundImageUtil.toRoundCorner(bitmap));
         is.close();
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   }
 }
Exemplo n.º 4
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_user_profile);
    preStep = (ImageView) findViewById(R.id.title_bar_menu_btn);
    photoCh = (ImageView) findViewById(R.id.change_photo);
    mSexImage = (ImageView) findViewById(R.id.sex_profile);
    mUserName = (TextView) findViewById(R.id.user_name_profile);
    mUserLabel = (TextView) findViewById(R.id.label_profile);
    Intent intent = getIntent();
    String user_name = intent.getStringExtra("user");
    if (user_name.equals("other")) mBeMyself = false;
    if (!mBeMyself) mOtherName = intent.getStringExtra("name");
    // mEditUserProfile = (ImageView) findViewById(R.id.edit_user_profle);
    // mEditUserProfile.setOnClickListener(this);
    preStep.setOnClickListener(this);
    photoCh.setOnClickListener(this);
    // fileChooserIntent = new Intent(this,fileChooserActivity.class);
    mCompletedTextView = (TextView) findViewById(R.id.compeleted_text);
    mUnCompletedTextView = (TextView) findViewById(R.id.uncompeleted_text);
    mScrollLayout = (ListScrollLayout) findViewById(R.id.listScrollLayout);
    mViewCount = mScrollLayout.getChildCount();
    LinearLayout linearLayout = (LinearLayout) findViewById(R.id.lllayout);
    mImageViews = new LinearLayout[mViewCount];
    for (int i = 0; i < mViewCount; i++) {
      mImageViews[i] = (LinearLayout) linearLayout.getChildAt(i);
      mImageViews[i].setEnabled(true);
      mImageViews[i].setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              // TODO Auto-generated method stub
              int pos = (Integer) (v.getTag());
              setCurPoint(pos);
              mScrollLayout.snapToScreen(pos);
            }
          });
      mImageViews[i].setTag(i);
    }
    mCurSel = 0;
    mImageViews[mCurSel].setEnabled(false);
    mScrollLayout.SetOnViewChangeListener(this);
    if (mBeMyself) {
      SharedPreferences sp = SharedPreferenceUtil.getSharedPreferences();
      String imageBase64 = sp.getString("imageBase64", "");
      String username = sp.getString("username", "");
      String sex = sp.getString("sex", "");
      String label = sp.getString("label", "");
      if (sex.equals("F")) {
        mSexImage.setImageResource(R.drawable.girl);
      } else {
        mSexImage.setImageResource(R.drawable.boy);
      }
      mUserName.setText(username);
      mUserLabel.setText(label);
      byte[] base64Bytes = Base64.decode(imageBase64.getBytes(), Base64.DEFAULT);
      ByteArrayInputStream bais = new ByteArrayInputStream(base64Bytes);
      Bitmap bitmap = RoundImageUtil.toRoundCorner(BitmapFactory.decodeStream(bais));
      photoCh.setImageBitmap(bitmap);
      mDefaultBit = BitmapFactory.decodeResource(getResources(), R.drawable.user_photo);
    } else {
      try {
        setInfo_other();
      } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    try {
      setJobs(PostandGetConnectionUtil.getCompletedUrl, mCompletedItemArray);
      setJobs(PostandGetConnectionUtil.getUnCompletedUrl, mUnCompletedItemArray);
    } catch (URISyntaxException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    mCompletedListAdapter =
        new ListItemArrayAdapter(UserProfileActivity.this, R.layout.list_item, mCompletedItemArray);
    mUnCompletedListAdapter =
        new ListItemArrayAdapter(
            UserProfileActivity.this, R.layout.list_item, mUnCompletedItemArray);
    mCompletedListView = (ListView) findViewById(R.id.completed_list);
    mUnCompletedListView = (ListView) findViewById(R.id.uncompleted_list);
    mCompletedListView.setItemsCanFocus(false);
    mUnCompletedListView.setItemsCanFocus(false);
    mCompletedListView.setAdapter(mCompletedListAdapter);
    mUnCompletedListView.setAdapter(mUnCompletedListAdapter);

    mUnCompletedListView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub
            Intent intent = new Intent();
            intent.putExtra("id", mUnCompletedItemArray.get((int) arg3).getmAcTId());
            intent.putExtra("name", mUnCompletedItemArray.get((int) arg3).getmUserName());
            intent.setClass(UserProfileActivity.this, InfoActivity.class);
            startActivity(intent);
          }
        });

    mCompletedListView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub
            Intent intent = new Intent();
            intent.putExtra("id", mCompletedItemArray.get((int) arg3).getmAcTId());
            intent.putExtra("name", mCompletedItemArray.get((int) arg3).getmUserName());
            intent.setClass(UserProfileActivity.this, InfoActivity.class);
            startActivity(intent);
          }
        });
  }