Example usage for android.content.res Configuration ORIENTATION_PORTRAIT

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

Introduction

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

Prototype

int ORIENTATION_PORTRAIT

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

Click Source Link

Document

Constant for #orientation , value corresponding to the port resource qualifier.

Usage

From source file:com.swisscom.safeconnect.fragment.LogoFragment.java

protected void adjustLogoOnKeyboardShow(final View v) {
    final int tablet = (getResources().getBoolean(R.bool.isTablet) ? 1 : 0);
    v.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override/*  w w  w  . j  av a2s. com*/
        public void onGlobalLayout() {
            Rect r = new Rect();
            v.getWindowVisibleDisplayFrame(r);
            int heightDiff = v.getRootView().getHeight() - (r.bottom - r.top);
            // keyboard detection
            if (heightDiff > 100) {
                int orientation = getActivity().getResources().getConfiguration().orientation;
                // Remove logo tablet landscape and phone portrait
                if ((getActivity() != null && orientation == Configuration.ORIENTATION_LANDSCAPE)
                        || (tablet == 0 && orientation == Configuration.ORIENTATION_PORTRAIT)) {
                    if (imgLogo != null) {
                        imgLogo.setVisibility(View.GONE);
                    }
                }
            } else {
                if (imgLogo != null) {
                    imgLogo.setVisibility(View.VISIBLE);
                }
            }
        }
    });
}

From source file:com.zpwebsites.linuxonandroid.BaseActivity.java

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

    setTitle(mTitleRes);//  w w w .  ja  v a2 s .  co  m

    // set the Behind View
    setBehindContentView(R.layout.menu_frame);

    // customize the SlidingMenu
    SlidingMenu sm = getSlidingMenu();
    sm.setShadowWidthRes(R.dimen.shadow_width);
    sm.setShadowDrawable(R.drawable.shadow);
    // sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    int width = displaymetrics.widthPixels;

    if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        // code to do for Portrait Mode
        sm.setBehindWidth((int) (width * 0.7));
    } else {
        // code to do for Landscape Mode
        sm.setBehindWidth((int) (width * 0.25));
    }
    sm.setFadeDegree(0.35f);
    sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    TextView txt_Installview = (TextView) findViewById(R.id.Installtxtview);
    txt_Installview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), Install_Guides.class);
            v.getContext().startActivity(intent);
        }

    });
    TextView txt_Launchtxtview = (TextView) findViewById(R.id.Launchtxtview);
    txt_Launchtxtview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), Launcher.class);
            v.getContext().startActivity(intent);
        }

    });
    TextView txt_Tipstxtview = (TextView) findViewById(R.id.Tipstxtview);
    txt_Tipstxtview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), Tips.class);
            v.getContext().startActivity(intent);
        }

    });
    TextView txt_FAQtxtview = (TextView) findViewById(R.id.FAQtxtview);
    txt_FAQtxtview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), FAQ.class);
            v.getContext().startActivity(intent);
        }

    });
    TextView txt_Changelogtxtview = (TextView) findViewById(R.id.Changelogtxtview);
    txt_Changelogtxtview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), Change_logs.class);
            v.getContext().startActivity(intent);
        }

    });
    TextView txt_Newstxtview = (TextView) findViewById(R.id.Newstxtview);
    txt_Newstxtview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), News.class);
            v.getContext().startActivity(intent);
        }

    });
    TextView txt_Aboutstxtview = (TextView) findViewById(R.id.Aboutstxtview);
    txt_Aboutstxtview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), About.class);
            v.getContext().startActivity(intent);
        }

    });

}

From source file:org.dvbviewer.controller.ui.phone.VideoPlayerActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    Log.i(VideoPlayerActivity.class.getSimpleName(), "onConfigurationChanged");
    int orientation = getResources().getConfiguration().orientation;
    if (orientation == Configuration.ORIENTATION_LANDSCAPE
            || orientation == Configuration.ORIENTATION_PORTRAIT) {
        if (videoFragment != null) {
            videoFragment.resetLayout();
        }/*from w  ww. j a  va  2  s  .  c  o m*/
    }
    super.onConfigurationChanged(newConfig);
}

