RecyclerView animation for items sliding on sequence - android

I want to animate the recyclerview so the items are added in a sequence (sliding from right to left), I mean, the first item starts sliding then when it's around the middle of the screen, the second item starts sliding and so on.
I tried adding this library (https://github.com/wasabeef/recyclerview-animators) but I'm not sure if I made something wrong or if it doesn't work like this.
Any ideas?
Activity
private ArrayList<OptionListItem> mOptionsList = new ArrayList<>();
private RecyclerView mRecyclerView;
private OptionListAdapter mListAdapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mListAdapter = new OptionListAdapter(mOptionsList);
mRecyclerView = (RecyclerView) findViewById(R.id.options_list);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.setAdapter(mListAdapter);
mRecyclerView.setItemAnimator(new SlideInLeftAnimator());
addOptionsToList();
}
private void addOptionsToList() {
OptionListItem listItem = new OptionListItem(
ScanActivity.class,
"Controle",
"Efetue o bloqueio/desbloqueio",
R.drawable.ic_lock,
R.drawable.colored_bar_bg1
);
mListAdapter.add(listItem);
listItem = new OptionListItem(
ScanActivity.class,
"Opção 2",
"Descrição da opção 2",
R.drawable.ic_car,
R.drawable.colored_bar_bg2
);
mListAdapter.add(listItem);
listItem = new OptionListItem(
ScanActivity.class,
"Opção 3",
"Descrição da opção 3",
R.drawable.ic_lightbulb,
R.drawable.colored_bar_bg4
);
mListAdapter.add(listItem);
}
Adapter
public class OptionListAdapter extends RecyclerView.Adapter<OptionListAdapter.OptionListItemHolder> {
private final ArrayList<OptionListItem> optionList;
public OptionListAdapter(ArrayList<OptionListItem> optionList) {
this.optionList = optionList;
}
#Override
public OptionListItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View item = LayoutInflater.from(parent.getContext())
.inflate(R.layout.options_list_item_layout, parent, false);
return new OptionListItemHolder(item);
}
#Override
public void onBindViewHolder(OptionListItemHolder holder, int position) {
OptionListItem item = optionList.get(position);
holder.cardTitle.setText(item.getTitle());
holder.cardSubtitle.setText(item.getSubtitle());
holder.icon.setImageResource(item.getIcon());
holder.coloredBar.setBackgroundResource(item.getBar());
holder.activity = item.getActivity();
}
public void add(OptionListItem item) {
int position = getItemCount();
this.optionList.add(position, item);
notifyItemInserted(position);
}
#Override
public int getItemCount() {
return optionList.size();
}
public class OptionListItemHolder extends RecyclerView.ViewHolder {
private TextView cardTitle;
private TextView cardSubtitle;
private ImageView icon;
private View coloredBar;
private View optionBackground;
private Class<?> activity;
public OptionListItemHolder(View v) {
super(v);
cardTitle = (TextView)v.findViewById(R.id.card_title);
cardSubtitle = (TextView)v.findViewById(R.id.card_subtitle);
icon = (ImageView)v.findViewById(R.id.icon);
coloredBar = v.findViewById(R.id.colored_bar);
optionBackground = v.findViewById(R.id.option_background_container);
v.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent intent = new Intent(view.getContext(), activity);
view.getContext().startActivity(intent);
}
});
}
}
}

Related

Get selected item position in Recyclerview

