List of usage examples for android.content.res TypedArray recycle
public void recycle()
From source file:com.afayear.android.client.activity.DualPaneActivity.java
protected int getPaneBackground() { final TypedArray a = obtainStyledAttributes(new int[] { android.R.attr.windowBackground }); final int background = a.getResourceId(0, 0); a.recycle(); return background; }
From source file:android.support.design.internal.ScrimInsetsRelativeLayout.java
public ScrimInsetsRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyleAttr, R.style.Widget_Design_ScrimInsetsFrameLayout); mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground); a.recycle(); setWillNotDraw(true); // No need to draw until the insets are adjusted ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() { @Override//from www . ja v a 2 s. c o m public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { if (null == mInsets) { mInsets = new Rect(); } mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()); setWillNotDraw(mInsets.isEmpty() || mInsetForeground == null); ViewCompat.postInvalidateOnAnimation(ScrimInsetsRelativeLayout.this); return insets.consumeSystemWindowInsets(); } }); }
From source file:butter.droid.widget.ScrimInsetsFrameLayout.java
private void init(Context context, AttributeSet attrs, int defStyle) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsView, defStyle, 0); if (a == null) { return;/*w w w .ja v a 2 s . c o m*/ } mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetForegroundColor); a.recycle(); setWillNotDraw(true); }
From source file:android.support.designox.internal.ScrimInsetsFrameLayout.java
public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyleAttr, R.style.Widget_Design_ScrimInsetsFrameLayout); mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground); a.recycle(); setWillNotDraw(true); // No need to draw until the insets are adjusted ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4ox.view.OnApplyWindowInsetsListener() { @Override//from w w w .jav a 2s .c o m public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { if (null == mInsets) { mInsets = new Rect(); } mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()); onInsetsChanged(mInsets); setWillNotDraw(mInsets.isEmpty() || mInsetForeground == null); ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this); return insets.consumeSystemWindowInsets(); } }); }
From source file:android.support.design.internal.ScrimInsetsFrameLayout.java
public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyleAttr, R.style.Widget_Design_ScrimInsetsFrameLayout); mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground); a.recycle(); setWillNotDraw(true); // No need to draw until the insets are adjusted ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() { @Override/* ww w .ja v a 2 s . c o m*/ public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { if (null == mInsets) { mInsets = new Rect(); } mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()); onInsetsChanged(insets); setWillNotDraw(!insets.hasSystemWindowInsets() || mInsetForeground == null); ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this); return insets.consumeSystemWindowInsets(); } }); }
From source file:android.support.design.widget.BottomSheetDialog.java
boolean shouldWindowCloseOnTouchOutside() { if (!mCanceledOnTouchOutsideSet) { if (Build.VERSION.SDK_INT < 11) { mCanceledOnTouchOutside = true; } else {//from w ww.ja va2s. co m TypedArray a = getContext() .obtainStyledAttributes(new int[] { android.R.attr.windowCloseOnTouchOutside }); mCanceledOnTouchOutside = a.getBoolean(0, true); a.recycle(); } mCanceledOnTouchOutsideSet = true; } return mCanceledOnTouchOutside; }
From source file:arun.com.chromer.settings.widgets.ColorPreference.java
private void init(Context context, AttributeSet attrs) { setWidgetLayoutResource(R.layout.widget_color_preference); DEFAULT_COLOR = ContextCompat.getColor(getContext(), R.color.colorPrimary); if (attrs != null) { TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ColorPreference); int colorRes = ta.getResourceId(R.styleable.ColorPreference_color, 0); if (colorRes != 0) { color = ContextCompat.getColor(getContext(), colorRes); }//w w w. j a va 2 s. co m ta.recycle(); } }
From source file:au.com.lumo.ameego.uiUtils.MultiSwipeRefreshLayout.java
public MultiSwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MultiSwipeRefreshLayout, 0, 0); mForegroundDrawable = a.getDrawable(R.styleable.MultiSwipeRefreshLayout_foreground); if (mForegroundDrawable != null) { mForegroundDrawable.setCallback(this); setWillNotDraw(false);// w ww. j a v a2 s . com } a.recycle(); }
From source file:com.nextgis.maplibui.formcontrol.Sign.java
protected void init() { //1. get clean int[] attrs = new int[] { R.attr.ic_clear }; TypedArray ta = getContext().obtainStyledAttributes(attrs); mCleanImage = ta.getDrawable(0);// ww w. j a v a2s . c om ta.recycle(); mClearBuff = (int) (getContext().getResources().getDisplayMetrics().density * CLEAR_BUFF_DP); mClearImageSize = (int) (getContext().getResources().getDisplayMetrics().density * CLEAR_IMAGE_SIZE_DP); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(3); mPaint.setDither(true); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); boolean bDark = PreferenceManager.getDefaultSharedPreferences(getContext()) .getString(SettingsConstantsUI.KEY_PREF_THEME, "light").equals("dark"); if (bDark) mPaint.setColor(Color.WHITE); else mPaint.setColor(Color.BLACK); mPath = new Path(); mPaths.add(mPath); }
From source file:cat.ereza.customactivityoncrash.activity.DefaultErrorReportActivity.java
@SuppressLint("PrivateResource") @Override//from www . j a v a 2 s . com protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); //This is needed to avoid a crash if the developer has not specified //an app-level theme that extends Theme.AppCompat TypedArray a = obtainStyledAttributes(R.styleable.AppCompatTheme); if (!a.hasValue(R.styleable.AppCompatTheme_windowActionBar)) { setTheme(R.style.Theme_AppCompat_Light_DarkActionBar); } a.recycle(); setContentView(R.layout.customactivityoncrash_default_error_activity); //Close/restart button logic: //If a class if set, use restart. //Else, use close and just finish the app. //It is recommended that you follow this logic if implementing a custom error activity. Button restartButton = (Button) findViewById(R.id.customactivityoncrash_error_activity_restart_button); final CaocConfig config = CustomActivityOnCrash.getConfigFromIntent(getIntent()); if (config.isShowRestartButton() && config.getRestartActivityClass() != null) { restartButton.setText(R.string.customactivityoncrash_error_activity_restart_app); restartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CustomActivityOnCrash.restartApplication(DefaultErrorReportActivity.this, config); } }); } else { restartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CustomActivityOnCrash.closeApplication(DefaultErrorReportActivity.this, config); } }); } Button moreInfoButton = (Button) findViewById(R.id.customactivityoncrash_error_activity_more_info_button); if (config.isShowErrorDetails()) { moreInfoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //We retrieve all the error data and show it AlertDialog dialog = new AlertDialog.Builder(DefaultErrorReportActivity.this) .setTitle(R.string.customactivityoncrash_error_activity_error_details_title) .setMessage(CustomActivityOnCrash .getAllErrorDetailsFromIntent(DefaultErrorReportActivity.this, getIntent())) .setPositiveButton(R.string.customactivityoncrash_error_activity_error_details_close, null) .setNeutralButton(R.string.customactivityoncrash_error_activity_error_details_copy, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { copyErrorToClipboard(); Toast.makeText(DefaultErrorReportActivity.this, R.string.customactivityoncrash_error_activity_error_details_copied, Toast.LENGTH_SHORT).show(); } }) .show(); TextView textView = (TextView) dialog.findViewById(android.R.id.message); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources() .getDimension(R.dimen.customactivityoncrash_error_activity_error_details_text_size)); } }); } else { moreInfoButton.setVisibility(View.GONE); } Integer defaultErrorActivityDrawableId = config.getErrorDrawable(); ImageView errorImageView = ((ImageView) findViewById(R.id.customactivityoncrash_error_activity_image)); if (defaultErrorActivityDrawableId != null) { errorImageView.setImageDrawable( ResourcesCompat.getDrawable(getResources(), defaultErrorActivityDrawableId, getTheme())); } }