Example usage for android.content.res TypedArray getInt

List of usage examples for android.content.res TypedArray getInt

Introduction

In this page you can find the example usage for android.content.res TypedArray getInt.

Prototype

public int getInt(@StyleableRes int index, int defValue) 

Source Link

Document

Retrieve the integer value for the attribute at index.

Usage

From source file:com.dean.phonesafe.ui.SlideSwitch.java

public SlideSwitch(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    listener = null;/*from  www.j  a v  a2  s.c o m*/
    paint = new Paint();
    //
    paint.setAntiAlias(true);
    //?Xml?
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.slideswitch);
    color_theme = a.getColor(R.styleable.slideswitch_themeColor, DEFAULT_COLOR_THEME);
    isOpen = a.getBoolean(R.styleable.slideswitch_isOpen, false);
    shape = a.getInt(R.styleable.slideswitch_shape, SHAPE_RECT);
    a.recycle();
}

From source file:com.aksalj.viewpagerslideshow.LinePageIndicator.java

public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//w ww. ja va 2 s .  c  om

    final Resources res = getResources();

    //Load defaults from resources
    final int defaultLineStyle = res.getInteger(R.integer.default_line_style);
    final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
    final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
    final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
    final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
    final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator, defStyle, 0);

    mBoxStyle = a.getInt(R.styleable.LinePageIndicator_lineStyle, defaultLineStyle) == 1;
    mCentered = a.getBoolean(R.styleable.LinePageIndicator_centered, mBoxStyle ? false : defaultCentered);
    mLineWidth = a.getDimension(R.styleable.LinePageIndicator_lineWidth, defaultLineWidth);
    mGapWidth = a.getDimension(R.styleable.LinePageIndicator_gapWidth, mBoxStyle ? 0.0f : defaultGapWidth);
    setStrokeWidth(a.getDimension(R.styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintUnselected
            .setColor(a.getColor(R.styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor));
    mPaintSelected.setColor(a.getColor(R.styleable.LinePageIndicator_selectedColor, defaultSelectedColor));

    Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

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

From source file:com.github.nutomic.pegasus.activities.AreaList.java

/**
 * Context item on ListView selected, allow choosing the associated sound 
 * profile, renaming, learning or deleting the area.
 *///from w  ww  .  j  a v  a2 s . c o m
@Override
public boolean onContextItemSelected(MenuItem item) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    final Database db = Database.getInstance(this);
    switch (item.getItemId()) {
    case R.id.rename:
        renameArea(info.id, getAreaName((AdapterContextMenuInfo) item.getMenuInfo()));
        return true;
    case R.id.learn:
        new AlertDialog.Builder(this).setTitle(R.string.arealist_learn)
                .setItems(R.array.arealist_learn_area_strings, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        TypedArray millisecondValues = getResources()
                                .obtainTypedArray(R.array.arealist_learn_area_values);
                        long interval = millisecondValues.getInt(which, 0);

                        if (interval > 0) {
                            // Add future cells during interval.
                            Intent i = new Intent(AreaList.this, LocationService.class);
                            i.putExtra(LocationService.MESSAGE_LEARN_AREA, info.id);
                            i.putExtra(LocationService.MESSAGE_LEARN_INTERVAL, interval);
                            startService(i);
                            // Add only the current cell from database.
                            interval = 0;
                        } else {
                            // Do not pass the negativity to Database.
                            interval = -interval;
                        }

                        final long selectionStartTime = System.currentTimeMillis() - interval;
                        new UpdateTask() {

                            @Override
                            protected Long doInBackground(Void... params) {
                                ContentValues cv = new ContentValues();
                                cv.put(CellColumns.AREA_ID, info.id);
                                // Set current area in current cell and in any cell that was visited during interval.
                                db.getWritableDatabase().update(CellColumns.TABLE_NAME, cv,
                                        CellColumns._ID + " = (SELECT " + CellLogColumns.CELL_ID + " FROM "
                                                + CellLogColumns.TABLE_NAME + " ORDER BY "
                                                + CellLogColumns.TIMESTAMP + " DESC Limit 1) OR "
                                                + CellColumns._ID + " IN (SELECT " + CellLogColumns.CELL_ID
                                                + " FROM " + CellLogColumns.TABLE_NAME + " WHERE "
                                                + CellLogColumns.TIMESTAMP + " > ?)",
                                        new String[] { Long.toString(selectionStartTime) });
                                return null;
                            }
                        }.execute((Void) null);
                    }
                }).show();
        return true;
    case R.id.delete:
        new AlertDialog.Builder(this).setTitle(R.string.arealist_delete)
                .setMessage(R.string.arealist_delete_message)
                .setPositiveButton(android.R.string.yes, new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        new UpdateTask() {

                            @Override
                            protected Long doInBackground(Void... params) {
                                // Don't delete default area.
                                if (info.id != AreaColumns.AREA_DEFAULT) {
                                    db.getWritableDatabase().delete(AreaColumns.TABLE_NAME,
                                            AreaColumns._ID + " = ?", new String[] { Long.toString(info.id) });
                                    // Reset cells to default area.
                                    ContentValues cv = new ContentValues();
                                    cv.put(CellColumns.AREA_ID, AreaColumns.AREA_DEFAULT);
                                    db.getWritableDatabase().update(CellColumns.TABLE_NAME, cv,
                                            CellColumns.AREA_ID + " = ?",
                                            new String[] { Long.toString(info.id) });
                                }
                                return null;
                            }
                        }.execute((Void) null);
                    }
                }).setNegativeButton(android.R.string.no, null).show();
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.codetroopers.betterpickers.radialtimepicker.RadialSelectorView.java

