Example usage for android.view.animation AlphaAnimation AlphaAnimation

List of usage examples for android.view.animation AlphaAnimation AlphaAnimation

Introduction

In this page you can find the example usage for android.view.animation AlphaAnimation AlphaAnimation.

Prototype

public AlphaAnimation(float fromAlpha, float toAlpha) 

Source Link

Document

Constructor to use when building an AlphaAnimation from code

Usage

From source file:de.qspool.clementineremote.ui.ConnectActivity.java

private void initializeUi() {
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));

    // Get the Layoutelements
    mBtnConnect = (Button) findViewById(R.id.btnConnect);
    mBtnConnect.setOnClickListener(oclConnect);
    mBtnConnect.requestFocus();// www  .j av  a 2s .  co m

    mBtnClementine = (ImageButton) findViewById(R.id.btnClementineIcon);
    mBtnClementine.setOnClickListener(oclClementine);

    // Setup the animation for the Clementine icon
    mAlphaDown = new AlphaAnimation(1.0f, 0.3f);
    mAlphaUp = new AlphaAnimation(0.3f, 1.0f);
    mAlphaDown.setDuration(ANIMATION_DURATION);
    mAlphaUp.setDuration(ANIMATION_DURATION);
    mAlphaDown.setFillAfter(true);
    mAlphaUp.setFillAfter(true);
    mAlphaUp.setAnimationListener(mAnimationListener);
    mAlphaDown.setAnimationListener(mAnimationListener);
    mAnimationCancel = false;

    // Ip and Autoconnect
    mEtIp = (AutoCompleteTextView) findViewById(R.id.etIp);
    mEtIp.setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    mEtIp.setThreshold(3);

    // Get old ip and auto-connect from shared prefences
    mEtIp.setText(mSharedPref.getString(SharedPreferencesKeys.SP_KEY_IP, ""));
    mEtIp.setSelection(mEtIp.length());

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.select_dialog_item,
            mKnownIps.toArray(new String[0]));
    mEtIp.setAdapter(adapter);

    // Get the last auth code
    mAuthCode = mSharedPref.getInt(SharedPreferencesKeys.SP_LAST_AUTH_CODE, 0);
}

From source file:com.chinabike.plugins.mip.activity.LocalAlbumDetail.java

private void hideViewPager() {
    pagerContainer.setVisibility(View.GONE);
    gridView.setVisibility(View.VISIBLE);
    findViewById(FakeR.getId(this, "id", "album_title_bar")).setVisibility(View.VISIBLE);
    AnimationSet set = new AnimationSet(true);
    ScaleAnimation scaleAnimation = new ScaleAnimation(1, (float) 0.9, 1, (float) 0.9,
            pagerContainer.getWidth() / 2, pagerContainer.getHeight() / 2);
    scaleAnimation.setDuration(200);/*  w w  w.  j  ava 2 s  .com*/
    set.addAnimation(scaleAnimation);
    AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
    alphaAnimation.setDuration(200);
    set.addAnimation(alphaAnimation);
    pagerContainer.startAnimation(set);
    ((BaseAdapter) gridView.getAdapter()).notifyDataSetChanged();
}

From source file:com.calgen.udacity.lego.ui.ArticleDetailFragment.java

private void playAnimation(ImageView photoView) {
    Animation fadeIn = new AlphaAnimation(0, 1);
    fadeIn.setInterpolator(new AccelerateInterpolator());
    fadeIn.setDuration(500);/*from   ww w .  j a v  a2 s.c o  m*/
    photoView.startAnimation(fadeIn);
    shareFab.setVisibility(View.VISIBLE);
    shareFab.startAnimation(fadeIn);
}

