inflater

An implementation of ContextWrapper that provides pre and post inflation callbacks

License

License

GroupId

GroupId

io.github.minyushov
ArtifactId

ArtifactId

inflater
Last Version

Last Version

1.2.0
Release Date

Release Date

Type

Type

aar
Description

Description

inflater
An implementation of ContextWrapper that provides pre and post inflation callbacks
Project URL

Project URL

https://github.com/minyushov/inflater
Source Code Management

Source Code Management

https://github.com/minyushov/inflater/tree/master

Download inflater

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.minyushov/inflater/ -->
<dependency>
    <groupId>io.github.minyushov</groupId>
    <artifactId>inflater</artifactId>
    <version>1.2.0</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/io.github.minyushov/inflater/
implementation 'io.github.minyushov:inflater:1.2.0'
// https://jarcasting.com/artifacts/io.github.minyushov/inflater/
implementation ("io.github.minyushov:inflater:1.2.0")
'io.github.minyushov:inflater:aar:1.2.0'
<dependency org="io.github.minyushov" name="inflater" rev="1.2.0">
  <artifact name="inflater" type="aar" />
</dependency>
@Grapes(
@Grab(group='io.github.minyushov', module='inflater', version='1.2.0')
)
libraryDependencies += "io.github.minyushov" % "inflater" % "1.2.0"
[io.github.minyushov/inflater "1.2.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Inflater

Maven Central

An implementation of ContextWrapper that provides pre- and post-inflation callbacks.

Getting started

Include inflater as a Gradle compile dependency:

dependencies {
    implementation 'io.github.minyushov:inflater:$version'
}

Implement InflationInterceptor or PostInflationListener:

private final ContextWrapper.InflationInterceptor inflationInterceptor = new ContextWrapper.InflationInterceptor() {
  @Nullable
  @Override
  public View onCreateView(@NonNull Context context, @Nullable View parent, @NonNull String name, @Nullable AttributeSet attrs) {
    if (name.equals("TextView")) {
      return new CustomTextView(context, attrs);
    }
    return null;
  }
};
private final ContextWrapper.PostInflationListener postInflationListener = new ContextWrapper.PostInflationListener() {
  @Override
  public void onViewCreated(@NonNull View view, @Nullable AttributeSet attrs) {
    if (view instanceof TextView) {
      ((TextView) view).setTypeface(Typeface.MONOSPACE);
    }
  }
};

Attach interceptors and listeners to an Activity using ContextWrapper:

public class MainActivity extends AppCompatActivity {
  @Override
  protected void attachBaseContext(Context baseContext) {
    super.attachBaseContext(new ContextWrapper.Builder(baseContext)
         .addInterceptor(inflationInterceptor)
         .addListener(postInflationListener)
         .build());
  }
}

From this point all TextViews will be replaced with CustomTextViews, and all TextViews will use monospace typeface.

Versions

Version
1.2.0