Search in sources :

Example 1 with KcaUtils.getContextWithLocale

use of com.antest1.kcanotify.KcaUtils.getContextWithLocale in project kcanotify by antest1.

the class KcaExpeditionCheckViewService method onCreate.

public void onCreate() {
    super.onCreate();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(getApplicationContext())) {
        // Can not draw overlays: pass
        stopSelf();
    }
    try {
        active = true;
        locale = LocaleUtils.getResourceLocaleCode(KcaUtils.getStringPreferences(getApplicationContext(), PREF_KCA_LANGUAGE));
        ship_data = new ArrayList<>();
        checkdata = new HashMap<>();
        dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
        contextWithLocale = KcaUtils.getContextWithLocale(getApplicationContext(), getBaseContext());
        mInflater = LayoutInflater.from(contextWithLocale);
        mView = mInflater.inflate(R.layout.view_excheck_list, null);
        KcaUtils.resizeFullWidthView(getApplicationContext(), mView);
        mView.setVisibility(View.GONE);
        itemView = mView.findViewById(R.id.view_excheck_detail);
        mParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT, getWindowLayoutType(), WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT);
        mParams.gravity = Gravity.CENTER;
        mManager = (WindowManager) getSystemService(WINDOW_SERVICE);
        mManager.addView(mView, mParams);
        Display display = ((WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        displayWidth = size.x;
    } catch (Exception e) {
        e.printStackTrace();
        active = false;
        error_flag = true;
        stopSelf();
    }
}
Also used : Point(android.graphics.Point) KcaUtils.getStringFromException(com.antest1.kcanotify.KcaUtils.getStringFromException) WindowManager(android.view.WindowManager) Display(android.view.Display)

Aggregations

Point (android.graphics.Point)1 Display (android.view.Display)1 WindowManager (android.view.WindowManager)1 KcaUtils.getStringFromException (com.antest1.kcanotify.KcaUtils.getStringFromException)1