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.raja.knowme.FragmentSpecialization.java

private AppTextView addItem(final SpecializationDetailsObject data) {
    final AppTextView mTextView = new AppTextView(getActivity());

    /*                 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();
        LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSpecializationName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(14);//from   ww  w . j a v a 2s  .co m
        mTextView.setPadding(3, 15, 0, 0);
    }

    //Normal Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
        //   Toast.makeText(getActivity(), "normal", Toast.LENGTH_SHORT).show();
        LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSpecializationName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(16);
        mTextView.setPadding(3, 15, 0, 0);
    }

    // Large Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        //  Toast.makeText(getActivity(), "large", Toast.LENGTH_SHORT).show();
        LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSpecializationName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(20);
        mTextView.setPadding(3, 15, 0, 0);

    }

    //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();
        LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSpecializationName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(24);
        mTextView.setPadding(3, 15, 0, 0);
    }

    //Undefined Size

    else {
        //Toast.makeText(getActivity(), "undefined", Toast.LENGTH_SHORT).show();
        LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSpecializationName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(20);
        mTextView.setPadding(3, 15, 0, 0);

    }

    /*try {
      mTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, mImage, 0);
    } catch (Exception e) {
      Log.w(this.getClass().getName(), "Drawable not found for : " + name);
    }*/
    if (data.getSpecializationLink().length() > 0) {
        mTextView.setBackgroundResource(R.drawable.button_config);
        mTextView.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (data.getSpecializationLink().trim().length() > 0)
                    openWebPage(data.getSpecializationLink(), mTextView);
                else {
                    mTextView.startAnimation(shake);
                    Toast.makeText(getActivity(), R.string.error_redirection_link, Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
    return mTextView;
}

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

private AppTextView addItem(final SkillsDetailsObject data) {
    final AppTextView mTextView = new AppTextView(getActivity());

    /*                 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();
        LinearLayout.LayoutParams mViewParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSkillsName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(12);/*from  www  .ja  v  a 2  s .  co m*/
        mTextView.setPadding(3, 15, 0, 0);
    }

    //Normal Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
        // Toast.makeText(getActivity(), "normal", Toast.LENGTH_SHORT).show();
        LinearLayout.LayoutParams mViewParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSkillsName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(16);
        mTextView.setPadding(3, 15, 0, 0);

    }

    // Large Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        //  Toast.makeText(getActivity(), "large", Toast.LENGTH_SHORT).show();
        LinearLayout.LayoutParams mViewParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSkillsName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(20);
        mTextView.setPadding(3, 15, 0, 0);

    }

    //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();
        LinearLayout.LayoutParams mViewParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSkillsName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(24);
        mTextView.setPadding(3, 15, 0, 0);

    }

    //Undefined Size

    else {
        // Toast.makeText(getActivity(), "undefined", Toast.LENGTH_SHORT).show();
        LinearLayout.LayoutParams mViewParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSkillsName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(20);
        mTextView.setPadding(3, 15, 0, 0);

    }

    /*try {
      mTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, mImage, 0);
    } catch (Exception e) {
      Log.w(this.getClass().getName(), "Drawable not found for : " + name);
    }*/
    if (data.getSkillsLink().length() > 0) {
        mTextView.setBackgroundResource(R.drawable.button_config);
        mTextView.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (data.getSkillsLink().trim().length() > 0)
                    openWebPage(data.getSkillsLink(), mTextView);
                else {
                    mTextView.startAnimation(shake);
                    Toast.makeText(getActivity(), R.string.error_redirection_link, Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
    return mTextView;
}

From source file:whipkey.stemesteem.components.EndingListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) < Configuration.SCREENLAYOUT_SIZE_LARGE) { // checks for large/xlarge screen.
        fillData();/*from   ww  w .ja  va  2  s  .co  m*/
    } // if we are on a large/xlarge screen device, skip the above and wait
      // for StemEsteem to call for fillData().
    addEndingButton = (Button) getView().findViewById(R.id.addEndingButton);
    addEndingButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (b != null) { // make sure a bundle existant.
                dialogClickListener.dialogItemClick(b, 1); // our add ending
                // button was
            } // clicked, ask for
              // a
              // AddEndingDialog.
        }
    });

}

From source file:com.juegoteca.actividades.Opciones.java

