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);
}
}
}
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;
}
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));
}
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;
}
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;
}
Aggregations