Example usage for android.os LocaleList setDefault

List of usage examples for android.os LocaleList setDefault

Introduction

In this page you can find the example usage for android.os LocaleList setDefault.

Prototype

public static void setDefault(@NonNull @Size(min = 1) LocaleList locales) 

Source Link

Document

Also sets the default locale by calling Locale.setDefault() with the first locale in the list.

Usage

From source file:com.android.settings.localepicker.LocaleDragAndDropAdapter.java

public void updateLocalesWhenAnimationStops(final LocaleList localeList) {
    if (localeList.equals(mLocalesToSetNext)) {
        return;/*from  www  .  j a  v  a 2  s  . c  o m*/
    }

    // This will only update the Settings application to make things feel more responsive,
    // the system will be updated later, when animation stopped.
    LocaleList.setDefault(localeList);

    mLocalesToSetNext = localeList;
    final RecyclerView.ItemAnimator itemAnimator = mParentView.getItemAnimator();
    itemAnimator.isRunning(new RecyclerView.ItemAnimator.ItemAnimatorFinishedListener() {
        @Override
        public void onAnimationsFinished() {
            if (mLocalesToSetNext == null || mLocalesToSetNext.equals(mLocalesSetLast)) {
                // All animations finished, but the locale list did not change
                return;
            }

            LocalePicker.updateLocales(mLocalesToSetNext);
            mLocalesSetLast = mLocalesToSetNext;
            mLocalesToSetNext = null;

            mNumberFormatter = NumberFormat.getNumberInstance(Locale.getDefault());
        }
    });
}