/**
 * Helper method to determine if the device has an extra-large screen. For
 * example, 10" tablets are extra-large.
 *//*from ww  w .j  a v  a2s.  c  om*/
@SuppressLint("InlinedApi")
private static boolean isXLargeTablet(Context context) {
    return (context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}

From source file:com.arisprung.tailgate.utilities.FacebookImageLoader.java

public FacebookImageLoader(Context context) {
    mContext = context;/*  ww w.  j a  v  a 2  s  . co m*/
    mMaxDimension = getMaxThumbnailDimension(mContext, false);
    int screenSize = context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK;
    // DisplayMetrics metrics = context.getResources().getDisplayMetrics();

}

From source file:com.near.chimerarevo.fragments.ProductsListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.products_grid_layout, container, false);

    boolean isLandscapeLarge = false;

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if ((getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
            isLandscapeLarge = true;/*  w ww  .  jav a  2  s  . co m*/
    } else
        isLandscapeLarge = false;

    if (!isLandscapeLarge)
        v.setPadding(0, getResources().getDimensionPixelSize(R.dimen.actionbar_height), 0, 0);

    GridView mGrid = (GridView) v.findViewById(R.id.products_grid);
    mCat = (Spinner) v.findViewById(R.id.category_spinner);
    mBrand = (Spinner) v.findViewById(R.id.brand_spinner);
    mLoading = (ProgressWheel) v.findViewById(R.id.product_progress);

    brandsList = new ArrayList<>();
    catList = new ArrayList<>();
    catIdList = new ArrayList<>();

    arrayList = new ArrayList<>();

    mAdapter = new ProductsAdapter(arrayList);
    if (mGrid != null) {
        mGrid.setAdapter(mAdapter);
        mGrid.setOnScrollListener(this);
        mGrid.setOnItemClickListener(this);
    }

    return v;
}

From source file:gr.scify.newsum.ui.Facebook.java

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

    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_NORMAL
            & (getResources().getConfiguration().screenLayout
                    & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_SMALL) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    }/*from   w w w  .j  a  v a  2 s  .  com*/

    SharedPreferences userlang = getSharedPreferences("lang", 0);
    String newlang = userlang.getString("lang", Locale.getDefault().getLanguage());
    // Changed getApplicationContext() to "this"
    Setlanguage.updateLanguage(this, newlang);

    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY);
        pendingAction = PendingAction.valueOf(name);
    }

    setContentView(R.layout.facebook);

    Bundle extras = getIntent().getExtras();
    summaryF = extras.getString("summaryF");

    loginButton = (LoginButton) findViewById(R.id.login_button);
    loginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() {
        @Override
        public void onUserInfoFetched(GraphUser user) {
            Facebook.this.user = user;
            updateUI();
            // It's possible that we were waiting for this.user to be populated in order to post a
            // status update.
            handlePendingAction();
        }
    });

    profilePictureView = (ProfilePictureView) findViewById(R.id.profilePicture);
    greeting = (TextView) findViewById(R.id.greeting);

    postStatusUpdateButton = (Button) findViewById(R.id.postStatusUpdateButton);
    postStatusUpdateButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            onClickPostStatusUpdate();
        }
    });

    controlsContainer = (ViewGroup) findViewById(R.id.main_ui_container);

    final FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragment_container);
    if (fragment != null) {
        // If we're being re-created and have a fragment, we need to a) hide the main UI controls and
        // b) hook up its listeners again.
        controlsContainer.setVisibility(View.GONE);
    }

    // Listen for changes in the back stack so we know if a fragment got popped off because the user
    // clicked the back button.
    fm.addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() {
        @Override
        public void onBackStackChanged() {
            if (fm.getBackStackEntryCount() == 0) {
                // We need to re-show our UI.
                controlsContainer.setVisibility(View.VISIBLE);
            }
        }
    });
}

