Example usage for android.view Gravity END

List of usage examples for android.view Gravity END

Introduction

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

Prototype

int END

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

Click Source Link

Document

Push object to x-axis position at the end of its container, not changing its size.

Usage

From source file:org.akop.crosswords.fragment.CrosswordFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Crossword.Word item = mHintAdapter.findWord((int) id);
    if (item != null) {
        mCrosswordView.selectWord(item);
        if (mDrawerLayout != null) {
            mDrawerLayout.closeDrawer(Gravity.END);
        }/*from www .  j  a  v a 2  s.c  om*/
    }
}

From source file:com.michaldabski.filemanager.folders.FolderActivity.java

@Override
public void onClipboardContentsChange(Clipboard clipboard) {
    invalidateOptionsMenu();//ww  w .j av  a 2s .  c  o m

    ListView clipboardListView = (ListView) findViewById(R.id.listClipboard);

    if (clipboard.isEmpty() && drawerLayout != null)
        drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.END);
    else {
        drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.END);
        FileManagerApplication application = (FileManagerApplication) getApplication();
        if (clipboardListView != null) {
            ClipboardFileAdapter clipboardFileAdapter = new ClipboardFileAdapter(this, clipboard,
                    application.getFileIconResolver());
            clipboardFileAdapter.setFontApplicator(fontApplicator);
            clipboardListView.setAdapter(clipboardFileAdapter);
        }
    }
}

From source file:com.rong.library.widget.mapsearchbar.MapSearchBar.java

public void inflateMenu(@MenuRes int menuRes) {
    if (menuRes > 0) {
        btnMenu.setVisibility(VISIBLE);/*from   w ww .j a  v  a  2  s  . co  m*/
        btnMenu.setOnClickListener(this);

        popupMenu = new PopupMenu(getContext(), btnMenu);
        popupMenu.setOnMenuItemClickListener(this);
        popupMenu.inflate(menuRes);
        popupMenu.setGravity(Gravity.END);
    }
}

From source file:fr.cph.chicago.core.adapter.FavoritesAdapter.java

private void handleStation(@NonNull final FavoritesViewHolder holder, @NonNull final Station station) {
    final int stationId = station.getId();
    final Set<TrainLine> trainLines = station.getLines();

    holder.favoriteImage.setImageResource(R.drawable.ic_train_white_24dp);
    holder.stationNameTextView.setText(station.getName());
    holder.detailsButton.setOnClickListener(v -> {
        if (!Util.isNetworkAvailable(context)) {
            Util.showNetworkErrorMessage(activity);
        } else {//from w w  w  .  ja va 2 s  .c  o m
            // Start station activity
            final Bundle extras = new Bundle();
            final Intent intent = new Intent(context, StationActivity.class);
            extras.putInt(activity.getString(R.string.bundle_train_stationId), stationId);
            intent.putExtras(extras);
            activity.startActivity(intent);
        }
    });

    holder.mapButton.setText(activity.getString(R.string.favorites_view_trains));
    holder.mapButton.setOnClickListener(v -> {
        if (!Util.isNetworkAvailable(context)) {
            Util.showNetworkErrorMessage(activity);
        } else {
            if (trainLines.size() == 1) {
                startActivity(trainLines.iterator().next());
            } else {
                final List<Integer> colors = new ArrayList<>();
                final List<String> values = Stream.of(trainLines).flatMap(line -> {
                    final int color = line != TrainLine.YELLOW ? line.getColor()
                            : ContextCompat.getColor(context, R.color.yellowLine);
                    colors.add(color);
                    return Stream.of(line.toStringWithLine());
                }).collect(Collectors.toList());

                final PopupFavoritesTrainAdapter ada = new PopupFavoritesTrainAdapter(activity, values, colors);

                final List<TrainLine> lines = new ArrayList<>();
                lines.addAll(trainLines);

                final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
                builder.setAdapter(ada, (dialog, position) -> startActivity(lines.get(position)));

                final int[] screenSize = Util.getScreenSize(context);
                final AlertDialog dialog = builder.create();
                dialog.show();
                if (dialog.getWindow() != null) {
                    dialog.getWindow().setLayout((int) (screenSize[0] * 0.7), LayoutParams.WRAP_CONTENT);
                }
            }
        }
    });

    Stream.of(trainLines).forEach(trainLine -> {
        boolean newLine = true;
        int i = 0;
        final Map<String, StringBuilder> etas = favoritesData.getTrainArrivalByLine(stationId, trainLine);
        for (final Entry<String, StringBuilder> entry : etas.entrySet()) {
            final LinearLayout.LayoutParams containParam = getInsideParams(newLine, i == etas.size() - 1);
            final LinearLayout container = new LinearLayout(context);
            container.setOrientation(LinearLayout.HORIZONTAL);
            container.setLayoutParams(containParam);

            // Left
            final RelativeLayout.LayoutParams leftParam = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            final RelativeLayout left = new RelativeLayout(context);
            left.setLayoutParams(leftParam);

            final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context, trainLine);
            int lineId = Util.generateViewId();
            lineIndication.setId(lineId);

            final RelativeLayout.LayoutParams destinationParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            destinationParams.addRule(RelativeLayout.RIGHT_OF, lineId);
            destinationParams.setMargins(pixelsHalf, 0, 0, 0);

            final String destination = entry.getKey();
            final TextView destinationTextView = new TextView(context);
            destinationTextView.setTextColor(grey5);
            destinationTextView.setText(destination);
            destinationTextView.setLines(1);
            destinationTextView.setLayoutParams(destinationParams);

            left.addView(lineIndication);
            left.addView(destinationTextView);

            // Right
            final LinearLayout.LayoutParams rightParams = new LinearLayout.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            rightParams.setMargins(marginLeftPixel, 0, 0, 0);
            final LinearLayout right = new LinearLayout(context);
            right.setOrientation(LinearLayout.VERTICAL);
            right.setLayoutParams(rightParams);

            final StringBuilder currentEtas = entry.getValue();
            final TextView arrivalText = new TextView(context);
            arrivalText.setText(currentEtas);
            arrivalText.setGravity(Gravity.END);
            arrivalText.setSingleLine(true);
            arrivalText.setTextColor(grey5);
            arrivalText.setEllipsize(TextUtils.TruncateAt.END);

            right.addView(arrivalText);

            container.addView(left);
            container.addView(right);

            holder.mainLayout.addView(container);

            newLine = false;
            i++;
        }
    });
}

