Example usage for android.content.res Configuration SCREENLAYOUT_SIZE_MASK

List of usage examples for android.content.res Configuration SCREENLAYOUT_SIZE_MASK

Introduction

In this page you can find the example usage for android.content.res Configuration SCREENLAYOUT_SIZE_MASK.

Prototype

int SCREENLAYOUT_SIZE_MASK

To view the source code for android.content.res Configuration SCREENLAYOUT_SIZE_MASK.

Click Source Link

Document

Constant for #screenLayout : bits that encode the size.

Usage

From source file:com.ushahidi.android.app.activities.BaseActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    log("onCreate");
    actionBar = getSupportActionBar();/*from   w  ww .  ja v a 2  s .com*/
    actionBar.setDisplayHomeAsUpEnabled(true);
    if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == 4)
        mXLargeDevice = true;
    if (layout != 0) {
        createMenuDrawer(layout);
    }

    if (viewClass != null) {
        view = Objects.createInstance(viewClass, Activity.class, this);
    }
}

From source file:com.ryan.ryanreader.common.General.java

/**
 * ???/*w w w . jav a  2 s. c  o m*/
 * 
 * @param context
 * @param sharedPreferences
 * @return
 */
public static boolean isTablet(final Context context, final SharedPreferences sharedPreferences) {

    final PrefsUtility.AppearanceTwopane pref = PrefsUtility.appearance_twopane(context, sharedPreferences);

    switch (pref) {
    case AUTO:
        return (context.getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
    case NEVER:
        return false;
    case FORCE:
        return true;
    default:
        BugReportActivity.handleGlobalError(context, "Unknown AppearanceTwopane value " + pref.name());
        return false;
    }
}

From source file:com.health.openscale.gui.OverviewFragment.java

@Override
public void updateOnView(ArrayList<ScaleData> scaleDataList) {
    ScaleUser scaleUser = OpenScale.getInstance(overviewView.getContext()).getSelectedScaleUser();

    txtOverviewTitle.setText(getResources().getString(R.string.label_overview_title_start) + " "
            + scaleUser.user_name + " " + getResources().getString(R.string.label_overview_title_end));

    List<ArcValue> arcValues = new ArrayList<ArcValue>();

    if (scaleDataList.isEmpty()) {
        lastScaleData = null;// ww w.  j  ava 2 s  . c o m
        return;
    }

    lastScaleData = scaleDataList.get(0);

    arcValues.add(new ArcValue(lastScaleData.fat, Utils.COLOR_ORANGE));
    arcValues.add(new ArcValue(lastScaleData.water, Utils.COLOR_BLUE));
    arcValues.add(new ArcValue(lastScaleData.muscle, Utils.COLOR_GREEN));

    PieChartData pieChartData = new PieChartData(arcValues);
    pieChartData.setHasLabels(true);
    pieChartData.setFormatter(new SimpleValueFormatter(1, false, null, " %".toCharArray()));
    pieChartData.setHasCenterCircle(true);
    pieChartData.setCenterText1(
            Float.toString(lastScaleData.weight) + " " + ScaleUser.UNIT_STRING[scaleUser.scale_unit]);
    pieChartData.setCenterText2(new SimpleDateFormat("dd. MMM yyyy (EE)").format(lastScaleData.date_time));

    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE
            || (getResources().getConfiguration().screenLayout
                    & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        pieChartData.setCenterText1FontSize(33);
        pieChartData.setCenterText2FontSize(14);
    } else {
        pieChartData.setCenterText1FontSize(12);
        pieChartData.setCenterText2FontSize(8);
        pieChartData.setValueLabelTextSize(8);
    }

    pieChart.setPieChartData(pieChartData);

    double avgWeight = 0;
    double avgFat = 0;
    double avgWater = 0;
    double avgMuscle = 0;

    for (ScaleData scaleData : scaleDataList) {
        avgWeight += scaleData.weight;
        avgFat += scaleData.fat;
        avgWater += scaleData.water;
        avgMuscle += scaleData.muscle;
    }

    avgWeight = avgWeight / scaleDataList.size();
    avgFat = avgFat / scaleDataList.size();
    avgWater = avgWater / scaleDataList.size();
    avgMuscle = avgMuscle / scaleDataList.size();

    txtAvgWeight.setText(String.format("%.1f " + ScaleUser.UNIT_STRING[scaleUser.scale_unit], avgWeight));
    txtAvgFat.setText(String.format("%.1f %%", avgFat));
    txtAvgWater.setText(String.format("%.1f %%", avgWater));
    txtAvgMuscle.setText(String.format("%.1f %%", avgMuscle));
}

From source file:com.raja.knowme.FragmentWorkExp.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View mHolderView = inflater.inflate(R.layout.fragment_work_exp, null);
    shake = AnimationUtils.loadAnimation(getActivity(), R.anim.shake);
    functions = new AppCommonFunctions(getActivity());
    pref = new AppPreferences(getActivity());
    knowmeData = new KnowMeDataObject(getActivity());
    mProgressDialog = new ProgressDialog(getActivity());
    mProgressDialog.setCancelable(false);
    mProgressDialog.setMessage(getString(R.string.loading));

    mCompanyNameSwitcher = (TextSwitcher) mHolderView.findViewById(R.id.work_company_name_text);
    mCompanySpanSwitcher = (TextSwitcher) mHolderView.findViewById(R.id.work_company_span_text);
    mCompanySummarySwitcher = (TextSwitcher) mHolderView.findViewById(R.id.work_company_summary_text);
    mScrollContainer = (ScrollView) mHolderView.findViewById(R.id.work_scrollview);
    mInstructionBtn = (RelativeLayout) mHolderView.findViewById(R.id.instrunstions_layout);

    if (!pref.getWorkFirstRun()) {
        mInstructionBtn.setVisibility(RelativeLayout.GONE);
    }/*ww  w .  j ava  2  s. co m*/

    mInstructionBtn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            pref.setWorkRunned();
            mInstructionBtn.setVisibility(RelativeLayout.GONE);
        }
    });
    /*                 Multiple Screen Size Condition             */

    // Small Size

    if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {
        // Toast.makeText(getActivity(), "small", Toast.LENGTH_SHORT).show();
        mCompanyNameSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(24 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySpanSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(12 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySummarySwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225));
                textSwitcher_text.setTextSize(6 * functions.getScreenDPI());
                return textSwitcher_text;
            }
        });
    }

    //Normal Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
        // Toast.makeText(getActivity(), "normal", Toast.LENGTH_SHORT).show();
        mCompanyNameSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(14 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySpanSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(10 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySummarySwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225));
                textSwitcher_text.setTextSize(9 * functions.getScreenDPI());
                return textSwitcher_text;
            }
        });
    }

    // Large Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        //  Toast.makeText(getActivity(), "large", Toast.LENGTH_SHORT).show();

        mCompanyNameSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(32 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySpanSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(24 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySummarySwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225));
                textSwitcher_text.setTextSize(18 * functions.getScreenDPI());
                return textSwitcher_text;
            }
        });
    }

    //X-large Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
        //  Toast.makeText(getActivity(), "xlarge", Toast.LENGTH_SHORT).show();
        mCompanyNameSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(48 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySpanSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(32 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySummarySwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225));
                textSwitcher_text.setTextSize(24 * functions.getScreenDPI());
                return textSwitcher_text;
            }
        });
    }

    //Undefined Size

    else {
        // Toast.makeText(getActivity(), "undefined", Toast.LENGTH_SHORT).show();

        mCompanyNameSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(19 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySpanSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(12 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySummarySwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225));
                textSwitcher_text.setTextSize(12 * functions.getScreenDPI());
                return textSwitcher_text;
            }
        });
    }

    mProgressDialog.show();
    new LoadData().execute();

    // Gesture detection
    gestureDetector = new GestureDetector(getActivity(), new OnGestureListener() {

        public boolean onSingleTapUp(MotionEvent e) {
            return false;
        }

        public void onShowPress(MotionEvent e) {
        }

        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            return false;
        }

        public void onLongPress(MotionEvent e) {
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            try {
                if (Math.abs(e1.getY() - e2.getY()) > AppGlobalVariables.SWIPE_MAX_OFF_PATH)
                    return false;
                /** Left swipe */
                if (e1.getX() - e2.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE
                        && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) {
                    if (count < (MAX_COUNT - 1))
                        nextCompany();
                    else {
                        mCompanyNameSwitcher.startAnimation(shake);
                        mCompanySpanSwitcher.startAnimation(shake);
                        mCompanySummarySwitcher.startAnimation(shake);
                    }
                    /** Right Swipe */
                } else if (e2.getX() - e1.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE
                        && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) {
                    if (count != 0)
                        previousComapny();
                    else {
                        mCompanyNameSwitcher.startAnimation(shake);
                        mCompanySpanSwitcher.startAnimation(shake);
                        mCompanySummarySwitcher.startAnimation(shake);
                    }
                }
            } catch (Exception e) {
            }

            return false;
        }

        public boolean onDown(MotionEvent e) {
            return false;
        }
    });

    gestureListener = new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            return gestureDetector.onTouchEvent(event);
        }
    };

    mScrollContainer.setOnTouchListener(gestureListener);
    return mHolderView;
}