From source file:com.coinblesk.client.KeyboardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_keyboard, container, false);

    final int screenLayout = getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK;
    switch (screenLayout) {
    case Configuration.SCREENLAYOUT_SIZE_LARGE:
    case Configuration.SCREENLAYOUT_SIZE_XLARGE:
        initLarge(view);/*from  w w  w.  j  a v  a 2s.c om*/
        break;
    default:
        initStandard(view);
        break;
    }

    TextView t1 = (TextView) view.findViewById(R.id.amount_large_text_view);
    TextView t2 = (TextView) view.findViewById(R.id.amount_large_text_currency);
    TextView t3 = (TextView) view.findViewById(R.id.amount_small_text_view);
    TextView t4 = (TextView) view.findViewById(R.id.amount_small_text_currency);

    View.OnLongClickListener listener = new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            DialogFragment fragment = CurrencyDialogFragment.newInstance();
            if (fragment != null) {
                fragment.show(KeyboardFragment.this.getFragmentManager(), TAG);
            }
            return true;
        }
    };

    t1.setOnLongClickListener(listener);
    t2.setOnLongClickListener(listener);
    t3.setOnLongClickListener(listener);
    t4.setOnLongClickListener(listener);

    UIUtils.refreshConnectionIconStatus(getActivity(), view);

    return view;
}

From source file:com.adjust.sdk.Util.java

private static String getScreenSize(final int screenLayout) {
    final int screenSize = screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;

    switch (screenSize) {
    case Configuration.SCREENLAYOUT_SIZE_SMALL:
        return SMALL;
    case Configuration.SCREENLAYOUT_SIZE_NORMAL:
        return NORMAL;
    case Configuration.SCREENLAYOUT_SIZE_LARGE:
        return LARGE;
    case 4:/*from   w w  w  .ja  v  a  2 s.c o  m*/
        return XLARGE;
    default:
        return UNKNOWN;
    }
}

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

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

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if ((getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
            isLandscapeLarge = true;//  w  ww.j ava2 s. c  o  m
    } else
        isLandscapeLarge = false;

    getToolbar().setNavigationIcon(getResources().getDrawable(R.drawable.ic_action_arrow_back));
    getToolbar().setNavigationOnClickListener(this);

    if (!isLandscapeLarge) {
        pager = (ViewPager) findViewById(R.id.view_pager);
        pager.setOnPageChangeListener(this);
    }
    mLoading = (ProgressWheel) findViewById(R.id.post_progress);
    mShadow = findViewById(R.id.drop_shadow);

    args = getIntent().getExtras();

    if (savedInstanceState != null)
        args = savedInstanceState.getBundle("arguments");

    if (args.containsKey(Constants.KEY_DATE))
        setToolbarStatusColor(args.getString(Constants.KEY_DATE).split("[\\x7C]")[1].trim());

    if (getIntent().getData() != null) {
        List<String> params = getIntent().getData().getPathSegments();
        if (params != null && params.size() > 0) {
            String ext_url = Constants.SITE_URL;
            for (String p : params) {
                ext_url += p + "/";
            }

            if (ext_url.contains("/" + Constants.PRODOTTI + "/")) {
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(ext_url));
                startActivity(i);
                finish();
            } else {
                if (ext_url.contains("/" + Constants.RECENSIONI + "/"))
                    args.putString(Constants.KEY_TYPE, Constants.RECENSIONI);
                else if (ext_url.contains("/" + Constants.VIDEO + "/"))
                    args.putString(Constants.KEY_TYPE, Constants.VIDEO);

                OkHttpUtils.getInstance().newCall(
                        new Request.Builder().url(URLUtils.getPostUrl(ext_url)).tag(ACTIVITY_TAG).build())
                        .enqueue(new GetPostCallback());
            }
        }
    }

    if (args != null) {
        if (!args.containsKey("isLandscapeLarge"))
            args.putBoolean("isLandscapeLarge", isLandscapeLarge);

        if (args.containsKey(Constants.KEY_ID)) {
            int post_id = args.getInt(Constants.KEY_ID);
            OkHttpUtils.getInstance()
                    .newCall(new Request.Builder().url(URLUtils.getPostUrl(post_id)).tag(ACTIVITY_TAG).build())
                    .enqueue(new GetPostCallback());
        } else if (args.containsKey(Constants.KEY_URL)) {
            String post_url = args.getString(Constants.KEY_URL);
            OkHttpUtils.getInstance()
                    .newCall(new Request.Builder().url(URLUtils.getPostUrl(post_url)).tag(ACTIVITY_TAG).build())
                    .enqueue(new GetPostCallback());
        }
    }
}