I am using Recyclerview. I added a menu with Recyclerview. I want to make a switch case in Recyclerview. So when I click on item 1, when I click on item 2, I click on step 3. When I click on my item .. I want to call a function. Currently I tried to read the position of the items with getAdapterPosition, but the output is always -1. For example, when I click on model, when I click on model2, I want to call a function.
Main2Activity
public class Main2Activity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
RecyclerView navRecyclerView;
LinearLayoutManager layoutManager;
ArrayList<NavigationDataModel> arrayList = new ArrayList<>();
NavigationAdapter adapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
navigationView.setNavigationItemSelectedListener(this);
navRecyclerView = findViewById(R.id.navRecyclerView);
navRecyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
navRecyclerView.setLayoutManager(layoutManager);
DividerItemDecoration divider = new DividerItemDecoration(
navRecyclerView.getContext(),
DividerItemDecoration.VERTICAL
);
divider.setDrawable(ContextCompat.getDrawable(getBaseContext(), R.drawable.diveder_recycler));
navRecyclerView.addItemDecoration(divider);
initArray();
adapter = new NavigationAdapter(this, arrayList);
navRecyclerView.setAdapter(adapter);
private void initArray() {
NavigationDataModel model = new NavigationDataModel();
model.setIcon(R.mipmap.avatar);
model.setTitle("Hesabım");
arrayList.add(model);
NavigationDataModel model2 = new NavigationDataModel();
model2.setIcon(R.mipmap.sss3);
model2.setTitle("S.S.S");
arrayList.add(model2);
}
NavigationAdapter
public class NavigationAdapter extends RecyclerView.Adapter<NavigationAdapter.ViewHolder> {
Context context;
ArrayList<NavigationDataModel> arrayList = new ArrayList<>();
public NavigationAdapter(Context context, ArrayList<NavigationDataModel> arrayList) {
this.context = context;
this.arrayList = arrayList;
}
#NonNull
#Override
public ViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.navigationrecyclerview_adapter11, parent, false);
final ViewHolder holder = new ViewHolder(view);
holder.navTitle.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
int position = holder.getAdapterPosition();
System.out.println("asdasdadasd" + position);
}
});
return new ViewHolder(view);
}
#Override
public void onBindViewHolder(#NonNull ViewHolder holder, int position) {
holder.navIcon.setImageResource(arrayList.get(position).getIcon());
holder.navIconNew.setImageResource(arrayList.get(position).getIcon());
holder.rootView.setBackgroundColor(arrayList.get(position).getColor());
holder.navTitle.setText(arrayList.get(position).getTitle());
}
#Override
public int getItemCount() {
return arrayList.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
ImageView navIcon, navIconNew;
TextView navTitle;
LinearLayout rootView;
public ViewHolder(View itemView) {
super(itemView);
rootView = itemView.findViewById(R.id.rootView);
navIcon = itemView.findViewById(R.id.navIcon);
navIconNew = itemView.findViewById(R.id.navIconNew);
navTitle = itemView.findViewById(R.id.navTitle);
Toast.makeText(context, String.valueOf(getAdapterPosition()), Toast.LENGTH_SHORT).show();
}
}
}
#Override
public void onBindViewHolder(#NonNull ViewHolder holder, int position) {
holder.navIcon.setImageResource(arrayList.get(position).getIcon());
holder.navIconNew.setImageResource(arrayList.get(position).getIcon());
holder.rootView.setBackgroundColor(arrayList.get(position).getColor());
holder.navTitle.setText(arrayList.get(position).getTitle());
holder.navTitle.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// use position herer
}
});
}

I want to set this icon like if the user wants to mark this chapter as it will read tapper this icon, so it will chancher to another icon

I want to set this icon like if the user wants to mark this chapter as it will read tapper this icon, so it will chancher to another icon.
image that described my work
my files:
SeptCoursAdapter.java
public class SeptCoursAdapter extends RecyclerView.Adapter<SeptCoursAdapter.MyViewHolder> {
private Context mContext;
private List<ItemSeptCours> chapList;
public class MyViewHolder extends RecyclerView.ViewHolder {
public TextView chapitreTitle;
public TextView nbHeures;
public ImageView pecLue;
public MyViewHolder(View view) {
super(view);
chapitreTitle = (TextView) view.findViewById(R.id.chapitre_title);
nbHeures = (TextView) view.findViewById(R.id.nb_heure);
pecLue = (ImageView) view.findViewById(R.id.image_lue);
}
}
public SeptCoursAdapter(Context mContext, List<ItemSeptCours> chapList) {
this.mContext = mContext;
this.chapList = chapList;
}
#Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.card_item_7_cours, parent, false);
return new MyViewHolder(itemView);
}
#Override
public void onBindViewHolder(final MyViewHolder holder, int position) {
ItemSeptCours itemSeptCours = chapList.get(position);
holder.chapitreTitle.setText(itemSeptCours.getChapitreTitle());
holder.nbHeures.setText(itemSeptCours.getNbHeures());
Glide.with(mContext).load(itemSeptCours.getPecLue()).into(holder.pecLue);
holder.pecLue.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if(holder.pecLue.getVisibility()== View.VISIBLE)
holder.pecLue.setVisibility(View.INVISIBLE);
}
});
}
#Override
public int getItemCount() {
return chapList.size();
}
}
CoursSeptFragment.java
public class CoursSeptBaseFragment extends Fragment {
#Nullable
private RecyclerView recyclerView;
private RecyclerView.Adapter adapter;
private List<ItemSeptCours> chapList;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.cours_sept_base_fragment, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView_sept);
chapList = new ArrayList<>();
adapter = new SeptCoursAdapter(view.getContext(), chapList);
if (recyclerView != null) {
recyclerView.setHasFixedSize(true);
}
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(view.getContext());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setAdapter(adapter);
prepareChapitre();
return view;
}
private void prepareChapitre() {
int[] luePecTab = new int[]{
R.drawable.ic_visibility_black_18dp_blue,
R.drawable.ic_visibility_off_black_18dp_blue};
ItemSeptCours a = new ItemSeptCours("Chap 1: Ordinateur et systèmes d'exploitation", "4 séances", luePecTab[0]);
chapList.add(a);
a = new ItemSeptCours("Chap 2: Exploitations de logiciels", "4 séances", luePecTab[0]);
chapList.add(a);
a = new ItemSeptCours("Chap 3: L'Internet : Le web", "4 séances", luePecTab[0]);
chapList.add(a);
a = new ItemSeptCours("Un mini projet", "6 séances", luePecTab[0]);
chapList.add(a);
adapter.notifyDataSetChanged();
}
}
I think you are almost there. (assuming pecLue is your little eye image)
Pseudo code:
holder.pecLue.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
//if(holder.pecLue.getVisibility()== View.VISIBLE)
// holder.pecLue.setVisibility(View.INVISIBLE);
if(conditionIfChapterIsMarked){
holder.pecLue.setImageResource(R.drawable.pec_lue_icon_unmarked);
//unmarkChapterLogic()
}else{
holder.pecLue.setImageResource(R.drawable.pec_lue_icon_marked);
//markChapterLogic()
}
}
});