From source file:com.honeycomb.cocos2dx.Soccer.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(com.honeycomb.cocos2dx.R.layout.main);
    interstitial = new InterstitialAd(this);
    interstitial.setAdUnitId("ca-app-pub-2442035138707094/8795197567");
    activity = Soccer.this;
    AndroidNDKHelper.SetNDKReciever(this);

    Cocos2dxGLSurfaceView mGLView = (Cocos2dxGLSurfaceView) findViewById(
            com.honeycomb.cocos2dx.R.id.game_gl_surfaceview);

    mGLView.setEGLContextClientVersion(2);
    mGLView.setCocos2dxRenderer(new Cocos2dxRenderer());

    new Handler().postDelayed(new Runnable() {
        @Override//from  w w  w . j  av a  2 s  . c  o m
        public void run() {
            Soccer.this.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    findViewById(com.honeycomb.cocos2dx.R.id.logolayout).setVisibility(View.GONE);
                }
            });
        }
    }, 3000);

    iapSetup = new IAPSetup();
    mIABHelper = iapSetup.mIABHelper;

    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
        isLargeDevice = true;
    } else if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        isLargeDevice = true;
    } else if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
        isLargeDevice = false;
    } else if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {
        isLargeDevice = false;
    }
    gamePrefrence = getSharedPreferences("null", MODE_PRIVATE);
}

