Example usage for android.graphics Paint ANTI_ALIAS_FLAG

List of usage examples for android.graphics Paint ANTI_ALIAS_FLAG

Introduction

In this page you can find the example usage for android.graphics Paint ANTI_ALIAS_FLAG.

Prototype

int ANTI_ALIAS_FLAG

To view the source code for android.graphics Paint ANTI_ALIAS_FLAG.

Click Source Link

Document

Paint flag that enables antialiasing when drawing.

Usage

From source file:com.cssweb.android.view.FTrendView.java

public void drawChart(Canvas canvas) throws JSONException {
    paint = new Paint(Paint.ANTI_ALIAS_FLAG); //
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(1);/*from  w  w  w .ja v a2 s.  c  om*/
    tPaint = new Paint();
    tPaint.setStyle(Paint.Style.STROKE);
    tPaint.setTypeface(Typeface.DEFAULT_BOLD);
    tPaint.setAntiAlias(true); //
    dataPaint = new Paint(Paint.ANTI_ALIAS_FLAG); //
    dataPaint.setStyle(Paint.Style.STROKE);
    dataPaint.setStrokeWidth(3);
    tPaint.setTextSize(dTextSize);
    axisLabelHeight = Font.getFontHeight(dTextSize);
    axisLabelWidth = (int) tPaint.measureText("0.00000") + offSet;
    klineWidth = width - axisLabelWidth;
    klineHeight = height - axisLabelHeight * 2 - iSLowerScreen;
    klineX = axisLabelWidth;
    klineY = axisLabelHeight;

    SPACE = Arith.div(klineWidth, count); //klineWidth/count;
    scale = klineHeight / (highPrice - lowPrice); //
    double ratio = (highPrice - lowPrice) / rowNum; //
    rowHeight = klineHeight / rowNum;
    colWeight = klineWidth / colNum;
    tPaint.setColor(GlobalColor.colorLabelName);
    tPaint.setTextAlign(Paint.Align.LEFT);

    /**
     * 
     */
    canvas.drawText(":" + quoteData.getJSONArray(isTrackNumber).getString(0), axisLabelWidth,
            axisLabelHeight - 5, tPaint);
    canvas.drawText(":" + quoteData.getJSONArray(isTrackNumber).getDouble(3), axisLabelWidth + width / 2,
            axisLabelHeight - 5, tPaint);
    paint.setColor(GlobalColor.clrGrayLine);
    /**
     * 
     */

    tPaint.setTextAlign(Paint.Align.RIGHT);
    for (int i = 0; i <= rowNum; i++) {
        if (i == 0 || i == rowNum) {
            canvas.drawLine(klineX, klineY + rowHeight * i, klineX + klineWidth, klineY + rowHeight * i, paint);
        } else {
            Graphics.drawDashline(canvas, klineX, klineY + rowHeight * i, klineX + klineWidth,
                    klineY + rowHeight * i, paint);
        }
        if (i == 0) {
            canvas.drawText(Utils.dataFormation(highPrice, 3), klineX,
                    klineY + rowHeight * i + axisLabelHeight / 2, tPaint);
        } else if (i == rowNum) {
            canvas.drawText(Utils.dataFormation(lowPrice, 3), klineX, klineY + rowHeight * i, tPaint);
        } else {
            double AxisLabelPrice = highPrice - ratio * i;
            canvas.drawText(Utils.dataFormation(AxisLabelPrice, 3), klineX,
                    klineY + rowHeight * i + axisLabelHeight / 2, tPaint);
        }
    }
    /**
     * 
     */
    for (int i = 0; i <= colNum; i++) {
        if (i == 0) {
            canvas.drawLine(klineX, klineY, klineX, klineY + klineHeight, paint);
        } else if (i == colNum) {
            canvas.drawLine(width - 1, klineY, width - 1, klineY + klineHeight, paint);
        } else {
            Graphics.drawDashline(canvas, klineX + colWeight * i, klineY, klineX + colWeight * i,
                    klineY + klineHeight, paint);
        }
    }

    /**
     * ?
     */
    double x1 = 0;
    double y1 = 0;
    double x2 = 0;
    double y2 = 0;
    double temp = 0;
    double tHeight = 0;
    dataPaint.setColor(GlobalColor.colorStockName);
    dataPaint.setStrokeWidth(3);
    for (int i = begin; i < (begin + count); i++) {
        temp = quoteData.getJSONArray(i).getDouble(3);
        if (i - begin == 0) {
            x1 = klineX + SPACE * (i - begin);
            x2 = klineX + SPACE * (i - begin + 1);
            tHeight = (temp - lowPrice) * scale; // tHeight = ( - ) *  
            y1 = axisLabelHeight + klineHeight - tHeight; //  - tHeight 
            y2 = axisLabelHeight + klineHeight - tHeight;
        } else {
            canvas.drawLine((int) x1, (int) y1, (int) x2, (int) y2, dataPaint);
            x1 = x2;
            x2 = klineX + SPACE * (i - begin + 1);
            tHeight = (temp - lowPrice) * scale;
            y1 = y2;
            y2 = axisLabelHeight + klineHeight - tHeight;
        }
    }
    /**
     * 
     */
    tPaint.setColor(GlobalColor.colorLabelName);
    tPaint.setTextAlign(Paint.Align.LEFT);
    canvas.drawText(quoteData.getJSONArray(begin).getString(0), axisLabelWidth,
            klineHeight + axisLabelHeight * 2 - 5, tPaint);
    canvas.drawText(quoteData.getJSONArray(begin + count - 1).getString(0),
            (float) (width - tPaint.measureText(quoteData.getJSONArray(begin + count - 1).getString(0))),
            klineHeight + axisLabelHeight * 2 - 5, tPaint);

    /**
     * 
     */
    if (isTrackStatus) {
        canvas.save();
        //??
        paint.setColor(GlobalColor.colorLine);
        canvas.drawLine(trackLineV, axisLabelHeight, trackLineV, klineHeight + axisLabelHeight, paint);
        canvas.restore();
    }
}

