public void addElementCircles() { CircleImageView civ; circle_holder.removeAllViewsInLayout(); circleIndex.clear(); QData qData; for (int i = 0; i < elements.size(); i++) { qData = elements.get(i); if (qData.isText()) { civ = new CircleImageView(this); civ.setImageDrawable(getResources().getDrawable(R.drawable.text)); civ.setBorderColor(getResources().getColor(R.color.blue)); civ.setBorderWidth(10); civ.setOnClickListener(circleClickListener); circle_holder.addView(civ, circle_params); circleIndex.add(civ); } else if (!qData.isText()) { civ = new CircleImageView(this); // byte[] array = fragments.get(i).mData.getImage(); civ.setImageBitmap(elements.get(i).getImageBitmap()); civ.setBorderColor(getResources().getColor(R.color.blue)); civ.setBorderWidth(10); civ.setOnClickListener(circleClickListener); circle_holder.addView(civ, circle_params); circleIndex.add(civ); } if (i == 0) circleIndex.get(i).setBorderColor(Color.WHITE); } }
/** * 保存裁剪之后的图片数据 * * @param picdata */ private void setPicToView(Intent picdata) { Bundle extras = picdata.getExtras(); if (extras != null) { // 取得SDCard图片路径做显示 Bitmap avaterBitmap = extras.getParcelable("data"); ByteArrayOutputStream stream = new ByteArrayOutputStream(); avaterBitmap.compress(Bitmap.CompressFormat.JPEG, 50, stream); // (0 - 100)压缩文件 mImgUserAvatar.setImageBitmap(avaterBitmap); mAvaterUrl = FileUtil.saveFile(RegisterActivity.this, IMAGE_FILE_NAME, avaterBitmap); isTakeAvatar = true; // 压缩图片 // BitmapFactory.Options option = new BitmapFactory.Options(); // 压缩图片:表示缩略图大小为原始图片大小的几分之一,1为原图 // option.inSampleSize = 2; // 根据图片的SDCard路径读出Bitmap // genderBitmap = BitmapFactory.decodeFile(avaterUrl, option); Toast.makeText( RegisterActivity.this, "头像保存在:" + mAvaterUrl.replaceAll(IMAGE_FILE_NAME, ""), Toast.LENGTH_LONG) .show(); // 新线程后台上传服务端 // new Thread(uploadImageRunnable).start(); } }
private void getUserDetailsFromParse() { parseUser = ParseUser.getCurrentUser(); // Fetch profile photo try { ParseFile parseFile = parseUser.getParseFile("profileThumb"); byte[] data = parseFile.getData(); Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length); mProfileImage.setImageBitmap(bitmap); } catch (Exception e) { e.printStackTrace(); } mEmailID.setText(parseUser.getEmail()); mUsername.setText(parseUser.getUsername()); Toast.makeText( MainActivity.this, "Welcome back " + mUsername.getText().toString(), Toast.LENGTH_SHORT) .show(); }
private void initializeProfileInformation() { imgAvatar = (CircleImageView) findViewById(R.id.imgAvatar); imgAvatar.setOnClickListener(this); final TextView txtName = (TextView) findViewById(R.id.txtName); final TextView txtEmail = (TextView) findViewById(R.id.txtEmail); if (((GlobalApplication) getApplication()).getAvatar() != null) { imgAvatar.setImageBitmap(((GlobalApplication) getApplication()).getAvatar()); txtName.setText(((GlobalApplication) getApplication()).getFullName()); txtEmail.setText(((GlobalApplication) getApplication()).getEmail()); Log.i(TAG, "Get Profile Information from GlobalApplication"); return; } Log.i(TAG, "Get Profile Information from Server"); ParseFile parseFile = (ParseFile) currentUser.get("avatar"); if (parseFile != null) { parseFile.getDataInBackground( new GetDataCallback() { @Override public void done(byte[] bytes, ParseException e) { if (e == null) { String fullName = currentUser.getString("fullName"); String email = currentUser.getEmail(); userAvatar = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); imgAvatar.setImageBitmap(userAvatar); txtName.setText(fullName); txtEmail.setText(email); ((GlobalApplication) getApplication()).setAvatar(userAvatar); ((GlobalApplication) getApplication()).setFullName(fullName); ((GlobalApplication) getApplication()).setPhoneNumber(currentUser.getUsername()); ((GlobalApplication) getApplication()).setEmail(email); } } }); } }
@Nullable @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); final View view = inflater.inflate(R.layout.second_login_view, null); email = (TextView) view.findViewById(R.id.email); name = (TextView) view.findViewById(R.id.name); editTextPassword = (EditText) view.findViewById(R.id.editTextPassword); profile_image = (CircleImageView) view.findViewById(R.id.profile_image); pass_forget = (Button) view.findViewById(R.id.pass_forget); pass_forget_description = (TextView) view.findViewById(R.id.pass_forget_description); progressBarSecond = (ProgressBar) view.findViewById(R.id.progressBarSecond); layoutSecond = (RevealLinearLayout) view.findViewById(R.id.layoutSecond); buttonLogin = (Button) view.findViewById(R.id.buttonLogin); progressBarSecond.setVisibility(View.GONE); if (mtsl != null) { email.setText(mtsl.getEmail()); name.setText(mtsl.getName()); profile_image.setImageBitmap(mtsl.getBitmap()); if (mtsl.getButton_login_text_color() != 0) buttonLogin.setTextColor(mtsl.getButton_login_text_color()); if (mtsl.getButton_login_background() != 0) buttonLogin.setBackgroundResource(mtsl.getButton_login_background()); if (mtsl.getButton_login_text() != 0) buttonLogin.setText(mtsl.getButton_login_text()); if (mtsl.getEdittext_password_background() != 0) editTextPassword.setBackgroundResource(mtsl.getEdittext_password_background()); if (mtsl.getEdittext_password_text_color() != 0) editTextPassword.setTextColor(mtsl.getEdittext_password_text_color()); if (mtsl.getName_text_color() != 0) name.setTextColor(mtsl.getName_text_color()); if (mtsl.getButton_passforget_text_color() != 0) pass_forget.setTextColor(mtsl.getButton_passforget_text_color()); if (mtsl.getButton_passforget_text() != 0) pass_forget.setText(mtsl.getButton_passforget_text()); if (mtsl.getPassforget_description_text_color() != 0) pass_forget_description.setTextColor(mtsl.getPassforget_description_text_color()); if (mtsl.getPassforget_description_text() != 0) pass_forget_description.setTextColor(mtsl.getPassforget_description_text()); if (mtsl.getEmail_text_color() != 0) email.setTextColor(mtsl.getEmail_text_color()); } buttonLogin.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { progressBarSecond.setVisibility(View.VISIBLE); layoutSecond.setVisibility(View.GONE); mListener.onLoginClicked(editTextPassword.getText().toString()); } }); pass_forget.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mListener.onRecoverPasswordClicked(); } }); view.setBackgroundColor(mtsl.getSecond_step_background_color()); return view; }