Example usage for android.view Gravity LEFT

List of usage examples for android.view Gravity LEFT

Introduction

In this page you can find the example usage for android.view Gravity LEFT.

Prototype

int LEFT

To view the source code for android.view Gravity LEFT.

Click Source Link

Document

Push object to the left of its container, not changing its size.

Usage

From source file:com.actionbarsherlock.internal.widget.IcsSpinner.java

/**
 * Describes how the selected item view is positioned. Currently only the horizontal component
 * is used. The default is determined by the current theme.
 *
 * @param gravity See {@link android.view.Gravity}
 *
 * @attr ref android.R.styleable#Spinner_gravity
 *///from  w  w w. ja  v  a 2s.  c  om
public void setGravity(int gravity) {
    if (mGravity != gravity) {
        if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == 0) {
            gravity |= Gravity.LEFT;
        }
        mGravity = gravity;
        requestLayout();
    }
}

From source file:com.github.obsessive.simplifyreader.ui.activity.HomeActivity.java

@Override
public void initializeViews(List<BaseLazyFragment> fragments, List<NavigationEntity> navigationList) {
    mActionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.drawer_open,
            R.string.drawer_close) {//from  ww w  .ja v  a2  s.c o  m

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            setTitle(getString(R.string.app_name));
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (null != mNavListAdapter) {
                setTitle(mNavListAdapter.getItem(mCurrentMenuCheckedPos).getName());
            }
        }
    };

    mActionBarDrawerToggle.setDrawerIndicatorEnabled(true);
    mDrawerLayout.setDrawerListener(mActionBarDrawerToggle);

    if (null != fragments && !fragments.isEmpty()) {
        mViewPager.setEnableScroll(false);
        mViewPager.setOffscreenPageLimit(fragments.size());
        mViewPager.setAdapter(new VPFragmentAdapter(getSupportFragmentManager(), fragments));
    }

    mNavListAdapter = new ListViewDataAdapter<NavigationEntity>(new ViewHolderCreator<NavigationEntity>() {

        @Override
        public ViewHolderBase<NavigationEntity> createViewHolder(int position) {

            return new ViewHolderBase<NavigationEntity>() {

                ImageView itemIcon;
                TextView itemName;

                @Override
                public View createView(LayoutInflater layoutInflater) {
                    View convertView = layoutInflater.inflate(R.layout.list_item_navigation, null);
                    itemIcon = ButterKnife.findById(convertView, R.id.list_item_navigation_icon);
                    itemName = ButterKnife.findById(convertView, R.id.list_item_navigation_name);

                    return convertView;
                }

                @Override
                public void showData(int i, NavigationEntity navigationEntity) {
                    itemIcon.setImageResource(navigationEntity.getIconResId());
                    itemName.setText(navigationEntity.getName());

                    if (mCurrentMenuCheckedPos == i) {
                        // checked
                        itemName.setTextColor(getResources().getColor(mCheckedListItemColorResIds[i]));
                    } else {
                        // unchecked
                        itemName.setTextColor(getResources().getColor(android.R.color.black));
                    }
                }
            };
        }
    });

    mNavListView.setAdapter(mNavListAdapter);
    mNavListAdapter.getDataList().addAll(navigationList);
    mNavListAdapter.notifyDataSetChanged();
    setTitle(mNavListAdapter.getItem(mCurrentMenuCheckedPos).getName());

    mNavListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mCurrentMenuCheckedPos = position;
            mNavListAdapter.notifyDataSetChanged();
            mDrawerLayout.closeDrawer(Gravity.LEFT);
            mViewPager.setCurrentItem(mCurrentMenuCheckedPos, false);
        }
    });
}

From source file:android.support.transition.Slide.java