From source file:com.crs4.roodin.moduletester.CustomView.java

/**
 * @param canvas//w  w  w.ja v a 2 s.  co  m
 */
private void drawRadar(Canvas canvas) {
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.RED);
    paint.setAlpha(100);

    float rotation = currentRotation; //gRotationZ_deg + initialMapRotation;

    for (int i = -35; i < 35; i = i + 2) {
        float arrowX1 = (float) (translateX - Math.sin(Math.toRadians(rotation + i)) * 45);
        float arrowY1 = (float) (translateY - Math.cos(Math.toRadians(rotation + i)) * 45);
        canvas.drawLine(translateX, translateY, arrowX1, arrowY1, paint);

    }

    paint.setAlpha(100);
    paint.setColor(Color.RED);
    canvas.drawCircle(translateX, translateY, 7, paint);

    paint.setColor(Color.YELLOW);
    canvas.drawCircle(translateX, translateY, 6, paint);

    paint.setColor(Color.RED);
    canvas.drawCircle(translateX, translateY, 1, paint);
}

From source file:com.google.android.apps.santatracker.doodles.tilt.ColoredRectangleActor.java

public ColoredRectangleActor(Vector2D position, Vector2D dimens, String type) {
    super(position, Vector2D.get());

    this.dimens = dimens;
    this.type = type;
    this.zIndex = -1;

    if (type.equals(FAIRWAY_GREEN)) {
        this.zIndex = -2;
    }/* w  w  w.j a v a  2  s  .  c o m*/

    selectedDirection = Direction.NONE;
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(TYPE_TO_COLOR_MAP.get(type));
    paint.setStyle(Style.FILL);

    midpointPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    midpointPaint.setColor(Color.WHITE);

    updateExtents();
}

From source file:com.hippo.widget.Slider.java

