Dongle
Dongle

Reputation: 23

How to use calligraphy library in Android

I want use Calligraphy library in my project, but in my application is use this code for change google map language :

@Override
protected void attachBaseContext(Context newBase) {
}

for use calligraphy i should use this code :

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

How can i use two attachBaseContext in my project?

Upvotes: 0

Views: 617

Answers (1)

Eugen Pechanec
Eugen Pechanec

Reputation: 38243

Actually it's pretty easy, just chain it:

@Override
protected void attachBaseContext(Context newBase) {
    newBase = MyContextWrapper.wrap(newBase, "fa_IR");
    super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}

Or you could extract a parent BaseActivity and apply Calligraphy to all your activities in one place. And override language only in the map activity. In that case it will look like your orginal code as each wrapper will be applied in a different class.

Upvotes: 1

Related Questions