/**
 * Change the edge that Views appear and disappear from.
 *
 * @param slideEdge The edge of the scene to use for Views appearing and disappearing. One of
 *                  {@link android.view.Gravity#LEFT}, {@link android.view.Gravity#TOP},
 *                  {@link android.view.Gravity#RIGHT}, {@link android.view.Gravity#BOTTOM},
 *                  {@link android.view.Gravity#START}, {@link android.view.Gravity#END}.
 *///from  w  w  w. j  av  a  2s  . c  o  m
public void setSlideEdge(@GravityFlag int slideEdge) {
    switch (slideEdge) {
    case Gravity.LEFT:
        mSlideCalculator = sCalculateLeft;
        break;
    case Gravity.TOP:
        mSlideCalculator = sCalculateTop;
        break;
    case Gravity.RIGHT:
        mSlideCalculator = sCalculateRight;
        break;
    case Gravity.BOTTOM:
        mSlideCalculator = sCalculateBottom;
        break;
    case Gravity.START:
        mSlideCalculator = sCalculateStart;
        break;
    case Gravity.END:
        mSlideCalculator = sCalculateEnd;
        break;
    default:
        throw new IllegalArgumentException("Invalid slide direction");
    }
    mSlideEdge = slideEdge;
    SidePropagation propagation = new SidePropagation();
    propagation.setSide(slideEdge);
    setPropagation(propagation);
}

From source file:angeloid.dreamnarae.SwipeyTabs.java

/**
 * Update the ellipsize of the text views
 *//*  ww w .  j  a  v a  2s  .  c  o  m*/
private void updateEllipsize() {
    if (mAdapter == null) {
        return;
    }

    final int count = mAdapter.getCount();

    for (int i = 0; i < count; i++) {
        TextView tab = (TextView) getChildAt(i);

        if (i < mCurrentPos) {
            tab.setEllipsize(null);
            tab.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
        } else if (i == mCurrentPos) {
            tab.setEllipsize(TruncateAt.END);
            tab.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
        } else if (i > mCurrentPos) {
            tab.setEllipsize(null);
            tab.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
        }
    }
}

From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java

/**
 * SINGLE IMAGE ROW/*  w  w w  . j a  va 2 s.com*/
 * @param att
 * @param linear
 * @return
 */
public LinearLayout getSingleImageRow(Map<String, String> att, LinearLayout linear) {

    LinearLayout container_layout = new LinearLayout(context);
    container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo));
    container_layout.setMinimumHeight(46);
    container_layout.setVerticalGravity(Gravity.CENTER);

    LinearLayout.LayoutParams value = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.5f);
    TextView tx = new TextView(context);
    tx.setText(att.get("title"));
    tx.setTextSize(11);
    tx.setTypeface(null, Typeface.BOLD);
    tx.setGravity(Gravity.LEFT);
    tx.setPadding(3, 0, 0, 2);
    tx.setTextColor(Color.rgb(66, 66, 66));
    container_layout.addView(tx, value);

    LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 40, 0.5f);
    ImageView img = new ImageView(context);
    String path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value"));
    img.setImageResource(context.getResources().getIdentifier(path, null, null));
    img.setPadding(0, 3, 0, 3);
    container_layout.addView(img, value_params);

    linear.addView(container_layout);
    return linear;
}

From source file:com.chess.genesis.view.SwipeTabs.java

/**
 * Update the ellipsize of the text views
 *//* w w w  .  java2  s.  co m*/
private void updateEllipsize() {
    if (mAdapter == null)
        return;

    final int count = mAdapter.getCount();

    for (int i = 0; i < count; i++) {
        final TextView tab = (TextView) getChildAt(i);

        if (i < mCurrentPos) {
            tab.setEllipsize(null);
            tab.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
        } else if (i == mCurrentPos) {
            tab.setEllipsize(TruncateAt.END);
            tab.setGravity(Gravity.CENTER | Gravity.CENTER_VERTICAL);
        } else if (i > mCurrentPos) {
            tab.setEllipsize(null);
            tab.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
        }
    }
}

From source file:com.farmerbb.taskbar.service.StartMenuService.java

