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


Java Configuration類代碼示例

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


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

示例1: checkScreenSize

import android.content.res.Configuration; //導入依賴的package包/類
public void checkScreenSize() {

        int screenSize = getResources().getConfiguration().screenLayout &
                Configuration.SCREENLAYOUT_SIZE_MASK;

        switch (screenSize) {
            case Configuration.SCREENLAYOUT_SIZE_XLARGE:

                column_no = 4;
                break;
            case Configuration.SCREENLAYOUT_SIZE_UNDEFINED:
                column_no = 3;
                break;
            case Configuration.SCREENLAYOUT_SIZE_LARGE:
                column_no = 3;
                break;
            case Configuration.SCREENLAYOUT_SIZE_NORMAL:
                column_no = 2;
                break;
            case Configuration.SCREENLAYOUT_SIZE_SMALL:
                column_no = 2;
                break;
            default:
                column_no = 2;
        }
    }
 
開發者ID:MuditSrivastava,項目名稱:Canvas-Vision,代碼行數:27,代碼來源:DiscoverFragment.java

示例2: onConfigurationChanged

import android.content.res.Configuration; //導入依賴的package包/類
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    //當屏幕變為橫屏時
    if (isLandscape()) {
        //設置為全屏
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        mControlLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
        mRoomInfoLayout.setVisibility(View.GONE);
        mFullScreen.setVisibility(View.GONE);
        mDanmakuView.show();
        isShowDanmu = true;
    } else {
        //退出全屏
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        mRoomInfoLayout.setVisibility(View.VISIBLE);
        mFullScreen.setVisibility(View.VISIBLE);
        mDanmakuView.hide();
        isShowDanmu = false;
    }

    updateVideoLayoutParams();
}
 
開發者ID:yinyiliang,項目名稱:RabbitCloud,代碼行數:25,代碼來源:LiveRoomActivity.java

示例3: adjustFullScreen

import android.content.res.Configuration; //導入依賴的package包/類
/**
 * Adjusts immersive full-screen flags depending on the screen orientation.
 *
 * @param config The current {@link Configuration}.
 */
private void adjustFullScreen(Configuration config) {
    final View decorView = getWindow().getDecorView();
    if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        decorView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        mScrollView.setVisibility(View.GONE);
        mMovieView.setAdjustViewBounds(false);
    } else {
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        mScrollView.setVisibility(View.VISIBLE);
        mMovieView.setAdjustViewBounds(true);
    }
}
 
開發者ID:googlesamples,項目名稱:android-PictureInPicture,代碼行數:24,代碼來源:MediaSessionPlaybackActivity.java

示例4: resetRecyclerViewPadding

import android.content.res.Configuration; //導入依賴的package包/類
private void resetRecyclerViewPadding(int orientation) {
    if (mRecyclerView == null) return;

    int padding = 0;
    int navBar = 0;
    if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        padding = getActivity().getResources().getDimensionPixelSize(R.dimen.content_padding);
        navBar = padding;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        boolean tabletMode = getResources().getBoolean(R.bool.android_helpers_tablet_mode);
        if (tabletMode || orientation == Configuration.ORIENTATION_PORTRAIT) {
            navBar = WindowHelper.getNavigationBarHeight(getActivity());
        }
    }
    mRecyclerView.setPadding(padding, padding, 0, navBar);
}
 
開發者ID:danimahardhika,項目名稱:wallpaperboard,代碼行數:19,代碼來源:AboutFragment.java

示例5: detectLanguage

import android.content.res.Configuration; //導入依賴的package包/類
@SuppressWarnings("deprecation")
public static void detectLanguage(Context context) {
	SharedPreferences setting = PreferenceManager
			.getDefaultSharedPreferences(context);
	String language = setting.getString(Util.PREF_LANGUAGE, "auto");
	Resources res = context.getResources();
	Configuration conf = res.getConfiguration();
	switch (language) {
		case "en":
		case "zh":
			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
				conf.setLocale(new Locale(language));
			} else {
				conf.locale = new Locale(language);
			}
			break;
		default:
			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
				conf.setLocale(Resources.getSystem().getConfiguration().getLocales().get(0));
			} else {
				conf.locale = Resources.getSystem().getConfiguration().locale;
			}
	}
	DisplayMetrics dm = res.getDisplayMetrics();
	res.updateConfiguration(conf, dm);
}
 