From source file:net.gaast.giggity.ScheduleViewActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    app = (Giggity) getApplication();/*from w ww .j  a  v  a2  s.c  o  m*/

    pref = PreferenceManager.getDefaultSharedPreferences(app);
    curView = getResources()
            .getIdentifier(pref.getString("default_view", "net.gaast.giggity:id/block_schedule"), null, null);
    showHidden = pref.getBoolean("show_hidden", false);

    /* Consider making this a setting, some may find their tablet too small. */
    int screen = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
    tabletView = (screen >= Configuration.SCREENLAYOUT_SIZE_LARGE);

    setContentView(R.layout.schedule_view_activity);
    View dl = drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
    drawer = (RelativeLayout) dl.findViewById(R.id.drawer);

    drawer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // NOOP at least for now just so touches don't fall through to bigScreen.
        }
    });

    ViewGroup menu = (LinearLayout) dl.findViewById(R.id.menu);
    menu.getChildCount();
    /* Set event handler for all static buttons, going to the option menu code. Dynamic buttons
     * (from the schedule) have their own handlers. */
    for (int i = 0; i < menu.getChildCount(); ++i) {
        View btn = menu.getChildAt(i);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // Not for now as I can't undo it (toggler not calling handlers?) TODO v.setBackground(getResources().getDrawable(R.drawable.menu_gradient));
                onOptionsItemSelectedInt(v.getId());
                drawerLayout.closeDrawers();
            }
        });
    }

    if (wantDrawer) {
        /* Hamburger menu! */
        /* Should still consider v7-appcompat, depending on how much it, again, affects apk size.. */
        getActionBar().setDisplayHomeAsUpEnabled(true);
        drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_menu_white_24dp,
                R.string.navdrawer_on, R.string.navdrawer_off) {
            @Override
            public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);
                invalidateOptionsMenu();
                /* Looks like this code doesn't actually run BTW. Need to figure that out later. */
                updateNavDrawer();
            }

            @Override
            public void onDrawerClosed(View drawerView) {
                super.onDrawerClosed(drawerView);
                invalidateOptionsMenu();
            }
        };
    } else {
        drawerLayout.removeView(drawer);
    }

    bigScreen = (LinearLayout) dl.findViewById(R.id.bigScreen);
    updateOrientation(getResources().getConfiguration().orientation);

    viewerContainer = (RelativeLayout) dl.findViewById(R.id.viewerContainer);

    /* TODO: See if I can do this in XML as well? (It's a custom private view.) */
    RelativeLayout.LayoutParams lp;
    lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    days = new DayButtons(this);
    viewerContainer.addView(days, lp);

    redraw = false;
    timer = new Handler();

    /* If the OS informs us that the timezone changes, close this activity so the schedule
       gets reloaded. (This because input is usually TZ-unaware while our objects aren't.) */
    tzClose = new BroadcastReceiver() {
        @Override
        public void onReceive(Context arg0, Intent arg1) {
            ScheduleViewActivity.this.finish();
        }
    };
    registerReceiver(tzClose, new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED));

    if (!getIntent().getAction().equals(Intent.ACTION_VIEW))
        return;

    String url = getIntent().getDataString();
    Fetcher.Source fs;
    if (getIntent().getBooleanExtra("PREFER_CACHED", false))
        fs = Fetcher.Source.CACHE_ONLINE;
    else
        fs = Fetcher.Source.ONLINE_CACHE;

    /* I think reminders come in via this activity (instead of straight to itemview)
       because we may have to reload schedule data? */
    if (url.contains("#")) {
        String parts[] = url.split("#", 2);
        url = parts[0];
        showEventId = parts[1];
    }

    if (app.hasSchedule(url)) {
        try {
            sched = app.getSchedule(url, fs);
        } catch (Exception e) {
            // Java makes me tired.
            e.printStackTrace();
        }
        onScheduleLoaded();
    } else {
        loadScheduleAsync(url, fs);
    }
}

