I am developing an app that shows in a RecyclerView an image and a text that comes from firebase.
When I open the application the recyclerview does not appear but if I turn off and then turn on the screen the recyclerview appears correctly with the image and text obtained from firebase. I need help please
ViewHolder:
public class ViewHolderServicio extends RecyclerView.ViewHolder {
View mView;
public ViewHolderServicio(#NonNull View itemView) {
super(itemView);
mView = itemView;
}
public void setDetails(Context ctx, String nombreServicio, String imagenPerfil) {
TextView mNombreServicio = mView.findViewById(R.id.NombreServicio);
ImageView mImagenPerfil = mView.findViewById(R.id.imageViewServicio);
mNombreServicio.setText(nombreServicio);
Picasso.get().load(imagenPerfil).into(mImagenPerfil);
}
}
Model:
public class ModelServicio {
String idUsuario, nombreServicio, descripcion, imagenPerfil;
public ModelServicio(){}
public String getIdUsuario() {
return idUsuario;
}
public void setIdUsuario(String idUsuario) {
this.idUsuario = idUsuario;
}
public String getNombreServicio() {
return nombreServicio;
}
public void setNombreServicio(String nombreServicio) {
this.nombreServicio = nombreServicio;
}
public String getDescripcion() {
return descripcion;
}
public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}
public String getImagenPerfil() {
return imagenPerfil;
}
public void setImagenPerfil(String imagenPerfil) {
this.imagenPerfil = imagenPerfil;
}
}
class activity:
public class DetalleServicio extends AppCompatActivity {
RecyclerView RVbot;
FirebaseDatabase mFirebaseDatabase;
DatabaseReference mRef;
FirebaseRecyclerAdapter<ModelServicio, ViewHolderServicio> firebaseRecyclerAdapter;
FirebaseRecyclerOptions<ModelServicio> options;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detalle_servicio);
RVbot = findViewById(R.id.RVBot);
RVbot.setHasFixedSize(true);
RVbot.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
mFirebaseDatabase = FirebaseDatabase.getInstance();
mRef = mFirebaseDatabase.getReference("Servicios");
mostrarDatos();
}
private void mostrarDatos() {
options = new FirebaseRecyclerOptions.Builder<ModelServicio>().setQuery(mRef, ModelServicio.class).build();
firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<ModelServicio, ViewHolderServicio>(options) {
#Override
protected void onBindViewHolder(#NonNull ViewHolderServicio holder, int position, #NonNull ModelServicio model) {
holder.setDetails(getApplicationContext(), model.getNombreServicio(), model.getImagenPerfil());
}
#NonNull
#Override
public ViewHolderServicio onCreateViewHolder(#NonNull ViewGroup viewGroup, int i) {
View itemView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.servicioitem, viewGroup, false);
ViewHolderServicio viewHolder = new ViewHolderServicio(itemView);
return viewHolder;
}
};
RVbot.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
}
#Override
protected void onStart() {
super.onStart();
firebaseRecyclerAdapter.startListening();
RVbot.setAdapter(firebaseRecyclerAdapter);
}
}
Have you tried
firebaseRecyclerAdapter.notifyDataSetChanged();
after calling an Adapter?
Related
I made an app that fetches and stores data from the Android application to the Firebase, and I made activity that includes RecyclerView in which the data is displayed, but the problem is that when I click on any record in RecyclerView, I want to open another screen that contains the same data that was pressed, and I Try the code mentioned below, but when you press on RecyclerView, the application stops (and I think the problem is in the process of transferring data when I click on the record)
Please help me to solve the problem
The class code
public class EMP_INFO implements Serializable {
private String Id;
private String Name;
private String City;
public EMP_INFO() {
}
public String getEmployeeID() {
return Id;
}
public void setEmployeeID(String ID) {
this.Id = ID;
}
public String getEmployeeName() {
return Name;
}
public void setEmployeeName(String Name) {
this.Name = Name;
}
public String getEmployeeCity() {
return City;
}
public void setEmployeeCity(String City) {
this.City = City;
}
}
The adapter code
public class EMP_INFO_Adapter extends FirebaseRecyclerAdapter<EMP_INFO, EMP_INFO_Adapter.personsViewholder> {
public EMP_INFO_Adapter(#NonNull FirebaseRecyclerOptions<EMP_INFO> options)
{
super(options);
}
#Override
protected void
onBindViewHolder(#NonNull personsViewholder holder, int position, #NonNull EMP_INFO model)
{
holder.F_ID.setText(model.getEmployeeID());
holder.F_name.setText(model.getEmployeeName());
holder.F_city.setText(model.getEmployeeCity());
Intent intent = new Intent(context, FireBase_Save_data_1.class);
intent.putExtra("FB_id1", String.valueOf(model.getEmployeeID()));
intent.putExtra("FB_name1", String.valueOf(model.getEmployeeName()));
intent.putExtra("FB_city1", String.valueOf(model.getEmployeeCity()));
activity.startActivityForResult(intent, 1);
}
#NonNull
#Override
public personsViewholder
onCreateViewHolder(#NonNull ViewGroup parent, int viewType)
{
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.fire_base_my_row, parent, false);
return new EMP_INFO_Adapter.personsViewholder(view);
}
class personsViewholder extends RecyclerView.ViewHolder { TextView F_ID, F_name, F_city;
public personsViewholder(#NonNull View itemView)
{
super(itemView);
F_ID = itemView.findViewById(R.id.F_ID);
F_name = itemView.findViewById(R.id.F_name);
F_city = itemView.findViewById(R.id.F_city);
}
}
}
The RecyclerView activity code
public class FireBase_Recyclerview_2 extends AppCompatActivity {
private RecyclerView recyclerView;
Button add_button;
EMP_INFO_Adapter adapter;
//EMP_INFO_Adapter_3 adapter;
DatabaseReference mbase;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fire_base_recyclerview_2);
add_button = findViewById(R.id.add_button);
recyclerView = findViewById(R.id.recycler1);
// To display the Recycler view linearly
recyclerView.setLayoutManager(new LinearLayoutManager(this));
mbase = FirebaseDatabase.getInstance().getReference("EmployeeInfo") ;
FirebaseRecyclerOptions<EMP_INFO> options = new FirebaseRecyclerOptions.Builder<EMP_INFO>()
.setQuery(mbase, EMP_INFO.class).build();
adapter = new EMP_INFO_Adapter(options);
//adapter = new EMP_INFO_Adapter_3(options);
recyclerView.setAdapter(adapter);
add_button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent intent = new Intent(FireBase_Recyclerview_2.this, FireBase_Save_data_1.class);
startActivity(intent);
}
});
}
#Override protected void onStart()
{
super.onStart();
adapter.startListening();
}
#Override protected void onStop()
{
super.onStop();
adapter.stopListening();
}
}
You may put a click Listener on the item inside your adapter's onBindViewHolder,as shown below.
holder.itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Context context = v.getContext();
Intent intent = new Intent(context, FireBase_Save_data_1.class);
intent.putExtra("empId", model.getEmployeeID());
intent.putExtra("empName", model.getEmployeeName());
intent.putExtra("empCity", model.getEmployeeCity());
context.startActivity(intent);
}
});
You can't start activity within onBinViewHolder.move that code to viewholder class.
public class EMP_INFO_Adapter extends FirebaseRecyclerAdapter<EMP_INFO, EMP_INFO_Adapter.personsViewholder> {
public EMP_INFO_Adapter(#NonNull FirebaseRecyclerOptions<EMP_INFO> options)
{
super(options);
}
#Override
protected void
onBindViewHolder(#NonNull personsViewholder holder, int position, #NonNull EMP_INFO model)
{
holder.F_ID.setText(model.getEmployeeID());
holder.F_name.setText(model.getEmployeeName());
holder.F_city.setText(model.getEmployeeCity());
}
#NonNull
#Override
public personsViewholder
onCreateViewHolder(#NonNull ViewGroup parent, int viewType)
{
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.fire_base_my_row, parent, false);
return new EMP_INFO_Adapter.personsViewholder(view);
}
class personsViewholder extends RecyclerView.ViewHolder implements View.OnClickListener
TextView F_ID, F_name, F_city;
public personsViewholder(#NonNull View itemView)
{
super(itemView);
F_ID = itemView.findViewById(R.id.F_ID);
F_name = itemView.findViewById(R.id.F_name);
F_city = itemView.findViewById(R.id.F_city);
itemView.setOnClickListener(this);
}
#Override
public void onClick(View view) {
int id=getAdapterPosition();
Intent intent = new Intent(context, FireBase_Save_data_1.class);
intent.putExtra("FB_id1", String.valueOf(model.get(id).getEmployeeID()));
intent.putExtra("FB_name1", String.valueOf(model.get(id).getEmployeeName()));
intent.putExtra("FB_city1", String.valueOf(model.get(id).getEmployeeCity()));
activity.startActivityForResult(intent, 1);
}
}
}
}
}
the firebase data doesn't appear in the recycler view
i have some realtimeDb in Google firebase
i try to read it in the recyclerView but nothing appears ,
logcat shows null and here is my code:
1-Here is HomeFragment(Main) Code
public class HomeFragment extends Fragment {
private HomeViewModel homeViewModel;
Unbinder unbinder;
#BindView(R.id.recycler_popular)
RecyclerView recyclerView;
public View onCreateView(#NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
homeViewModel =
ViewModelProviders.of(this).get(HomeViewModel.class);
View root = inflater.inflate(R.layout.fragment_home, container, false);
unbinder= ButterKnife.bind(this,root);
init();
homeViewModel.getPopularList().observe(this, new Observer<List<PopularCategoryModel>>() {
#Override
public void onChanged(List<PopularCategoryModel> PopularCategoryModel) {
//create adapter
MyPopularCategoriesAdapter adapter = new MyPopularCategoriesAdapter(HomeFragment.this.getContext(), PopularCategoryModel);
recyclerView.setAdapter(adapter);
}
});
return root;
}
private void init() {
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
}
}
2-Here is HomeViewModel Code
public class HomeViewModel extends ViewModel implements IPopularCallbackListener {
private static final String TAG = "HomeViewModel";
private MutableLiveData<List<PopularCategoryModel>> popularList;
private MutableLiveData<String> messageError;
private IPopularCallbackListener popularCallbackListener;
public HomeViewModel() {
}
public MutableLiveData<List<PopularCategoryModel>> getPopularList() {
if (popularList== null){
popularList=new MutableLiveData<>();
messageError=new MutableLiveData<>();
loadPopularList();
}
return popularList;
}
private void loadPopularList() {
final List<PopularCategoryModel> tempList = new ArrayList<>();
DatabaseReference popularRef= FirebaseDatabase.getInstance().getReference(Common.POPULAR_CATEGORY_REF);
popularRef.addListenerForSingleValueEvent(new ValueEventListener() {
#Override
public void onDataChange(#NonNull DataSnapshot dataSnapshot) {
tempList.clear();
for (DataSnapshot itemSnapShot:dataSnapshot.getChildren()){
PopularCategoryModel model=itemSnapShot.getValue(PopularCategoryModel.class);
tempList.add(model);
Log.d(TAG, "onDataChange:Adel2020"+tempList.size()+popularRef);
}
//popularCallbackListener.onPopularLoadSuccess(tempList);
Log.e(TAG, "Data received:" + tempList.size());
}
#Override
public void onCancelled(#NonNull DatabaseError databaseError) {
popularCallbackListener.onPopularLoadFailed(databaseError.getMessage());
}
});
}
public MutableLiveData<String> getMessageError() {
return messageError;
}
#Override
public void onPopularLoadSuccess(List<PopularCategoryModel> popularCategoryModels) {
popularList.setValue(popularCategoryModels);
}
#Override
public void onPopularLoadFailed(String message) {
messageError.setValue(message);
}
}
3- This is the Adapter
public class MyPopularCategoriesAdapter extends RecyclerView.Adapter<MyPopularCategoriesAdapter.PopViewHolder> {
private List<PopularCategoryModel> listPopularCategoryModel ;
Context context;
public MyPopularCategoriesAdapter( Context context,List<PopularCategoryModel> listPopularCategoryModel) {
this.listPopularCategoryModel = listPopularCategoryModel;
this.context = context;
}
#NonNull
#Override
public PopViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
return new PopViewHolder(LayoutInflater.from(parent.getContext()).inflate
(R.layout.layout_popular_categories_item, parent, false));
}
#Override
public void onBindViewHolder(#NonNull PopViewHolder holder, int position) {
Glide.with(context).load(listPopularCategoryModel.get(position).getImage()).into(holder.popCategoryImage);
holder.popCategoryName.setText(listPopularCategoryModel.get(position).getName());
}
#Override
public int getItemCount() {
return listPopularCategoryModel.size();
}
public class PopViewHolder extends RecyclerView.ViewHolder {
Unbinder unbinder;
#BindView(R.id.pop_category_name)
TextView popCategoryName;
#BindView(R.id.pop_category_image)
CircleImageView popCategoryImage;
public PopViewHolder(#NonNull View itemView) {
super(itemView);
unbinder= ButterKnife.bind(this,itemView);
}
}
}
4-This is Model
public class PopularCategoryModel {
private String menu_id,food_id,name,image;
public PopularCategoryModel() {
}
public PopularCategoryModel(String menu_id, String food_id, String name, String image) {
this.menu_id = menu_id;
this.food_id = food_id;
this.name = name;
this.image = image;
}
public PopularCategoryModel(String name, String image) {
this.name = name;
this.image = image;
}
+SetterGetter
5-Here is the Data
I'm developing an android app for online order. User needs to click on an food item in recyclerView and I'm trying to send the food ID to the AddOrderActivity. How can I get the FId and pass it to the new activity?
CustomerHomeFragment.java
public class CustomerHomeFragment extends Fragment {
private RecyclerView recyclerView;
private FoodsAdapter adapter;
private List<Food> foodList;
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_home_customer, container, false);
}
#Override
public void onViewCreated(#NonNull View view, #Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
recyclerView = view.findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
Call<FoodsResponse> call = RetrofitClient.getInstance().getApi().getFoods();
call.enqueue(new Callback<FoodsResponse>() {
#Override
public void onResponse(Call<FoodsResponse> call, Response<FoodsResponse> response) {
foodList = response.body().getFoods();
adapter = new FoodsAdapter(getActivity(), foodList);
recyclerView.setAdapter(adapter);
}
#Override
public void onFailure(Call<FoodsResponse> call, Throwable t) {
}
});
}
}
public class FoodsAdapter extends RecyclerView.Adapter implements View.OnClickListener{
private Context mCtx;
private List<Food> foodList;
public FoodsAdapter(Context mCtx, List<Food> foodList) {
this.mCtx = mCtx;
this.foodList = foodList;
}
#NonNull
#Override
public FoodsViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mCtx).inflate(R.layout.recyclerview_foods, parent, false);
return new FoodsViewHolder(view);
}
#Override
public void onBindViewHolder(#NonNull FoodsViewHolder holder, int position) {
Food food = foodList.get(position);
holder.textViewFName.setText(food.getFName());
holder.textViewUnitPrice.setText(String.format("%d", food.getUnitPrice()));
holder.textViewAvailCount.setText(String.format("%d", food.getAvailCount()));
}
#Override
public int getItemCount() {
return foodList.size();
}
//////////////
#Override
public void onClick(View view) {
Intent intent = new Intent(this.mCtx, AddOrderActivity.class);
this.mCtx.startActivity(intent);
}
/////////////////
class FoodsViewHolder extends RecyclerView.ViewHolder {
TextView textViewFName, textViewUnitPrice, textViewAvailCount;
public FoodsViewHolder(View itemView) {
super(itemView);
textViewFName = itemView.findViewById(R.id.textViewFName);
textViewUnitPrice = itemView.findViewById(R.id.textViewUnitPrice);
textViewAvailCount = itemView.findViewById(R.id.textViewAvailCount);
}
}
}
public class Food {
private int fid, unitprice, availcount;
private String fname;
public Food(int fid, String fname, int unitprice, int availcount) {
this.fid = fid;
this.fname = fname;
this.unitprice = unitprice;
this.availcount = availcount;
}
public int getFId() {
return fid;
}
public String getFName() {
return fname;
}
public int getUnitPrice() {
return unitprice;
}
public int getAvailCount() {
return availcount;
}
}
in the your adapter class inside the onBindViewHolder function add this code
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent=new Intent(context,NoteActivity.class);
intent.putExtra("note_id", currentNote.getNoteId());
intent.putExtra("note_name",currentNote.getNoteName());
intent.putExtra("note_teacher",currentNote.getNoteTeacher());
intent.putExtra("note_university",currentNote.getNoteUniversity());
intent.putExtra("note_image",currentNote.getNoteImage());
intent.putExtra("note_is_downloaded", currentNote.getIsDownloaded());
intent.putExtra("note_storage_path", currentNote.getStoragePath());
intent.putExtra("note_download_link", currentNote.getNoteDownloadLink());
context.startActivity(intent);
}
});
I am getting error
"com.google.firebase.database.DatabaseException:
Can't convert object of type java.lang.String to type
krunoslavkovac.ferit.test.Add"
And can't figure it out why is it happening.
I've searched many solutions here but still didn't figure it out.
MAIN ACTIVITY :
public class MainActivity extends AppCompatActivity {
EditText et_task ;
Button btn_add;
RecyclerView recycler_view;
//Firebase
FirebaseDatabase database;
DatabaseReference dbRef ;
FirebaseRecyclerOptions<Add> options;
FirebaseRecyclerAdapter<Add, MyRecyclerViewHolder> adapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et_task = (EditText) findViewById(R.id.et_task);
btn_add = (Button) findViewById(R.id.btn_add);
recycler_view = (RecyclerView) findViewById(R.id.recycler_view);
recycler_view.setLayoutManager(new LinearLayoutManager(this));
database = FirebaseDatabase.getInstance();
dbRef = database.getReference("Test");
btn_add.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
addTask();
}
});
displayTask();
}
private void addTask(){
String task = et_task.getText().toString();
Add add = new Add(task);
dbRef.push().setValue(task);
adapter.notifyDataSetChanged();
}
private void displayTask() {
options =
new FirebaseRecyclerOptions.Builder<Add>()
.setQuery(dbRef,Add.class)
.build();
adapter =
new FirebaseRecyclerAdapter<Add, MyRecyclerViewHolder>(options) {
#Override
protected void onBindViewHolder(#NonNull MyRecyclerViewHolder holder, int position, #NonNull Add model) {
holder.tv_task.setText(model.getTask());
}
#NonNull
#Override
public MyRecyclerViewHolder onCreateViewHolder(#NonNull ViewGroup viewGroup, int i) {
View itemView = LayoutInflater.from(getBaseContext()).inflate(R.layout.add_item,viewGroup, false);
return new MyRecyclerViewHolder(itemView);
}
};
adapter.startListening();
recycler_view.setAdapter(adapter);
}
}
Add class
public class Add {
private String task;
public Add(){
}
public Add(String task) {
this.task = task;
}
public String getTask() {
return task;
}
public void setTask(String task) {
this.task = task;
}
}
RecyclervViewHolder
public class MyRecyclerViewHolder extends RecyclerView.ViewHolder {
TextView tv_task;
public MyRecyclerViewHolder(#NonNull View itemView) {
super(itemView);
tv_task = (TextView) itemView.findViewById(R.id.tv_task);
}
}
Database:
I want to display data from firebase.
Replace this
dbRef.push().setValue(task);
To
dbRef.push().setValue(add);
I am currently working on a chat app. In chat activity, I wanted to show profile picture only on the first item and when I used Runnable (onItemChanged) it slowed down my recycler view very much and now it looks like I added motion blur to my recycler view and it is very very lazy.
Here is a gif of my chat activity:
https://i.gyazo.com/f0489ca7fe9ad28519061c0ff8963fb4.gif
Im not actually sure that it is Runnable that slows down my recycler view but when I remove :
if (i > 0)
if (mMessageList.get(i - 0).getFrom().equals(mMessageList.get(i).getFrom())) {
makeDPInvisible(i - 0);
}
if (invisibleIds.contains(i)) {
viewHolder.displayName.setVisibility(View.GONE);
viewHolder.profileImage.setVisibility(View.INVISIBLE);
}
and
private void makeDPInvisible(final int i) {
invisibleIds.add(i);
recyclerView.post(new Runnable(){
#Override
public void run() {
notifyItemRangeChanged(i);
}
});
}
my recycler is very smooth and without any problems...
Here is my MessaageAdapter.java
/**
* Created by Aryojj on 24/07/17.
*/
public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MessageViewHolder>{
private FirebaseAuth mAuth;
private ArrayList<Integer> invisibleIds = new ArrayList<>();
private RecyclerView recyclerView;
private List<Messages> mMessageList;
private DatabaseReference mUserDatabase;
public MessageAdapter(List<Messages> mMessageList) {
this.mMessageList = mMessageList;
}
#Override
public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.message_single_layout ,parent, false);
mAuth = FirebaseAuth.getInstance();
return new MessageViewHolder(v);
}
#Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
this.recyclerView = recyclerView;
}
public class MessageViewHolder extends RecyclerView.ViewHolder {
public TextView messageText;
public CircleImageView profileImage;
public TextView displayName;
public ImageView messageImage;
public MessageViewHolder(View view) {
super(view);
messageText = (TextView) view.findViewById(R.id.message_text_layout);
profileImage = (CircleImageView) view.findViewById(R.id.message_profile_layout);
displayName = (TextView) view.findViewById(R.id.name_text_layout);
messageImage = (ImageView) view.findViewById(R.id.message_image_layout);
}
}
#Override
public void onBindViewHolder(final MessageViewHolder viewHolder, int i) {
String message_sender_id = mAuth.getCurrentUser().getUid();
Messages c = mMessageList.get(i);
String from_user = c.getFrom();
String message_type = c.getType();
if (i > 0)
if (mMessageList.get(i - 0).getFrom().equals(mMessageList.get(i).getFrom())) {
makeDPInvisible(i - 0);
}
if (invisibleIds.contains(i)) {
viewHolder.displayName.setVisibility(View.GONE);
viewHolder.profileImage.setVisibility(View.INVISIBLE);
}
mUserDatabase = FirebaseDatabase.getInstance().getReference().child("Users").child(from_user);
mUserDatabase.addValueEventListener(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
String name = dataSnapshot.child("name").getValue().toString();
String image = dataSnapshot.child("thumb_image").getValue().toString();
viewHolder.displayName.setText(name);
Picasso.with(viewHolder.profileImage.getContext()).load(image)
.placeholder(R.drawable.default_avatar).into(viewHolder.profileImage);
}
#Override
public void onCancelled(DatabaseError databaseError) {
}
});
if (message_type.equals("text")) {
viewHolder.messageText.setText(c.getMessage());
viewHolder.messageImage.setVisibility(View.INVISIBLE);
} else {
viewHolder.messageText.setVisibility(View.INVISIBLE);
Picasso.with(viewHolder.profileImage.getContext()).load(c.getMessage())
.networkPolicy(NetworkPolicy.OFFLINE).placeholder(R.drawable.default_avatar).into(viewHolder.messageImage);
}
}
private void makeDPInvisible(final int i) {
invisibleIds.add(i);
recyclerView.post(new Runnable(){
#Override
public void run() {
notifyItemRangeChanged(i);
}
});
}
#Override
public int getItemCount() {
return mMessageList.size();
}
}