Example usage for android.view View isSelected

List of usage examples for android.view View isSelected

Introduction

In this page you can find the example usage for android.view View isSelected.

Prototype

@ViewDebug.ExportedProperty
public boolean isSelected() 

Source Link

Document

Indicates the selection state of this view.

Usage

From source file:at.linuxtage.companion.widgets.SlidingTabLayout.java

static void setSelectedCompat(View view, boolean selected) {
    final boolean becomeSelected = selected && !view.isSelected();
    view.setSelected(selected);/*from  ww  w.java  2 s. c o  m*/
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN && becomeSelected) {
        // Pre-JB we need to manually send the TYPE_VIEW_SELECTED event
        view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
    }
}

From source file:com.liferay.alerts.callback.LikeCallback.java

@Override
public void onClick(View view) {
    Session session = SettingsUtil.getSession(this);

    PushnotificationsentryService service = new PushnotificationsentryService(session);

    try {//www  .  j a va 2s .  com
        _like = !view.isSelected();

        if (_like) {
            service.likePushNotificationsEntry(_alertId);
        } else {
            service.unlikePushNotificationsEntry(_alertId);
        }
    } catch (Exception e) {
        ToastUtil.show(_context, R.string.like_failure, true);
    }
}

From source file:com.popumovies.DetailActivityFragment.java

private void onClickFavorite(View v, Uri mUri) {
    v.setSelected(!v.isSelected());
    ContentValues movieValues = new ContentValues();
    movieValues.put(MovieContract.MovieEntry.COLUMN_FAVORITE, v.isSelected());
    Log.d(LOG_TAG, "calling update with args: uri=>" + mUri + ",mv=>" + movieValues.toString());
    getActivity().getContentResolver().update(mUri, movieValues, null, null);
    // List should be refreshed
    // I would expect the observer from the ContentProvider to detect the chage, but
    // it seems to be missing something.
    // Some comments point to adapter.notifyDataSetChanged();
    MainActivityFragment mf = (MainActivityFragment) getActivity().getSupportFragmentManager()
            .findFragmentByTag(MainActivity.MAINFRAGMENT_TAG);
    mf.restartLoader();// w  w  w.j a  va 2 s. c om
}

From source file:com.creationgroundmedia.popularmovies.MovieListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_main, menu);
    inflater.inflate(R.menu.menu_fragment, menu);
    /**// ww  w .ja  v  a 2  s  . c om
     * use a spinner to select sort order, that way the user can always see what the order is
     */
    MenuItem item = menu.findItem(R.id.action_sorting_spinner);
    Spinner sortingSpinner = (Spinner) MenuItemCompat.getActionView(item);
    ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(this, R.array.sorting_modes,
            R.layout.spinner_item);
    spinnerAdapter.setDropDownViewResource(R.layout.spinner_item);
    sortingSpinner.setAdapter(spinnerAdapter);
    sortingSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            sortOrder = sortOrders[position];
            movieCursorLoader = getSupportLoaderManager().restartLoader(URL_LOADER, null,
                    MovieListActivity.this);
            recyclerView.getAdapter().notifyDataSetChanged();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    item = menu.findItem(R.id.action_faves_only);
    Button faveButton = (Button) MenuItemCompat.getActionView(item);
    faveButton.setSelected(mFavoritesOnly);
    faveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mFavoritesOnly = !v.isSelected();
            v.setSelected(mFavoritesOnly);
            mSelectFavorites = mFavoritesOnly ? MoviesContract.MovieEntry.COLUMN_FAVORITE + " = 1" : null;
            movieCursorLoader = getSupportLoaderManager().restartLoader(URL_LOADER, null,
                    MovieListActivity.this);
        }
    });

    return super.onCreateOptionsMenu(menu);
}

From source file:com.popumovies.DetailActivityFragment.java