From source file:com.android.datetimepicker.date.DatePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView: ");
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    View view = inflater.inflate(R.layout.date_picker_dialog, null);

    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
    mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.date_picker_year);
    mYearView.setOnClickListener(this);

    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = MONTH_AND_DAY_VIEW;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinYear = savedInstanceState.getInt(KEY_YEAR_START);
        mMaxYear = savedInstanceState.getInt(KEY_YEAR_END);
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
    }//from  ww w  . ja  v a2 s.  c o  m

    final Activity activity = getActivity();
    mDayPickerView = new SimpleDayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);

    Resources res = getResources();
    mDayPickerDescription = res.getString(R.string.day_picker_description);
    mSelectDay = res.getString(R.string.select_day);
    mYearPickerDescription = res.getString(R.string.year_picker_description);
    mSelectYear = res.getString(R.string.select_year);

    mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);
    mAnimator.setDateMillis(mCalendar.getTimeInMillis());
    // TODO: Replace with animation decided upon by the design team.
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(ANIMATION_DURATION);
    mAnimator.setInAnimation(animation);
    // TODO: Replace with animation decided upon by the design team.
    Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
    animation2.setDuration(ANIMATION_DURATION);
    mAnimator.setOutAnimation(animation2);

    mDoneButton = (Button) view.findViewById(R.id.done);
    mDoneButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            if (mCallBack != null) {
                mCallBack.onDateSet(DatePickerDialog.this, mCalendar.get(Calendar.YEAR),
                        mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));
            }
            dismiss();
        }
    });

    updateDisplay(false);
    setCurrentView(currentView);

    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        } else if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }

    mHapticFeedbackController = new HapticFeedbackController(activity);
    return view;
}

From source file:ly.kite.journey.selection.ProductOverviewFragment.java

/*****************************************************
 *
 * Returns the content view for this fragment
 *
 *****************************************************/
