當前位置: 首頁>>代碼示例>>Java>>正文


Java UiModeManager類代碼示例

本文整理匯總了Java中android.app.UiModeManager的典型用法代碼示例。如果您正苦於以下問題:Java UiModeManager類的具體用法?Java UiModeManager怎麽用?Java UiModeManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


UiModeManager類屬於android.app包,在下文中一共展示了UiModeManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onSharedPreferenceChanged

import android.app.UiModeManager; //導入依賴的package包/類
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
    if (s.equals("nightmode_use")) {
        boolean night = sharedPreferences.getBoolean("nightmode_use", false);
        int startH = sharedPreferences.getInt("nightmode_use_start", AnotherRSS.Config.DEFAULT_NIGHT_START);
        int stopH = sharedPreferences.getInt("nightmode_use_stop", AnotherRSS.Config.DEFAULT_NIGHT_STOP);
        if (night && AnotherRSS.inTimeSpan(startH, stopH)) {
            umm.setNightMode(UiModeManager.MODE_NIGHT_YES);
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
        } else {
            umm.setNightMode(UiModeManager.MODE_NIGHT_NO);
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
        }
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
            getActivity().recreate();
        }
    }
}
 
開發者ID:no-go,項目名稱:AnotherRSS,代碼行數:19,代碼來源:MyPreferenceFragment.java

示例2: getDeviceType

import android.app.UiModeManager; //導入依賴的package包/類
/**
 * Returns true when running Android TV
 *
 * @param c Context to detect UI Mode.
 * @return true when device is running in tv mode, false otherwise.
 */
public static String getDeviceType(Context c) {
    UiModeManager uiModeManager = (UiModeManager) c.getSystemService(Context.UI_MODE_SERVICE);
    int modeType = uiModeManager.getCurrentModeType();
    switch (modeType){
        case Configuration.UI_MODE_TYPE_TELEVISION:
            return "TELEVISION";
        case Configuration.UI_MODE_TYPE_WATCH:
            return "WATCH";
        case Configuration.UI_MODE_TYPE_NORMAL:
            String type = isTablet(c) ? "TABLET" : "PHONE";
            return type;
        case Configuration.UI_MODE_TYPE_UNDEFINED:
            return "UNKOWN";
        default:
            return "";
    }
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:24,代碼來源:Utils.java

示例3: mapNightModeToYesNo

import android.app.UiModeManager; //導入依賴的package包/類
private int mapNightModeToYesNo(int mode) {
    switch (mode) {
        case -1:
            switch (((UiModeManager) this.mContext.getSystemService("uimode")).getNightMode()) {
                case 0:
                    return 0;
                case 2:
                    return 2;
                default:
                    return 1;
            }
        case 0:
            if (getTwilightManager().isNight()) {
                return 2;
            }
            return 1;
        case 2:
            return 2;
        default:
            return 1;
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:23,代碼來源:AppCompatDelegateImplV14.java

示例4: setupNightModeSwitch

import android.app.UiModeManager; //導入依賴的package包/類
private void setupNightModeSwitch() {
    // 設置夜間模式
    uiManager = (UiModeManager) getActivity().getSystemService(Context.UI_MODE_SERVICE);
    nightModeSwitch = (SwitchPreference) getPreferenceManager().findPreference("night_mode_switch");
    nightModeSwitch.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            boolean nextNightMode = !PreferenceHelper.isNightModeEnabled();
            if (nextNightMode) {
                uiManager.setNightMode(UiModeManager.MODE_NIGHT_YES);
            } else {
                uiManager.setNightMode(UiModeManager.MODE_NIGHT_NO);
            }
            return true;
        }
    });
}
 
開發者ID:dianlujitao,項目名稱:BigNews,代碼行數:18,代碼來源:SettingsActivity.java

示例5: mapNightModeToYesNo

