Example usage for android.widget ImageView getId

List of usage examples for android.widget ImageView getId

Introduction

In this page you can find the example usage for android.widget ImageView getId.

Prototype

@IdRes
@ViewDebug.CapturedViewProperty
public int getId() 

Source Link

Document

Returns this view's identifier.

Usage

From source file:com.swater.meimeng.activity.oomimg.SimpleThumbnailCursorAdapter.java

@Override
public void setViewImage(ImageView v, String value) {
    final int id = v.getId();
    for (int i = 0; i < mImageIDs.length; i++) {
        if (id == mImageIDs[i]) {
            final List<String> alternates = mAlternateImages.get(id);
            if (alternates != null && alternates.size() > 1) {
                final Cursor c = getCursor();
                for (final String alternate : alternates) {
                    final int idx = c.getColumnIndex(alternate);
                    if (c.isNull(idx)) {
                        continue;
                    } else {
                        // only set the first one that isn't null
                        setViewImageAndTag(v, c.getString(idx), defaultImages[i]);
                        break;
                    }/*from   w w  w  .j a v  a  2s  .  c o  m*/
                }
            } else {
                setViewImageAndTag(v, value, defaultImages[i]);
            }
        }
    }
}

From source file:com.github.omadahealth.slidepager.lib.views.SlideChartView.java

/**
 * Init the {@link android.graphics.Color} of the {@link #mChartBarList}
 *///from  ww w . j a v a 2 s  .c o  m
private void initBarColorsAndSize() {
    for (ImageView imageView : mChartBarList) {
        imageView.setBackgroundColor(mChartBarColor);
        if (imageView.getId() != R.id.progress_bottom_axis) {
            imageView.setMinimumHeight((int) (mChartBarSize / 2.0f));
        }
    }
}

From source file:com.retroteam.studio.retrostudio.EditorLandscape.java

/**
 * Start MeasureEditor with an intent with all the data.
 * @param view/*from ww w  . j av a2s. c o m*/
 */

private void editMeasure(View view) {

    Intent intent = new Intent(this, MeasureEditor.class);

    intent.putExtra("Project", theproject);
    ImageView viewi = (ImageView) view;
    intent.putExtra(MEASURE_TRACK, (int) viewi.getTag(R.id.TAG_ROW));
    intent.putExtra(MEASURE, (int) viewi.getTag(R.id.TAG_COLUMN));
    intent.putExtra(MEASURE_TITLE, Integer.toString((int) viewi.getTag(R.id.TAG_COLUMN)) + ","
            + Integer.toString((int) viewi.getTag(R.id.TAG_ROW)));
    intent.putExtra("measureID", viewi.getId());
    intent.putExtra("SourceActivity", "EditorLandscape");
    intent.putExtra("guiSNAP", (int) viewi.getTag(R.id.TAG_GUISNAP));
    intent.putExtra("filledNotes", (ArrayList<int[]>) viewi.getTag(R.id.TAG_FILLED_NOTES));
    intent.putExtra("tsBeats", TS_BEATS);
    intent.putExtra("tsNotes", TS_NOTES);
    startActivityForResult(intent, 123);
}

From source file:com.htc.dotdesign.ToolBoxService.java