From source file:com.maskyn.fileeditorpro.activity.MainActivity.java

@Override
public void onBackPressed() {

    try {//from ww w .  ja  va 2  s.c  om
        // if we should ignore the back button
        if (PreferenceHelper.getIgnoreBackButton(this))
            return;

        if (mDrawerLayout.isDrawerOpen(Gravity.START) && fileOpened) {
            mDrawerLayout.closeDrawer(Gravity.START);
        } else if (mDrawerLayout.isDrawerOpen(Gravity.END) && fileOpened) {
            mDrawerLayout.closeDrawer(Gravity.END);
        } else if (fileOpened && mEditor.canSaveFile()) {
            new SaveFileDialog(greatUri, pageSystem.getAllText(mEditor.getText().toString()), currentEncoding)
                    .show(getFragmentManager(), "dialog");
        } else if (fileOpened) {

            // remove editor fragment
            hideTextEditor();

            // Set the default title
            getSupportActionBar().setTitle(getString(R.string.nome_app_turbo_editor));

            closedTheFile();

            mDrawerLayout.openDrawer(Gravity.START);
            mDrawerLayout.closeDrawer(Gravity.END);
        } else {
            showInterstitial();
            super.onBackPressed();
        }
    } catch (Exception e) {
        // maybe something is null, who knows
    }
}

From source file:org.odk.collect.android.activities.AppListActivity.java

@Override
public void onBackPressed() {
    if (drawerLayout.isDrawerOpen(Gravity.END)) {
        drawerLayout.closeDrawer(Gravity.END);
    } else {/*w  ww .j  a va 2  s. c  o m*/
        super.onBackPressed();
    }
}

From source file:sharedcode.turboeditor.activity.MainActivity.java

@Override
public void onBackPressed() {

    try {/*from w  w  w  .  j  a va 2s.  c  o  m*/
        // if we should ignore the back button
        if (PreferenceHelper.getIgnoreBackButton(this))
            return;

        if (mDrawerLayout.isDrawerOpen(Gravity.START) && fileOpened) {
            mDrawerLayout.closeDrawer(Gravity.START);
        } else if (mDrawerLayout.isDrawerOpen(Gravity.END) && fileOpened) {
            mDrawerLayout.closeDrawer(Gravity.END);
        } else if (fileOpened && mEditor.canSaveFile()) {
            SaveFileDialog.newInstance(sFilePath, pageSystem.getAllText(mEditor.getText().toString()),
                    currentEncoding).show(getFragmentManager(), "dialog");
        } else if (fileOpened) {

            // remove editor fragment
            hideTextEditor();

            // Set the default title
            getSupportActionBar().setTitle(getString(R.string.nome_app_turbo_editor));

            onEvent(new EventBusEvents.ClosedAFile());

            mDrawerLayout.openDrawer(Gravity.START);
            mDrawerLayout.closeDrawer(Gravity.END);
        } else {
            displayInterstitial();
            super.onBackPressed();
        }
    } catch (Exception e) {
        // maybe something is null, who knows
    }
}