@Override//from www  .j  a v  a2 s  .  com
public View onCreateView(LayoutInflater layoutInflator, ViewGroup container, Bundle savedInstanceState) {
    boolean slidingDrawerIsExpanded = false;

    // Get any saved instance state

    if (savedInstanceState != null) {
        slidingDrawerIsExpanded = savedInstanceState.getBoolean(BUNDLE_KEY_SLIDING_DRAWER_IS_EXPANDED, false);
    } else {
        Analytics.getInstance(mKiteActivity).trackProductOverviewScreenViewed(mProduct);
    }

    // Set up the screen. Note that the SDK allows for different layouts to be used in place of the standard
    // one, so some of these views are optional and may not actually exist in the current layout.

    View view = layoutInflator.inflate(R.layout.screen_product_overview, container, false);

    mProductImageViewPager = (ViewPager) view.findViewById(R.id.view_pager);
    mOverlaidComponents = view.findViewById(R.id.overlaid_components);
    mPagingDots = (PagingDots) view.findViewById(R.id.paging_dots);
    mOverlaidStartButton = (Button) view.findViewById(R.id.overlaid_start_button);
    mSlidingOverlayFrame = (SlidingOverlayFrame) view.findViewById(R.id.sliding_overlay_frame);
    mDrawerControlLayout = view.findViewById(R.id.drawer_control_layout);
    mOpenCloseDrawerIconImageView = (ImageView) view.findViewById(R.id.open_close_drawer_icon_image_view);
    mProceedOverlayButton = (Button) view.findViewById(R.id.proceed_overlay_button);
    TextView priceTextView = (TextView) view.findViewById(R.id.price_text_view);
    TextView summaryDescriptionTextView = (TextView) view.findViewById(R.id.summary_description_text_view);
    TextView summaryShippingTextView = (TextView) view.findViewById(R.id.summary_shipping_text_view);
    View descriptionLayout = view.findViewById(R.id.description_layout);
    TextView descriptionTextView = (TextView) view.findViewById(R.id.description_text_view);
    View sizeLayout = view.findViewById(R.id.size_layout);
    TextView sizeTextView = (TextView) view.findViewById(R.id.size_text_view);
    View quantityLayout = view.findViewById(R.id.quantity_layout);
    TextView quantityTextView = (TextView) view.findViewById(R.id.quantity_text_view);
    TextView shippingTextView = (TextView) view.findViewById(R.id.shipping_text_view);

    // Paging dots

    Animation pagingDotOutAlphaAnimation = new AlphaAnimation(PAGING_DOT_ANIMATION_OPAQUE,
            PAGING_DOT_ANIMATION_TRANSLUCENT);
    pagingDotOutAlphaAnimation.setFillAfter(true);
    pagingDotOutAlphaAnimation.setDuration(PAGING_DOT_ANIMATION_DURATION_MILLIS);

    Animation pagingDotOutScaleAnimation = new ScaleAnimation(0f, PAGING_DOT_ANIMATION_NORMAL_SCALE, 0f,
            PAGING_DOT_ANIMATION_NORMAL_SCALE, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
            0.5f);

    pagingDotOutScaleAnimation.setFillAfter(true);
    pagingDotOutScaleAnimation.setDuration(PAGING_DOT_ANIMATION_DURATION_MILLIS);
    pagingDotOutScaleAnimation.setInterpolator(new BellInterpolator(1.0f, 0.8f, true));

    AnimationSet pagingDotOutAnimation = new AnimationSet(false);
    pagingDotOutAnimation.addAnimation(pagingDotOutAlphaAnimation);
    pagingDotOutAnimation.addAnimation(pagingDotOutScaleAnimation);
    pagingDotOutAnimation.setFillAfter(true);

    Animation pagingDotInAlphaAnimation = new AlphaAnimation(PAGING_DOT_ANIMATION_TRANSLUCENT,
            PAGING_DOT_ANIMATION_OPAQUE);
    pagingDotInAlphaAnimation.setFillAfter(true);
    pagingDotInAlphaAnimation.setDuration(PAGING_DOT_ANIMATION_DURATION_MILLIS);

    Animation pagingDotInScaleAnimation = new ScaleAnimation(0f, PAGING_DOT_ANIMATION_NORMAL_SCALE, 0f,
            PAGING_DOT_ANIMATION_NORMAL_SCALE, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
            0.5f);

    pagingDotInScaleAnimation.setFillAfter(true);
    pagingDotInScaleAnimation.setDuration(PAGING_DOT_ANIMATION_DURATION_MILLIS);
    pagingDotInScaleAnimation.setInterpolator(new BellInterpolator(1.0f, 1.2f));

    AnimationSet pagingDotInAnimation = new AnimationSet(false);
    pagingDotInAnimation.addAnimation(pagingDotInAlphaAnimation);
    pagingDotInAnimation.addAnimation(pagingDotInScaleAnimation);
    pagingDotInAnimation.setFillAfter(true);

    mPagingDots.setProperties(mProduct.getImageURLList().size(), R.drawable.paging_dot_unselected,
            R.drawable.paging_dot_selected);
    mPagingDots.setOutAnimation(pagingDotOutAlphaAnimation);
    mPagingDots.setInAnimation(pagingDotInAnimation);

    mProductImageViewPager.setOnPageChangeListener(mPagingDots);

    mOverlaidComponents.setAlpha(slidingDrawerIsExpanded ? 0f : 1f); // If the drawer starts open, these components need to be invisible

    if (mSlidingOverlayFrame != null) {
        mSlidingOverlayFrame.snapToExpandedState(slidingDrawerIsExpanded);
        mSlidingOverlayFrame.setSlideAnimationDuration(SLIDE_ANIMATION_DURATION_MILLIS);
        mOpenCloseDrawerIconImageView.setRotation(
                slidingDrawerIsExpanded ? OPEN_CLOSE_ICON_ROTATION_DOWN : OPEN_CLOSE_ICON_ROTATION_UP);
    }

    SingleUnitSize size = mProduct.getSizeWithFallback(UnitOfLength.CENTIMETERS);
    boolean formatAsInt = size.getWidth() == (int) size.getWidth()
            && size.getHeight() == (int) size.getHeight();
    String sizeFormatString = getString(
            formatAsInt ? R.string.product_size_format_string_int : R.string.product_size_format_string_float);
    String sizeString = String.format(sizeFormatString, size.getWidth(), size.getHeight(),
            size.getUnit().shortString(mKiteActivity));

    int quantityPerSheet = mProduct.getQuantityPerSheet();
    MultipleDestinationShippingCosts shippingCosts = mProduct.getShippingCosts();

    Locale locale = Locale.getDefault();
    Country country = Country.getInstance(locale);

    SingleCurrencyAmount singleCurrencyCost;

    // Price

    if (isVisible(priceTextView)) {
        singleCurrencyCost = mProduct.getCostWithFallback(locale);

        if (singleCurrencyCost != null)
            priceTextView.setText(singleCurrencyCost.getDisplayAmountForLocale(locale));
    }

    // Summary description. This is a short description - not to be confused with the (full) description.

    if (isVisible(summaryDescriptionTextView)) {
        String summaryDescription = String.valueOf(quantityPerSheet) + " " + mProduct.getName()
                + (Product.isSensibleSize(size) ? " (" + sizeString + ")" : "");

        summaryDescriptionTextView.setText(summaryDescription);
    }

    // (Full) description

    String description = mProduct.getDescription();

    boolean haveDescription = (description != null && (!description.trim().equals("")));

    if (haveDescription && descriptionLayout != null && descriptionTextView != null) {
        descriptionLayout.setVisibility(View.VISIBLE);
        descriptionTextView.setVisibility(View.VISIBLE);

        descriptionTextView.setText(description);
    } else {
        if (descriptionLayout != null)
            descriptionLayout.setVisibility(View.GONE);
        if (descriptionTextView != null)
            descriptionTextView.setVisibility(View.GONE);
    }

    // Size

    if (isVisible(sizeTextView)) {
        if (Product.isSensibleSize(size)) {
            sizeTextView.setText(String.format(sizeFormatString, size.getWidth(), size.getHeight(),
                    size.getUnit().shortString(mKiteActivity)));
        } else {
            sizeLayout.setVisibility(View.GONE);
        }
    }

    // Quantity

    if (isVisible(quantityTextView)) {
        if (quantityPerSheet > 1) {
            quantityLayout.setVisibility(View.VISIBLE);

            quantityTextView.setText(getString(R.string.product_quantity_format_string, quantityPerSheet));
        } else {
            quantityLayout.setVisibility(View.GONE);
        }
    }

    // Shipping description

    if (isVisible(summaryShippingTextView)) {
        // Currently we just check that shipping is free everywhere. If it isn't - we don't display
        // anything.

        boolean freeShippingEverywhere = true;

        MultipleDestinationShippingCosts multipleDestinationShippingCosts = shippingCosts;

        for (SingleDestinationShippingCost singleDestinationShippingCosts : multipleDestinationShippingCosts
                .asList()) {
            MultipleCurrencyAmount multipleCurrencyShippingCost = singleDestinationShippingCosts.getCost();

            for (SingleCurrencyAmount singleCurrencyShippingCost : multipleCurrencyShippingCost
                    .asCollection()) {
                if (singleCurrencyShippingCost.isNonZero()) {
                    freeShippingEverywhere = false;
                }
            }
        }

        if (freeShippingEverywhere) {
            summaryShippingTextView.setText(R.string.product_free_worldwide_shipping);
        } else {
            summaryShippingTextView.setText(getString(R.string.product_shipping_summary_format_string,
                    shippingCosts.getDisplayCost(locale)));
        }
    }

    // Shipping (postage)

    if (isVisible(shippingTextView)) {
        List<SingleDestinationShippingCost> sortedShippingCostList = mProduct.getSortedShippingCosts(country);

        StringBuilder shippingCostsStringBuilder = new StringBuilder();

        String newlineString = "";

        for (SingleDestinationShippingCost singleDestinationShippingCost : sortedShippingCostList) {
            // We want to prepend a new line for every shipping destination except the first

            shippingCostsStringBuilder.append(newlineString);

            newlineString = "\n";

            // Get the cost in the default currency for the locale, and format the amount.

            singleCurrencyCost = singleDestinationShippingCost.getCost().getDefaultAmountWithFallback();

            if (singleCurrencyCost != null) {
                String formatString = getString(R.string.product_shipping_format_string);

                String costString = (singleCurrencyCost.isNonZero()
                        ? singleCurrencyCost.getDisplayAmountForLocale(locale)
                        : getString(R.string.product_free_shipping));

                shippingCostsStringBuilder.append(String.format(formatString,
                        singleDestinationShippingCost.getDestinationDescription(mKiteActivity), costString));
            }

            shippingTextView.setText(shippingCostsStringBuilder.toString());
        }
    }

    if (mProceedOverlayButton != null) {
        mProceedOverlayButton.setText(R.string.product_overview_start_button_text);

        mProceedOverlayButton.setOnClickListener(this);
    }

    mProductImageViewPager.setOnClickListener(this);

    if (mDrawerControlLayout != null)
        mDrawerControlLayout.setOnClickListener(this);

    mOverlaidStartButton.setOnClickListener(this);

    return (view);
}