private void setSelectedColor(ImageView button) {
    Drawable select = getResources().getDrawable(R.drawable.dot_design_select);
    select.setColorFilter(getResources().getColor(R.color.overlay_color), Mode.SRC_IN);

    ImageView selectedIcon = (ImageView) mPalette.findViewById(R.id.selected);
    selectedIcon.setBackground(select);//  w  w w  .ja  v  a2  s.c o  m

    Resources res = getResources();
    int id = button.getId();
    int buttonLeft = button.getLeft();
    int buttonTop = button.getTop();
    int m1 = res.getDimensionPixelSize(R.dimen.margin_l);
    int m2 = res.getDimensionPixelSize(R.dimen.margin_m);
    int colorSize = res.getDimensionPixelSize(R.dimen.hv01);
    if (id == R.id.btn_color_11 || id == R.id.btn_color_12 || id == R.id.btn_color_13
            || id == R.id.btn_color_14) {
        buttonTop = m2;
    } else if (id == R.id.btn_color_21 || id == R.id.btn_color_22 || id == R.id.btn_color_23
            || id == R.id.btn_color_24) {
        buttonTop = m2 + colorSize + m1;
    } else {
        buttonTop = m2 + 2 * colorSize + 2 * m1;
    }

    if (id == R.id.btn_color_11 || id == R.id.btn_color_21 || id == R.id.btn_color_31) {
        buttonLeft = m2;
    } else if (id == R.id.btn_color_12 || id == R.id.btn_color_22 || id == R.id.btn_color_32) {
        buttonLeft = 3 * m2 + colorSize;
    } else if (id == R.id.btn_color_13 || id == R.id.btn_color_23 || id == R.id.btn_color_33) {
        buttonLeft = 5 * m2 + 2 * colorSize;
    } else {
        buttonLeft = 7 * m2 + 3 * colorSize;
    }

    int widthDiff = res.getDimensionPixelSize(R.dimen.select_color_width) - colorSize;
    int heightDiff = res.getDimensionPixelSize(R.dimen.select_color_height) - colorSize;
    int marginLeft = buttonLeft - (widthDiff / 2);
    int marginTop = buttonTop - (heightDiff / 2);

    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) selectedIcon.getLayoutParams();
    params.setMargins(marginLeft, marginTop, 0, 0);
    selectedIcon.setLayoutParams(params);
    selectedIcon.setVisibility(View.VISIBLE);
}

From source file:com.fabernovel.alertevoirie.ReportDetailsActivity.java