開發者ID:collaction,項目名稱:content-farm-blocker-android,代碼行數:27,代碼來源:Util.java

示例6: simulateDayNight

import android.content.res.Configuration; //導入依賴的package包/類
void simulateDayNight(int currentSetting) {
    final int DAY = 0;
    final int NIGHT = 1;
    final int FOLLOW_SYSTEM = 3;

    int currentNightMode = getResources().getConfiguration().uiMode
            & Configuration.UI_MODE_NIGHT_MASK;
    if (currentSetting == DAY && currentNightMode != Configuration.UI_MODE_NIGHT_NO) {
        AppCompatDelegate.setDefaultNightMode(
                AppCompatDelegate.MODE_NIGHT_NO);
    } else if (currentSetting == NIGHT && currentNightMode != Configuration.UI_MODE_NIGHT_YES) {
        AppCompatDelegate.setDefaultNightMode(
                AppCompatDelegate.MODE_NIGHT_YES);
    } else if (currentSetting == FOLLOW_SYSTEM) {
        AppCompatDelegate.setDefaultNightMode(
                AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
    }
}
 
開發者ID:doljko,項目名稱:youth-health,代碼行數:19,代碼來源:AboutUsActivity.java

示例7: onCreate

import android.content.res.Configuration; //導入依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();
    Resources resources = getResources();
    DisplayMetrics dm = resources.getDisplayMetrics();
    Configuration config = resources.getConfiguration();
    // 應用用戶選擇語言
    String language = SPUtil.getInstance(this).getLanguage();
    if ("".equals(language)){
        language =Locale.getDefault().getLanguage();
    }
    if (language.equals(SPUtil.LANGUAGE_CHINESE)) {
        config.setLocale(Locale.getDefault());
    } else  {
        config.setLocale(Locale.ENGLISH);
    }
    resources.updateConfiguration(config, dm);

    mContext=getApplicationContext();
}
 
開發者ID:EggUncle,項目名稱:XposedNavigationBar,代碼行數:21,代碼來源:MyApplication.java

示例8: PopulateDetailsPoster

import android.content.res.Configuration; //導入依賴的package包/類
/**
 * Populates poster in screen.
 * @param container TVShowData
 * @param callback callback
 */
private void PopulateDetailsPoster(final TVShowData container, Callback callback) {

    ActivityUtils.loadImage(this, TMDB_IMAGE_URL + SIZE_W342 + container.getPosterPath(), true,
            R.drawable.disk_reel, tvShowPoster, null);

    String backgroundPosterPath = container.getBackgroundPath();
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        ActivityUtils.loadImage(this, BACKGROUND_BASE_URI + backgroundPosterPath, true,
                R.drawable.no_background_poster, backgroundPoster, callback);
    } else {
        ActivityUtils.loadImage(this, BACKGROUND_BASE_URI + backgroundPosterPath, false,
                R.drawable.no_background_poster, backgroundPoster, callback);
    }

    // Save background movie image poster to use in PersonProfile page.
    ActivityUtils.saveStringToPreferences(this, KNOWN_FOR_BACKGROUND_POSTER,
            container.getBackgroundPath());
}
 
開發者ID:an-garcia,項目名稱:MovieGuide,代碼行數:24,代碼來源:TVShowActivity.java

示例9: applyGravity

import android.content.res.Configuration; //導入依賴的package包/類
/**
 * apply the gravity for window params.
 *
 * @param expectGravity the expect gravity
 * @param applyWlp      the window layout params.
 */
private static void applyGravity(Context context,int expectGravity, WindowManager.LayoutParams applyWlp) {
    if (Build.VERSION.SDK_INT >= 17) {
        final Configuration configuration = context.getResources().getConfiguration();
        final int gravity = Gravity.getAbsoluteGravity(expectGravity, configuration.getLayoutDirection());
        applyWlp.gravity = gravity;
        if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.FILL_HORIZONTAL) {
            applyWlp.horizontalWeight = 1.0f;
        }
        if ((gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.FILL_VERTICAL) {
            applyWlp.verticalWeight = 1.0f;
        }
    } else {
        applyWlp.gravity = expectGravity;
    }
}
 