From source file:org.lol.reddit.common.General.java

public static boolean isTablet(final Context context, final SharedPreferences sharedPreferences) {

    final PrefsUtility.AppearanceTwopane pref = PrefsUtility.appearance_twopane(context, sharedPreferences);

    switch (pref) {
    case AUTO://from   w  w  w  .ja v a  2s . c  o m
        return (context.getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
    case NEVER:
        return false;
    case FORCE:
        return true;
    default:
        BugReportActivity.handleGlobalError(context, "Unknown AppearanceTwopane value " + pref.name());
        return false;
    }
}

From source file:com.near.chimerarevo.activities.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    instanceState = savedInstanceState;//from   w  w  w  .ja v  a  2  s  .  co  m

    if (!getSharedPreferences(Constants.PREFS_TAG, Context.MODE_PRIVATE).getBoolean("hasTutorialShown", false))
        startActivity(new Intent(this, TutorialActivity.class));

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if ((getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
            isLandscapeLarge = true;
    } else
        isLandscapeLarge = false;

    mDrawerList = (ExpandableListView) findViewById(R.id.left_drawer_list);

    mFooter = LayoutInflater.from(this).inflate(R.layout.drawer_list_footer, mDrawerList, false);
    mDrawerList.addFooterView(mFooter);
    mShadow = findViewById(R.id.drop_shadow);

    if (!isLandscapeLarge) {
        mDrawerList.addHeaderView(
                LayoutInflater.from(this).inflate(R.layout.drawer_list_header, mDrawerList, false), null,
                false);
        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);
        mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.colorPrimaryDark));

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
            SysUtils.setTopStatusMargin(this, mDrawerLayout);
    }

    mDrawerList.setGroupIndicator(null);
    mDrawerList.setOnGroupClickListener(this);
    mDrawerList.setOnChildClickListener(this);
    mDrawerList.setOnGroupExpandListener(this);

    mMenuAdapter = new MenuAdapter(this);
    mDrawerList.setAdapter(mMenuAdapter);

    if (!isLandscapeLarge) {
        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, getToolbar(), R.string.drawer_open,
                R.string.drawer_close);
        mDrawerLayout.setDrawerListener(mDrawerToggle);
    }

    mFooter.findViewById(R.id.unlock_premium_btn).setVisibility(View.GONE);
    try {
        mHelper = new IabHelper(this, Constants.LICENSE_KEY);
        mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
            public void onIabSetupFinished(IabResult result) {
                isLicensed = result.isSuccess();
                if (isLicensed)
                    mHelper.queryInventoryAsync(MainActivity.this);
                else
                    SysUtils.toggleAppWidgets(MainActivity.this, false);
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (savedInstanceState != null) {
        prevSelection = savedInstanceState.getByte("prevSelection");

        mMenuAdapter.toggleSelection(0);
        if (prevSelection != 2)
            mMenuAdapter.toggleSelection(prevSelection);

        selectMenuItem(prevSelection);
    } else
        selectMenuItem(0);
}

From source file:yet.another.hackernews.reader.HackernewsFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View v, int pos, long id) {
    final News news = (News) parent.getAdapter().getItem(pos);

    if (news.getTitle().equals("More")) {
        return;/*  w ww.j  av a 2 s. c om*/
    }

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

    switch (screenLayout) {

    case Configuration.SCREENLAYOUT_SIZE_XLARGE:

        final FragmentManager fManager = getSherlockActivity().getSupportFragmentManager();
        final ViewFragment fragment = (ViewFragment) fManager.findFragmentById(R.id.fragment_view);

        if (fragment != null) {
            ViewFragment.setNews(news);
            fragment.update(null);
            v.setEnabled(true);
        }

        break;
    default:

        Bundle sendArgs = new Bundle();
        sendArgs.putString("NewsObject", news.toString());

        Intent browser = new Intent(getSherlockActivity(), ViewActivity.class);
        browser.putExtras(sendArgs);
        startActivity(browser);

        break;
    }
}