HelloIhaveadatabaseonfirebasethathassomemoviesandseriesandeventvshows,Iwantedtoseparatetheseattributesintogenres,forexample:whateverseriesisfixedinseriesandwhatevermovieisfixedinMoviesetc...butthisIwantedtoputincardsusingrecyclerviewtolistandinthatrecyclerviewaseparationofeachgenreusinghorizontally.Iwantedalight,couldanyonehelpme?
publicclassSalaActivityextendsAppCompatActivityimplementsICRUDAction{privateMyAdapterappListCenterAdapter,appListStartAdapter;privateList<ConteudoSala>conteudoSala,conteudoSala1;privateStringname;privateStringa;privateProgressDialogprogressDialog;
//privateRecyclerViewmRecyclerView;
privatebooleanmHorizontal;publicRecyclerViewrecyclerView;publicRecyclerViewrecyclerView2;DatabaseReferencemDatabase=FirebaseDatabase.getInstance().getReference(DATABASE_PATH_ANIME);@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.sala_lista);ButterKnife.bind(this);progressDialog=newProgressDialog(this);progressDialog.setMessage("Por favor, espere...");
progressDialog.show();
getAnime();
getFilmes();
request_user_name();
}
public void getAnime(){
conteudoSala = new ArrayList<>();
recyclerView = (RecyclerView)findViewById(R.id.recyclerView);
mDatabase.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
Log.i("onDataChange", snapshot.toString());
for (DataSnapshot postSnapshot : snapshot.getChildren()) {
ConteudoSala produto = postSnapshot.getValue(ConteudoSala.class);
conteudoSala.add(produto);
}
LinearLayoutManager layoutManagerCenter
= new LinearLayoutManager(SalaActivity.this, LinearLayoutManager.HORIZONTAL, false);
recyclerView.setLayoutManager(layoutManagerCenter);
SnapHelper snapHelperCenter = new LinearSnapHelper();
snapHelperCenter.attachToRecyclerView(recyclerView);
appListCenterAdapter = new MyAdapter(SalaActivity.this, conteudoSala);
recyclerView.setAdapter(appListCenterAdapter);
appListCenterAdapter.notifyDataSetChanged();
}
@Override
public void onCancelled(DatabaseError databaseError) {
progressDialog.dismiss();
}
});
}
public void getFilmes() {
conteudoSala1 = new ArrayList<>();
recyclerView2 = (RecyclerView)findViewById(R.id.recyclerView2);
DatabaseReference mDatabase2 = FirebaseDatabase.getInstance().getReference(DATABASE_PATH_FILME);
mDatabase2.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
progressDialog.dismiss();
Log.i("onDataChange", snapshot.toString());
for (DataSnapshot postSnapshot : snapshot.getChildren()) {
ConteudoSala produto1 = postSnapshot.getValue(ConteudoSala.class);
conteudoSala1.add(produto1);
}
appListStartAdapter = new MyAdapter(SalaActivity.this, conteudoSala1);
LinearLayoutManager layoutManagerStart = new LinearLayoutManager(SalaActivity.this, LinearLayoutManager.HORIZONTAL, false);
recyclerView2.setLayoutManager(layoutManagerStart);
SnapHelper snapHelperStart = new StartSnapHelper();
snapHelperStart.attachToRecyclerView(recyclerView2);
recyclerView2.setAdapter(appListStartAdapter);
appListStartAdapter.notifyDataSetChanged();
}
@Override
public void onCancelled(DatabaseError databaseError) {
progressDialog.dismiss();
}
});
progressDialog.hide();
}