From source file:com.doomonafireball.betterpickers.calendardatepicker.CalendarDatePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView: ");
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    View view = inflater.inflate(R.layout.calendar_date_picker_dialog, null);

    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
    mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.date_picker_year);
    mYearView.setOnClickListener(this);

    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = MONTH_AND_DAY_VIEW;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinYear = savedInstanceState.getInt(KEY_YEAR_START);
        mMaxYear = savedInstanceState.getInt(KEY_YEAR_END);
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
    }/*from ww w .  j av  a 2s. co m*/

    final Activity activity = getActivity();
    mDayPickerView = new SimpleDayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);

    Resources res = getResources();
    mDayPickerDescription = res.getString(R.string.day_picker_description);
    mSelectDay = res.getString(R.string.select_day);
    mYearPickerDescription = res.getString(R.string.year_picker_description);
    mSelectYear = res.getString(R.string.select_year);

    mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);
    mAnimator.setDateMillis(mCalendar.getTimeInMillis());
    // TODO: Replace with animation decided upon by the design team.
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(ANIMATION_DURATION);
    mAnimator.setInAnimation(animation);
    // TODO: Replace with animation decided upon by the design team.
    Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
    animation2.setDuration(ANIMATION_DURATION);
    mAnimator.setOutAnimation(animation2);

    mDoneButton = (Button) view.findViewById(R.id.done);
    mDoneButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            if (mCallBack != null) {
                mCallBack.onDateSet(CalendarDatePickerDialog.this, mCalendar.get(Calendar.YEAR),
                        mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));
            }
            dismiss();
        }
    });

    updateDisplay(false);
    setCurrentView(currentView);

    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        } else if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }

    mHapticFeedbackController = new HapticFeedbackController(activity);
    return view;
}