From source file:com.bartoszlipinski.flippablestackview.sample.activity.MainActivity.java

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

    setContentView(R.layout.activity_main);

    createViewPagerFragments();//from  ww w  .j a v a2s  . c o m
    mPageAdapter = new ColorFragmentAdapter(getSupportFragmentManager(), mViewPagerFragments);

    boolean portrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;

    mFlippableStack = (FlippableStackView) findViewById(R.id.flippable_stack_view);
    mFlippableStack.initStack(4,
            portrait ? StackPageTransformer.Orientation.VERTICAL : StackPageTransformer.Orientation.HORIZONTAL);
    mFlippableStack.setAdapter(mPageAdapter);
}

From source file:com.mruddy.devdataviewer.DevDataListFragment.java

@SuppressLint("InlinedApi")
private static void initMaps() {
    DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_LOW, "LDPI");
    DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_MEDIUM, "MDPI");
    DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_HIGH, "HDPI");
    DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_XHIGH, "XHDPI");
    DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_XXHIGH, "XXHDPI");
    DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_XXXHIGH, "XXXHDPI");
    DevDataListFragment.ROTATION.append(Surface.ROTATION_0, "0");
    DevDataListFragment.ROTATION.append(Surface.ROTATION_90, "90");
    DevDataListFragment.ROTATION.append(Surface.ROTATION_180, "180");
    DevDataListFragment.ROTATION.append(Surface.ROTATION_270, "270");
    DevDataListFragment.ORIENTATION.append(Configuration.ORIENTATION_UNDEFINED, "undefined");
    DevDataListFragment.ORIENTATION.append(Configuration.ORIENTATION_PORTRAIT, "portrait");
    DevDataListFragment.ORIENTATION.append(Configuration.ORIENTATION_LANDSCAPE, "landscape");
    DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_UNDEFINED, "undefined");
    DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_SMALL, "small");
    DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_NORMAL, "normal");
    DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_LARGE, "large");
    DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_XLARGE, "xlarge");
}

From source file:com.zpwebsites.linuxonandroid.ListBaseActivity.java

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

    setTitle(mTitleRes);/*from  w w  w  .j av  a2  s  .  c  o  m*/

    // set the Behind View
    setBehindContentView(R.layout.menu_frame);

    // customize the SlidingMenu
    SlidingMenu sm = getSlidingMenu();
    sm.setShadowWidthRes(R.dimen.shadow_width);
    sm.setShadowDrawable(R.drawable.shadow);
    //sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    int width = displaymetrics.widthPixels;

    if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        // code to do for Portrait Mode
        sm.setBehindWidth((int) (width * 0.7));
    } else {
        // code to do for Landscape Mode  
        sm.setBehindWidth((int) (width * 0.25));
    }
    sm.setFadeDegree(0.35f);
    sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    TextView txt_Installview = (TextView) findViewById(R.id.Installtxtview);
    txt_Installview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), Install_Guides.class);
            v.getContext().startActivity(intent);
        }

    });
    TextView txt_Launchtxtview = (TextView) findViewById(R.id.Launchtxtview);
    txt_Launchtxtview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), Launcher.class);
            v.getContext().startActivity(intent);
        }

    });
    TextView txt_Tipstxtview = (TextView) findViewById(R.id.Tipstxtview);
    txt_Tipstxtview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), Tips.class);
            v.getContext().startActivity(intent);
        }

    });
    TextView txt_FAQtxtview = (TextView) findViewById(R.id.FAQtxtview);
    txt_FAQtxtview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), FAQ.class);
            v.getContext().startActivity(intent);
        }

    });
    TextView txt_Changelogtxtview = (TextView) findViewById(R.id.Changelogtxtview);
    txt_Changelogtxtview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), Change_logs.class);
            v.getContext().startActivity(intent);
        }

    });
    TextView txt_Newstxtview = (TextView) findViewById(R.id.Newstxtview);
    txt_Newstxtview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), News.class);
            v.getContext().startActivity(intent);
        }

    });
    TextView txt_Aboutstxtview = (TextView) findViewById(R.id.Aboutstxtview);
    txt_Aboutstxtview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), About.class);
            v.getContext().startActivity(intent);
        }

    });
}

