Java Code Examples for android.support.v7.widget.CardView#setCardElevation()

The following examples show how to use android.support.v7.widget.CardView#setCardElevation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AboutAdapter.java    From wallpaperboard with Apache License 2.0 6 votes vote down vote up
ContributorsViewHolder(View itemView) {
    super(itemView);
    TextView title = itemView.findViewById(R.id.title);

    CardView card = itemView.findViewById(R.id.card);
    if (!Preferences.get(mContext).isShadowEnabled() && card != null) {
        card.setCardElevation(0);
    }

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
            mContext, R.drawable.ic_toolbar_people, color), null, null, null);
    title.setText(mContext.getResources().getString(R.string.about_contributors_title));

    title.setOnClickListener(this);
}
 
Example 2
Source File: AboutAdapter.java    From wallpaperboard with Apache License 2.0 6 votes vote down vote up
FooterViewHolder(View itemView) {
    super(itemView);
    ButterKnife.bind(this, itemView);

    CardView card = itemView.findViewById(R.id.card);
    if (!Preferences.get(mContext).isShadowEnabled() && card != null) {
        card.setCardElevation(0);
    }

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    TextView title = itemView.findViewById(R.id.about_dashboard_title);
    title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
            mContext, R.drawable.ic_toolbar_dashboard, color), null, null, null);

    instagram.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_instagram, color));
    googlePlus.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_google_plus, color));
    github.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_github, color));

    instagram.setOnClickListener(this);
    googlePlus.setOnClickListener(this);
    github.setOnClickListener(this);
    licenses.setOnClickListener(this);
    contributors.setOnClickListener(this);
    translator.setOnClickListener(this);
}
 
Example 3
Source File: HomeAdapter.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
WallpapersViewHolder(View itemView) {
    super(itemView);
    title = itemView.findViewById(R.id.title);
    TextView muzei = itemView.findViewById(R.id.muzei);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        card.setCardElevation(0);
    }

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
            mContext, R.drawable.ic_toolbar_wallpapers, color), null, null, null);

    muzei.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.get(
            mContext, R.drawable.ic_home_app_muzei), null, null, null);

    title.setOnClickListener(this);
    muzei.setOnClickListener(this);
}
 
Example 4
Source File: AlohaActivity.java    From YImagePicker with Apache License 2.0 5 votes vote down vote up
/**
 * 设置简单图片适配器
 *
 * @param imageItems 图片信息列表
 */
public void setImageViewList(@Nullable List<? extends ImageItem> imageItems) {
    if (imageItems == null) {
        return;
    }
    if (viewList == null) {
        viewList = new ArrayList<>();
    } else {
        viewList.clear();
    }
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    for (final ImageItem entity : imageItems) {
        CardView cardView = new CardView(this);
        cardView.setCardElevation(dp(2));
        cardView.setRadius(dp(5));
        cardView.setLayoutParams(params);

        CropImageView imageView = new CropImageView(this);
        imageView.setLayoutParams(params);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        if (entity.getCropUrl() != null && entity.getCropUrl().length() > 0) {
            Glide.with(this).load(entity.getCropUrl()).into(imageView);
        } else {
            Glide.with(this).load(entity.path).into(imageView);
        }
        cardView.addView(imageView);
        viewList.add(cardView);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                intentCrop(entity);
            }
        });
    }
    setViewList(viewList);
}
 
