vinaygaba / creditcardview Goto Github PK
View Code? Open in Web Editor NEW💳 CreditCardView is an Android library that allows developers to create the UI which replicates an actual Credit Card.
💳 CreditCardView is an Android library that allows developers to create the UI which replicates an actual Credit Card.
When gaining focus to the expiration field, the keyboard turns into a full keyboard. Suggestion is to keep it as the numeric keyboard.
I have dialog fragment which saves/sets the creditcard information programmatically. Everything works ok but the show the saved creditcard info.
I'm using this line of code to set creditcard programmtically:
creditCardView.setExpiryDate(expdate);
creditCardView.setCardNumber(creditCard.number);
I think the problem is that you dont reset the text
of your expiryDate
and cardNumber
, just call the function invalidate();
to redraw
the view.
Hello,
The library works fine when the data is put in xml but does not work when I want to put values from java side. Please help
Would be nice to use a CardView
instead of the LinearLayout
as root layout.
-> corner radius for free
-> elevation for free
I have a CardView
with app:cardNumberFormat="masked_all_but_last_four"
and app:type="auto"
but when I type the card number the type is not auto detected. With the normal format it works correctly.
This happens on both manually typing in the app and by setting it programatically.
Comparison goes below.
how do I save the cardnumber , cardName values as their is no button on whuch we click so that it can save the data !! and how do I set and get cvv values ?
Cómo pueda sacar dinero de aki$
I have the credit card setup to be blank so a user can input a new card. If I click in the credit card field and then click out without entering a number, I get this exception:
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
at com.vinaygaba.creditcardview.CreditCardView$2.onFocusChange(CreditCardView.java:215)
at android.view.View.onFocusChanged(View.java:5206)
at android.widget.TextView.onFocusChanged(TextView.java:7913)
at android.view.View.clearFocusInternal(View.java:5089)
at android.view.View.unFocus(View.java:5122)
at android.view.ViewGroup.requestChildFocus(ViewGroup.java:658)
at android.view.View.handleFocusGainInternal(View.java:4955)
at android.view.View.requestFocusNoSearch(View.java:7678)
at android.view.View.requestFocus(View.java:7657)
at android.view.View.requestFocus(View.java:7624)
at android.view.View.requestFocus(View.java:7603)
at android.view.View.onTouchEvent(View.java:9439)
at android.widget.TextView.onTouchEvent(TextView.java:7965)
at android.view.View.dispatchTouchEvent(View.java:8471)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2369)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1719)
at android.app.Activity.dispatchTouchEvent(Activity.java:2742)
at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2330)
at android.view.View.dispatchPointerEvent(View.java:8666)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4123)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3989)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3680)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3737)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
at android.view.ViewRootImpl.deliverInputEvent(Vi
cvv_max_length for Amex is 4
The CreditCardView
crashes when type is set to 'none'
Vinay im using updated version of your library 1.0.4 but there is no get or set cvv function !! how would i get and set this cvv code ?
I want to put CVV to the view. Please help me on this issue.
I saw many app have this feature, if the app have this feature, people do not input any message, it's very convenience
I use CreditCardView as an item layout xml for using in RecyclerView but I can't set data by using code :(
Can you check it please?
I waste all day for it :(
Thank you so much
public class CreditCardViewAdapter extends RecyclerView.Adapter<CreditCardViewAdapter.CreditViewHolder> {
private Context context;
private List<PaymentAccount> paymentAccountList;
public CreditCardViewAdapter(Context context, List<PaymentAccount> paymentAccountList) {
this.context = context;
this.paymentAccountList = paymentAccountList;
}
@Override
public CreditViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater
.from(parent.getContext())
.inflate(R.layout.item_credit_card, parent, false);
return new CreditViewHolder(itemView);
}
@Override
public void onBindViewHolder(CreditViewHolder holder, int position) {
PaymentAccount paymentAccount = paymentAccountList.get(position);
holder.setPaymentAccount(paymentAccount);
}
@Override
public int getItemCount() {
return paymentAccountList.size();
}
public class CreditViewHolder extends RecyclerView.ViewHolder {
protected CreditCardView creditCardView;
protected PaymentAccount paymentAccount;
public CreditViewHolder(View itemView) {
super(itemView);
creditCardView = (CreditCardView) itemView.findViewById(R.id.cv_credit_card);
}
public void setPaymentAccount(PaymentAccount paymentAccount) {
this.paymentAccount = paymentAccount;
creditCardView.setCardNumber(this.paymentAccount.getNumber());
creditCardView.setExpiryDate(this.paymentAccount.getExpireMonth() + "/" + this.paymentAccount.getExpireYear());
creditCardView.setCardName(this.paymentAccount.getFirstName() + " " + this.paymentAccount.getLastName());
}
}
}
Lithuanian letters are not supported in this font 😞
ąčęėįšųūž ĄČĘĖĮŠŲŪŽ
Could you please add update with possibility to change font to standart?
It would be nice to have a cvv field in the card. I was thinking of sending a pr, but I need your opinion about the placement.
The current package name is the default package name by Androi Studio. This was overlooked initally and needs to change.
I've added the credit card to one of my fragments. When I select the design view for that fragment I get the following exception:
java.lang.RuntimeException: Font asset not found fonts/creditcard2.ttf
at android.graphics.Typeface.createFromAsset(Typeface.java:190)
at com.vinaygaba.creditcardview.CreditCardView.init(CreditCardView.java:73)
at com.vinaygaba.creditcardview.CreditCardView.<init>(CreditCardView.java:59)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:437)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:154)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:93)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:190)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:410)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:321)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:511)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:499)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:888)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:499)
at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:72)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:611)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:608)
at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:364)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:608)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:630)
at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$6.run(AndroidDesignerEditorPanel.java:480)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:351)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
This setCardName function is not working
CreditCardView creditCardView = (CreditCardView) findViewById(R.id.custom_card_image);
creditCardView.setCardName("Burak");
It's all in the title. I have jitpack
declared as the very first repo to look in for dependencies, I've cleared every possible cache, and yet I still get a jar
of the library that has old code -- even though the jar
has 1.0.3
in the name, things like programmatic setters do not update the views.
It would be great if we could have some kind of state change listener which fires after all of the CreditCardView's internal text changed processing has taken place.
This would allow client code to update models and validate the current state of the card entry (i.e. valid enables a button).
I'd really like to see the editable state being applied to individual fields rather than the card as a whole.
E.g. Our app only allows users to update expiry of cards once created.
These files are located here: https://github.com/vinaygaba/CreditCardView/tree/master/library/src/main/assets/fonts
This typeface was created by and is available under license from K-Type: http://www.k-type.com/fonts/credit-card/
Their license terms do not permit redistribution in open-source projects: http://www.k-type.com/licences/
I'm using the card view in a list. In the list adapter's getView, I findViewById for the credit card view and then I set card number, name and expiry.
The following scenarios happen:
cant find "crediCardView"
Even when i make the correct spelling of by adding the 'T' to make it "creditcardview", it still cant find that class
Would be nice if the View would keep the correct (or a specified) aspect ratio.
Strictly follow Code Style Guidelines for further contribution.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.