開發者ID:LightSun,項目名稱:android-util2,代碼行數:22,代碼來源:BaseWindow.java

示例10: onConfigurationChanged

import android.content.res.Configuration; //導入依賴的package包/類
/**
 * We need to do locale work here, because we need to intercept
 * each hit to onConfigurationChanged.
 */
@Override
public void onConfigurationChanged(Configuration config) {
    // Do nothing if we're in the background. It'll simply cause a loop
    // (Bug 936756 Comment 11), and it's not necessary.
    if (mInBackground) {
        super.onConfigurationChanged(config);
        return;
    }

    // Otherwise, correct the locale. This catches some cases that the current Activity
    // doesn't get a chance to.
    try {
        LocaleManager.getInstance().correctLocale(this, getResources(), config);
    } catch (IllegalStateException ex) {
        // Activity hasn't started yey, so we have no ContextGetter in LocaleManager.
    }

    super.onConfigurationChanged(config);
}
 
開發者ID:mozilla-mobile,項目名稱:firefox-tv,代碼行數:24,代碼來源:LocaleAwareApplication.java

示例11: getNavBarHeight

import android.content.res.Configuration; //導入依賴的package包/類
static int getNavBarHeight(Context c) {
    int result = 0;
    boolean hasMenuKey = ViewConfiguration.get(c).hasPermanentMenuKey();
    boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);

    if (!hasMenuKey && !hasBackKey) {
        // The device has a navigation bar
        Resources res = c.getResources();

        int orientation = res.getConfiguration().orientation;
        int resourceId;
        if (isTablet(c)) {
            resourceId = res.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android");
        } else {
            resourceId = res.getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_width", "dimen", "android");
        }
        if (resourceId > 0) {
            return res.getDimensionPixelSize(resourceId);
        }
    }
    return result;
}
 
開發者ID:tylersuehr7,項目名稱:chips-input-layout,代碼行數:23,代碼來源:Utils.java

示例12: setFullScreenForSmallLandscape

import android.content.res.Configuration; //導入依賴的package包/類
protected void setFullScreenForSmallLandscape()	{
	int nScreenSizeCategory = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
	int nScreenOrientation = getResources().getConfiguration().orientation;
	if (nScreenOrientation != Configuration.ORIENTATION_LANDSCAPE)	{
		if (nScreenSizeCategory == Configuration.SCREENLAYOUT_SIZE_SMALL)	{        // making it full screen in portrait mode if small screen
			getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
					WindowManager.LayoutParams.FLAG_FULLSCREEN);
		} else	{
			getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
		}
	} else	{
		if (nScreenSizeCategory == Configuration.SCREENLAYOUT_SIZE_SMALL
				|| nScreenSizeCategory == Configuration.SCREENLAYOUT_SIZE_NORMAL)	{        // making it full screen in landscape mode if small or normal screen
			getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
					WindowManager.LayoutParams.FLAG_FULLSCREEN);
		} else	{
			getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
		}
	}
	
}
 
開發者ID:woshiwpa,項目名稱:SmartMath,代碼行數:22,代碼來源:ActivityImeMultiEdtsOri.java

示例13: onUpdate

import android.content.res.Configuration; //導入依賴的package包/類
/**
 * Function fire on system update widget
 *
 * @param context          Context of application
 * @param appWidgetManager App widget manger
 * @param appWidgetIds     Widget system ids
 */
