Introduction

This is part of the Android Live Courses Season 1 series. In this season one we are looking at how to perform crud operations against mysql database backed by retrofit. In the process we are creating a full scientists app.

In this lesson we want to initialize Calligraphy, our custom font library.

App.java

Create a file called App.java in the root package of your project.

Add the following code:

package info.camposha.retrofitmysqlcrud;

import android.app.Application;

import io.github.inflationx.calligraphy3.CalligraphyConfig;
import io.github.inflationx.calligraphy3.CalligraphyInterceptor;
import io.github.inflationx.viewpump.ViewPump;

public class App extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        ViewPump.init(ViewPump.builder()
                .addInterceptor(new CalligraphyInterceptor(
                        new CalligraphyConfig.Builder()
                                .setDefaultFontPath("fonts/Roboto-Bold.ttf")
                                .setFontAttrId(R.attr.fontPath)
                                .build()))
                .build());
    }
}
//end

Let’s move to the next lesson.

Video Lesson(Recommended)

 

Conclusion

Now we’ve looked at the app class. That class is our Application class in that it derives from `android.app.Application`, which is an android component. It is this app class where we’ve loaded our custom fonts. We said we are using a library called Calligraphy as our font loading library.

 

Now move over to the next lesson.