void setTheme(TypedArray themeColors) {
    mPaint.setColor(themeColors.getColor(R.styleable.BetterPickersDialogs_bpRadialPointerColor,
            ContextCompat.getColor(getContext(), R.color.bpBlue)));
    mSelectionAlpha = themeColors.getInt(R.styleable.BetterPickersDialogs_bpRadialPointerAlpha, 35);
}

From source file:com.ant.sunshine.app.fragments.ForecastFragment.java

@Override
public void onInflate(Context activity, AttributeSet attrs, Bundle savedInstanceState) {
    super.onInflate(activity, attrs, savedInstanceState);
    TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.ForecastFragment, 0, 0);
    mChoiceMode = a.getInt(R.styleable.ForecastFragment_android_choiceMode, AbsListView.CHOICE_MODE_NONE);
    mAutoSelectView = a.getBoolean(R.styleable.ForecastFragment_autoSelectView, false);
    mHoldForTransition = a.getBoolean(R.styleable.ForecastFragment_sharedElementTransitions, false);
    a.recycle();/*  w  w  w.j  a v a 2 s  .  c o m*/
}

From source file:com.example.waitou.rxjava.LoadingView.java

public LoadingView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mRing = new Ring();
    bounds = new Rect();
    mPaint = new Paint();
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(mRing.strokeWidth);

    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LoadingView, 0, 0);
        setColor(a.getInt(R.styleable.LoadingView_loadding_color, DEFAULT_COLOR));
        setRingStyle(a.getInt(R.styleable.LoadingView_ring_style, RING_STYLE_SQUARE));
        setProgressStyle(a.getInt(R.styleable.LoadingView_progress_style, PROGRESS_STYLE_MATERIAL));
        setStrokeWidth(a.getDimension(R.styleable.LoadingView_ring_width, dp2px(STROKE_WIDTH)));
        setCenterRadius(a.getDimension(R.styleable.LoadingView_ring_radius, dp2px(CENTER_RADIUS)));
        a.recycle();/*from   ww  w . ja v a  2s. c o  m*/
    }
}

From source file:com.me.harris.androidanimations._06_touch.swipelistview.SwipeListView.java

/**
 * Init ListView/*from  w  w  w  . jav a 2 s.  c om*/
 *
 * @param attrs AttributeSet
 */
private void init(AttributeSet attrs) {

    int swipeMode = SWIPE_MODE_BOTH;
    boolean swipeOpenOnLongPress = true;
    boolean swipeCloseAllItemsWhenMoveList = true;
    int swipeFrontView = 0;
    int swipeBackView = 0;
    long swipeAnimationTime = 0;
    float swipeOffsetLeft = 0;
    float swipeOffsetRight = 0;

    int swipeActionLeft = SWIPE_ACTION_REVEAL;
    int swipeActionRight = SWIPE_ACTION_REVEAL;

    if (attrs != null) {
        TypedArray styled = getContext().obtainStyledAttributes(attrs, R.styleable.SwipeListView);
        swipeMode = styled.getInt(R.styleable.SwipeListView_swipeMode, SWIPE_MODE_BOTH);
        swipeActionLeft = styled.getInt(R.styleable.SwipeListView_swipeActionLeft, SWIPE_ACTION_REVEAL);
        swipeActionRight = styled.getInt(R.styleable.SwipeListView_swipeActionRight, SWIPE_ACTION_REVEAL);
        swipeOffsetLeft = styled.getDimension(R.styleable.SwipeListView_swipeOffsetLeft, 0);
        swipeOffsetRight = styled.getDimension(R.styleable.SwipeListView_swipeOffsetRight, 0);
        swipeOpenOnLongPress = styled.getBoolean(R.styleable.SwipeListView_swipeOpenOnLongPress, true);
        swipeAnimationTime = styled.getInteger(R.styleable.SwipeListView_swipeAnimationTime, 0);
        swipeCloseAllItemsWhenMoveList = styled
                .getBoolean(R.styleable.SwipeListView_swipeCloseAllItemsWhenMoveList, true);
        swipeFrontView = styled.getResourceId(R.styleable.SwipeListView_swipeFrontView, 0);
        swipeBackView = styled.getResourceId(R.styleable.SwipeListView_swipeBackView, 0);
    }

    if (swipeFrontView == 0 || swipeBackView == 0) {
        throw new RuntimeException("Missed attribute swipeFrontView or swipeBackView");
    }

    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    touchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    touchListener = new SwipeListViewTouchListener(this, swipeFrontView, swipeBackView);
    if (swipeAnimationTime > 0) {
        touchListener.setAnimationTime(swipeAnimationTime);
    }
    touchListener.setRightOffset(swipeOffsetRight);
    touchListener.setLeftOffset(swipeOffsetLeft);
    touchListener.setSwipeActionLeft(swipeActionLeft);
    touchListener.setSwipeActionRight(swipeActionRight);
    touchListener.setSwipeMode(swipeMode);
    touchListener.setSwipeClosesAllItemsWhenListMoves(swipeCloseAllItemsWhenMoveList);
    touchListener.setSwipeOpenOnLongPress(swipeOpenOnLongPress);
    setOnTouchListener(touchListener);
    setOnScrollListener(touchListener.makeScrollListener());
}