import android.app.UiModeManager; //導入依賴的package包/類
@BinaryNightMode
private int mapNightModeToYesNo(@NightMode final int mode) {
    switch (mode) {
        case MODE_NIGHT_AUTO:
            return getTwilightManager().isNight() ? MODE_NIGHT_YES : MODE_NIGHT_NO;
        case MODE_NIGHT_FOLLOW_SYSTEM:
            final UiModeManager uiModeManager = (UiModeManager)
                    mContext.getSystemService(Context.UI_MODE_SERVICE);
            switch (uiModeManager.getNightMode()) {
                case UiModeManager.MODE_NIGHT_YES:
                    return MODE_NIGHT_YES;
                case UiModeManager.MODE_NIGHT_AUTO:
                    return MODE_NIGHT_AUTO;
                case UiModeManager.MODE_NIGHT_NO:
                default:
                    return MODE_NIGHT_NO;
            }
        case MODE_NIGHT_YES:
            return MODE_NIGHT_YES;
        case MODE_NIGHT_NO:
        default:
            return MODE_NIGHT_NO;
    }
}
 
開發者ID:GigigoGreenLabs,項目名稱:permissionsModule,代碼行數:25,代碼來源:AppCompatDelegateImplV14.java

示例6: onSharedPreferenceChanged

import android.app.UiModeManager; //導入依賴的package包/類
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
    if (s.equals("nightmode_use")) {
        boolean night = sharedPreferences.getBoolean("nightmode_use", false);
        int startH = sharedPreferences.getInt("nightmode_use_start", ViboraApp.Config.DEFAULT_NIGHT_START);
        int stopH = sharedPreferences.getInt("nightmode_use_stop", ViboraApp.Config.DEFAULT_NIGHT_STOP);
        if (night && ViboraApp.inTimeSpan(startH, stopH)) {
            umm.setNightMode(UiModeManager.MODE_NIGHT_YES);
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
        } else {
            umm.setNightMode(UiModeManager.MODE_NIGHT_NO);
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
        }
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
            getActivity().recreate();
        }
    }
}
 
開發者ID:no-go,項目名稱:ViboraFeed,代碼行數:19,代碼來源:MyPreferenceFragment.java

示例7: onCreate

import android.app.UiModeManager; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LogHelper.d(TAG, "onCreate");
    Intent newIntent;
    UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
    if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
        LogHelper.d(TAG, "Running on a TV Device");
        newIntent = new Intent(this, TvPlaybackActivity.class);
    } else {
        LogHelper.d(TAG, "Running on a non-TV Device");
        newIntent = new Intent(this, MusicPlayerActivity.class);
    }
    startActivity(newIntent);
    finish();
}
 
開發者ID:mrinalgit-dev,項目名稱:MrinalMusicPlayer,代碼行數:17,代碼來源:NowPlayingActivity.java

示例8: SoundWaveWallpaperEngine

import android.app.UiModeManager; //導入依賴的package包/類
public SoundWaveWallpaperEngine() {

            // Enable automatic NightMode switch
            UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
            uiModeManager.setNightMode(UiModeManager.MODE_NIGHT_AUTO);

            Paint wavePaint = new Paint();
            wavePaint.setColor(waveColor);
            wavePaint.setAlpha(150);

            // Define all three waves
            wave1 = new Wave(wavePaint, 50, 15, timePerValue);
            wave2 = new Wave(wavePaint, 35, 20, timePerValue);
            wave3 = new Wave(wavePaint, 25, 25, timePerValue);

            handler.post(drawRunner);
        }
 
開發者ID:ManuelBauer,項目名稱:soundscape-livewallpaper,代碼行數:18,代碼來源:MainWallpaperService.java

示例9: onCreate

import android.app.UiModeManager; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate");
    Intent newIntent;
    UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
    if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
        Log.d(TAG, "Running on a TV Device");
        // TODO: add launch Android TV "Now Playing" activity
        // newIntent = new Intent(this, TvNowPlayingActivity.class);
        throw new UnsupportedOperationException("Android TV is not yet supported");
    } else {
        Log.d(TAG, "Running on a non-TV Device");
        newIntent = new Intent(this, MusicPlayerActivity.class);
    }
    startActivity(newIntent);
    finish();
}
 
開發者ID:SoumyaParida,項目名稱:MyGaana-Universal,代碼行數:19,代碼來源:NowPlayingActivity.java

示例10: notifyNewRootView

