Что передать в getVerticalData () внизу
Я хочу отобразить БД в getVerticalData.get (0);
Что пройти туда, чтобы отобразить базу данных?
Как отобразить мою базу данных Firebase с этим массивом внизу?
private ArrayList<Object> objects = new ArrayList<();
MainAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_View);
adapter = new MainAdapter(this, getObject());
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(newLinearLayoutManager(this));
}
private ArrayList <Object> getObject() {
objects.add(getVerticalData().get(0));
objects.add(getHorizontalData().get(0));
objects.add(getVerticalData2().get(0));
return objects;
}
Здесь я хотел бы отобразить данные из базы данных FB.
public static ArrayList<SingleVertical> getVerticalData() {
final ArrayList<SingleVertical> singleVerticals = new ArrayList<>();
/* DatabaseReference db = FirebaseDatabase.getInstance().getReference("test");
db.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
SingleVertical post = dataSnapshot.getValue(SingleVertical.class);
singleVerticals.add(post);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
}); */
singleVerticals.add(new SingleVertical("Charlie Chaplin", "Sir Charles Spencer \"Charlie\" Chaplin, KBE was an English comic actor,....", R.mipmap.ic_launcher));
singleVerticals.add(new SingleVertical("Mr.Bean", "Mr. Bean is a British sitcom created by Rowan Atkinson and Richard Curtis, and starring Atkinson as the title character.", R.mipmap.ic_launcher_round));
singleVerticals.add(new SingleVertical("Jim Carrey", "James Eugene \"Jim\" Carrey is a Canadian-American actor, comedian, impressionist, screenwriter...", R.mipmap.ic_launcher));
return singleVerticals;
}
public static ArrayList<SingleVertical> getVerticalData2() {
ArrayList<SingleVertical> singleVerticals = new ArrayList<>();
singleVerticals.add(new SingleVertical("Charlie Chaplin", "Sir Charles Spencer \"Charlie\" Chaplin, KBE was an English comic actor,....", R.mipmap.ic_launcher));
singleVerticals.add(new SingleVertical("Mr.Bean", "Mr. Bean is a British sitcom created by Rowan Atkinson and Richard Curtis, and starring Atkinson as the title character.", R.mipmap.ic_launcher_round));
singleVerticals.add(new SingleVertical("Jim Carrey", "James Eugene \"Jim\" Carrey is a Canadian-American actor, comedian, impressionist, screenwriter...", R.mipmap.ic_launcher));
return singleVerticals;
}
public static ArrayList<SingleHorizontal> getHorizontalData() {
ArrayList<SingleHorizontal> singleHorizontals = new ArrayList<>();
singleHorizontals.add(new SingleHorizontal(R.mipmap.ic_launcher, "Charlie Chaplin", "Sir Charles Spencer \"Charlie\" Chaplin, KBE was an English comic actor,....", "2010/2/1"));
singleHorizontals.add(new SingleHorizontal(R.mipmap.ic_launcher_round, "Mr.Bean", "Mr. Bean is a British sitcom created by Rowan Atkinson and Richard Curtis, and starring Atkinson as the title character.", "2010/2/1"));
singleHorizontals.add(new SingleHorizontal(_launcher, "Jim Carrey", "James Eugene \"Jim\" Carrey is a Canadian-American actor, comedian, impressionist, screenwriter...", "2010/2/1"));
return singleHorizontals;
}
Я не могу понять, какой параметр я должен передать getVertical();