How can I implements OnItemClickListener on ListView

I have one android fragment that have a listView. Now I want implement onItemClickListener and show a Modal, if the user click on one item of ListView. Then, if I click on one items, I should to see a Modal with another listView. So with my code, if I try to click on one items, I can display the items of the last element of my principal listView, and it is not good.
This is my Fragment:
public class AlertsFragment extends Fragment {
private AlertAdapter pAdapter;
AlertXAgentAdapter agentAdapter;
AlertXReactionAdapter reactionAdapter;
private RecyclerView recyclerView,recyclerAgentView,recyclerReactionView;
private List<Alert> lista= new ArrayList<Alert>();
View v;
ExpandableListView expandableListView;
ExpandableListAdapter expandableListAdapter;
private static final int ARG_SECTION_NUMBER =6;
#Override
public void onAttach(Context context) {
super.onAttach(context);
((AndroidNavDrawerActivity) context).onSectionAttached(
ARG_SECTION_NUMBER);
}
public View onCreateView(LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
v=inflater.inflate(R.layout.alerts_activity, container, false);
recyclerView = (RecyclerView) v.findViewById(R.id.recycler_view);
//recupero la lista delle medication
AlertDAO manager = new AlertDAO(this.getContext());
lista = manager.getAlerts();
pAdapter = new AlertAdapter(lista, new AlertAdapter.OnItemClickListener() {
#Override
public void onItemClick(Alert item) {
try{
final Dialog dialog = new Dialog(v.getContext());
LayoutInflater inflater = LayoutInflater.from(v.getContext());
View dialogView = inflater.inflate(R.layout.alert_agent_reaction_modal, null);
//agent
recyclerAgentView = (RecyclerView) dialogView.findViewById(R.id.recycler_agent_view);
//reaction
recyclerReactionView = (RecyclerView) dialogView.findViewById(R.id.recycler_reaction_view);
dialog.setContentView(dialogView);
dialog.setTitle("Agent and Reaction");
//agent
agentAdapter = new AlertXAgentAdapter(item.getListaAgent());
//reaction
reactionAdapter = new AlertXReactionAdapter(item.getListaReaction());
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(v.getContext());
recyclerAgentView.setLayoutManager(mLayoutManager);
recyclerAgentView.setItemAnimator(new DefaultItemAnimator());
recyclerAgentView.setAdapter(agentAdapter);
RecyclerView.LayoutManager mLayoutManager2 = new LinearLayoutManager(v.getContext());
recyclerReactionView.setLayoutManager(mLayoutManager2);
recyclerReactionView.setItemAnimator(new DefaultItemAnimator());
recyclerReactionView.setAdapter(reactionAdapter);
dialog.show();
}catch(Exception e){
Log.e("","");
}
}
});
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(v.getContext());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(pAdapter);
/**
* Inflate the layout for this fragment
*/
return v;
}
}
This is my Adapter
public class AlertAdapter extends RecyclerView.Adapter<AlertAdapter.MyViewHolder> {
private List<Alert> list;
public Alert alert;
public OnItemClickListener listener;
public interface OnItemClickListener {
void onItemClick(Alert item);
}
public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView startDate, endDate,description,status;
public MyViewHolder(View view) {
super(view);
startDate = (TextView) view.findViewById(R.id.startDate);
endDate = (TextView) view.findViewById(R.id.endDate);
description = (TextView) view.findViewById(R.id.description);
status = (TextView) view.findViewById(R.id.status);
view.setOnClickListener(this);
}
#Override
public void onClick(View v) {
if(listener != null){
listener.onItemClick(alert);
}
}
}
public AlertAdapter(List<Alert> list,OnItemClickListener listener) {
this.list = list;
this.listener=listener;
}
#Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.alert_list_row, parent, false);
return new MyViewHolder(itemView);
}
#Override
public void onBindViewHolder(MyViewHolder holder, int position) {
alert = list.get(position);
holder.startDate.setText(alert.getDateStart()!=null ? alert.getDateStart() : "");
holder.endDate.setText(alert.getDateEnd()!=null ? alert.getDateEnd() : "");
holder.description.setText(alert.getAlertInfo().getDisplayName());
//holder.type.setText(planOfCare.getDateEnd()!=null ? planOfCare.getDateEnd() : "");
holder.status.setText(alert.getAlarmAlertInfo().getDisplayName());
}
#Override
public int getItemCount() {
return list.size();
}
}
Your Alert variable is not getting assigned to proper object as you are assigning it in onBindViewHolder method. In your ViewHolder's onclick method try using this instead of passing the Alert variable
listener.onItemClick(list.get(this.getAdapterPosition()));
I think you should do something like this
public class AlertsFragment extends Fragment implements OnClickListener {
personRewardAdapter =new PersonRewardAdapter(PersonRewardSelectionActivity.this, Utilities.R_entities);
rewardList.setAdapter(personRewardAdapter);
rewardList.setOnclickListener(getActivity());
}
public void OnClick(){
}
do this in onCreateView. I am doing this in my code and maybe It helps you, so i am sharing to you