import android.app.UiModeManager; //導入依賴的package包/類
public static void notifyNewRootView(Activity activity)
{
    View rootView = activity.findViewById(android.R.id.content);
    UiModeManager modeMgr = (UiModeManager) activity.getSystemService(Context.UI_MODE_SERVICE);

    if (modeMgr.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION)
    {
        // Increase view padding on TVs
        float scale = activity.getResources().getDisplayMetrics().density;
        int verticalPaddingPixels = (int) (TV_VERTICAL_PADDING_DP*scale + 0.5f);
        int horizontalPaddingPixels = (int) (TV_HORIZONTAL_PADDING_DP*scale + 0.5f);

        rootView.setPadding(horizontalPaddingPixels, verticalPaddingPixels,
                horizontalPaddingPixels, verticalPaddingPixels);
    }
}
 
開發者ID:moonlight-stream,項目名稱:moonlight-android,代碼行數:17,代碼來源:UiHelper.java

示例11: onResume

import android.app.UiModeManager; //導入依賴的package包/類
@Override
protected void onResume() {
    Log.d(AnotherRSS.TAG, "onResume");
    AnotherRSS.withGui = true;
    new DbExpunge().execute();

    SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    boolean night = mPreferences.getBoolean("nightmode_use", false);
    if (night) {
        int startH = mPreferences.getInt("nightmode_use_start", AnotherRSS.Config.DEFAULT_NIGHT_START);
        int stopH = mPreferences.getInt("nightmode_use_stop", AnotherRSS.Config.DEFAULT_NIGHT_STOP);
        if (AnotherRSS.inTimeSpan(startH, stopH) && umm.getNightMode() != UiModeManager.MODE_NIGHT_YES) {
            umm.setNightMode(UiModeManager.MODE_NIGHT_YES);
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
        }
        if (!AnotherRSS.inTimeSpan(startH, stopH) && umm.getNightMode() != UiModeManager.MODE_NIGHT_NO) {
            umm.setNightMode(UiModeManager.MODE_NIGHT_NO);
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
        }
    } else {
        if (umm.getNightMode() == UiModeManager.MODE_NIGHT_YES) {
            umm.setNightMode(UiModeManager.MODE_NIGHT_NO);
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
        }
    }
    super.onResume();
}
 
開發者ID:no-go,項目名稱:AnotherRSS,代碼行數:28,代碼來源:MainActivity.java

示例12: onCreate

import android.app.UiModeManager; //導入依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    // 創建Activity時設置夜間模式
    uiManager = (UiModeManager) getSystemService(Context.UI_MODE_SERVICE);
    if (PreferenceHelper.isNightModeEnabled()) {
        uiManager.setNightMode(UiModeManager.MODE_NIGHT_YES);
    }
    super.onCreate(savedInstanceState);
}
 
開發者ID:dianlujitao,項目名稱:BigNews,代碼行數:10,代碼來源:BaseActivity.java

示例13: isRunningOnOUYA

import android.app.UiModeManager; //導入依賴的package包/類
public boolean isRunningOnOUYA() {
    try {
        PackageInfo packageInfo = getPackageManager().getPackageInfo("tv.ouya", 0);
        return true;
    } catch (PackageManager.NameNotFoundException e) {
    }
    UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
    return (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) || Globals.OuyaEmulation;
}
 
開發者ID:NeoTerm,項目名稱:NeoTerm,代碼行數:10,代碼來源:MainActivity.java

示例14: isAndroidTV

import android.app.UiModeManager; //導入依賴的package包/類
public boolean isAndroidTV() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
        return uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
    } else {
        return false;
    }
}
 
開發者ID:pe-pan,項目名稱:flappy,代碼行數:9,代碼來源:TlappyActivity.java

示例15: onCreate

import android.app.UiModeManager; //導入依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();

    UiModeManager uiManager = (UiModeManager) getSystemService(Context.UI_MODE_SERVICE);
    uiManager.setNightMode(UiModeManager.MODE_NIGHT_AUTO);
}
 
開發者ID:sourceallies,項目名稱:zonebeacon,代碼行數:8,代碼來源:ZoneBeaconApplication.java


注:本文中的android.app.UiModeManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。