Exemplo n.º 1
0
 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);
   }
 }
Exemplo n.º 2
0
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode != RESULT_OK) {
      return;
    }
    Bitmap bm = null;
    ContentResolver resolver = getContentResolver();
    if (requestCode == REQUEST_CODE_PICK_IMAGE) {
      try {
        bm = null;
        Uri originalUri = data.getData();
        bm = MediaStore.Images.Media.getBitmap(resolver, originalUri);
        String[] proj = {MediaStore.Images.Media.DATA};
        Cursor cursor = managedQuery(originalUri, proj, null, null, null);
        int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        cursor.moveToFirst();
        String path = cursor.getString(column_index);
        Toast.makeText(getBaseContext(), "pick:" + path, Toast.LENGTH_SHORT).show();
        Bitmap bt = convertToBitmap(path, 100, 120);

        profile_circleimageview.setImageDrawable(new BitmapDrawable(bt));
        saveBitmap(bt);

      } catch (IOException e) {
      }
    } else if (requestCode == CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE) {
      //  Bitmap bt=convertToBitmap(path,100,120);
      bm = null;
      try {
        Uri originalUri = data.getData();
        bm = MediaStore.Images.Media.getBitmap(resolver, originalUri);
        String[] proj = {MediaStore.Images.Media.DATA};
        Cursor cursor = managedQuery(originalUri, proj, null, null, null);
        int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        cursor.moveToFirst();
        String path = cursor.getString(column_index);
        Bitmap bt = convertToBitmap(path, 100, 120);
        // Toast.makeText(getBaseContext(),"take:"+path,Toast.LENGTH_SHORT).show();
        profile_circleimageview.setImageDrawable(new BitmapDrawable(bt));
        saveBitmap(bt);

      } catch (IOException e) {
        Toast.makeText(getBaseContext(), "Exception", Toast.LENGTH_SHORT).show();
      }
    }
  }
Exemplo n.º 3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_profile);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    et_username = (TextView) findViewById(R.id.editUsername);

    et_email = (EditText) findViewById(R.id.editEmail);
    et_address = (EditText) findViewById(R.id.editAddress);
    et_password = (EditText) findViewById(R.id.editPassword);
    ib_avatar = (CircleImageView) findViewById(R.id.avatarEditProfile);
    ib_avatar.setImageDrawable(null);
    ib_avatar.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            showSelectImageDialog();
          }
        });
    client = new AsyncHttpClient();
    //        final ProgressGenerator progressGenerator = new ProgressGenerator(this);
    btnSave = (ActionProcessButton) findViewById(R.id.btnSave);
    btnSave.setMode(ActionProcessButton.Mode.ENDLESS);
    btnSave.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (checkingMissingInfo()) {
              Variables.refreshFlag = true;
              btnSave.setProgress(50);
              enableInput(false);
              if (avatarBitmap != null) {
                uploadImage(avatarBitmap);
              } else {
                saveChanges(originAvatarUrl);
              }
            }
          }
        });
    imageUploadClient = new AsyncHttpClient();
    imageUploadClient.addHeader("Authorization", "Client-ID 9806c7ef5d11150"); // TODO

    loadInfo();
    resetSaveButton();
    settingShowcase();
  }
Exemplo n.º 4
0
 private void beginCrop(Uri source) {
   ib_avatar.setImageDrawable(null);
   Uri destination = Uri.fromFile(new File(getCacheDir(), "cropped"));
   Crop.of(source, destination).asSquare().start(this);
 }