private void setPictureToImageView(String pictureName, ImageView imageView) {
    Bitmap picture = null;// www  . ja  va  2  s.  c o  m

    try {
        InputStream in = openFileInput(pictureName);
        picture = BitmapFactory.decodeStream(in);
        in.close();

        LayerDrawable d = (LayerDrawable) getResources().getDrawable(R.drawable.editable_picture_frame);
        if (picture.getHeight() > picture.getWidth()) {
            Matrix m = new Matrix();
            m.postRotate(-90);
            picture = Bitmap.createBitmap(picture, 0, 0, picture.getWidth(), picture.getHeight(), m, true);
        }
        picture = Bitmap.createScaledBitmap(picture, d.getIntrinsicWidth(), d.getIntrinsicHeight(), true);

        d.setDrawableByLayerId(R.id.picture, new BitmapDrawable(picture));
        imageView.setImageDrawable(d);

        if (!hasPic)
            hasPic = (imageView.getId() == R.id.ImageView_far);

        // WTF ?
        // if (hasPic && (imageView.getId() == R.id.ImageView_far)) {
        // loadZoom();
        // }

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:net.idlesoft.android.apps.github.activities.Commit.java

protected void buildUi() {
    // Get the commit data for that commit ID so that we can get the
    // tree ID and filename.
    try {/*from  w ww.  java 2  s .c om*/
        final ImageView authorImage = (ImageView) findViewById(R.id.commit_view_author_gravatar);
        final ImageView committerImage = (ImageView) findViewById(R.id.commit_view_committer_gravatar);

        // If the committer is the author then just show them as the
        // author, otherwise show
        // both people
        ((TextView) findViewById(R.id.commit_view_author_name)).setText(mAuthorName);
        if (mAuthorGravatar != null) {
            authorImage.setImageBitmap(mAuthorGravatar);
        } else {
            authorImage.setImageBitmap(Commit.loadGravatarByLoginName(Commit.this, mAuthor));
        }

        // Set the commit message
        ((TextView) findViewById(R.id.commit_view_message)).setText(mJson.getString("message"));

        final SimpleDateFormat dateFormat = new SimpleDateFormat(Hubroid.GITHUB_TIME_FORMAT);
        Date commit_time;
        Date current_time;
        String authorDate = "";

        try {
            commit_time = dateFormat.parse(mJson.getString("authored_date"));
            current_time = dateFormat.parse(dateFormat.format(new Date()));
            ((TextView) findViewById(R.id.commit_view_author_time))
                    .setText(Commit.getHumanDate(current_time, commit_time));

            commit_time = dateFormat.parse(mJson.getString("committed_date"));
            authorDate = Commit.getHumanDate(current_time, commit_time);

        } catch (final ParseException e) {
            e.printStackTrace();
        }

        if (!mAuthor.equals(mCommitter)) {
            // They are not the same person, make the author visible and
            // fill in the details
            ((LinearLayout) findViewById(R.id.commit_view_author_layout)).setVisibility(View.VISIBLE);
            ((TextView) findViewById(R.id.commit_view_committer_name)).setText(mCommitterName);
            ((TextView) findViewById(R.id.commit_view_committer_time)).setText(authorDate);
            if (mCommitterGravatar != null) {
                committerImage.setImageBitmap(mCommitterGravatar);
            } else {
                committerImage.setImageBitmap(Commit.loadGravatarByLoginName(Commit.this, mCommitter));
            }
        }

        final OnClickListener onGravatarClick = new OnClickListener() {
            public void onClick(final View v) {
                final Intent i = new Intent(Commit.this, Profile.class);
                if (v.getId() == authorImage.getId()) {
                    i.putExtra("username", mAuthor);
                } else if (v.getId() == committerImage.getId()) {
                    i.putExtra("username", mCommitter);
                } else {
                    return;
                }
                startActivity(i);
            }
        };

        if ((mAuthor != null) && !mAuthor.equals("")) {
            authorImage.setOnClickListener(onGravatarClick);
        }
        if ((mCommitter != null) && !mCommitter.equals("")) {
            committerImage.setOnClickListener(onGravatarClick);
        }

        int filesAdded, filesRemoved, filesChanged;

        try {
            filesAdded = mJson.getJSONArray("added").length();
        } catch (final JSONException e) {
            filesAdded = 0;
        }
        try {
            filesRemoved = mJson.getJSONArray("removed").length();
        } catch (final JSONException e) {
            filesRemoved = 0;
        }
        try {
            filesChanged = mJson.getJSONArray("modified").length();
        } catch (final JSONException e) {
            filesChanged = 0;
        }

        final Button filesAddedButton = (Button) findViewById(R.id.btn_commit_addedFiles);
        final Button filesRemovedButton = (Button) findViewById(R.id.btn_commit_removedFiles);
        final Button filesChangedButton = (Button) findViewById(R.id.btn_commit_changedFiles);

        Log.d("debug", filesAdded + " " + filesRemoved + " " + filesChanged);
        if (filesAdded > 0) {
            filesAddedButton.setText(filesAdded + " files added");
        } else {
            filesAddedButton.setVisibility(View.GONE);
        }
        if (filesRemoved > 0) {
            filesRemovedButton.setText(filesRemoved + " files removed");
        } else {
            filesRemovedButton.setVisibility(View.GONE);
        }
        if (filesChanged > 0) {
            filesChangedButton.setText(filesChanged + " files changed");
        } else {
            filesChangedButton.setVisibility(View.GONE);
        }

        filesAddedButton.setOnClickListener(new OnClickListener() {
            public void onClick(final View v) {
                final Intent i = new Intent(Commit.this, DiffFilesList.class);
                i.putExtra("type", "added");
                i.putExtra("json", mJson.toString());
                i.putExtra("repo_owner", mRepositoryOwner);
                i.putExtra("repo_name", mRepositoryName);
                startActivity(i);
            }
        });
        filesRemovedButton.setOnClickListener(new OnClickListener() {
            public void onClick(final View v) {
                final Intent i = new Intent(Commit.this, DiffFilesList.class);
                i.putExtra("type", "removed");
                i.putExtra("json", mJson.toString());
                i.putExtra("repo_owner", mRepositoryOwner);
                i.putExtra("repo_name", mRepositoryName);
                startActivity(i);
            }
        });
        filesChangedButton.setOnClickListener(new OnClickListener() {
            public void onClick(final View v) {
                final Intent i = new Intent(Commit.this, DiffFilesList.class);
                i.putExtra("type", "modified");
                i.putExtra("json", mJson.toString());
                i.putExtra("repo_owner", mRepositoryOwner);
                i.putExtra("repo_name", mRepositoryName);
                startActivity(i);
            }
        });
    } catch (final JSONException e) {
        e.printStackTrace();
    }
}