package waymaker.gen; // Copyright © 2016 Michael Allan. Licence MIT. import android.app.Activity; import android.os.Bundle; /** An Android activity with member extensions. */ public @ThreadRestricted("app main") class ActivityX extends Activity { /** The size of a scale-independent pixel as measured in physical pixels. Returns the value of * getResources.getDisplayMetrics.scaledDensity * cached (for speed) when this activity was created. * The value is {@linkplain ApplicationX#pxDP() pxDP} “scaled by the user’s font size”, * larger or smaller according to preference. A change of font size, e.g. by the Settings app, * will recreate the activity and thereby refresh the value. * * @see Resources § Dimension * @see Handling runtime changes */ public final float pxSP() { return pxSP; } private float pxSP; /* Final after onCreate. Bound here to activity because change of font size by test user (Settings app, 2016) does not recreate ApplicationX. Binding to the application would wrongly suggest that the value is a constant for the application thereby assignable, for example, within a view class as a (static final) named number. */ // - A c t i v i t y -------------------------------------------------------------------------------- protected @Override void onCreate( final Bundle inB ) { super.onCreate( inB ); // obeying API pxSP = getResources().getDisplayMetrics().scaledDensity; } }