@SuppressLint("RtlHardcoded")
private void drawStartMenu() {
    IconCache.getInstance(this).clearCache();

    final SharedPreferences pref = U.getSharedPreferences(this);
    final boolean hasHardwareKeyboard = getResources()
            .getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS;

    switch (pref.getString("show_search_bar", "keyboard")) {
    case "always":
        shouldShowSearchBox = true;/*from   w  w w .j av a 2s.  c  o  m*/
        break;
    case "keyboard":
        shouldShowSearchBox = hasHardwareKeyboard;
        break;
    case "never":
        shouldShowSearchBox = false;
        break;
    }

    // Initialize layout params
    windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    U.setCachedRotation(windowManager.getDefaultDisplay().getRotation());

    final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_PHONE,
            shouldShowSearchBox ? 0
                    : WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                            | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
            PixelFormat.TRANSLUCENT);

    // Determine where to show the start menu on screen
    switch (U.getTaskbarPosition(this)) {
    case "bottom_left":
        layoutId = R.layout.start_menu_left;
        params.gravity = Gravity.BOTTOM | Gravity.LEFT;
        break;
    case "bottom_vertical_left":
        layoutId = R.layout.start_menu_vertical_left;
        params.gravity = Gravity.BOTTOM | Gravity.LEFT;
        break;
    case "bottom_right":
        layoutId = R.layout.start_menu_right;
        params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
        break;
    case "bottom_vertical_right":
        layoutId = R.layout.start_menu_vertical_right;
        params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
        break;
    case "top_left":
        layoutId = R.layout.start_menu_top_left;
        params.gravity = Gravity.TOP | Gravity.LEFT;
        break;
    case "top_vertical_left":
        layoutId = R.layout.start_menu_vertical_left;
        params.gravity = Gravity.TOP | Gravity.LEFT;
        break;
    case "top_right":
        layoutId = R.layout.start_menu_top_right;
        params.gravity = Gravity.TOP | Gravity.RIGHT;
        break;
    case "top_vertical_right":
        layoutId = R.layout.start_menu_vertical_right;
        params.gravity = Gravity.TOP | Gravity.RIGHT;
        break;
    }

    // Initialize views
    int theme = 0;

    switch (pref.getString("theme", "light")) {
    case "light":
        theme = R.style.AppTheme;
        break;
    case "dark":
        theme = R.style.AppTheme_Dark;
        break;
    }

    ContextThemeWrapper wrapper = new ContextThemeWrapper(this, theme);
    layout = (StartMenuLayout) LayoutInflater.from(wrapper).inflate(layoutId, null);
    startMenu = (GridView) layout.findViewById(R.id.start_menu);

    if ((shouldShowSearchBox && !hasHardwareKeyboard)
            || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1)
        layout.viewHandlesBackButton();

    boolean scrollbar = pref.getBoolean("scrollbar", false);
    startMenu.setFastScrollEnabled(scrollbar);
    startMenu.setFastScrollAlwaysVisible(scrollbar);
    startMenu.setScrollBarStyle(scrollbar ? View.SCROLLBARS_OUTSIDE_INSET : View.SCROLLBARS_INSIDE_OVERLAY);

    if (pref.getBoolean("transparent_start_menu", false))
        startMenu.setBackgroundColor(0);

    searchView = (SearchView) layout.findViewById(R.id.search);

    int backgroundTint = U.getBackgroundTint(this);

    FrameLayout startMenuFrame = (FrameLayout) layout.findViewById(R.id.start_menu_frame);
    FrameLayout searchViewLayout = (FrameLayout) layout.findViewById(R.id.search_view_layout);
    startMenuFrame.setBackgroundColor(backgroundTint);
    searchViewLayout.setBackgroundColor(backgroundTint);

    if (shouldShowSearchBox) {
        if (!hasHardwareKeyboard)
            searchView.setIconifiedByDefault(true);

        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String query) {
                if (!hasSubmittedQuery) {
                    ListAdapter adapter = startMenu.getAdapter();
                    if (adapter != null) {
                        hasSubmittedQuery = true;

                        if (adapter.getCount() > 0) {
                            View view = adapter.getView(0, null, startMenu);
                            LinearLayout layout = (LinearLayout) view.findViewById(R.id.entry);
                            layout.performClick();
                        } else {
                            if (pref.getBoolean("hide_taskbar", true)
                                    && !FreeformHackHelper.getInstance().isInFreeformWorkspace())
                                LocalBroadcastManager.getInstance(StartMenuService.this)
                                        .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_TASKBAR"));
                            else
                                LocalBroadcastManager.getInstance(StartMenuService.this)
                                        .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU"));

                            Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
                            intent.putExtra(SearchManager.QUERY, query);
                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            if (intent.resolveActivity(getPackageManager()) != null)
                                startActivity(intent);
                            else {
                                Uri uri = new Uri.Builder().scheme("https").authority("www.google.com")
                                        .path("search").appendQueryParameter("q", query).build();

                                intent = new Intent(Intent.ACTION_VIEW);
                                intent.setData(uri);
                                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

                                try {
                                    startActivity(intent);
                                } catch (ActivityNotFoundException e) {
                                    /* Gracefully fail */ }
                            }
                        }
                    }
                }
                return true;
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                searchView.setIconified(false);

                View closeButton = searchView.findViewById(R.id.search_close_btn);
                if (closeButton != null)
                    closeButton.setVisibility(View.GONE);

                refreshApps(newText, false);

                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) {
                    new Handler().postDelayed(() -> {
                        EditText editText = (EditText) searchView.findViewById(R.id.search_src_text);
                        if (editText != null) {
                            editText.requestFocus();
                            editText.setSelection(editText.getText().length());
                        }
                    }, 50);
                }

                return true;
            }
        });

        searchView.setOnQueryTextFocusChangeListener((view, b) -> {
            if (!hasHardwareKeyboard) {
                ViewGroup.LayoutParams params1 = startMenu.getLayoutParams();
                params1.height = getResources().getDimensionPixelSize(b
                        && !U.isServiceRunning(this, "com.farmerbb.secondscreen.service.DisableKeyboardService")
                                ? R.dimen.start_menu_height_half
                                : R.dimen.start_menu_height);
                startMenu.setLayoutParams(params1);
            }

            if (!b) {
                if (hasHardwareKeyboard && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1)
                    LocalBroadcastManager.getInstance(StartMenuService.this)
                            .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU"));
                else {
                    InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
                    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
                }
            }
        });

        searchView.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);

        LinearLayout powerButton = (LinearLayout) layout.findViewById(R.id.power_button);
        powerButton.setOnClickListener(view -> {
            int[] location = new int[2];
            view.getLocationOnScreen(location);
            openContextMenu(location);
        });

        powerButton.setOnGenericMotionListener((view, motionEvent) -> {
            if (motionEvent.getAction() == MotionEvent.ACTION_BUTTON_PRESS
                    && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) {
                int[] location = new int[2];
                view.getLocationOnScreen(location);
                openContextMenu(location);
            }
            return false;
        });

        searchViewLayout.setOnClickListener(view -> searchView.setIconified(false));

        startMenu.setOnItemClickListener((parent, view, position, id) -> {
            hideStartMenu();

            AppEntry entry = (AppEntry) parent.getAdapter().getItem(position);
            U.launchApp(StartMenuService.this, entry.getPackageName(), entry.getComponentName(),
                    entry.getUserId(StartMenuService.this), null, false, false);
        });

        if (pref.getBoolean("transparent_start_menu", false))
            layout.findViewById(R.id.search_view_child_layout).setBackgroundColor(0);
    } else
        searchViewLayout.setVisibility(View.GONE);

    textView = (TextView) layout.findViewById(R.id.no_apps_found);

    LocalBroadcastManager.getInstance(this).unregisterReceiver(toggleReceiver);
    LocalBroadcastManager.getInstance(this).unregisterReceiver(toggleReceiverAlt);
    LocalBroadcastManager.getInstance(this).unregisterReceiver(hideReceiver);

    LocalBroadcastManager.getInstance(this).registerReceiver(toggleReceiver,
            new IntentFilter("com.farmerbb.taskbar.TOGGLE_START_MENU"));
    LocalBroadcastManager.getInstance(this).registerReceiver(toggleReceiverAlt,
            new IntentFilter("com.farmerbb.taskbar.TOGGLE_START_MENU_ALT"));
    LocalBroadcastManager.getInstance(this).registerReceiver(hideReceiver,
            new IntentFilter("com.farmerbb.taskbar.HIDE_START_MENU"));

    handler = new Handler();
    refreshApps(true);

    windowManager.addView(layout, params);
}

