Search in sources :

Example 1 with CardView

use of android.support.v7.widget.CardView in project MaterialList by dexafree.

the class CardProvider method render.

/////////////////////////////////////////////////////////////////
//
//      Functions for rendering.
//
/////////////////////////////////////////////////////////////////
/**
     * Renders the content and style of the card to the view.
     *
     * @param view to display the content and style on.
     * @param card to render.
     */
@SuppressWarnings("unchecked")
public void render(@NonNull final View view, @NonNull final Card card) {
    // The card background
    final CardView cardView = findViewById(view, R.id.cardView, CardView.class);
    if (cardView != null) {
        cardView.setCardBackgroundColor(getBackgroundColor());
    }
    // Title
    final TextView title = findViewById(view, R.id.title, TextView.class);
    if (title != null) {
        title.setText(getTitle());
        title.setTextColor(getTitleColor());
        title.setGravity(getTitleGravity());
    }
    // Subtitle
    final TextView subtitle = findViewById(view, R.id.subtitle, TextView.class);
    if (subtitle != null) {
        subtitle.setText(getSubtitle());
        subtitle.setTextColor(getSubtitleColor());
        subtitle.setGravity(getSubtitleGravity());
        if (getSubtitle() == null || getSubtitle().isEmpty()) {
            subtitle.setVisibility(View.GONE);
        } else {
            subtitle.setVisibility(View.VISIBLE);
        }
    }
    // Description
    final TextView supportingText = findViewById(view, R.id.supportingText, TextView.class);
    if (supportingText != null) {
        supportingText.setText(getDescription());
        supportingText.setTextColor(getDescriptionColor());
        supportingText.setGravity(getDescriptionGravity());
    }
    // Image
    final ImageView imageView = findViewById(view, R.id.image, ImageView.class);
    if (imageView != null) {
        if (getDrawable() != null) {
            imageView.setImageDrawable(getDrawable());
        } else {
            final RequestCreator requestCreator = Picasso.with(getContext()).load(getImageUrl());
            if (getOnImageConfigListenerListener() != null) {
                getOnImageConfigListenerListener().onImageConfigure(requestCreator);
            }
            requestCreator.into(imageView);
        }
    }
    // Divider
    final View divider = findViewById(view, R.id.divider, View.class);
    if (divider != null) {
        divider.setVisibility(isDividerVisible() ? View.VISIBLE : View.INVISIBLE);
        // according to the preferences
        if (isDividerVisible()) {
            // If the divider has to be from side to side, the margin will be 0
            final ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) divider.getLayoutParams();
            if (isFullWidthDivider()) {
                params.setMargins(0, 0, 0, 0);
            } else {
                int dividerMarginPx = dpToPx(DIVIDER_MARGIN_DP);
                // Set the margin
                params.setMargins(dividerMarginPx, 0, dividerMarginPx, 0);
            }
        }
    }
    // Actions
    for (final Map.Entry<Integer, Action> entry : mActionMapping.entrySet()) {
        final View actionViewRaw = findViewById(view, entry.getKey(), View.class);
        if (actionViewRaw != null) {
            final Action action = entry.getValue();
            action.setProvider(this);
            action.onRender(actionViewRaw, card);
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) CardView(android.support.v7.widget.CardView) ImageView(android.widget.ImageView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) RequestCreator(com.squareup.picasso.RequestCreator) TextView(android.widget.TextView) ImageView(android.widget.ImageView) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with CardView

use of android.support.v7.widget.CardView in project WilliamChart by diogobernardino.

the class ChartsFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = inflater.inflate(R.layout.charts, container, false);
    ((AppCompatActivity) getActivity()).setSupportActionBar((Toolbar) layout.findViewById(R.id.toolbar));
    ((TextView) layout.findViewById(R.id.title)).setTypeface(Typeface.createFromAsset(getContext().getAssets(), "Ponsi-Regular.otf"));
    (new LineCardOne((CardView) layout.findViewById(R.id.card1), getContext())).init();
    (new LineCardThree((CardView) layout.findViewById(R.id.card2), getContext())).init();
    (new BarCardOne((CardView) layout.findViewById(R.id.card3), getContext())).init();
    (new StackedCardThree((CardView) layout.findViewById(R.id.card4), getContext())).init();
    (new StackedCardOne((CardView) layout.findViewById(R.id.card5))).init();
    (new BarCardThree((CardView) layout.findViewById(R.id.card6), getContext())).init();
    (new BarCardTwo((CardView) layout.findViewById(R.id.card7), getContext())).init();
    (new StackedCardTwo((CardView) layout.findViewById(R.id.card8))).init();
    (new LineCardTwo((CardView) layout.findViewById(R.id.card9))).init();
    return layout;
}
Also used : StackedCardOne(com.db.williamchartdemo.stackedchart.StackedCardOne) BarCardThree(com.db.williamchartdemo.barchart.BarCardThree) LineCardTwo(com.db.williamchartdemo.linechart.LineCardTwo) AppCompatActivity(android.support.v7.app.AppCompatActivity) BarCardTwo(com.db.williamchartdemo.barchart.BarCardTwo) StackedCardTwo(com.db.williamchartdemo.stackedchart.StackedCardTwo) TextView(android.widget.TextView) StackedCardThree(com.db.williamchartdemo.stackedchart.StackedCardThree) BarCardOne(com.db.williamchartdemo.barchart.BarCardOne) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) View(android.view.View) LineCardOne(com.db.williamchartdemo.linechart.LineCardOne) LineCardThree(com.db.williamchartdemo.linechart.LineCardThree)