From source file:com.teclib.flyvemdm.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        setContentView(R.layout.activity_main_portrait);
        FlyveLog.d("PORTRAIT");
    } else {//from  ww w .jav a2 s .c o m
        setContentView(R.layout.activity_main_paysage);
        FlyveLog.d("PAYSAGE");
    }

    View someView = findViewById(R.id.view);
    View root = someView.getRootView();
    root.setBackgroundColor(getResources().getColor(R.color.status_text));

    Intent inventoryService = new Intent(this.getBaseContext(), Agent.class);
    this.getBaseContext().startService(inventoryService);

    Intent monServiceIntent = new Intent(this.getBaseContext(), BootService.class);
    this.getBaseContext().startService(monServiceIntent);
}

From source file:rocks.ecox.flickster.adapters.MovieArrayAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // Get the data item for position
    Movie movie = getItem(position);/*from w  w  w  .  j a v  a  2  s.  co m*/
    // Determine orientation
    int orientation = getContext().getResources().getConfiguration().orientation;
    // Determine the movie rating
    Double rating = movie.getRating();
    final Double highRating = 5.0;
    String layout = "";

    ViewHolder viewHolder;
    LayoutInflater inflater = LayoutInflater.from(getContext());
    viewHolder = new ViewHolder();

    // Choose whether layout should have movie details
    if (orientation == Configuration.ORIENTATION_PORTRAIT && rating >= highRating) {
        convertView = inflater.inflate(R.layout.item_movie_high_rating, parent, false);
        layout = "highRating";
    } else {
        convertView = inflater.inflate(R.layout.item_movie, parent, false);
        layout = "lowRating";
    }
    // Find the ImageView
    viewHolder.placeholder = (Drawable) ContextCompat.getDrawable(getContext(), R.drawable.poster_placeholder);
    viewHolder.ivImage = (ImageView) convertView.findViewById(R.id.ivMovieImage);
    viewHolder.tvTitle = (TextView) convertView.findViewById(tvTitle);
    viewHolder.tvOverview = (TextView) convertView.findViewById(tvOverview);
    // Cache the viewHolder object inside the fresh view
    convertView.setTag(viewHolder);

    // Set the background to black
    convertView.setBackgroundColor(Color.BLACK);
    // Clear out image from convertView
    viewHolder.ivImage.setImageResource(0);

    // Populate data
    if (layout.equals("lowRating")) {
        viewHolder.tvTitle.setText(movie.getOriginalTitle());
        viewHolder.tvOverview.setText(movie.getOverview());
    }

    if (orientation == Configuration.ORIENTATION_PORTRAIT && layout.equals("lowRating")) {
        Picasso.with(getContext()).load(movie.getPosterPath()).error(viewHolder.placeholder)
                .placeholder(viewHolder.placeholder).into(viewHolder.ivImage);
    } else {
        Picasso.with(getContext()).load(movie.getBackdropPath()).error(viewHolder.placeholder)
                .placeholder(viewHolder.placeholder).into(viewHolder.ivImage);
    }

    // Return the view
    return convertView;
}

From source file:com.waz.zclient.utils.ViewUtils.java

public static void lockScreenOrientation(int orientation, Activity activity) {
    switch (orientation) {
    case Configuration.ORIENTATION_PORTRAIT:
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;//  w ww.  java  2  s  . c  o m
    case Configuration.ORIENTATION_LANDSCAPE:
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        break;
    default:
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        break;
    }
}

From source file:org.iisgcp.waterwalk.fragment.FactFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_fact, container, false);
    mFactText = (TextView) view.findViewById(R.id.fact_text);

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        mLayout = (LinearLayout) view.findViewById(R.id.picture_layout);
    } else {/* w w w.  j a  v  a2  s .c  om*/
        mImageView = (ImageView) view.findViewById(R.id.picture);
    }

    return view;
}