From source file:com.eutectoid.dosomething.picker.PlacePickerFragment.java

@Override
public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) {
    super.onInflate(activity, attrs, savedInstanceState);
    TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.picker_place_picker_fragment);

    setRadiusInMeters(a.getInt(R.styleable.picker_place_picker_fragment_radius_in_meters, radiusInMeters));
    setResultsLimit(a.getInt(R.styleable.picker_place_picker_fragment_results_limit, resultsLimit));
    if (a.hasValue(R.styleable.picker_place_picker_fragment_results_limit)) {
        setSearchText(a.getString(R.styleable.picker_place_picker_fragment_search_text));
    }//from   www. j  a  v a2 s.c  o  m
    showSearchBox = a.getBoolean(R.styleable.picker_place_picker_fragment_show_search_box, showSearchBox);

    a.recycle();
}

From source file:cn.refactor.ultraindicator.lib.UltraIndicatorView.java

private void init(AttributeSet attrs) {
    TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.UltraIndicatorView);
    mCheckedColor = ta.getColor(R.styleable.UltraIndicatorView_checkedColor, DEFAULT_CHECKED_COLOR);
    mUnCheckedColor = ta.getColor(R.styleable.UltraIndicatorView_uncheckedColor, DEFAULT_UNCHECKED_COLOR);
    mAnimDuration = ta.getInt(R.styleable.UltraIndicatorView_duration, DEFAULT_ANIM_DURATION);
    ta.recycle();//from ww w  .  j av  a 2  s . c  o  m

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStyle(Paint.Style.FILL);
}

From source file:com.dlazaro66.wheelindicatorview.WheelIndicatorView.java

private void init(AttributeSet attrs) {
    TypedArray attributesArray = getContext().getTheme().obtainStyledAttributes(attrs,
            R.styleable.WheelIndicatorView, 0, 0);

    int itemsLineWidth = attributesArray.getDimensionPixelSize(R.styleable.WheelIndicatorView_itemsLineWidth,
            DEFAULT_ITEM_LINE_WIDTH);//from   w w w .j  a  v  a2 s.co m
    setItemsLineWidth(itemsLineWidth);

    int filledPercent = attributesArray.getInt(R.styleable.WheelIndicatorView_filledPercent,
            DEFAULT_FILLED_PERCENT);
    setFilledPercent(filledPercent);

    int bgColor = attributesArray.getColor(R.styleable.WheelIndicatorView_backgroundColor, -1);
    if (bgColor != -1)
        setBackgroundColor(bgColor);

    this.wheelIndicatorItems = new ArrayList<>();
    this.wheelItemsAngles = new ArrayList<>();

    itemArcPaint = new Paint();
    itemArcPaint.setStyle(Paint.Style.STROKE);
    itemArcPaint.setStrokeWidth(itemsLineWidth * 2);
    itemArcPaint.setAntiAlias(true);

    innerBackgroundCirclePaint = new Paint();
    innerBackgroundCirclePaint.setColor(INNER_BACKGROUND_CIRCLE_COLOR);
    innerBackgroundCirclePaint.setStyle(Paint.Style.STROKE);
    innerBackgroundCirclePaint.setStrokeWidth(itemsLineWidth * 2);
    innerBackgroundCirclePaint.setAntiAlias(true);

    itemEndPointsPaint = new Paint();
    itemEndPointsPaint.setAntiAlias(true);
}