Skip to content

Instantly share code, notes, and snippets.

View Mustufa786's full-sized avatar
🎯
Focusing

Mustufa Ansari Mustufa786

🎯
Focusing
View GitHub Profile
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
@Mustufa786
Mustufa786 / item_list.xml
Created August 4, 2019 12:10
This is our list item what will hold each row of recyclerView.
<?xml version="1.0" encoding="utf-8"?>
<com.balysv.materialripple.MaterialRippleLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/parentLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
public class Person {
public int image;
public String name;
public String description;
public Person() {
}
public class RecyclerAnimationAdapter extends RecyclerView.Adapter<RecyclerAnimationAdapter.ViewHolder> {
Context context;
List<Person> list;
public RecyclerAnimationAdapter(Context context, List<Person> personList) {
this.context = context;
this.list = personList;
<string-array name="people_names">
<item>Anderson Thomas</item>
<item>Adams Green</item>
<item>Laura Michelle</item>
<item>Betty L</item>
<item>Miller Wilson</item>
<item>Garcia Lewis</item>
<item>Roberts Turner</item>
<item>Mary Jackson</item>
<item>Sarah Scott</item>
public class MainActivity extends AppCompatActivity {
ActivityMainBinding bi;
List<Person> list;
RecyclerAnimationAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
<?xml version="1.0" encoding="utf-8"?>
<layout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
public class RecyclerAnimationAdapter extends RecyclerView.Adapter<RecyclerAnimationAdapter.ViewHolder> {
Context context;
List<Person> list;
long DURATION = 500;
private boolean on_attach = true;
public RecyclerAnimationAdapter(Context context, List<Person> personList) {
private void FromLeftToRight(View itemView, int i) {
if(!on_attach){
i = -1;
}
boolean not_first_item = i == -1;
i = i + 1;
itemView.setTranslationX(-400f);
itemView.setAlpha(0.f);
AnimatorSet animatorSet = new AnimatorSet();
ObjectAnimator animatorTranslateY = ObjectAnimator.ofFloat(itemView, "translationX", -400f, 0);
private void FromRightToLeft(View itemView, int i) {
if(!on_attach){
i = -1;
}
boolean not_first_item = i == -1;
i = i + 1;
itemView.setTranslationX(itemView.getX() + 400);
itemView.setAlpha(0.f);
AnimatorSet animatorSet = new AnimatorSet();
ObjectAnimator animatorTranslateY = ObjectAnimator.ofFloat(itemView, "translationX", itemView.getX() + 400, 0);