@Override
public void onUpdate(Context context, final AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    final int count = appWidgetIds.length;

    //set widget language with the system language
    Locale locale = new Locale(Resources.getSystem().getConfiguration().locale.getLanguage());
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
    this.context = context;

    //loop in all widgets
    for (int i = 0; i < count; i++) {
        svcIntent = new Intent(context, CalenderRemoteViewsService.class);
        final int widgetId = appWidgetIds[i];
        remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_calender);
        remoteViews.setRemoteAdapter(R.id.calendar_pager, svcIntent);
        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds[i], R.id.calendar_pager);
        HGDate hgDate = new HGDate();
        hgDate.toHigri();
        remoteViews.setTextViewText(R.id.textView8, Dates.getCurrentWeekDay());
        remoteViews.setTextViewText(R.id.textView7, NumbersLocal.convertToNumberTypeSystem(context, hgDate.getDay() + ""));
        remoteViews.setTextViewText(R.id.textView24, NumbersLocal.convertToNumberTypeSystem(context, hgDate.getYear() + ""));
        remoteViews.setTextViewText(R.id.curr_month_txt, Dates.islamicMonthName(context, hgDate.getMonth() - 1));
        remoteViews.setTextViewText(R.id.curr_month_txt_other, showOtherMonth(hgDate));

        PendingIntent configPendingIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);
        remoteViews.setOnClickPendingIntent(R.id.relativeLayout, configPendingIntent);
        appWidgetManager.updateAppWidget(widgetId, remoteViews);

    }
}
 
開發者ID:fekracomputers,項目名稱:MuslimMateAndroid,代碼行數:41,代碼來源:CalenderWidget.java

示例14: resetViewBottomPadding

import android.content.res.Configuration; //導入依賴的package包/類
public static void resetViewBottomPadding(@Nullable View view, boolean scroll) {
    if (view == null) return;

    Context context = ContextHelper.getBaseContext(view);
    int orientation = context.getResources().getConfiguration().orientation;

    int left = view.getPaddingLeft();
    int right = view.getPaddingRight();
    int bottom = view.getPaddingTop();
    int top = view.getPaddingTop();
    int navBar = 0;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        boolean tabletMode = context.getResources().getBoolean(R.bool.android_helpers_tablet_mode);
        if (tabletMode || orientation == Configuration.ORIENTATION_PORTRAIT) {
            navBar = getNavigationBarHeight(context);
        }

        if (!scroll) {
            navBar += getStatusBarHeight(context);
        }
    }

    if (!scroll) {
        navBar += getToolbarHeight(context);
    }
    view.setPadding(left, top, right, (bottom + navBar));
}
 
開發者ID:danimahardhika,項目名稱:wallpaperboard,代碼行數:29,代碼來源:ViewHelper.java

示例15: drawResizedBitmap

import android.content.res.Configuration; //導入依賴的package包/類
private void drawResizedBitmap(final Bitmap src, final Bitmap dst) {

        Display getOrient = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        int orientation = Configuration.ORIENTATION_UNDEFINED;
        Point point = new Point();
        getOrient.getSize(point);
        int screen_width = point.x;
        int screen_height = point.y;
        Log.d(TAG, String.format("screen size (%d,%d)", screen_width, screen_height));
        if (screen_width < screen_height) {
            orientation = Configuration.ORIENTATION_PORTRAIT;
            mScreenRotation = -90;
        } else {
            orientation = Configuration.ORIENTATION_LANDSCAPE;
            mScreenRotation = 0;
        }

        Assert.assertEquals(dst.getWidth(), dst.getHeight());
        final float minDim = Math.min(src.getWidth(), src.getHeight());

        final Matrix matrix = new Matrix();

        // We only want the center square out of the original rectangle.
        final float translateX = -Math.max(0, (src.getWidth() - minDim) / 2);
        final float translateY = -Math.max(0, (src.getHeight() - minDim) / 2);
        matrix.preTranslate(translateX, translateY);

        final float scaleFactor = dst.getHeight() / minDim;
        matrix.postScale(scaleFactor, scaleFactor);

        // Rotate around the center if necessary.
        if (mScreenRotation != 0) {
            matrix.postTranslate(-dst.getWidth() / 2.0f, -dst.getHeight() / 2.0f);
            matrix.postRotate(mScreenRotation);
            matrix.postTranslate(dst.getWidth() / 2.0f, dst.getHeight() / 2.0f);
        }

        final Canvas canvas = new Canvas(dst);
        canvas.drawBitmap(src, matrix, null);
    }
 
開發者ID:gicheonkang,項目名稱:fast_face_android,代碼行數:41,代碼來源:OnGetImageListener.java


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