From source file:com.hippo.widget.slidingdrawerlayout.ActionBarDrawerToggle.java

/**
 * Synchronize the state of the drawer indicator/affordance with the linked DrawerLayout.
 *
 * <p>This should be called from your <code>Activity</code>'s
 * {@link Activity#onPostCreate(android.os.Bundle) onPostCreate} method to synchronize after
 * the DrawerLayout's instance state has been restored, and any other time when the state
 * may have diverged in such a way that the ActionBarDrawerToggle was not notified.
 * (For example, if you stop forwarding appropriate drawer events for a period of time.)</p>
 *//*from  w  ww.jav  a 2  s  . c  o m*/
public void syncState() {
    if (mDrawerLayout.isDrawerOpen(Gravity.LEFT)) {
        mSlider.setPosition(1);
    } else {
        mSlider.setPosition(0);
    }
    if (mDrawerIndicatorEnabled) {
        setActionBarUpIndicator((Drawable) mSlider,
                mDrawerLayout.isDrawerOpen(Gravity.LEFT) ? mCloseDrawerContentDescRes
                        : mOpenDrawerContentDescRes);
    }
}

From source file:com.aegiswallet.actions.MainActivity.java

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

    application = (PayBitsApplication) getApplication();
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    smsTxnsPrefs = application.getSharedPreferences(getString(R.string.sms_transaction_filename),
            Context.MODE_PRIVATE);
    //smsTxnsPrefs.edit().clear().commit();
    wallet = application.getWallet();/*w ww. j  av  a  2s.c o m*/
    application.initializeShamirSecretSharing(context);

    checkIfAppInitiated();

    setContentView(R.layout.activity_main);
    getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    getActionBar().setCustomView(R.layout.aegis_actionbar);

    openDrawerButton = (ImageButton) findViewById(R.id.action_bar_icon);
    openDrawerButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mDrawerLayout != null) {
                if (mDrawerLayout.isDrawerOpen(Gravity.LEFT))
                    mDrawerLayout.closeDrawer(Gravity.LEFT);
                else
                    mDrawerLayout.openDrawer(Gravity.LEFT);
            }
        }
    });

    notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    blockchainStatus = (TextView) findViewById(R.id.blockchain_status);
    blockchainStatus.setTypeface(BasicUtils.getCustomTypeFace(getBaseContext()));

    setupBlockchainBroadcastReceiver(blockchainStatus);

    GetCurrencyInfoTask currencyInfoTask = new GetCurrencyInfoTask(getApplicationContext());
    currencyInfoTask.execute();
    //currencyInfoTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);

    watchedBalanceLinearLayout = (LinearLayout) findViewById(R.id.watched_balance_view);

    walletBalanceView = (TextView) findViewById(R.id.wallet_balance);
    walletBalanceView.setTypeface(BasicUtils.getCustomTypeFace(getBaseContext()));

    if (!prefs.contains(Constants.CURRENCY_PREF_KEY)) {
        prefs.edit().putString(Constants.CURRENCY_PREF_KEY, "USD").commit();
    }

    walletWatchAddressBalanceView = (TextView) findViewById(R.id.watch_only_balance);

    updateMainViews();
    determineSelectedAddress();
    application.startBlockchainService(false);
    handleButtons();

    recentTransactions = (ArrayList<Transaction>) wallet.getRecentTransactions(50, true);
    transactionListAdapter = new TransactionListAdapter(this, R.layout.transaction_detail_row,
            recentTransactions, wallet);

    transactionListView = (ListView) findViewById(R.id.transaction_list);
    if (recentTransactions == null || recentTransactions.size() == 0)
        transactionListView.setEmptyView(findViewById(R.id.transaction_empty_view_main));

    transactionListView.setAdapter(transactionListAdapter);

    handlePendingTransactions();

    initiateHandlers(walletBalanceView);
    application.addWalletListener(balanceHandler);

    checkWalletEncryptionStatus();
    this.registerReceiver(receiver, new IntentFilter(PeerBlockchainService.ACTION_BLOCKCHAIN_STATE));

    doDrawerSetup();

    String message = getIntent().getStringExtra("message");
    if (message != null) {
        Toast.makeText(context, message, Toast.LENGTH_LONG).show();
        getIntent().removeExtra("message");
    }

    nfcEnabled = prefs.contains(Constants.SHAMIR_ENCRYPTED_KEY) ? false : true;
    checkBackupDone();
    doBackupReminder();

    isServiceBound = this.bindService(new Intent(this, PeerBlockchainService.class),
            blockchainServiceConnection, Context.BIND_AUTO_CREATE);

    HandleSMSResponsesTask handleSMSResponsesTask = new HandleSMSResponsesTask(this);
    //handleSMSResponsesTask.execute();
    handleSMSResponsesTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);

    sendMessagesToWear();

}