From source file:com.glabs.homegenie.StartActivity.java

public void showLogo() {
    _islogovisible = true;/* w w  w  .jav  a2 s .  c o  m*/
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            Animation fadeIn = new AlphaAnimation(0, 0.8f);
            fadeIn.setInterpolator(new AccelerateInterpolator()); //and this
            fadeIn.setStartOffset(0);
            fadeIn.setDuration(500);
            //
            AnimationSet animation = new AnimationSet(false); //change to false
            animation.addAnimation(fadeIn);
            animation.setFillAfter(true);
            RelativeLayout ivlogo = (RelativeLayout) findViewById(R.id.logo);
            ivlogo.startAnimation(animation);
        }
    });
}

From source file:com.launcher.silverfish.HomeScreenFragment.java

@SuppressWarnings("deprecation")
private void updateShortcuts() {
    int count = appsList.size();
    int size = (int) Math.ceil(Math.sqrt(count));
    shortcutLayout.removeAllViews();//from   ww  w  .  j  a  v  a  2  s  . c  om

    if (size == 0) {
        size = 1;
    }

    // Redraw the layout
    shortcutLayout.setSize(size);
    shortcutLayout.requestLayout();
    shortcutLayout.invalidate();

    for (int i = 0; i < appsList.size(); i++) {
        final AppDetail app = appsList.get(i);
        View convertView = getActivity().getLayoutInflater().inflate(R.layout.shortcut_item, null);

        // load the app icon in an async task
        ImageView im = (ImageView) convertView.findViewById(R.id.item_app_icon);
        Utils.loadAppIconAsync(mPacMan, app.name.toString(), im);

        TextView tv = (TextView) convertView.findViewById(R.id.item_app_label);
        tv.setText(app.label);
        shortcutLayout.addView(convertView);

        convertView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent event) {
                switch (MotionEventCompat.getActionMasked(event)) {
                case MotionEvent.ACTION_DOWN:
                    updateTouchDown(event);
                    break;

                case MotionEvent.ACTION_MOVE:
                    tryConsumeSwipe(event);
                    break;

                case MotionEvent.ACTION_UP:
                    // We only want to launch the activity if the touch was not consumed yet!
                    if (!touchConsumed) {
                        Intent i = mPacMan.getLaunchIntentForPackage(app.name.toString());
                        startActivity(i);
                    }
                    break;
                }

                return touchConsumed;
            }
        });

        // start a drag when an app has been long clicked
        final long appId = app.id;
        final int appIndex = i;
        convertView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                String[] mime_types = { ClipDescription.MIMETYPE_TEXT_PLAIN };
                ClipData data = new ClipData(Constants.DRAG_SHORTCUT_REMOVAL, mime_types,
                        new ClipData.Item(Long.toString(appId)));

                data.addItem(new ClipData.Item(Integer.toString(appIndex)));

                View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(
                        view.findViewById(R.id.item_app_icon));

                // "This method was deprecated in API level 24. Use startDragAndDrop()
                // for newer platform versions."
                if (Build.VERSION.SDK_INT < 24) {
                    view.startDrag(data, shadowBuilder, view, 0);
                } else {
                    view.startDragAndDrop(data, shadowBuilder, view, 0);
                }

                // Show removal indicator
                FrameLayout rem_ind = (FrameLayout) rootView.findViewById(R.id.remove_indicator);
                rem_ind.setVisibility(View.VISIBLE);
                AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f);
                animation.setDuration(500);
                rem_ind.startAnimation(animation);
                return true;

            }
        });
    }
}

