All Projects → InflationX → Viewpump

InflationX / Viewpump

Licence: apache-2.0
View Inflation you can intercept.

Programming Languages

java
68154 projects - #9 most used programming language
kotlin
9241 projects

Projects that are alternatives of or similar to Viewpump

filter
Go语言的数据过滤包,由 数据输入、格式化、校验、输出 几个部份组成。
Stars: ✭ 22 (-97.01%)
Mutual labels:  interceptor
Martian
The HTTP abstraction library for Clojure/script, supporting Swagger, Schema, re-frame and more
Stars: ✭ 294 (-60.05%)
Mutual labels:  interceptor
Uni Simple Router
a simple, lightweight routing plugin that supports interception and lifecycle triggering
Stars: ✭ 481 (-34.65%)
Mutual labels:  interceptor
RetryRequestInterceptor-for-OkHttp
a interceptor for OkHttp which can save failed request in storage and will retry request until success or retry times over limit , or request live time over limit
Stars: ✭ 42 (-94.29%)
Mutual labels:  interceptor
Turbo
A lightweight microservice tool, turn your grpc|thrift APIs into HTTP APIs!
Stars: ✭ 275 (-62.64%)
Mutual labels:  interceptor
Muuntaja
Clojure library for fast http api format negotiation, encoding and decoding.
Stars: ✭ 304 (-58.7%)
Mutual labels:  interceptor
BothamNetworking
Networking Framework written in Swift.
Stars: ✭ 26 (-96.47%)
Mutual labels:  interceptor
Kakapo.js
🐦 Next generation mocking framework in Javascript
Stars: ✭ 535 (-27.31%)
Mutual labels:  interceptor
Fetch Intercept
Interceptor library for the native fetch command inspired by angular http intercepts.
Stars: ✭ 279 (-62.09%)
Mutual labels:  interceptor
Angular Token
🔑 Token based authentication service for Angular with interceptor and multi-user support. Works best with devise token auth for Rails. Example:
Stars: ✭ 376 (-48.91%)
Mutual labels:  interceptor
DotNETCarRental
Daily car rental simulation with ASP.NET.
Stars: ✭ 13 (-98.23%)
Mutual labels:  interceptor
wxapp-api-interceptors
微信小程序api拦截器
Stars: ✭ 99 (-86.55%)
Mutual labels:  interceptor
Ng Http Loader
🍡 Smart angular HTTP interceptor - Intercepts automagically HTTP requests and shows a spinkit spinner / loader / progress bar
Stars: ✭ 327 (-55.57%)
Mutual labels:  interceptor
kras
Efficient server proxying and mocking in Node.js. 💪
Stars: ✭ 18 (-97.55%)
Mutual labels:  interceptor
Xniffer
A swift network profiler built on top of URLSession.
Stars: ✭ 488 (-33.7%)
Mutual labels:  interceptor
okhttp-awssigner
An OkHttp interceptor for signing requests with AWSv4 signatures
Stars: ✭ 14 (-98.1%)
Mutual labels:  interceptor
Ok2curl
Convert OkHttp requests into curl logs.
Stars: ✭ 295 (-59.92%)
Mutual labels:  interceptor
Testing Nestjs
A repository to show off to the community methods of testing NestJS including Unit Tests, Integration Tests, E2E Tests, pipes, filters, interceptors, GraphQL, Mongo, TypeORM, and more!
Stars: ✭ 685 (-6.93%)
Mutual labels:  interceptor
Axios Auth Refresh
Library that helps you implement automatic refresh of authorization via axios interceptors. You can easily intercept the original request when it fails, refresh the authorization and continue with the original request, without user even noticing.
Stars: ✭ 502 (-31.79%)
Mutual labels:  interceptor
Go Grpc Middleware
Golang gRPC Middlewares: interceptor chaining, auth, logging, retries and more.
Stars: ✭ 4,170 (+466.58%)
Mutual labels:  interceptor

ViewPump

View inflation you can intercept.

ViewPump installs a custom LayoutInflater via a ContextThemeWrapper and provides an API of pre/post-inflation interceptors.

Getting started

Dependency

Include the dependency Download (.aar) :

dependencies {
    implementation 'io.github.inflationx:viewpump:2.0.3'
}

Usage

Define your interceptor. Below is a somewhat arbitrary example of a post-inflation interceptor that prefixes the text in a TextView.

public class TextUpdatingInterceptor implements Interceptor {
    @Override
    public InflateResult intercept(Chain chain) {
        InflateResult result = chain.proceed(chain.request());
        if (result.view() instanceof TextView) {
            // Do something to result.view()
            // You have access to result.context() and result.attrs()
            TextView textView = (TextView) result.view();
            textView.setText("[Prefix] " + textView.getText());
        }
        return result;
    }
}

Below is an example of a pre-inflation interceptor that returns a CustomTextView when a TextView was defined in the layout's XML.

public class CustomTextViewInterceptor implements Interceptor {
    @Override
    public InflateResult intercept(Chain chain) {
        InflateRequest request = chain.request();
        if (request.name().endsWith("TextView")) {
            CustomTextView view = new CustomTextView(request.context(), request.attrs());
            return InflateResult.builder()
                    .view(view)
                    .name(view.getClass().getName())
                    .context(request.context())
                    .attrs(request.attrs())
                    .build();
        } else {
            return chain.proceed(request);
        }
    }
}

Installation

Add your interceptors to the ViewPump.builder(), in your Application class in the #onCreate() method and init the ViewPump. The order of the interceptors is important since they form the interceptor chain of requests and results.

An interceptor may choose to return a programmatically instantiated view rather than letting the default inflation occur, in which case interceptors added after it will be skipped. For this reason, it is better to add your post-inflation interceptors before the pre-inflation interceptors

@Override
public void onCreate() {
    super.onCreate();
    ViewPump.init(ViewPump.builder()
                .addInterceptor(new TextUpdatingInterceptor())
                .addInterceptor(new CustomTextViewInterceptor())
                .build());
    //....
}

Inject into Context

Wrap the Activity Context:

@Override
protected void attachBaseContext(Context newBase) {
    super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
}

You're good to go!

To see more ideas for potential use cases, check out the Recipes wiki page.

Collaborators

Licence

Copyright 2017 InflationX

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].