当前位置: 首页>>代码示例>>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;未经允许,请勿转载。