@SuppressWarnings("deprecation")
private void init(Context context, AttributeSet attrs) {
    mContext = context;//from   w  w  w  .  j  a  va 2 s.  c  om
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextAlign(Paint.Align.CENTER);

    Resources resources = context.getResources();
    mBubbleMinWidth = resources.getDimensionPixelOffset(R.dimen.slider_bubble_width);
    mBubbleMinHeight = resources.getDimensionPixelOffset(R.dimen.slider_bubble_height);

    mBubble = new BubbleView(context, textPaint);
    mBubble.setScaleX(0.0f);
    mBubble.setScaleY(0.0f);
    AbsoluteLayout absoluteLayout = new AbsoluteLayout(context);
    absoluteLayout.addView(mBubble);
    absoluteLayout.setBackgroundDrawable(null);
    mPopup = new PopupWindow(absoluteLayout);
    mPopup.setOutsideTouchable(false);
    mPopup.setTouchable(false);
    mPopup.setFocusable(false);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Slider);
    textPaint.setColor(a.getColor(R.styleable.Slider_textColor, Color.WHITE));
    textPaint.setTextSize(a.getDimensionPixelSize(R.styleable.Slider_textSize, 12));

    updateTextSize();

    setRange(a.getInteger(R.styleable.Slider_start, 0), a.getInteger(R.styleable.Slider_end, 0));
    setProgress(a.getInteger(R.styleable.Slider_slider_progress, 0));
    mThickness = a.getDimension(R.styleable.Slider_thickness, 2);
    mRadius = a.getDimension(R.styleable.Slider_radius, 6);
    setColor(a.getColor(R.styleable.Slider_color, Color.BLACK));

    mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBgPaint.setColor(a.getBoolean(R.styleable.Slider_dark, false) ? 0x4dffffff : 0x42000000);

    a.recycle();

    mProgressAnimation = new ValueAnimator();
    mProgressAnimation.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
    mProgressAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(@NonNull ValueAnimator animation) {
            float value = (Float) animation.getAnimatedValue();
            mDrawPercent = value;
            mDrawProgress = Math.round(MathUtils.lerp((float) mStart, mEnd, value));
            updateBubblePosition();
            mBubble.setProgress(mDrawProgress);
            invalidate();
        }
    });

    mBubbleScaleAnimation = new ValueAnimator();
    mBubbleScaleAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(@NonNull ValueAnimator animation) {
            float value = (Float) animation.getAnimatedValue();
            mDrawBubbleScale = value;
            mBubble.setScaleX(value);
            mBubble.setScaleY(value);
            invalidate();
        }
    });
}

From source file:com.jaspersoft.android.jaspermobile.widget.AnnotationView.java

private void addPath() {
    Paint annotationPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    annotationPaint.setColor(mColor);/*from ww  w  .  j  a  v a2s  .c  o  m*/
    annotationPaint.setStyle(Paint.Style.STROKE);
    annotationPaint.setStrokeJoin(Paint.Join.ROUND);
    annotationPaint.setStrokeCap(Paint.Cap.ROUND);

    DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
    int strokeSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mSize, metrics);
    annotationPaint.setStrokeWidth(strokeSize);

    Path annotationPath = new Path();
    annotationPath.moveTo(mStartX, mStartY);

    mDrawingCache.add(new Pair<>(annotationPaint, annotationPath));
}

From source file:com.amitupadhyay.aboutexample.ui.widget.CollapsingTitleLayout.java

public CollapsingTitleLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    setWillNotDraw(false);//from w  w  w  . jav a 2  s  .co  m
    paint = new TextPaint(Paint.ANTI_ALIAS_FLAG);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingTitleLayout);
    final boolean isRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;

    // first check if all insets set the same
    titleInsetStart = titleInsetEnd = titleInsetBottom = a
            .getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInset, 0);
    titleInsetTop = titleInsetStart;

    if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetStart)) {
        final int insetStart = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInsetStart, 0);
        if (isRtl) {
            titleInsetEnd = insetStart;
        } else {
            titleInsetStart = insetStart;
        }
    }
    if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetTop)) {
        titleInsetTop = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInsetTop, 0);
    }
    if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetEnd)) {
        final int insetEnd = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInsetEnd, 0);
        if (isRtl) {
            titleInsetStart = insetEnd;
        } else {
            titleInsetEnd = insetEnd;
        }
    }
    if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetBottom)) {
        titleInsetBottom = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInsetBottom, 0);
    }

    final int textAppearance = a.getResourceId(R.styleable.CollapsingTitleLayout_android_textAppearance,
            android.R.style.TextAppearance);
    TypedArray atp = getContext().obtainStyledAttributes(textAppearance, R.styleable.CollapsingTextAppearance);
    paint.setColor(atp.getColor(R.styleable.CollapsingTextAppearance_android_textColor, Color.WHITE));
    collapsedTextSize = atp.getDimensionPixelSize(R.styleable.CollapsingTextAppearance_android_textSize, 0);
    if (atp.hasValue(R.styleable.CollapsingTextAppearance_font)) {
        paint.setTypeface(FontUtil.get(getContext(), atp.getString(R.styleable.CollapsingTextAppearance_font)));
    }
    atp.recycle();

    if (a.hasValue(R.styleable.CollapsingTitleLayout_collapsedTextSize)) {
        collapsedTextSize = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_collapsedTextSize, 0);
        paint.setTextSize(collapsedTextSize);
    }

    maxExpandedTextSize = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_maxExpandedTextSize,
            Integer.MAX_VALUE);
    lineHeightHint = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_lineHeightHint, 0);
    maxLines = a.getInteger(R.styleable.CollapsingTitleLayout_android_maxLines, 5);
    a.recycle();
}