Example 5
Source File: ToastUtils.java    From YCDialog with Apache License 2.0 5 votes vote down vote up
public Toast build() {
    if (!DialogUtils.checkNull(mToast)) {
        mToast.get().cancel();
    }
    Toast toast = new Toast(context);
    if (isFill) {
        toast.setGravity(gravity | Gravity.FILL_HORIZONTAL, 0, yOffset);
    } else {
        toast.setGravity(gravity, 0, yOffset);
    }
    toast.setDuration(duration);
    toast.setMargin(0, 0);
    if(layout==0){
        CardView rootView = (CardView) LayoutInflater.from(context).inflate(R.layout.view_toast_custom, null);
        TextView textView = rootView.findViewById(R.id.toastTextView);
        TextView descTv = rootView.findViewById(R.id.desc);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            //rootView.setElevation(elevation);
            rootView.setCardElevation(elevation);
        }
        rootView.setRadius(radius);
        rootView.setCardBackgroundColor(backgroundColor);
        //rootView.setBackgroundColor(backgroundColor);
        textView.setTextColor(textColor);
        textView.setText(title);
        if(TextUtils.isEmpty(desc)){
            descTv.setVisibility(View.GONE);
        }else{
            descTv.setText(desc);
            descTv.setVisibility(View.VISIBLE);
        }
        toast.setView(rootView);
    }else {
        View view = LayoutInflater.from(context).inflate(layout, null);
        toast.setView(view);
    }
    mToast = new SoftReference<>(toast);
    return toast;
}
 
Example 6
Source File: HomeAdapter.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
IconRequestViewHolder(View itemView) {
    super(itemView);
    title = itemView.findViewById(R.id.title);
    installedApps = itemView.findViewById(R.id.installed_apps);
    missedApps = itemView.findViewById(R.id.missed_apps);
    themedApps = itemView.findViewById(R.id.themed_apps);
    progress = itemView.findViewById(R.id.progress);
    container = itemView.findViewById(R.id.container);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        card.setCardElevation(0);
    }

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
            mContext, R.drawable.ic_toolbar_icon_request, color), null, null, null);

    int accent = ColorHelper.getAttributeColor(mContext, R.attr.colorAccent);
    progress.getProgressDrawable().setColorFilter(accent, PorterDuff.Mode.SRC_IN);

    container.setOnClickListener(this);
}
 
Example 7
Source File: ViewHelper.java    From FABRevealMenu-master with Apache License 2.0 5 votes vote down vote up
public CardView generateBaseView() {
    //Base view
    CardView mBaseView = new CardView(mContext);
    mBaseView.setLayoutParams(matchParams);
    mBaseView.setCardElevation(dpToPx(mContext, 5));
    mBaseView.setRadius(mContext.getResources().getDimension(R.dimen.card_radius));
    return mBaseView;
}
 
Example 8
Source File: SimpleItemTouchHelperCallback.java    From Rey-MusicPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
    if (mBeingDrawn) {
        mBeingDrawn = false;
    } else {
        CardView cardView = (CardView) viewHolder.itemView.findViewById(R.id.background);
        cardView.setCardElevation(16);
        cardView.setBackgroundColor(ContextCompat.getColor(viewHolder.itemView.getContext(), R.color.white));
    }
    super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
 
Example 9
Source File: AboutAdapter.java    From wallpaperboard with Apache License 2.0 5 votes vote down vote up
HeaderViewHolder(View itemView) {
    super(itemView);
    ButterKnife.bind(this, itemView);
    RecyclerView recyclerView = itemView.findViewById(R.id.recyclerview);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, true));
    recyclerView.setHasFixedSize(true);

    String[] urls = mContext.getResources().getStringArray(R.array.about_social_links);
    if (urls.length == 0) {
        recyclerView.setVisibility(View.GONE);

        subtitle.setPadding(
                subtitle.getPaddingLeft(),
                subtitle.getPaddingTop(),
                subtitle.getPaddingRight(),
                subtitle.getPaddingBottom() + mContext.getResources().getDimensionPixelSize(R.dimen.content_margin));
    } else {
        if (recyclerView.getLayoutParams() instanceof LinearLayout.LayoutParams) {
            LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) recyclerView.getLayoutParams();
            if (urls.length < 7) {
                params.width = LinearLayout.LayoutParams.WRAP_CONTENT;
                params.gravity = Gravity.CENTER_HORIZONTAL;
                recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
            }
        }
        recyclerView.setAdapter(new AboutSocialAdapter(mContext, urls));
    }

    subtitle.setHtml(mContext.getResources().getString(R.string.about_desc));

    CardView card = itemView.findViewById(R.id.card);
    if (!Preferences.get(mContext).isShadowEnabled()) {
        if (card != null) card.setCardElevation(0);

        profile.setShadowRadius(0f);
        profile.setShadowColor(Color.TRANSPARENT);
    }
}
 
