View GenericAdapterActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mDataBinding.recyclerview.setAdapter(new GenericAdapter<String, ListitemGenericAdapterBinding>(this,getStringsList()) { | |
@Override | |
public int getLayoutResId() { | |
return R.layout.listitem_generic_adapter; | |
} | |
@Override | |
public void onBindData(String model, int position, ListitemGenericAdapterBinding dataBinding) { | |
dataBinding.txtName.setText("String " + position); | |
} |
View GenericAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class GenericAdapter<T, D> extends RecyclerView.Adapter<RecyclerView.ViewHolder> { | |
private Context mContext; | |
private ArrayList<T> mArrayList; | |
public abstract int getLayoutResId(); | |
public abstract void onBindData(T model, int position, D dataBinding); | |
public abstract void onItemClick(T model, int position); |
View SampleGenericAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SampleAdapter extends GenericAdapter<Model, ListitemGenericAdapterBinding> { | |
public SampleAdapter(Context context, ArrayList<Model> arrayList) { | |
super(context, arrayList); | |
} | |
@Override | |
public int getLayoutResId() { | |
return R.layout.listitem_generic_adapter; | |
} |
View CustomTextView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomTextView extends AppCompatTextView { | |
public CustomTextView(Context context) { | |
super(context); | |
} | |
public CustomTextView(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
setFont(context, attrs); | |
} |
View attrs.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<declare-styleable name="CustomTextView"> | |
<attr name="fontname" format="integer"> | |
<enum name="UbuntuRegular" value="1" /> | |
<enum name="UbuntuBold" value="2" /> | |
<enum name="UbuntuItalic" value="3" /> | |
</attr> | |
</declare-styleable> |
View activity_customview.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<com.manojbhadane.customtextview.CustomTextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Ubuntu Regular" | |
android:textSize="25sp" | |
app:fontname="UbuntuRegular" /> |
View CustomTextView.png
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
 |
View PaymentCardView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Init | |
PaymentCardView paymentCard = (PaymentCardView) findViewById(R.id.creditCard); | |
// Options | |
paymentCard.setCardTitle("Pay Now"); // set from xml as well | |
paymentCard.setSubmitButtonText("Done"); // set from xml as well | |
// Callbacks |
View PaymentCardViewMaven.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Step 1. Add the JitPack repository to your build file | |
<repositories> | |
<repository> | |
<id>jitpack.io</id> | |
<url>https://jitpack.io</url> | |
</repository> | |
</repositories> | |
View PaymentCardViewGradle.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Step 1. Add the JitPack repository to your build file | |
allprojects { | |
repositories { | |
... | |
maven { url 'https://jitpack.io' } | |
} | |
} | |
OlderNewer