From source file:com.aniruddhc.acemusic.player.NowPlayingActivity.PlaylistPagerFlippedFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_playlist_pager_flipped, container,
            false);//from w w w.j av  a2  s  . com
    mContext = getActivity().getApplicationContext();
    mApp = (Common) mContext;

    ratingBar = (RatingBar) rootView.findViewById(R.id.playlist_pager_flipped_rating_bar);
    lyricsRelativeLayout = (RelativeLayout) rootView.findViewById(R.id.lyricsRelativeLayout);
    lyricsTextView = (TextView) rootView.findViewById(R.id.playlist_pager_flipped_lyrics);
    headerTextView = (TextView) rootView.findViewById(R.id.playlist_pager_flipped_title);
    noLyricsFoundText = (TextView) rootView.findViewById(R.id.no_embedded_lyrics_found_text);

    lyricsTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
    lyricsTextView
            .setPaintFlags(lyricsTextView.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    headerTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
    headerTextView
            .setPaintFlags(headerTextView.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    noLyricsFoundText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
    noLyricsFoundText.setPaintFlags(
            noLyricsFoundText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    lyricsRelativeLayout.setOnLongClickListener(new OnLongClickListener() {

        @Override
        public boolean onLongClick(View arg0) {
            //Fire a broadcast that notifies the PlaylistPager to update flip back to the album art.
            Intent intent = new Intent(broadcastMessage);
            intent.putExtra("MESSAGE", broadcastMessage);

            //Initialize the local broadcast manager.
            localBroadcastManager = LocalBroadcastManager.getInstance(mContext);
            localBroadcastManager.sendBroadcast(intent);

            return true;
        }

    });

    //Get the file path of the current song.
    String updatedSongTitle = "";
    String updatedSongArtist = "";
    String songFilePath = "";
    String songId = "";
    MediaMetadataRetriever mmdr = new MediaMetadataRetriever();
    tempCursor = mApp.getService().getCursor();
    tempCursor.moveToPosition(
            mApp.getService().getPlaybackIndecesList().get(mApp.getService().getCurrentSongIndex()));
    if (tempCursor.getColumnIndex(DBAccessHelper.SONG_FILE_PATH) == -1) {
        //Retrieve the info from the file's metadata.
        songFilePath = tempCursor.getString(tempCursor.getColumnIndex(null));
        mmdr.setDataSource(songFilePath);

        updatedSongTitle = mmdr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE);
        updatedSongArtist = mmdr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST);

    } else {
        /* Check if the cursor has the SONG_FILE_PATH column. If it does, we're dealing 
         * with the SONGS table. If not, we're dealing with the PLAYLISTS table. We'll 
         * retrieve data from the appropriate columns using this info. */
        if (tempCursor.getColumnIndex(DBAccessHelper.SONG_FILE_PATH) == -1) {
            //We're dealing with the Playlists table.
            songFilePath = tempCursor.getString(tempCursor.getColumnIndex(DBAccessHelper.PLAYLIST_FILE_PATH));
            mmdr.setDataSource(songFilePath);

            updatedSongTitle = mmdr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE);
            updatedSongArtist = mmdr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST);
        } else {
            //We're dealing with the songs table.
            songFilePath = tempCursor.getString(tempCursor.getColumnIndex(DBAccessHelper.SONG_FILE_PATH));
            updatedSongTitle = tempCursor.getString(tempCursor.getColumnIndex(DBAccessHelper.SONG_TITLE));
            updatedSongArtist = tempCursor.getString(tempCursor.getColumnIndex(DBAccessHelper.SONG_ARTIST));
            songId = tempCursor.getString(tempCursor.getColumnIndex(DBAccessHelper.SONG_ID));
        }

    }

    headerTextView.setText(updatedSongTitle + " - " + updatedSongArtist);
    ratingBar.setStepSize(1);
    int rating = mApp.getDBAccessHelper().getSongRating(songId);
    ratingBar.setRating(rating);

    //Get the rating value for the song.
    AudioFile audioFile = null;
    File file = null;
    try {
        audioFile = null;
        file = new File(songFilePath);
        try {
            audioFile = AudioFileIO.read(file);
        } catch (CannotReadException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (org.jaudiotagger.tag.TagException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (ReadOnlyFileException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (InvalidAudioFrameException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    try {
        final AudioFile finalizedAudioFile = audioFile;
        final String finalSongFilePath = songFilePath;
        final String finalSongId = songId;
        ratingBar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {

            @Override
            public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
                //Change the rating in the DB and the actual audio file itself.

                Log.e("DEBUG", ">>>>>RATING: " + rating);

                try {
                    Tag tag = finalizedAudioFile.getTag();
                    tag.addField(FieldKey.RATING, "" + ((int) rating));
                } catch (KeyNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (FieldDataInvalidException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (Exception e) {
                    e.printStackTrace();
                    Log.e("DEBUG", ">>>>>>>RATING FIELD NOT FOUND");
                }

                try {
                    finalizedAudioFile.commit();
                } catch (CannotWriteException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (Exception e) {
                    e.printStackTrace();
                }

                mApp.getDBAccessHelper().setSongRating(finalSongId, (int) rating);

            }

        });

        //Check if the audio file has any embedded lyrics.
        String lyrics = null;
        try {
            Tag tag = audioFile.getTag();
            lyrics = tag.getFirst(FieldKey.LYRICS);

            if (lyrics == null || lyrics.isEmpty()) {
                lyricsTextView.setVisibility(View.GONE);
                noLyricsFoundText.setVisibility(View.VISIBLE);
                return rootView;
            }

            //Since the song has embedded lyrics, display them in the layout.
            lyricsTextView.setVisibility(View.VISIBLE);
            noLyricsFoundText.setVisibility(View.GONE);
            lyricsTextView.setText(lyrics);

        } catch (Exception e) {
            e.printStackTrace();
            lyricsTextView.setVisibility(View.GONE);
            noLyricsFoundText.setVisibility(View.VISIBLE);
            return rootView;
        }
    } catch (Exception e) {
        e.printStackTrace();
        //Can't do much here.
    }

    return rootView;
}

From source file:io.plaidapp.core.ui.widget.CollapsingTitleLayout.java

public CollapsingTitleLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    setWillNotDraw(false);/*from  www. j  a v  a  2s. c  o m*/
    paint = new TextPaint(Paint.ANTI_ALIAS_FLAG);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingTitleLayout);
    final boolean isRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;

    // first check if all insets set the same
    titleInsetStart = titleInsetEnd = titleInsetBottom = a
            .getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInset, 0);
    titleInsetTop = titleInsetStart;

    if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetStart)) {
        final int insetStart = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInsetStart, 0);
        if (isRtl) {
            titleInsetEnd = insetStart;
        } else {
            titleInsetStart = insetStart;
        }
    }
    if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetTop)) {
        titleInsetTop = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInsetTop, 0);
    }
    if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetEnd)) {
        final int insetEnd = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInsetEnd, 0);
        if (isRtl) {
            titleInsetStart = insetEnd;
        } else {
            titleInsetEnd = insetEnd;
        }
    }
    if (a.hasValue(R.styleable.CollapsingTitleLayout_titleInsetBottom)) {
        titleInsetBottom = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_titleInsetBottom, 0);
    }

    // first check TextAppearance for text attributes
    if (a.hasValue(R.styleable.CollapsingTitleLayout_android_textAppearance)) {
        final int textAppearanceId = a.getResourceId(R.styleable.CollapsingTitleLayout_android_textAppearance,
                android.R.style.TextAppearance);
        TypedArray ta = getContext().obtainStyledAttributes(textAppearanceId,
                R.styleable.CollapsingTitleLayout);
        // default collapsedTextSize to regular android:textSize in the TextAppearance
        collapsedTextSize = ta.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_android_textSize, 0);
        parseTextAttrs(ta);
        ta.recycle();
    }

    // then check view for text attributes
    parseTextAttrs(a);
    a.recycle();
}