Example 10
Source File: RequestAdapter.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
ContentViewHolder(View itemView) {
    super(itemView);
    title = itemView.findViewById(R.id.name);
    content = itemView.findViewById(R.id.requested);
    icon = itemView.findViewById(R.id.icon);
    checkbox = itemView.findViewById(R.id.checkbox);
    container = itemView.findViewById(R.id.container);
    divider = itemView.findViewById(R.id.divider);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getRequestStyle() == CandyBarApplication.Style.PORTRAIT_FLAT_LANDSCAPE_FLAT &&
            card != null) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        if (card != null) card.setCardElevation(0);
    }

    container.setOnClickListener(this);
    container.setOnLongClickListener(this);
}
 
Example 11
Source File: ShadowTransformer.java    From Dictionary with Apache License 2.0 4 votes vote down vote up
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    int realCurrentPosition;
    int nextPosition;
    float baseElevation = mAdapter.getBaseElevation();
    float realOffset;
    boolean goingLeft = mLastOffset > positionOffset;

    // If we're going backwards, onPageScrolled receives the last position
    // instead of the current one
    if (goingLeft) {
        realCurrentPosition = position + 1;
        nextPosition = position;
        realOffset = 1 - positionOffset;
    } else {
        nextPosition = position + 1;
        realCurrentPosition = position;
        realOffset = positionOffset;
    }

    // Avoid crash on overscroll
    if (nextPosition > mAdapter.getCount() - 1
            || realCurrentPosition > mAdapter.getCount() - 1) {
        return;
    }

    CardView currentCard = mAdapter.getCardViewAt(realCurrentPosition);

    // This might be null if a fragment is being used
    // and the views weren't created yet
    if (currentCard != null) {
        if (mScalingEnabled) {
            currentCard.setScaleX((float) (1 + 0.1 * (1 - realOffset)));
            currentCard.setScaleY((float) (1 + 0.1 * (1 - realOffset)));
        }
        currentCard.setCardElevation((baseElevation + baseElevation
                * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (1 - realOffset)));
    }

    CardView nextCard = mAdapter.getCardViewAt(nextPosition);

    // We might be scrolling fast enough so that the next (or previous) card
    // was already destroyed or a fragment might not have been created yet
    if (nextCard != null) {
        if (mScalingEnabled) {
            nextCard.setScaleX((float) (1 + 0.1 * (realOffset)));
            nextCard.setScaleY((float) (1 + 0.1 * (realOffset)));
        }
        nextCard.setCardElevation((baseElevation + baseElevation
                * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (realOffset)));
    }

    mLastOffset = positionOffset;
}
 
Example 12
Source File: ShadowTransformer.java    From MusicPlayer_XiangDa with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    int realCurrentPosition;
    int nextPosition;
    float realOffset;
    boolean goingLeft = mLastOffset > positionOffset;

    // If we're going backwards, onPageScrolled receives the last position
    // instead of the current one
    if (goingLeft) {
        realCurrentPosition = position + 1;
        nextPosition = position;
        realOffset = 1 - positionOffset;
    } else {
        nextPosition = position + 1;
        realCurrentPosition = position;
        realOffset = positionOffset;
    }


    // Avoid crash on overscroll
    if (nextPosition > mAdapter.getCount() - 1 || realCurrentPosition > mAdapter.getCount() - 1) {
        return;
    }

    CardView currentCard = mAdapter.getCardViewAt(realCurrentPosition);
    // This might be null if a fragment is being used
    // and the views weren't created yet
    if (currentCard != null) {
        currentCard.setScaleX((1 + mScaleRatio * (1 - realOffset)));
        currentCard.setScaleY((1 + mScaleRatio * (1 - realOffset)));
        currentCard.setCardElevation(mAdapter.getMaxElevationFactor() * (1 - realOffset));
    }
    CardView nextCard = mAdapter.getCardViewAt(nextPosition);
    // We might be scrolling fast enough so that the next (or previous) card
    // was already destroyed or a fragment might not have been created yet
    if (nextCard != null) {
        nextCard.setScaleX((1 + mScaleRatio * (realOffset)));
        nextCard.setScaleY((1 + mScaleRatio * (realOffset)));
        nextCard.setCardElevation(mAdapter.getMaxElevationFactor() * (realOffset));
    }


    if (realOffset == 1) {  //适用于:pos从0->3 ,过程中realOffset并不能至于0,所以伸缩会受到影响
        CardView cardView = null;
        if (goingLeft && nextPosition + 2 < mAdapter.getCount()) {
            cardView = mAdapter.getCardViewAt(nextPosition + 2);
        } else if (goingLeft && nextPosition - 2 > 0) {
            cardView = mAdapter.getCardViewAt(nextPosition - 2);
        }
        if (cardView != null) {
            cardView.setCardElevation(0);
            cardView.setScaleX((1));
            cardView.setScaleY((1));
        }
    }

    mLastOffset = positionOffset;
}
 
