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;
}
}
项目:RabbitCloud
文件:LiveRoomActivity.java
@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();
}
项目:android-PictureInPicture
文件:MediaSessionPlaybackActivity.java
/**
* 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);
}
}
项目:wallpaperboard
文件:AboutFragment.java
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,navBar);
}
项目:content-farm-blocker-android
文件:Util.java
@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);
}
项目:youth-health
文件:AboutUsActivity.java
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);
}
}
项目:techstar-org
文件:AboutUsActivity.java
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);
}
}
@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();
}
项目:MovieGuide
文件:TVShowActivity.java
/**
* 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,R.drawable.no_background_poster,backgroundPoster,callback);
} else {
ActivityUtils.loadImage(this,false,callback);
}
// Save background movie image poster to use in PersonProfile page.
ActivityUtils.saveStringToPreferences(this,KNowN_FOR_BACKGROUND_POSTER,container.getBackgroundpath());
}
项目:android-util2
文件:BaseWindow.java
/**
* 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;
}
}
项目:firefox-tv
文件:LocaleAwareApplication.java
/**
* 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);
}
项目:chips-input-layout
文件:Utils.java
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","android");
}
if (resourceId > 0) {
return res.getDimensionPixelSize(resourceId);
}
}
return result;
}
项目:SmartMath
文件:ActivityImeMultiEdtsOri.java
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);
}
}
}
项目:MuslimMateAndroid
文件:CalenderWidget.java
/**
* 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,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,new Intent(context,MainActivity.class),0);
remoteViews.setonClickPendingIntent(R.id.relativeLayout,configPendingIntent);
appWidgetManager.updateAppWidget(widgetId,remoteViews);
}
}
项目:wallpaperboard
文件:ViewHelper.java
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));
}
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);
}
项目:CameraFragment
文件:Utils.java
public static int getDeviceDefaultOrientation(Context context) {
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Configuration config = context.getResources().getConfiguration();
int rotation = windowManager.getDefaultdisplay().getRotation();
if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) &&
config.orientation == Configuration.ORIENTATION_LANDSCAPE)
|| ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) &&
config.orientation == Configuration.ORIENTATION_PORTRAIT)) {
return Configuration.ORIENTATION_LANDSCAPE;
} else {
return Configuration.ORIENTATION_PORTRAIT;
}
}
项目:ClassLoader
文件:MyApplication.java
@Override
public void onConfigurationChanged(Configuration paramConfiguration) {
super.onConfigurationChanged(paramConfiguration);
if (this.j != null) {
try {
this.j.getClass().getDeclaredMethod("onConfigurationChanged",new Class[]{Configuration.class})
.invoke(this.j,new Object[]{paramConfiguration});
return;
} catch (Exception localException) {
Log.e(TAG,"onLowMemory()" + localException);
}
}
}
项目:Linphone4Android
文件:ChatFragment.java
public void hideKeyboardVisibleMode() {
boolean isOrientationLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
//contactPicture.setVisibility(View.VISIBLE);
if (isOrientationLandscape && topBar != null) {
//topBar.setVisibility(View.VISIBLE);
}
LinphoneActivity.instance().hideTabBar(false);
}
项目:phonk
文件:MainActivity.java
@Override
public void onConfigurationChanged(Configuration newConfig) {
MLog.d(TAG,"changing conf");
removeFragment(mConnectionInfoFragment);
removeFragment(mEmptyFragment);
removeFragment(mProjectListFragment);
removeFragment(mFolderListFragment);
if (mCombinedFolderAndProjectFragment != null) removeFragment(mCombinedFolderAndProjectFragment);
RelativeLayout mainContent = (RelativeLayout) findViewById(R.id.main_content);
mainContent.removeAllViews();
super.onConfigurationChanged(newConfig);
loadUI();
}
项目:AndroidOCRFforID
文件:CameraSourcePreview.java
private boolean isPortraitMode() {
int orientation = mContext.getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
return false;
}
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
return true;
}
Log.d(TAG,"isPortraitMode returning false by default");
return false;
}
项目:wallpaperboard
文件:FavoritesFragment.java
项目:letv
文件:ProxyFragment.java
项目:SciChart.Android.Examples
文件:MainActivity.java
@Override
protected void onCreate(Bundle bundle) {
SciChartBuilder.init(this);
super.onCreate(bundle);
setContentView(R.layout.activity_main);
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
getwindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
TextView titleView = (TextView) findViewById(R.id.title);
titleView.setText(getTitle().toString());
setUpDrawerAndToolbar();
settingsButton = (ImageButton) findViewById(R.id.toolbar_button);
settingsButton.setonClickListener(new View.OnClickListener() {
@Override
public void onClick(View item) {
drawerLayout.onMenuItemClick();
}
});
drawerLayout.setViewsClickableAction(new Action1<Boolean>() {
@Override
public void execute(Boolean isEnabled) {
settingsButton.setEnabled(isEnabled);
}
});
exampleFragment = (ExampleBaseFragment) getFragmentManager().findFragmentById(R.id.fragment_id);
}
项目:trust-wallet-android
文件:CameraSourcePreview.java
private boolean isPortraitMode() {
int orientation = mContext.getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
return false;
}
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
return true;
}
Log.d(TAG,"isPortraitMode returning false by default");
return false;
}
public BarConfig(Activity activity) {
Resources res = activity.getResources();
mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
mSmallestWidthDp = getSmallestWidthDp(activity);
mStatusBarHeight = getInternalDimensionSize(res,STATUS_BAR_HEIGHT_RES_NAME);
mActionBarHeight = getActionBarHeight(activity);
mNavigationBarHeight = getNavigationBarHeight(activity);
mNavigationBarWidth = getNavigationBarWidth(activity);
mHasNavigationBar = (mNavigationBarHeight > 0);
}
项目:LianXiZhihu
文件:DetailPresenter.java
private String convertDoubanContent() {
if (doubanMomentStory.getContent() == null) {
return null;
}
String css;
if ((context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK)
== Configuration.UI_MODE_NIGHT_YES) {
css = "<link rel=\"stylesheet\" href=\"file:///android_asset/douban_dark.css\" type=\"text/css\">";
} else {
css = "<link rel=\"stylesheet\" href=\"file:///android_asset/douban_light.css\" type=\"text/css\">";
}
String content = doubanMomentStory.getContent();
ArrayList<DoubanMomentNews.posts.thumbs> imageList = doubanMomentStory.getPhotos();
for (int i = 0; i < imageList.size(); i++) {
String old = "<img id=\"" + imageList.get(i).getTag_name() + "\" />";
String newStr = "<img id=\"" + imageList.get(i).getTag_name() + "\" "
+ "src=\"" + imageList.get(i).getMedium().getUrl() + "\"/>";
content = content.replace(old,newStr);
}
StringBuilder builder = new StringBuilder();
builder.append( "<!DOCTYPE html>\n");
builder.append("<html lang=\"ZH-CN\" xmlns=\"http://www.w3.org/1999/xhtml\">\n");
builder.append("<head>\n<Meta charset=\"utf-8\" />\n");
builder.append(css);
builder.append("\n</head>\n<body>\n");
builder.append("<div class=\"container bs-docs-container\">\n");
builder.append("<div class=\"post-container\">\n");
builder.append(content);
builder.append("</div>\n</div>\n</body>\n</html>");
return builder.toString();
}
/**
* Called by the system when the device configuration changes while your activity is running.
*
* @param newConfig The new device configuration
*/
public void onConfigurationChanged(Configuration newConfig) {
for (CordovaPlugin plugin : this.pluginMap.values()) {
if (plugin != null) {
plugin.onConfigurationChanged(newConfig);
}
}
}
@Override
public void onConfigurationChanged(final Configuration conf) {
SettingsValues settingsValues = mSettings.getCurrent();
if (settingsValues.mHasHardwareKeyboard != Settings.readHasHardwareKeyboard(conf)) {
// If the state of having a hardware keyboard changed,then we want to reload the
// settings to adjust for that.
// Todo: we should probably do this unconditionally here,rather than only when we
// have a change in hardware keyboard configuration.
loadSettings();
}
super.onConfigurationChanged(conf);
}
private void fixLayoutInternal() {
if (getParentActivity() == null) {
return;
}
WindowManager manager = (WindowManager) gallery.applicationContext
.getSystemService(Activity.WINDOW_SERVICE);
int rotation = manager.getDefaultdisplay().getRotation();
columnsCount = 2;
if (!AndroidUtilities.isTablet()
&& (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90)) {
columnsCount = 4;
}
listadapter.notifyDataSetChanged();
if (dropDownContainer != null) {
if (!AndroidUtilities.isTablet()) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) dropDownContainer
.getLayoutParams();
layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21
? AndroidUtilities.statusBarHeight : 0);
dropDownContainer.setLayoutParams(layoutParams);
}
if (!AndroidUtilities.isTablet() && gallery.applicationContext.getResources()
.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
dropDown.setTextSize(18);
} else {
dropDown.setTextSize(20);
}
}
}
项目:TitanCompanion
文件:LocaleHelper.java
@TargetApi(Build.VERSION_CODES.N)
private static Context updateResources(Context context,String language) {
Locale locale = new Locale(language);
Locale.setDefault(locale);
Configuration configuration = context.getResources().getConfiguration();
configuration.setLocale(locale);
configuration.setLayoutDirection(locale);
return context.createConfigurationContext(configuration);
}
项目:Moneycim
文件:CameraSourcePreview.java
private boolean isPortraitMode() {
int orientation = mContext.getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
return false;
}
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
return true;
}
Log.d(TAG,"isPortraitMode returning false by default");
return false;
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (mLocale != null && !newConfig.locale.getLanguage().equals("en")) {
Resources res = getBaseContext().getResources();
Configuration config = res.getConfiguration();
Locale.setDefault(mLocale);
config.locale = mLocale;
res.updateConfiguration(config,res.getdisplayMetrics());
}
}
项目:NanoIconPack
文件:ReqMenuDialog.java
@Override
public void setupDialog(Dialog dialog,int style) {
super.setupDialog(dialog,style);
Bundle bundle = getArguments();
pos = bundle.getInt("pos");
bean = (AppBean) bundle.getSerializable("bean");
contentView = View.inflate(getContext(),R.layout.fragment_req_menu,null);
dialog.setContentView(contentView);
((TextView) contentView.findViewById(R.id.tv_title)).setText(bean.getLabel());
if (bean.isMark()) {
contentView.findViewById(R.id.view_menu_mark).setVisibility(View.GONE);
contentView.findViewById(R.id.view_menu_undo_mark).setonClickListener(this);
contentView.findViewById(R.id.view_hint_undo_mark)
.setVisibility(bean.isHintUndoMark() ? View.VISIBLE : View.GONE);
} else {
contentView.findViewById(R.id.view_menu_undo_mark).setVisibility(View.GONE);
contentView.findViewById(R.id.view_menu_mark).setonClickListener(this);
contentView.findViewById(R.id.view_hint_mark)
.setVisibility(bean.isHintMark() ? View.VISIBLE : View.GONE);
}
contentView.findViewById(R.id.view_hint_lost)
.setVisibility(bean.isHintLost() ? View.VISIBLE : View.GONE);
contentView.findViewById(R.id.view_menu_goto_market).setonClickListener(this);
contentView.findViewById(R.id.view_menu_copy_code).setonClickListener(this);
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior
.from((View) contentView.getParent());
if (bean.isHintLost()) {
// In landscape,STATE_EXPANDED doesn't make sheet expanded.
// Maybe it's a bug. So do this to fix it.
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
contentView.measure(0,0);
bottomSheetBehavior.setPeekHeight(contentView.getMeasuredHeight());
}
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
} else {
bottomSheetBehavior.setPeekHeight(getResources()
.getDimensionPixelSize(R.dimen.req_bottom_menu_height));
}
}
项目:MuslimMateAndroid
文件:SettingsActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String languagetoLoad = ConfigPreferences.getApplicationLanguage(this);
Locale locale = new Locale(languagetoLoad);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,getBaseContext().getResources().getdisplayMetrics());
getSupportActionBar().setdisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(getString(R.string.title_activity_settings));
getFragmentManager().beginTransaction().replace(android.R.id.content,new MainSettings()).commit();
}
项目:MKVideoPlayer
文件:MKPlayerActivity.java
项目:PimPam
文件:SettingsFragment.java
public void setLocale(String lang) {
Locale myLocale = new Locale(lang);
Resources res = getResources();
displayMetrics dm = res.getdisplayMetrics();
Configuration conf = res.getConfiguration();
conf.locale = myLocale;
res.updateConfiguration(conf,dm);
Intent refresh = new Intent(getContext(),MainActivity.class);
startActivity(refresh);
getActivity().finish();
}
private SystemBarConfig(Activity activity,boolean translucentStatusBar,boolean traslucentNavBar) {
Resources res = activity.getResources();
mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
mSmallestWidthDp = getSmallestWidthDp(activity);
mStatusBarHeight = getInternalDimensionSize(res,STATUS_BAR_HEIGHT_RES_NAME);
mActionBarHeight = getActionBarHeight(activity);
mNavigationBarHeight = getNavigationBarHeight(activity);
mNavigationBarWidth = getNavigationBarWidth(activity);
mHasNavigationBar = (mNavigationBarHeight > 0);
mTranslucentStatusBar = translucentStatusBar;
mTranslucentNavBar = traslucentNavBar;
}
项目:GitHub
文件:MDRootLayout.java
private void invertGravityIfNecessary() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) return;
Configuration config = getResources().getConfiguration();
if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
switch (buttonGravity) {
case START:
buttonGravity = GravityEnum.END;
break;
case END:
buttonGravity = GravityEnum.START;
break;
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。