Example 3 with CardView

use of android.support.v7.widget.CardView in project FastDev4Android by jiangqqlmj.

the class CardViewRecyclerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.card_view_recycler_layout);
    top_bar_linear_back = (LinearLayout) this.findViewById(R.id.top_bar_linear_back);
    top_bar_linear_back.setOnClickListener(new CustomOnClickListener());
    top_bar_title = (TextView) this.findViewById(R.id.top_bar_title);
    top_bar_title.setText("CardView结合RecyclerView使用实例");
    recycler_cardview = (RecyclerView) this.findViewById(R.id.recycler_cardview);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setOrientation(OrientationHelper.VERTICAL);
    recycler_cardview.setLayoutManager(linearLayoutManager);
    recycler_cardview.setAdapter(new CardViewAdapter(this));
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 4 with CardView

use of android.support.v7.widget.CardView in project AboutLibraries by mikepenz.

the class LibsFragmentCompat method onCreateView.

public View onCreateView(Context context, LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState, Bundle arguments) {
    if (arguments != null) {
        builder = (LibsBuilder) arguments.getSerializable("data");
    } else {
        Log.e("AboutLibraries", "The AboutLibraries fragment can't be build without the bundle containing the LibsBuilder");
    }
    View view = inflater.inflate(R.layout.fragment_opensource, container, false);
    //allows to modify the view before creating
    if (LibsConfiguration.getInstance().getUiListener() != null) {
        view = LibsConfiguration.getInstance().getUiListener().preOnCreateView(view);
    }
    // init CardView
    RecyclerView mRecyclerView;
    if (view.getId() == R.id.cardListView) {
        mRecyclerView = (RecyclerView) view;
    } else {
        mRecyclerView = (RecyclerView) view.findViewById(R.id.cardListView);
    }
    mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
    if (LibsConfiguration.getInstance().getItemAnimator() != null) {
        mRecyclerView.setItemAnimator(LibsConfiguration.getInstance().getItemAnimator());
    } else {
        mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    }
    if (builder != null) {
        mAdapter = new FastAdapter();
        mItemAdapter = new ItemAdapter();
        mRecyclerView.setAdapter(mItemAdapter.wrap(mAdapter));
        mItemAdapter.add(new LoaderItem());
    }
    //allows to modify the view after creating
    if (LibsConfiguration.getInstance().getUiListener() != null) {
        view = LibsConfiguration.getInstance().getUiListener().postOnCreateView(view);
    }
    return view;
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) FastAdapter(com.mikepenz.fastadapter.FastAdapter) LoaderItem(com.mikepenz.aboutlibraries.ui.item.LoaderItem) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) ItemAdapter(com.mikepenz.fastadapter.adapters.ItemAdapter)

Example 5 with CardView

use of android.support.v7.widget.CardView in project ViewPagerCards by rubensousa.

the class ShadowTransformer method enableScaling.

public void enableScaling(boolean enable) {
    if (mScalingEnabled && !enable) {
        // shrink main card
        CardView currentCard = mAdapter.getCardViewAt(mViewPager.getCurrentItem());
        if (currentCard != null) {
            currentCard.animate().scaleY(1);
            currentCard.animate().scaleX(1);
        }
    } else if (!mScalingEnabled && enable) {
        // grow main card
        CardView currentCard = mAdapter.getCardViewAt(mViewPager.getCurrentItem());
        if (currentCard != null) {
            currentCard.animate().scaleY(1.1f);
            currentCard.animate().scaleX(1.1f);
        }
    }
    mScalingEnabled = enable;
}
Also used : CardView(android.support.v7.widget.CardView)

Aggregations

CardView (android.support.v7.widget.CardView)30 View (android.view.View)26 TextView (android.widget.TextView)24 ImageView (android.widget.ImageView)10 IconicsImageView (com.mikepenz.iconics.view.IconicsImageView)10 DialogInterface (android.content.DialogInterface)9 AlertDialog (android.support.v7.app.AlertDialog)9 RecyclerView (android.support.v7.widget.RecyclerView)9 ScrollView (android.widget.ScrollView)8 OnScrollListener (android.support.v7.widget.RecyclerView.OnScrollListener)5 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)5 Task (com.android.systemui.recents.model.Task)5 Intent (android.content.Intent)3 Nullable (android.support.annotation.Nullable)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 EditText (android.widget.EditText)3 SeekBar (android.widget.SeekBar)3 NonNull (android.support.annotation.NonNull)2 SwitchCompat (android.support.v7.widget.SwitchCompat)2 CompoundButton (android.widget.CompoundButton)2