Example 13
Source File: AboutAdapter.java    From candybar-library with Apache License 2.0 4 votes vote down vote up
FooterViewHolder(View itemView) {
    super(itemView);
    ImageView instagram = itemView.findViewById(R.id.about_dev_instagram);
    ImageView googlePlus = itemView.findViewById(R.id.about_dev_google_plus);
    ImageView github = itemView.findViewById(R.id.about_dev_github);
    TextView title = itemView.findViewById(R.id.about_dashboard_title);
    TextView licenses = itemView.findViewById(R.id.about_dashboard_licenses);
    TextView contributors = itemView.findViewById(R.id.about_dashboard_contributors);
    TextView translator = itemView.findViewById(R.id.about_dashboard_translator);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getAboutStyle() == CandyBarApplication.Style.PORTRAIT_FLAT_LANDSCAPE_FLAT &&
            card != null) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        if (card != null) card.setCardElevation(0);
    }

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
            mContext, R.drawable.ic_toolbar_dashboard, color), null, null, null);

    color = ConfigurationHelper.getSocialIconColor(mContext,
            CandyBarApplication.getConfiguration().getSocialIconColor());
    instagram.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_instagram, color));
    googlePlus.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_google_plus, color));
    github.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_github, color));

    instagram.setOnClickListener(this);
    googlePlus.setOnClickListener(this);
    github.setOnClickListener(this);
    licenses.setOnClickListener(this);
    contributors.setOnClickListener(this);
    translator.setOnClickListener(this);
}
 
Example 14
Source File: ShadowTransformer.java    From ahoy-onboarding with Apache License 2.0 4 votes vote down vote up
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    int realCurrentPosition;
    int nextPosition;
    float baseElevation = mAdapter.getBaseElevation();
    float realOffset;
    boolean goingLeft = mLastOffset > positionOffset;

    // If we're going backwards, onPageScrolled receives the last position
    // instead of the current one
    if (goingLeft) {
        realCurrentPosition = position + 1;
        nextPosition = position;
        realOffset = 1 - positionOffset;
    } else {
        nextPosition = position + 1;
        realCurrentPosition = position;
        realOffset = positionOffset;
    }

    // Avoid crash on overscroll
    if (nextPosition > mAdapter.getCount() - 1
            || realCurrentPosition > mAdapter.getCount() - 1) {
        return;
    }

    CardView currentCard = mAdapter.getCardViewAt(realCurrentPosition);

    // This might be null if a fragment is being used
    // and the views weren't created yet
    if (currentCard != null) {
        if (mScalingEnabled) {
            currentCard.setScaleX((float) (1 + 0.1 * (1 - realOffset)));
            currentCard.setScaleY((float) (1 + 0.1 * (1 - realOffset)));
        }
        currentCard.setCardElevation((baseElevation + baseElevation
                * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (1 - realOffset)));
    }

    CardView nextCard = mAdapter.getCardViewAt(nextPosition);

    // We might be scrolling fast enough so that the next (or previous) card
    // was already destroyed or a fragment might not have been created yet
    if (nextCard != null) {
        if (mScalingEnabled) {
            nextCard.setScaleX((float) (1 + 0.1 * (realOffset)));
            nextCard.setScaleY((float) (1 + 0.1 * (realOffset)));
        }
        nextCard.setCardElevation((baseElevation + baseElevation
                * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (realOffset)));
    }

    mLastOffset = positionOffset;
}
 