From source file:com.aniruddhc.acemusic.player.Drawers.InnerNavigationDrawerFragment.java

@SuppressLint("NewApi")
@Override//  w  w  w  . j a v  a2 s .c  o m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.navigation_drawer_layout, null);
    mApp = (Common) getActivity().getApplicationContext();

    browsersListView = (ListView) rootView.findViewById(R.id.browsers_list_view);
    librariesListView = (ListView) rootView.findViewById(R.id.libraries_list_view);
    browsersHeaderText = (TextView) rootView.findViewById(R.id.browsers_header_text);
    librariesHeaderText = (TextView) rootView.findViewById(R.id.libraries_header_text);
    librariesColorTagImageView = (ImageView) rootView.findViewById(R.id.library_color_tag);
    librariesIcon = (ImageView) rootView.findViewById(R.id.libraries_icon);
    librariesIcon.setImageResource(UIElementsHelper.getIcon(getActivity(), "libraries"));

    Drawable backgroundDrawable;
    if (mApp.getCurrentTheme() == Common.DARK_THEME) {
        backgroundDrawable = new ColorDrawable(0x191919);
    } else {
        backgroundDrawable = getResources().getDrawable(R.drawable.holo_white_selector);
    }

    int currentAPI = android.os.Build.VERSION.SDK_INT;
    if (currentAPI < android.os.Build.VERSION_CODES.JELLY_BEAN) {
        rootView.setBackgroundDrawable(backgroundDrawable);
    } else {
        rootView.setBackground(backgroundDrawable);
    }

    //Set the header text fonts/colors.
    browsersHeaderText.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light"));
    librariesHeaderText.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light"));
    browsersHeaderText.setPaintFlags(browsersHeaderText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    librariesHeaderText.setPaintFlags(librariesHeaderText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    //Apply the Browser ListView's adapter.
    List<String> titles = Arrays
            .asList(getActivity().getResources().getStringArray(R.array.sliding_menu_array));
    NavigationDrawerAdapter slidingMenuAdapter = new NavigationDrawerAdapter(getActivity(),
            new ArrayList<String>(titles));
    browsersListView.setAdapter(slidingMenuAdapter);
    browsersListView.setOnItemClickListener(browsersClickListener);
    setListViewHeightBasedOnChildren(browsersListView);

    /*//Apply the Libraries ListView's adapter.
    userLibrariesDBHelper = new DBAccessHelper(getActivity().getApplicationContext());
    cursor = userLibrariesDBHelper.getAllUniqueLibraries();
    NavigationDrawerLibrariesAdapter slidingMenuLibrariesAdapter = new NavigationDrawerLibrariesAdapter(getActivity(), cursor);
    librariesListView.setAdapter(slidingMenuLibrariesAdapter);
    setListViewHeightBasedOnChildren(librariesListView);*/
    librariesListView.setVisibility(View.GONE);
    librariesHeaderText.setVisibility(View.GONE);
    librariesIcon.setVisibility(View.GONE);

    return rootView;
}

From source file:com.dotit.gireve.ihm.viewpager.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle,
            R.style.Widget_CirclePageIndicator);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_orientation, defaultOrientation);
    mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke//from w ww .  ja v a2s  . c o  m
            .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}