From source file:org.catnut.ui.ComposeTweetActivity.java

private void injectActionBar() {
    mActionBar.setDisplayShowCustomEnabled(true);
    mCustomizedBar = LayoutInflater.from(this).inflate(R.layout.customized_actionbar, null);
    mTextCounter = (TextView) mCustomizedBar.findViewById(R.id.text_counter);
    mSender = mCustomizedBar.findViewById(R.id.action_send);
    mActionBar.setCustomView(mCustomizedBar, new ActionBar.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.MATCH_PARENT, Gravity.END));
}

From source file:com.example.angelina.travelapp.map.MapFragment.java

@Override
public void showRouteDetail(final int position) {
    // Remove the route header view,
    ///*  w w  w .j  av a  2 s.  co  m*/
    //since we're replacing it with a different header

    removeRouteHeaderView();
    // State  and stage flags
    mCurrentPosition = position;
    mShowingRouteDetail = true;

    // Hide action bar
    final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
    if (ab != null) {
        ab.hide();
    }

    // Display route detail header
    final LayoutInflater inflater = (LayoutInflater) getActivity()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final LinearLayout.LayoutParams routeDetailLayout = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    if (mRouteHeaderDetail == null) {
        mRouteHeaderDetail = (LinearLayout) inflater.inflate(R.layout.route_detail_header, null);
        TextView title = (TextView) mRouteHeaderDetail.findViewById(R.id.route_txt_detail);
        title.setText("Route Detail");

        mRouteHeaderDetail.setBackgroundColor(Color.WHITE);
        mMapView.addView(mRouteHeaderDetail, routeDetailLayout);
        mMapView.requestLayout();

        // Attach a listener to the back arrow
        ImageView imageBtn = (ImageView) mRouteHeaderDetail.findViewById(R.id.btnDetailHeaderClose);
        imageBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // Navigate back to directions list
                mShowingRouteDetail = false;
                ((MapActivity) getActivity()).showDirections(mRouteDirections);
            }
        });
    }

    // Display arrows to scroll through directions
    if (mSegmentNavigator == null) {
        mSegmentNavigator = (LinearLayout) inflater.inflate(R.layout.navigation_arrows, null);
        final FrameLayout navigatorLayout = (FrameLayout) getActivity()
                .findViewById(R.id.map_fragment_container);
        FrameLayout.LayoutParams frameLayoutParams = new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
                Gravity.BOTTOM | Gravity.END);
        frameLayoutParams.setMargins(0, 0, 0, 80);
        navigatorLayout.addView(mSegmentNavigator, frameLayoutParams);
        navigatorLayout.requestLayout();
        // Add button click listeners
        Button btnPrev = (Button) getActivity().findViewById(R.id.btnBack);

        btnPrev.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mCurrentPosition > 0) {
                    populateViewWithRouteDetail(mRouteDirections.get(mCurrentPosition - 1));
                    mCurrentPosition = mCurrentPosition - 1;
                }

            }
        });
        Button btnNext = (Button) getActivity().findViewById(R.id.btnNext);
        btnNext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mCurrentPosition < mRouteDirections.size() - 1) {
                    populateViewWithRouteDetail(mRouteDirections.get(mCurrentPosition + 1));
                    mCurrentPosition = mCurrentPosition + 1;
                }

            }
        });
    }

    // Populate with directions
    DirectionManeuver maneuver = mRouteDirections.get(position);
    populateViewWithRouteDetail(maneuver);

}

From source file:com.klinker.android.twitter.activities.MainActivity.java

@Override
public void onResume() {
    super.onResume();

    MainActivity.showIsRunning = false;//from   ww  w  .j  av  a 2 s.c o  m
    MainActivity.hideIsRunning = false;
    MainActivity.sendHandler.postDelayed(showSend, 1000);

    if (sharedPrefs.getBoolean("open_a_page", false)) {
        sharedPrefs.edit().putBoolean("open_a_page", false).commit();
        int page = sharedPrefs.getInt("open_what_page", 1);
        String title = "" + mSectionsPagerAdapter.getPageTitle(page);
        actionBar.setTitle(title);
        mViewPager.setCurrentItem(page);
    }

    if (sharedPrefs.getBoolean("open_interactions", false)) {
        sharedPrefs.edit().putBoolean("open_interactions", false).commit();
        mDrawerLayout.openDrawer(Gravity.END);
    }
}