List of usage examples for android.content.res Resources getBoolean
public boolean getBoolean(@BoolRes int id) throws NotFoundException
From source file:com.xxxifan.devbox.core.util.ViewUtils.java
private static boolean readInternalBoolean(String key, Resources res, boolean fallback) { int resourceId = res.getIdentifier(key, "bool", "android"); return resourceId != 0 ? res.getBoolean(resourceId) : fallback; }
From source file:com.frostwire.android.gui.util.UIUtils.java
public static boolean isTablet(Resources res) { return res.getBoolean(R.bool.isTablet); }
From source file:bangla.music.com.musicbanglatv.YouTubeRecyclerViewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // set the Picasso debug indicator only for debug builds Picasso.with(getActivity()).setIndicatorsEnabled(BuildConfig.DEBUG); // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.youtube_recycler_view_fragment, container, false); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.youtube_recycler_view); // use this setting to improve performance if you know that changes // in content do not change the layout size of the RecyclerView mRecyclerView.setHasFixedSize(true); Resources resources = getResources(); if (resources.getBoolean(R.bool.isTablet)) { // use a staggered grid layout if we're on a large screen device mLayoutManager = new StaggeredGridLayoutManager(resources.getInteger(R.integer.columns), StaggeredGridLayoutManager.VERTICAL); } else {/*w w w.j a va 2 s . c om*/ // use a linear layout on phone devices mLayoutManager = new LinearLayoutManager(getActivity()); } mRecyclerView.setLayoutManager(mLayoutManager); return rootView; }
From source file:com.amazingmvp.ui.activity.HomeActivity.java
/** * This method will only be executed if the device * is a tablet(sw bigger than 600dp)./* w w w. j ava2 s . co m*/ */ private void toggleTabletMode() { Resources res = getResources(); if (res.getBoolean(R.bool.tablet)) { int spacing = ViewUtil.getWidth(this) / res.getInteger(R.integer.view_pager_spacing); viewPager.setClipToPadding(false); viewPager.setPadding(spacing, 0, spacing, 0); viewPager.setPageMargin(spacing / 6); } }
From source file:develop.d2ru.kpop.fragments.YouTubeRecyclerViewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // set the Picasso debug indicator only for debug builds // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.youtube_recycler_view_fragment, container, false); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.youtube_recycler_view); // use this setting to improve performance if you know that changes // in content do not change the layout size of the RecyclerView mRecyclerView.setHasFixedSize(true); Resources resources = getResources(); if (resources.getBoolean(R.bool.isTablet)) { // use a staggered grid layout if we're on a large screen device mLayoutManager = new StaggeredGridLayoutManager(resources.getInteger(R.integer.columns), StaggeredGridLayoutManager.VERTICAL); } else {/*from w w w .j a v a 2 s.c om*/ // use a linear layout on phone devices mLayoutManager = new LinearLayoutManager(getActivity()); } mRecyclerView.setLayoutManager(mLayoutManager); return rootView; }
From source file:com.akoscz.youtube.YouTubeRecyclerViewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // set the Picasso debug indicator only for debug builds Picasso.with(getActivity()).setIndicatorsEnabled(BuildConfig.DEBUG); // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.youtube_recycler_view_fragment, container, false); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.youtube_recycler_view); // use this setting to improve performance if you know that changes // in content do not change the layout size of the RecyclerView mRecyclerView.setHasFixedSize(true); Resources resources = getResources(); if (resources.getBoolean(R.bool.isTablet)) { // use a staggered grid layout if we're on a large screen device mLayoutManager = new StaggeredGridLayoutManager(resources.getInteger(R.integer.columns), StaggeredGridLayoutManager.VERTICAL); } else {/*from w w w . j av a2 s . c om*/ // use a linear layout on phone devices mLayoutManager = new LinearLayoutManager(getActivity()); } mRecyclerView.setLayoutManager(mLayoutManager); mPlaylistSpinner = (Spinner) rootView.findViewById(R.id.youtube_playlist_spinner); return rootView; }
From source file:com.xandy.calendar.EventInfoActivity.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); // Get the info needed for the fragment Intent intent = getIntent();//from w ww . j a v a 2 s .co m int attendeeResponse = 0; mEventId = -1; boolean isDialog = false; ArrayList<ReminderEntry> reminders = null; if (icicle != null) { mEventId = icicle.getLong(EventInfoFragment.BUNDLE_KEY_EVENT_ID); mStartMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_START_MILLIS); mEndMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_END_MILLIS); attendeeResponse = icicle.getInt(EventInfoFragment.BUNDLE_KEY_ATTENDEE_RESPONSE); isDialog = icicle.getBoolean(EventInfoFragment.BUNDLE_KEY_IS_DIALOG); reminders = Utils.readRemindersFromBundle(icicle); } else if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) { mStartMillis = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, 0); mEndMillis = intent.getLongExtra(EXTRA_EVENT_END_TIME, 0); attendeeResponse = intent.getIntExtra(ATTENDEE_STATUS, Attendees.ATTENDEE_STATUS_NONE); Uri data = intent.getData(); if (data != null) { try { List<String> pathSegments = data.getPathSegments(); int size = pathSegments.size(); if (size > 2 && "EventTime".equals(pathSegments.get(2))) { // Support non-standard VIEW intent format: //dat = content://com.android.calendar/events/[id]/EventTime/[start]/[end] mEventId = Long.parseLong(pathSegments.get(1)); if (size > 4) { mStartMillis = Long.parseLong(pathSegments.get(3)); mEndMillis = Long.parseLong(pathSegments.get(4)); } } else { mEventId = Long.parseLong(data.getLastPathSegment()); } } catch (NumberFormatException e) { if (mEventId == -1) { // do nothing here , deal with it later } else if (mStartMillis == 0 || mEndMillis == 0) { // Parsing failed on the start or end time , make sure the times were not // pulled from the intent's extras and reset them. mStartMillis = 0; mEndMillis = 0; } } } } if (mEventId == -1) { Log.w(TAG, "No event id"); Toast.makeText(this, R.string.event_not_found, Toast.LENGTH_SHORT).show(); finish(); } // If we do not support showing full screen event info in this configuration, // close the activity and show the event in AllInOne. Resources res = getResources(); if (!res.getBoolean(R.bool.agenda_show_event_info_full_screen) && !res.getBoolean(R.bool.show_event_info_full_screen)) { CalendarController.getInstance(this).launchViewEvent(mEventId, mStartMillis, mEndMillis, attendeeResponse); finish(); return; } setContentView(R.layout.simple_frame_layout); // Get the fragment if exists mInfoFragment = (EventInfoFragment) getSupportFragmentManager().findFragmentById(R.id.main_frame); // Remove the application title ActionBar bar = getActionBar(); if (bar != null) { bar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME); } // Create a new fragment if none exists if (mInfoFragment == null) { FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); mInfoFragment = new EventInfoFragment(this, mEventId, mStartMillis, mEndMillis, attendeeResponse, isDialog, (isDialog ? EventInfoFragment.DIALOG_WINDOW_STYLE : EventInfoFragment.FULL_WINDOW_STYLE), reminders); ft.replace(R.id.main_frame, mInfoFragment); ft.commit(); } }
From source file:com.android.calendar.EventInfoActivity.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); // Get the info needed for the fragment Intent intent = getIntent();//from ww w . j a va 2 s . c om int attendeeResponse = 0; mEventId = -1; boolean isDialog = false; ArrayList<ReminderEntry> reminders = null; if (icicle != null) { mEventId = icicle.getLong(EventInfoFragment.BUNDLE_KEY_EVENT_ID); mStartMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_START_MILLIS); mEndMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_END_MILLIS); attendeeResponse = icicle.getInt(EventInfoFragment.BUNDLE_KEY_ATTENDEE_RESPONSE); isDialog = icicle.getBoolean(EventInfoFragment.BUNDLE_KEY_IS_DIALOG); reminders = Utils.readRemindersFromBundle(icicle); } else if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) { mStartMillis = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, 0); mEndMillis = intent.getLongExtra(EXTRA_EVENT_END_TIME, 0); attendeeResponse = intent.getIntExtra("attendeeStatus", Attendees.ATTENDEE_STATUS_NONE); Uri data = intent.getData(); if (data != null) { try { List<String> pathSegments = data.getPathSegments(); int size = pathSegments.size(); if (size > 2 && "EventTime".equals(pathSegments.get(2))) { // Support non-standard VIEW intent format: // dat = // content://com.android.calendar/events/[id]/EventTime/[start]/[end] mEventId = Long.parseLong(pathSegments.get(1)); if (size > 4) { mStartMillis = Long.parseLong(pathSegments.get(3)); mEndMillis = Long.parseLong(pathSegments.get(4)); } } else { mEventId = Long.parseLong(data.getLastPathSegment()); } } catch (NumberFormatException e) { if (mEventId == -1) { // do nothing here , deal with it later } else if (mStartMillis == 0 || mEndMillis == 0) { // Parsing failed on the start or end time , make sure // the times were not // pulled from the intent's extras and reset them. mStartMillis = 0; mEndMillis = 0; } } } } if (mEventId == -1) { Log.w(TAG, "No event id"); Toast.makeText(this, R.string.event_not_found, Toast.LENGTH_SHORT).show(); finish(); } // If we do not support showing full screen event info in this // configuration, // close the activity and show the event in AllInOne. Resources res = getResources(); if (!res.getBoolean(R.bool.agenda_show_event_info_full_screen) && !res.getBoolean(R.bool.show_event_info_full_screen)) { CalendarController.getInstance(this).launchViewEvent(mEventId, mStartMillis, mEndMillis, attendeeResponse); finish(); return; } setContentView(R.layout.simple_frame_layout); // Get the fragment if exists mInfoFragment = (EventInfoFragment) getSupportFragmentManager().findFragmentById(R.id.main_frame); // Remove the application title ActionBar bar = getActionBar(); if (bar != null) { bar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP); } // Create a new fragment if none exists if (mInfoFragment == null) { FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); mInfoFragment = new EventInfoFragment(this, mEventId, mStartMillis, mEndMillis, attendeeResponse, isDialog, (isDialog ? EventInfoFragment.DIALOG_WINDOW_STYLE : EventInfoFragment.FULL_WINDOW_STYLE), reminders); ft.replace(R.id.main_frame, mInfoFragment); ft.commit(); } }
From source file:com.z299studio.pb.Snackbar.java
@Override public void onStart() { super.onStart(); if (getDialog() != null) { Window window = getDialog().getWindow(); window.setWindowAnimations(R.style.SnackbarAnimation); Resources res = getResources(); int height = (int) (res.getDimension(R.dimen.snackbar_height_single) + 0.5f); boolean leftAlign = res.getBoolean(R.bool.snackbar_left_align); WindowManager.LayoutParams lp = window.getAttributes(); lp.gravity = Gravity.BOTTOM | Gravity.START; lp.x = 0;// ww w . j av a 2 s . c om lp.y = 0; lp.height = height; if (!leftAlign) { Point windowSize = new Point(); ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay() .getSize(windowSize); lp.width = windowSize.x; } else { lp.height += (int) (res.getDimension(R.dimen.snackbar_horizontal_margin) + 0.5f); } window.setAttributes(lp); } }
From source file:com.atwal.wakeup.battery.util.Utilities.java
@TargetApi(14) public static boolean hasNavBar(Context context) { final String SHOW_NAV_BAR_RES_NAME = "config_showNavigationBar"; String sNavBarOverride = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { try {/*from w w w .j a v a 2 s . co m*/ Class c = Class.forName("android.os.SystemProperties"); Method m = c.getDeclaredMethod("get", String.class); m.setAccessible(true); sNavBarOverride = (String) m.invoke(null, "qemu.hw.mainkeys"); } catch (Throwable e) { sNavBarOverride = null; } } Resources res = context.getResources(); int resourceId = res.getIdentifier(SHOW_NAV_BAR_RES_NAME, "bool", "android"); if (resourceId != 0) { boolean hasNav = res.getBoolean(resourceId); // check override flag (see static block) if ("1".equals(sNavBarOverride)) { hasNav = false; } else if ("0".equals(sNavBarOverride)) { hasNav = true; } return hasNav; } else { // fallback return !ViewConfiguration.get(context).hasPermanentMenuKey(); } }