private void fillForm(Bundle arguments) {
    String originalTitle = arguments.getString(MovieEntry.COLUMN_ORIGINAL_TITLE);
    Log.d(LOG_TAG, "fillForm/originalTitle => " + originalTitle);
    Date release_date = new Date(Long.parseLong(arguments.getString(MovieEntry.COLUMN_RELEASE_DATE)));
    String posterPath = arguments.getString(MovieEntry.COLUMN_POSTER_PATH);
    String backgroundPath = arguments.getString(MovieEntry.COLUMN_BACKGROUND_PATH);
    String voteAverage = arguments.getString(MovieEntry.COLUMN_VOTE_AVERAGE);
    String overView = arguments.getString(MovieEntry.COLUMN_OVERVIEW);
    boolean favorite;
    favorite = (arguments.getString(MovieEntry.COLUMN_FAVORITE).equals("1"));

    // Showing the original title as Movie title
    //        mTitleView.setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));
    mTitleView.setText(originalTitle);//from  w w  w  .  java2  s  .  com

    // extract the year
    SimpleDateFormat df = new SimpleDateFormat("yyyy");
    mYearView.setText(df.format(release_date));

    mVoteAverageView.setText(String.format(getString(R.string.vote_avg_string), voteAverage));

    float voteAverageNumber = Float.parseFloat(voteAverage) / 2;
    mVoteAverageRatingBar.setRating(voteAverageNumber);

    mDescriptionView.setText(overView);

    // Poster image is composed of 3 parts
    // 1 - The base URL will look like: http://image.tmdb.org/t/p/.
    // 2 - Then you will need a size, which will be one of the following:
    //  "w92", "w154", "w185", "w342", "w500", "w780", or "original". For most phones we recommend using w185?.
    // 3 - And finally the poster path returned by the query, in this case /nBNZadXqJSdt05SHLqgT0HuC5Gm.jpg?
    Context context = getContext();
    String poster = context.getString(R.string.TMDB_POSTER_URL)
            + context.getString(R.string.tmdb_poster_resolution) + "/" + posterPath;
    String background = context.getString(R.string.TMDB_POSTER_URL)
            + context.getString(R.string.tmdb_background_resolution) + "/" + backgroundPath;
    Log.d(LOG_TAG, "Loading poster url => " + poster);
    Picasso picasso = new HelperOkHttpClient().getPicassoInstance(context);
    picasso.load(poster).into(mPosterView);
    picasso.load(background).into(mBackgroundView);

    // Accessibility feature
    mPosterView.setContentDescription(arguments.getString(MovieEntry.COLUMN_ORIGINAL_TITLE));
    mBackgroundView.setContentDescription(arguments.getString(MovieEntry.COLUMN_ORIGINAL_TITLE));

    mFavoriteButton.setSelected(favorite);
    if (favorite)
        mFavoriteButton.setImageResource(R.drawable.ic_favorite_black_36dp);
    else
        mFavoriteButton.setImageResource(R.drawable.ic_favorite_border_black_36dp);

    mFavoriteButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Do something in response to button click
            //mUri = content://com.popumovies/movie/4
            onClickFavorite(v, mUri);
            if (v.isSelected()) {
                mFavoriteButton.setImageResource(R.drawable.ic_favorite_black_36dp);
            } else {
                mFavoriteButton.setImageResource(R.drawable.ic_favorite_border_black_36dp);
            }
        }
    });

    getLoaderManager().initLoader(FRAGMENT_DETAIL_VIDEO_LOADER, null, this);
    getLoaderManager().initLoader(FRAGMENT_DETAIL_REVIEW_LOADER, null, this);
}

From source file:com.ez.gallery.ucrop.UCropActivity.java

private void setupAspectRatioWidget() {

    // Set the colors before the default item is selected
    ((AspectRatioTextView) ((ViewGroup) findViewById(R.id.crop_aspect_ratio_1_1)).getChildAt(0))
            .setActiveColor(mActiveWidgetColor);
    ((AspectRatioTextView) ((ViewGroup) findViewById(R.id.crop_aspect_ratio_3_4)).getChildAt(0))
            .setActiveColor(mActiveWidgetColor);
    ((AspectRatioTextView) ((ViewGroup) findViewById(R.id.crop_aspect_ratio_original)).getChildAt(0))
            .setActiveColor(mActiveWidgetColor);
    ((AspectRatioTextView) ((ViewGroup) findViewById(R.id.crop_aspect_ratio_3_2)).getChildAt(0))
            .setActiveColor(mActiveWidgetColor);
    ((AspectRatioTextView) ((ViewGroup) findViewById(R.id.crop_aspect_ratio_16_9)).getChildAt(0))
            .setActiveColor(mActiveWidgetColor);

    mCropAspectRatioViews.add((ViewGroup) findViewById(R.id.crop_aspect_ratio_1_1));
    mCropAspectRatioViews.add((ViewGroup) findViewById(R.id.crop_aspect_ratio_3_4));
    mCropAspectRatioViews.add((ViewGroup) findViewById(R.id.crop_aspect_ratio_original));
    mCropAspectRatioViews.add((ViewGroup) findViewById(R.id.crop_aspect_ratio_3_2));
    mCropAspectRatioViews.add((ViewGroup) findViewById(R.id.crop_aspect_ratio_16_9));
    mCropAspectRatioViews.get(2).setSelected(true);

    for (ViewGroup cropAspectRatioView : mCropAspectRatioViews) {
        cropAspectRatioView.setOnClickListener(new View.OnClickListener() {
            @Override/*from w w w  . j  a v  a 2  s  .c  om*/
            public void onClick(View v) {
                mGestureCropImageView.setTargetAspectRatio(
                        ((AspectRatioTextView) ((ViewGroup) v).getChildAt(0)).getAspectRatio(v.isSelected()));
                mGestureCropImageView.setImageToWrapCropBounds();
                if (!v.isSelected()) {
                    for (ViewGroup cropAspectRatioView : mCropAspectRatioViews) {
                        cropAspectRatioView.setSelected(cropAspectRatioView == v);
                    }
                }
            }
        });
    }
}

From source file:demo.camera.library.ui.CameraCaptureActivity.java

