Skip to content
Permalink
Browse files
chnages in the recycler view to show author and isbn
  • Loading branch information
dacost13 committed Aug 30, 2021
1 parent 601f6cb commit 29af29838870f4082ca2f5e069716eeecacaf610
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 82 deletions.

Some generated files are not rendered by default. Learn more.

@@ -261,9 +261,6 @@ public class AccountFragment extends Fragment implements View.OnClickListener {
fr.commit();
}




@Override
public void onClick(View v) {
switch (v.getId()) {
@@ -2,25 +2,21 @@ package com.example.booksharing21;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Filter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.google.common.net.InternetDomainName;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.firestore.DocumentSnapshot;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;


public class HelperAdapter extends RecyclerView.Adapter<HelperAdapter.ViewHolder> {
@@ -52,6 +48,8 @@ public class HelperAdapter extends RecyclerView.Adapter<HelperAdapter.ViewHolder


holder.textView.setText(infoList.get(position).getBookname());
holder.author.setText(infoList.get(position).getAuthor());
holder.isbn.setText(infoList.get(position).getIsbn());
Glide.with(mContext).load(infoList.get(position).getUrl()).into(holder.imageView);


@@ -78,83 +76,30 @@ public class HelperAdapter extends RecyclerView.Adapter<HelperAdapter.ViewHolder
public class ViewHolder extends RecyclerView.ViewHolder {
ImageView imageView;
TextView textView;
TextView author;
TextView isbn;
View v;


public ViewHolder(@NonNull View itemView) {
super(itemView);
imageView = itemView.findViewById(R.id.iview);
textView = itemView.findViewById(R.id.ibookname);
author = itemView.findViewById(R.id.iAuthor);
isbn = itemView.findViewById(R.id.iisbn);
}
}

}













}


//
//
//
//
//
// private Context context;
// private ArrayList<info> infoList;
//
// public HelperAdapter (Context context , ArrayList<info> infoList){
// this.context = context;
// this.infoList = infoList;
// }
//
// public HelperAdapter(ArrayList<info> infoList) {
// }
//
//
// @NonNull
// @Override
// public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
// return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.info_item,parent , false));
// }
//
// @Override
// public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
//
// Glide.with(context).load(infoList.get(position).getUrl()).into(holder.iview);
// holder.ibookname.setText(infoList.get(position).getBookname());
//
//
// }
//
// @Override
// public int getItemCount() {
// return infoList.size();
// }
//
// public class ViewHolder extends RecyclerView.ViewHolder {
// ImageView iview;
// TextView ibookname;
//
// public ViewHolder(@NonNull View itemView) {
// super(itemView);
//
// iview = itemView.findViewById(R.id.iview);
// ibookname = itemView.findViewById(R.id.ibookname);
//
//
// }
//
// }



@@ -191,6 +191,8 @@ public class HomeFragment extends Fragment {
info.setPostid(dataSnapshot.child("postid").getValue().toString());
info.setUrl(dataSnapshot.child("url").getValue().toString());
info.setBookname(dataSnapshot.child("book name").getValue().toString());
info.setAuthor(dataSnapshot.child("author").getValue().toString());
info.setIsbn(dataSnapshot.child("isbn").getValue().toString());


infoList.add(info);
@@ -7,6 +7,8 @@ public class info {
public String url;
public String bookname;
public String postid;
public String isbn;
public String author;



@@ -17,11 +19,13 @@ public class info {
}


public info(String url, String bookname ,String postid) {
public info(String url, String bookname ,String postid , String isbn ,String author) {

this.url = url;
this.bookname = bookname;
this.postid = postid;
this.author= author;
this.isbn= isbn;

}

@@ -45,6 +49,17 @@ public class info {
return url;
}

public String getIsbn() {

return isbn;
}

public String getAuthor(){
return author;
}



public void setBookname(String bookname) {
this.bookname = bookname;

@@ -55,6 +70,16 @@ public class info {
this.url = url;
}

public void setIsbn(String isbn){

this.isbn = isbn;
}

public void setAuthor(String author){

this.author = author;
}




@@ -12,11 +12,11 @@

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/re_view"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="36dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:scrollbars="vertical"
android:padding="16dp"
android:padding="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@@ -1,33 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:name="com.google.android.gms.maps.SupportMapFragment"
app:cardCornerRadius="4dp">
android:layout_margin="5dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
app:cardMaxElevation="10dp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true">


<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical"
android:padding="5dp">
android:orientation="vertical">


<ImageView
android:id="@+id/iview"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:scaleType="centerCrop" />

<TextView
android:id="@+id/bookname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/iview"
android:layout_margin="5dp"
android:text="Name : "
android:textSize="15sp"
android:layout_toRightOf="@+id/iview"></TextView>

<TextView
android:id="@+id/ibookname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/bookname"
android:layout_margin="5dp"
android:textSize="15sp"
android:layout_toRightOf="@+id/iview"></TextView>




<TextView
android:id="@+id/Author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/iview"
android:layout_below="@+id/ibookname"
android:layout_margin="5dp"
android:text="Author : "
android:textSize="15sp"
android:layout_toRightOf="@+id/iview" />

<TextView
android:id="@+id/iAuthor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/Author"
android:layout_below="@+id/ibookname"
android:layout_margin="5dp"
android:textSize="15sp"
android:layout_toRightOf="@+id/iview"></TextView>

<TextView
android:id="@+id/isbn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/iview"
android:layout_margin="10dp"
android:textSize="16sp" />
android:layout_toEndOf="@+id/iview"
android:layout_below="@+id/Author"
android:layout_margin="5dp"
android:text="Isbn : "
android:textSize="15sp"
android:layout_toRightOf="@+id/iview"/>

<TextView
android:id="@+id/iisbn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/isbn"
android:layout_below="@+id/iAuthor"
android:layout_margin="5dp"
android:textSize="15sp"
android:layout_toRightOf="@+id/iview"></TextView>






</RelativeLayout>

0 comments on commit 29af298

Please sign in to comment.