Example 15
Source File: CardsFragment.java    From iGap-Android with GNU Affero General Public License v3.0 4 votes vote down vote up
private void addEmptyCard() {
    Context context = getContext();
    int dp8 = RaadCommonUtils.getPx(8, context);
    int dp16 = RaadCommonUtils.getPx(16, context);

    int cardHeight = BankCardView.getDefaultCardHeight(getContext());

    CardView cardView = new CardView(context);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, cardHeight);
    params.setMargins(dp16, 0, dp16, dp16);
    cardView.setLayoutParams(params);
    if (WalletActivity.isDarkTheme) {
        cardView.setCardBackgroundColor(Color.parseColor(WalletActivity.backgroundTheme_2));
    } else {
        cardView.setCardBackgroundColor(Color.parseColor(WalletActivity.backgroundTheme));
    }

    cardView.setPreventCornerOverlap(false);
    cardView.setCardElevation(RaadCommonUtils.getPx(6, context));
    cardView.setRadius(RaadCommonUtils.getPx(8, context));
    cardsLayout.addView(cardView);
    viewItems.add(cardView);

    TextView textView = new TextView(context);
    CardView.LayoutParams textViewParams = new CardView.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    textViewParams.gravity = Gravity.CENTER;
    textView.setLayoutParams(textViewParams);
    textView.setGravity(Gravity.CENTER);
    textView.setTextColor(Color.parseColor(WalletActivity.textTitleTheme));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
    textView.setTypeface(Typefaces.get(context, Typefaces.IRAN_YEKAN_REGULAR));
    textView.setText(R.string.click_here_for_adding_card);
    cardView.addView(textView);

    cardView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ((NavigationBarActivity) getActivity()).pushFullFragment(
                    new AddCardFragment(), "AddCardFragment");
        }
    });
}
 
Example 16
Source File: ShadowTransformer.java    From ViewPagerCards with Apache License 2.0 4 votes vote down vote up
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    int realCurrentPosition;
    int nextPosition;
    float baseElevation = mAdapter.getBaseElevation();
    float realOffset;
    boolean goingLeft = mLastOffset > positionOffset;

    // If we're going backwards, onPageScrolled receives the last position
    // instead of the current one
    if (goingLeft) {
        realCurrentPosition = position + 1;
        nextPosition = position;
        realOffset = 1 - positionOffset;
    } else {
        nextPosition = position + 1;
        realCurrentPosition = position;
        realOffset = positionOffset;
    }

    // Avoid crash on overscroll
    if (nextPosition > mAdapter.getCount() - 1
            || realCurrentPosition > mAdapter.getCount() - 1) {
        return;
    }

    CardView currentCard = mAdapter.getCardViewAt(realCurrentPosition);

    // This might be null if a fragment is being used
    // and the views weren't created yet
    if (currentCard != null) {
        if (mScalingEnabled) {
            currentCard.setScaleX((float) (1 + 0.1 * (1 - realOffset)));
            currentCard.setScaleY((float) (1 + 0.1 * (1 - realOffset)));
        }
        currentCard.setCardElevation((baseElevation + baseElevation
                * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (1 - realOffset)));
    }

    CardView nextCard = mAdapter.getCardViewAt(nextPosition);

    // We might be scrolling fast enough so that the next (or previous) card
    // was already destroyed or a fragment might not have been created yet
    if (nextCard != null) {
        if (mScalingEnabled) {
            nextCard.setScaleX((float) (1 + 0.1 * (realOffset)));
            nextCard.setScaleY((float) (1 + 0.1 * (realOffset)));
        }
        nextCard.setCardElevation((baseElevation + baseElevation
                * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (realOffset)));
    }

    mLastOffset = positionOffset;
}
 