private void setUpFlashButton() {
    mFlashButton = (ImageButton) findViewById(R.id.flashButton);
    mFlashButton.setOnClickListener(new View.OnClickListener() {
        @Override/* w  w w  .jav a  2  s.c o  m*/
        public void onClick(View v) {
            if (mCameraManager != null) {
                v.setSelected(!v.isSelected());
                if (v.isSelected()) {
                    mFlashButton.setImageResource(R.drawable.flash_on);
                } else {
                    mFlashButton.setImageResource(R.drawable.flash_off);
                }

                mCameraManager.toggleFlashMode();
            }
        }
    });
}

From source file:android.support.car.app.CarFragmentActivity.java

private static String viewToString(View view) {
    StringBuilder out = new StringBuilder(128);
    out.append(view.getClass().getName());
    out.append('{');
    out.append(Integer.toHexString(System.identityHashCode(view)));
    out.append(' ');
    switch (view.getVisibility()) {
    case View.VISIBLE:
        out.append('V');
        break;/*  w  ww .j  a  va  2s .c om*/
    case View.INVISIBLE:
        out.append('I');
        break;
    case View.GONE:
        out.append('G');
        break;
    default:
        out.append('.');
        break;
    }
    out.append(view.isFocusable() ? 'F' : '.');
    out.append(view.isEnabled() ? 'E' : '.');
    out.append(view.willNotDraw() ? '.' : 'D');
    out.append(view.isHorizontalScrollBarEnabled() ? 'H' : '.');
    out.append(view.isVerticalScrollBarEnabled() ? 'V' : '.');
    out.append(view.isClickable() ? 'C' : '.');
    out.append(view.isLongClickable() ? 'L' : '.');
    out.append(' ');
    out.append(view.isFocused() ? 'F' : '.');
    out.append(view.isSelected() ? 'S' : '.');
    out.append(view.isPressed() ? 'P' : '.');
    out.append(' ');
    out.append(view.getLeft());
    out.append(',');
    out.append(view.getTop());
    out.append('-');
    out.append(view.getRight());
    out.append(',');
    out.append(view.getBottom());
    final int id = view.getId();
    if (id != View.NO_ID) {
        out.append(" #");
        out.append(Integer.toHexString(id));
        final Resources r = view.getResources();
        if (id != 0 && r != null) {
            try {
                String pkgname;
                switch (id & 0xff000000) {
                case 0x7f000000:
                    pkgname = "app";
                    break;
                case 0x01000000:
                    pkgname = "android";
                    break;
                default:
                    pkgname = r.getResourcePackageName(id);
                    break;
                }
                String typename = r.getResourceTypeName(id);
                String entryname = r.getResourceEntryName(id);
                out.append(" ");
                out.append(pkgname);
                out.append(":");
                out.append(typename);
                out.append("/");
                out.append(entryname);
            } catch (Resources.NotFoundException e) {
            }
        }
    }
    out.append("}");
    return out.toString();
}

From source file:ru.adios.budgeter.widgets.DataTableLayout.java

public void disableUserOrdering() {
    orderResolver = Optional.empty();
    if (getChildCount() > 0) {
        final TableRow columnsRow = (TableRow) getChildAt(2);
        for (int i = 0; i < columnsRow.getChildCount(); i++) {
            final View childAt = columnsRow.getChildAt(i);
            if (childAt.isSelected()) {
                childAt.setSelected(false);
                childAt.invalidate();//from   w  w  w . j  a va2 s .c  o m
                break;
            }
        }
    }
}

From source file:me.trashout.fragment.TrashReportOrEditFragment.java

@OnClick({ R.id.trash_report_type_household_btn, R.id.trash_report_type_automotive_btn,
        R.id.trash_report_type_construction_btn, R.id.trash_report_type_plastic_btn,
        R.id.trash_report_type_electronic_btn, R.id.trash_report_type_organic_btn,
        R.id.trash_report_type_metal_btn, R.id.trash_report_type_liquid_btn,
        R.id.trash_report_type_dangerous_btn, R.id.trash_report_type_dead_animals_btn,
        R.id.trash_report_type_glass_btn })
public void onClick(View view) {
    view.setSelected(!view.isSelected());
    switch (view.getId()) {
    case R.id.trash_report_type_household_btn:
        break;//from w  ww  .ja  v a2 s  .c  o  m
    case R.id.trash_report_type_automotive_btn:
        break;
    case R.id.trash_report_type_construction_btn:
        break;
    case R.id.trash_report_type_plastic_btn:
        break;
    case R.id.trash_report_type_electronic_btn:
        break;
    case R.id.trash_report_type_organic_btn:
        break;
    case R.id.trash_report_type_metal_btn:
        break;
    case R.id.trash_report_type_liquid_btn:
        break;
    case R.id.trash_report_type_dangerous_btn:
        break;
    case R.id.trash_report_type_dead_animals_btn:
        break;
    case R.id.trash_report_type_glass_btn:
        break;
    }
}