How can add EventListener on my Adapter?

I have an Android Activity that have a RecycleView. I want to add an event listener, so I have build this code:
public class ResultActivity extends AppCompatActivity {
private List<Result> lista;
private RecyclerView recyclerView;
private ResultsAdapter pAdapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.results_activity);
recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
//recupero la lista delle medication
ResultDAO manager = new ResultDAO(this);
lista=manager.getResults();
pAdapter = new ResultsAdapter(lista, new ResultsAdapter.OnItemClickListener() {
#Override
public void onItemClick(Result item) {
try{
//recupero i dati della lista in pagina
final Dialog dialog = new Dialog(ResultActivity.this);
//setting custom layout to dialog
dialog.setContentView(R.layout.result_modal);
dialog.setTitle("Parametri");
}catch(Exception e){
Log.e("","");
}
}
});
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(pAdapter);
}
}
This is my custom adapter:
public class ResultsAdapter extends RecyclerView.Adapter<ResultsAdapter.MyViewHolder> {
private List<Result> list;
private final OnItemClickListener listener;
public interface OnItemClickListener {
void onItemClick(Result item);
}
public class MyViewHolder extends RecyclerView.ViewHolder{
public TextView startDate, endDate,examination;
Result result;
public MyViewHolder(View view) {
super(view);
startDate = (TextView) view.findViewById(R.id.startDate);
endDate = (TextView) view.findViewById(R.id.endDate);
examination = (TextView) view.findViewById(R.id.examination);
}
}
public ResultsAdapter(List<Result> list,OnItemClickListener listener)
{
this.listener=listener;
this.list = list;
}
#Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.results_list_row, parent, false);
return new MyViewHolder(itemView);
}
#Override
public void onBindViewHolder(MyViewHolder holder, int position) {
Result result = list.get(position);
holder.startDate.setText(result.getDateStart()!=null ? result.getDateStart() : "");
holder.endDate.setText(result.getDateEnd()!=null ? result.getDateEnd() : "");
holder.examination.setText(result.getInfo().getDisplayName());
}
#Override
public int getItemCount() {
return list.size();
}
}
Now if I try to start my application and I try to click on one or more item, the method OnClick, does not start.
How can I fixed it?
Read this answer for better understanding
Use below code in Adapter class :-
holher.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
// your code
}
});
Check this blog post.
http://www.littlerobots.nl/blog/Handle-Android-RecyclerView-Clicks/
It allows you to add 'on-click-listeners' in a much simpler, reusable way.
Example:
ItemClickSupport.addTo(recyclerView).setOnItemClickListener(new ItemClickSupport.OnItemClickListener() {
#Override
public void onItemClicked(RecyclerView recyclerView, int position, View v) {
// Do your thing
}
});