From source file:com.moods_final.moods.entertainment.VideoListDemoActivity.java

/**
 * Sets up the layout programatically for the three different states. Portrait, landscape or
 * fullscreen+landscape. This has to be done programmatically because we handle the orientation
 * changes ourselves in order to get fluent fullscreen transitions, so the xml layout resources
 * do not get reloaded./*  w  ww.j  a va  2  s  . c  o  m*/
 */
private void layout() {
    boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;

    listFragment.getView().setVisibility(isFullscreen ? View.GONE : View.VISIBLE);
    listFragment.setLabelVisibility(isPortrait);
    closeButton.setVisibility(isPortrait ? View.VISIBLE : View.GONE);

    if (isFullscreen) {
        videoBox.setTranslationY(0); // Reset any translation that was applied in portrait.
        setLayoutSize(videoFragment.getView(), MATCH_PARENT, MATCH_PARENT);
        setLayoutSizeAndGravity(videoBox, MATCH_PARENT, MATCH_PARENT, Gravity.TOP | Gravity.LEFT);
    } else if (isPortrait) {
        setLayoutSize(listFragment.getView(), MATCH_PARENT, MATCH_PARENT);
        setLayoutSize(videoFragment.getView(), MATCH_PARENT, WRAP_CONTENT);
        setLayoutSizeAndGravity(videoBox, MATCH_PARENT, WRAP_CONTENT, Gravity.BOTTOM);
    } else {
        videoBox.setTranslationY(0); // Reset any translation that was applied in portrait.
        int screenWidth = dpToPx(getResources().getConfiguration().screenWidthDp);
        setLayoutSize(listFragment.getView(), screenWidth / 4, MATCH_PARENT);
        int videoWidth = screenWidth - screenWidth / 4 - dpToPx(LANDSCAPE_VIDEO_PADDING_DP);
        setLayoutSize(videoFragment.getView(), videoWidth, WRAP_CONTENT);
        setLayoutSizeAndGravity(videoBox, videoWidth, WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL);
    }
}