Example 17
Source File: ShadowTransformer.java    From FastAccess with GNU General Public License v3.0 4 votes vote down vote up
@Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    int realCurrentPosition;
    int nextPosition;
    float baseElevation = mAdapter.getBaseElevation();
    float realOffset;
    boolean goingLeft = mLastOffset > positionOffset;

    // If we're going backwards, onPageScrolled receives the last position
    // instead of the current one
    if (goingLeft) {
        realCurrentPosition = position + 1;
        nextPosition = position;
        realOffset = 1 - positionOffset;
    } else {
        nextPosition = position + 1;
        realCurrentPosition = position;
        realOffset = positionOffset;
    }

    // Avoid crash on overscroll
    if (nextPosition > mAdapter.getCount() - 1
            || realCurrentPosition > mAdapter.getCount() - 1) {
        return;
    }

    CardView currentCard = mAdapter.getCardViewAt(realCurrentPosition);

    // This might be null if a fragment is being used
    // and the views weren't created yet
    if (currentCard != null) {
        if (mScalingEnabled) {
            currentCard.setScaleX((float) (1 + 0.1 * (1 - realOffset)));
            currentCard.setScaleY((float) (1 + 0.1 * (1 - realOffset)));
        }
        currentCard.setCardElevation((baseElevation + baseElevation
                * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (1 - realOffset)));
    }

    CardView nextCard = mAdapter.getCardViewAt(nextPosition);

    // We might be scrolling fast enough so that the next (or previous) card
    // was already destroyed or a fragment might not have been created yet
    if (nextCard != null) {
        if (mScalingEnabled) {
            nextCard.setScaleX((float) (1 + 0.1 * (realOffset)));
            nextCard.setScaleY((float) (1 + 0.1 * (realOffset)));
        }
        nextCard.setCardElevation((baseElevation + baseElevation * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (realOffset)));
    }

    mLastOffset = positionOffset;
}
 
Example 18
Source File: ShadowTransformer.java    From ViewPagerCards with Apache License 2.0 4 votes vote down vote up
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    int realCurrentPosition;
    int nextPosition;
    float baseElevation = mAdapter.getBaseElevation();
    float realOffset;
    boolean goingLeft = mLastOffset > positionOffset;

    // If we're going backwards, onPageScrolled receives the last position
    // instead of the current one
    if (goingLeft) {
        realCurrentPosition = position + 1;
        nextPosition = position;
        realOffset = 1 - positionOffset;
    } else {
        nextPosition = position + 1;
        realCurrentPosition = position;
        realOffset = positionOffset;
    }

    // Avoid crash on overscroll
    if (nextPosition > mAdapter.getCount() - 1
            || realCurrentPosition > mAdapter.getCount() - 1) {
        return;
    }

    CardView currentCard = mAdapter.getCardViewAt(realCurrentPosition);

    // This might be null if a fragment is being used
    // and the views weren't created yet
    if (currentCard != null) {
        if (mScalingEnabled) {
            currentCard.setScaleX((float) (1 + 0.1 * (1 - realOffset)));
            currentCard.setScaleY((float) (1 + 0.1 * (1 - realOffset)));
        }
        currentCard.setCardElevation((baseElevation + baseElevation
                * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (1 - realOffset)));
    }

    CardView nextCard = mAdapter.getCardViewAt(nextPosition);

    // We might be scrolling fast enough so that the next (or previous) card
    // was already destroyed or a fragment might not have been created yet
    if (nextCard != null) {
        if (mScalingEnabled) {
            nextCard.setScaleX((float) (1 + 0.1 * (realOffset)));
            nextCard.setScaleY((float) (1 + 0.1 * (realOffset)));
        }
        nextCard.setCardElevation((baseElevation + baseElevation
                * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (realOffset)));
    }

    mLastOffset = positionOffset;
}
 