Data from backend not showing up in recyclerview

I am trying to get data that I put into a Backendless console and show it in my android application but the data is not showing up. It just shows a blank activity/screen. It's not crashing either. Frankly, I'd be more pleased if it was. Any help would be greatly appreciated!
Heres my code:
private List<Cake> list;
private Context context;
public CakeAdapter(Context context, List<Cake> list) {
this.context = context;
this.list = list;
}
#Override
public CakeHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_cake, parent, false);
return new CakeHolder(view);
}
#Override
public void onBindViewHolder(CakeHolder holder, int position) {
final Cake cake = list.get(position);
holder.type.setText(cake.getType());
holder.description.setText(cake.getDescription());
// holder.type.setText("I dont know.");
// holder.description.setText("Just some random text. I am in the mood for pizza.");
}
#Override
public int getItemCount() {
return list.size();
}
public class CakeHolder extends RecyclerView.ViewHolder {
//Setup Views
CardView card;
TextView type;
TextView description;
public CakeHolder(View itemView) {
super(itemView);
//Assign views by ID
card = (CardView) itemView.findViewById(R.id.cakecard);
type = (TextView) itemView.findViewById(R.id.type);
description = (TextView) itemView.findViewById(R.id.description);
}
}
}
public class CakeActivity extends BaseActivity implements SwipeRefreshLayout.OnRefreshListener, FloatingActionButton.OnClickListener {
//Setup Views
private Toolbar toolbar;
private SwipeRefreshLayout swipe;
private FloatingActionButton fab;
private RecyclerView recycler;
//Setup adapter
private CakeAdapter adapter;
//Setup Cake
private List<Cake> Cake = new ArrayList<>();
//Setup backend call
private BackendlessCollection<Cake> cakes;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_Cake);
//Setup toolbar
toolbar = (Toolbar) findViewById(R.id.bar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
//Setup SwipeView
swipe = (SwipeRefreshLayout) findViewById(R.id.swipe);
swipe.setOnRefreshListener(this);
swipe.setColorSchemeResources(R.color.colorPrimaryDark,
R.color.blade,
android.R.color.holo_orange_light,
R.color.fruit);
//Setup Recyclerview
recycler = (RecyclerView) findViewById(R.id.recycler);
recycler.setItemAnimator(new DefaultItemAnimator());
recycler.setLayoutManager(new LinearLayoutManager(this));
recycler.setHasFixedSize(true);
adapter = new CakeAdapter(this, cake);
recycler.setAdapter(adapter);
//Setup FAB and attach to recycler
fab = (FloatingActionButton) findViewById(R.id.fab);
fab.attachToRecyclerView(recycler);
fab.setOnClickListener(this);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
supportFinishAfterTransition();
return true;
}
return super.onOptionsItemSelected(item);
}
#Override
public void onClick(View v) {
//do something later
}
#Override
public void onRefresh() {
refreshCakes();
if (swipe.isRefreshing()) {
swipe.setRefreshing(false);
}
}
private void refreshCakes() {
QueryOptions query = new QueryOptions();
query.setPageSize(20);
BackendlessDataQuery queries = new BackendlessDataQuery(query);
Backendless.Data.of(Cake.class).find(queries, new AsyncCallback<BackendlessCollection<Cake>>() {
#Override
public void handleResponse(BackendlessCollection<Cake> cakeBackendlessCollection) {
cakes = cakeBackendlessCollection;
addMore(cakeBackendlessCollection);
}
#Override
public void handleFault(BackendlessFault backendlessFault) {
Log.d("Cake", "Error: " + backendlessFault.getMessage());
}
});
}
private void addMore(BackendlessCollection<Cake> next) {
cake.addAll(next.getCurrentPage());
adapter.notifyDataSetChanged();
}
}
Well, I'm gonna duplicate an answer from the support topic: the name of the table on Backendless should match exactly the name of your class.
Or otherwise, you must call Backendless.Data.mapTableToClass("YourTableName", YourClassName.class) somewhere at the start of your program.

Categories

Resources