From source file:com.android.datetimepicker.date.DatePickerDialogCompat.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView: ");
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    View view = inflater.inflate(R.layout.date_picker_dialog, null);

    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
    mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.date_picker_year);
    mYearView.setOnClickListener(this);

    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = MONTH_AND_DAY_VIEW;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinDate = getCalendar(savedInstanceState.getInt(KEY_START));
        mMaxDate = getCalendar(savedInstanceState.getInt(KEY_END));
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
    }/*from  w  w  w  . ja v a  2s . c om*/

    final Activity activity = getActivity();
    mDayPickerView = new SimpleDayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);

    Resources res = getResources();
    mDayPickerDescription = res.getString(R.string.day_picker_description);
    mSelectDay = res.getString(R.string.select_day);
    mYearPickerDescription = res.getString(R.string.year_picker_description);
    mSelectYear = res.getString(R.string.select_year);

    mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);
    mAnimator.setDateMillis(mCalendar.getTimeInMillis());
    // TODO: Replace with animation decided upon by the design team.
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(ANIMATION_DURATION);
    mAnimator.setInAnimation(animation);
    // TODO: Replace with animation decided upon by the design team.
    Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
    animation2.setDuration(ANIMATION_DURATION);
    mAnimator.setOutAnimation(animation2);

    mDoneButton = (Button) view.findViewById(R.id.done);
    mDoneButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            if (mCallBack != null) {
                mCallBack.onDateSet(DatePickerDialogCompat.this, mCalendar.get(Calendar.YEAR),
                        mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));
            }
            dismiss();
        }
    });

    updateDisplay(false);
    setCurrentView(currentView);

    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        } else if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }

    mHapticFeedbackController = new HapticFeedbackController(activity);
    return view;
}

From source file:com.android.yijiang.kzx.widget.betterpickers.calendardatepicker.CalendarDatePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView: ");
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    View view = inflater.inflate(R.layout.calendar_date_picker_dialog, null);

    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
    mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.date_picker_year);
    mYearView.setOnClickListener(this);

    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = MONTH_AND_DAY_VIEW;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinYear = savedInstanceState.getInt(KEY_YEAR_START);
        mMaxYear = savedInstanceState.getInt(KEY_YEAR_END);
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
    }/*from   w w  w  .  j  a va 2s  .com*/

    final Activity activity = getActivity();
    mDayPickerView = new DayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);

    Resources res = getResources();
    mDayPickerDescription = res.getString(R.string.day_picker_description);
    mSelectDay = res.getString(R.string.select_day);
    mYearPickerDescription = res.getString(R.string.year_picker_description);
    mSelectYear = res.getString(R.string.select_year);

    mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);
    mAnimator.setDateMillis(mCalendar.getTimeInMillis());
    // TODO: Replace with animation decided upon by the design team.
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(ANIMATION_DURATION);
    mAnimator.setInAnimation(animation);
    // TODO: Replace with animation decided upon by the design team.
    Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
    animation2.setDuration(ANIMATION_DURATION);
    mAnimator.setOutAnimation(animation2);

    mDoneButton = (Button) view.findViewById(R.id.done);
    mDoneButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            if (mCallBack != null) {
                mCallBack.onDateSet(CalendarDatePickerDialog.this, mCalendar.get(Calendar.YEAR),
                        mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));
            }
            dismiss();
        }
    });

    updateDisplay(false);
    setCurrentView(currentView);

    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        } else if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }
    return view;
}