Example 19
Source File: ShadowTransformer.java    From FancyWalkthrough-Android with Apache License 2.0 4 votes vote down vote up
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    int realCurrentPosition;
    int nextPosition;
    float baseElevation = mAdapter.getBaseElevation();
    float realOffset;
    boolean goingLeft = mLastOffset > positionOffset;

    // If we're going backwards, onPageScrolled receives the last position
    // instead of the current one
    if (goingLeft) {
        realCurrentPosition = position + 1;
        nextPosition = position;
        realOffset = 1 - positionOffset;
    } else {
        nextPosition = position + 1;
        realCurrentPosition = position;
        realOffset = positionOffset;
    }

    // Avoid crash on overscroll
    if (nextPosition > mAdapter.getCount() - 1
            || realCurrentPosition > mAdapter.getCount() - 1) {
        return;
    }

    CardView currentCard = mAdapter.getCardViewAt(realCurrentPosition);

    // This might be null if a fragment is being used
    // and the views weren't created yet
    if (currentCard != null) {
        if (mScalingEnabled) {
            currentCard.setScaleX((float) (1 + 0.1 * (1 - realOffset)));
            currentCard.setScaleY((float) (1 + 0.1 * (1 - realOffset)));
        }
        currentCard.setCardElevation((baseElevation + baseElevation
                * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (1 - realOffset)));
    }

    CardView nextCard = mAdapter.getCardViewAt(nextPosition);

    // We might be scrolling fast enough so that the next (or previous) card
    // was already destroyed or a fragment might not have been created yet
    if (nextCard != null) {
        if (mScalingEnabled) {
            nextCard.setScaleX((float) (1 + 0.1 * (realOffset)));
            nextCard.setScaleY((float) (1 + 0.1 * (realOffset)));
        }
        nextCard.setCardElevation((baseElevation + baseElevation
                * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (realOffset)));
    }

    mLastOffset = positionOffset;
}
 
Example 20
Source File: ProcessViewer.java    From PowerFileExplorer with GNU General Public License v3.0 4 votes vote down vote up
@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      rootView = inflater.inflate(R.layout.processparent, container, false);
      setRetainInstance(false);
setStyle(DialogFragment.STYLE_NO_TITLE, 0);
      mainActivity = (ExplorerActivity) getActivity();

      ColorPreference colorPreference = mainActivity.getColorPreference();
accentColor = colorPreference.getColor(ColorUsage.ACCENT);
      primaryColor = colorPreference.getColor(ColorUsage.PRIMARY);
      if (mainActivity.getAppTheme().equals(AppTheme.DARK))
          rootView.setBackgroundResource((R.color.cardView_background));
      //mainActivity.updateViews(new ColorDrawable(primaryColor));
      //mainActivity.getAppbar().setTitle(getResources().getString(R.string.process_viewer));
      //mainActivity.floatingActionButton.hideMenuButton(true);
      //sharedPrefs = PreferenceManager.getDefaultSharedPreferences(mainActivity);
      //mainActivity.supportInvalidateOptionsMenu();

      mCardView = (CardView) rootView.findViewById(R.id.card_view);

      mLineChart = (LineChart) rootView.findViewById(R.id.progress_chart);
      mProgressImage = (ImageView) rootView.findViewById(R.id.progress_image);
      mCancelButton = (ImageButton) rootView.findViewById(R.id.delete_button);
      mProgressTypeText = (TextView) rootView.findViewById(R.id.text_view_progress_type);
      mProgressFileNameText = (TextView) rootView.findViewById(R.id.text_view_progress_file_name);
      mProgressBytesText = (TextView) rootView.findViewById(R.id.text_view_progress_bytes);
      mProgressFileText = (TextView) rootView.findViewById(R.id.text_view_progress_file);
      mProgressSpeedText = (TextView) rootView.findViewById(R.id.text_view_progress_speed);
      mProgressTimer = (TextView) rootView.findViewById(R.id.text_view_progress_timer);
mProgressTypeText.setTextColor(accentColor);
      if (!copyCancelled) {
	mCancelButton.setEnabled(true);
}
if (mainActivity.getAppTheme().equals(AppTheme.DARK)) {
          mCancelButton.setImageResource(R.drawable.ic_action_cancel);
          mCardView.setCardBackgroundColor(Utils.getColor(getContext(), R.color.cardView_foreground));
          mCardView.setCardElevation(0f);
      }

      return rootView;
  }