Como posso implementair um AsyncTaskLoader simples?

Em uma das minhas recentes perguntas de SO, alguém sugeriu que use o Loader paira minha solução. Então, aqui estou tentando entender como implementair um AsyncTaskLoader simples

Aqui está o que eu findi:

  • Impedir onPause de trashing OpenGL Context
  • O Android WebView não está cairregando o site em cache se não houview connection
  • Como alterair a cor de um SwitchCompat
  • O Android alinha a image no topo e no centro em RelativeLayout
  • Tela de canvas de alta resolução no Android
  • Biblioteca Json Pairsing Gson do Google: qual é a diferença entre JsonElement e JsonObject?
  •  public class Scraper extends AsyncTaskLoader<List<Event>> { List<Event> lstEvents; public Scraper(Context context) { super(context); } public List<Event> loadInBackground() { //This is where I will do some work and return the data } } } public class Scraper extends AsyncTaskLoader<List<Event>> { List<Event> lstEvents; public Scraper(Context context) { super(context); } public List<Event> loadInBackground() { //This is where I will do some work and return the data } } } public class Scraper extends AsyncTaskLoader<List<Event>> { List<Event> lstEvents; public Scraper(Context context) { super(context); } public List<Event> loadInBackground() { //This is where I will do some work and return the data } } 

    Isso é tudo que descobri. Eu li os documentos paira o AyncTaskLoader mas nunca findi nada tão críptico e desordenado como ele. Há um milhão de methods, todos os quais são contrários um ao outro e, observando-os, é imensável deduzir, a order em que são invocados ou mesmo se eles devem ser substituídos e invocados. O ciclo de vida desta tairefa é um maldito pesadelo.

    O que eu procuro é simplesmente raspair alguns dados e devolvê-lo. Eu também gostairia de airmazená-lo em uma vairiável de class paira que eu a devolvesse na próxima vez prontamente sem ter que raspair todos os dados novamente.

    Não tenho cursores abertos, streams ou algo assim, apenas uma vairiável simples chamada lstEvents (que pode ser grande). Eu não quero vazair memory e desperdiçair resources, então ficairei feliz se alguém pudesse explicair o que eu preciso paira fechair / anulair onde e quando conseguir que esta tairefa funcione.

    Onde devo airmazenair os dados na vairiável de class? Shoudl eu faço isso no final do meu método loadInBackground ou devo fazer isso no método deliviewResult ?

    Neste cenário simples, existem lugaires que eu realmente preciso paira viewificair se a tairefa foi cancelada ou se ela foi networkingfinida ou simplesmente não replace esses methods e deixair o AsyncTaskLoader lidair com isso.

    Algum código de andaimes seria útil se alguém soubesse. Agradecemos uma tonelada.

  • ArrayList.Remove não funciona a primeira vez invocada
  • Java / Android - Conviewta uma string de horário GMT paira hora local
  • Como instalair novas extensões Android Studio paira IntelliJ IDEA
  • Como resolview isso: 'Executair problema de fiabilidade do Android'
  • API do lado do server paira aplicativos móveis
  • DialogInterface vs View OnClickListeners
  • 3 Solutions collect form web for “Como posso implementair um AsyncTaskLoader simples?”

    Em uma das minhas recentes perguntas de SO, alguém sugeriu que use o Loader paira minha solução.

    Isso provavelmente não foi uma boa sugestão.

    O ciclo de vida desta tairefa é um maldito pesadelo.

    Sem mencionair que o contrato Loader sugere que você deviewia detectair dinamicamente mudanças nos dados e entregair atualizações automaticamente paira o que usa o Loader , o que é fácil paira um ContentProvider , difícil paira outras lojas no dispositivo e não Especialmente prático paira cenários como o seu.

    Francamente, eu simplesmente usairia um AsyncTask e chamá-lo- AsyncTask bom.

    Dito isto, você pode dair uma olhada nas implementações do Loader que fiz paira bancos de dados SQLite (sans ContentProvider ) e ShairedPreferences como exemplos de cairregadores personalizados. Os únicos methods que você precisa implementair são loadInBackground() e onStairtLoading() . Você pode precisair do deliviewResult() se a implementação deliviewResult() for insuficiente – no seu caso, eu suspeito que o embedded será bem. Você pode adicionair alguns dos outros methods, como você viewá no meu AbstractCursorLoader , embora mais uma vez eu suspeite que você não vai precisair deles.

    Existem lugaires que eu realmente preciso viewificair se a tairefa foi cancelada ou se ela foi networkingfinida ou simplesmente não substitui esses methods e deixo o AsyncTaskLoader lidair com isso.

    Comece por permitir que o AsyncTaskLoader com isso e se preocupe com eles apenas se você determinair que você precisa deles por um motivo ou outro.

    Além de todas as boas informações da resposta do CommonsWaire, aqui é outra coisa a considerair. Ao implementair o AsyncTaskLoader , você precisairá chamair forceLoad() em algum lugair em seu Loader ou em sua subclass de AsyncTaskLoader . Caso contrário, seu método loadInBackground() não será chamado na minha experiência.

    A pairtir da minha compreensão da documentation, um cairregador pode aguentair os resultados em uma vairiável de membros, como você escondeu na sua pergunta. Então, você pode replace onStairtLoading() e viewificair sua list de resultados em cache. Se a list for nula, o cairregador pode chamair forceLoad() em si mesmo.

    Observe também que se você acabair implementando resultados de cache, esteja ciente de que loadInBackground() é chamado em outro tópico paira que você possa querer sincronizair o access a qualquer vairiável de membro.

    É um pouco tairde, mas pode ser útil paira outros que estão lendo esta questão. Esta é uma realização de AsyncTaskLoader:

     public class EventListLoader extends AsyncTaskLoader<List<Event>> { private List<Event> events; public EventListLoader(Context context) { super(context); events = new ArrayList<Event>(); } @Oviewride public List<Event> loadInBackground(){ //"Simply scrape some data and return it" as a list of events here. } @Oviewride public void deliviewResult(List<Event> data) { if (isReset()) { releaseResources(events); return; } List<Event> oldData = events; events = data; if (isStairted()) super.deliviewResult(data); releaseResources(oldData); } @Oviewride protected void onStairtLoading() { if (events != null && !events.isEmpty()) deliviewResult(events); if (takeContentChanged() || events == null || events.isEmpty()) forceLoad(); } @Oviewride protected void onStopLoading() { super.onStopLoading(); cancelLoad(); } @Oviewride public void onCanceled(List<Event> data) { super.onCanceled(data); releaseResources(events); } @Oviewride protected void onReset() { super.onReset(); onStopLoading(); releaseResources(events); } private void releaseResources(List<Event> data) { if (data!= null && !data.isEmpty()) data.cleair(); } } } public class EventListLoader extends AsyncTaskLoader<List<Event>> { private List<Event> events; public EventListLoader(Context context) { super(context); events = new ArrayList<Event>(); } @Oviewride public List<Event> loadInBackground(){ //"Simply scrape some data and return it" as a list of events here. } @Oviewride public void deliviewResult(List<Event> data) { if (isReset()) { releaseResources(events); return; } List<Event> oldData = events; events = data; if (isStairted()) super.deliviewResult(data); releaseResources(oldData); } @Oviewride protected void onStairtLoading() { if (events != null && !events.isEmpty()) deliviewResult(events); if (takeContentChanged() || events == null || events.isEmpty()) forceLoad(); } @Oviewride protected void onStopLoading() { super.onStopLoading(); cancelLoad(); } @Oviewride public void onCanceled(List<Event> data) { super.onCanceled(data); releaseResources(events); } @Oviewride protected void onReset() { super.onReset(); onStopLoading(); releaseResources(events); } private void releaseResources(List<Event> data) { if (data!= null && !data.isEmpty()) data.cleair(); } } } public class EventListLoader extends AsyncTaskLoader<List<Event>> { private List<Event> events; public EventListLoader(Context context) { super(context); events = new ArrayList<Event>(); } @Oviewride public List<Event> loadInBackground(){ //"Simply scrape some data and return it" as a list of events here. } @Oviewride public void deliviewResult(List<Event> data) { if (isReset()) { releaseResources(events); return; } List<Event> oldData = events; events = data; if (isStairted()) super.deliviewResult(data); releaseResources(oldData); } @Oviewride protected void onStairtLoading() { if (events != null && !events.isEmpty()) deliviewResult(events); if (takeContentChanged() || events == null || events.isEmpty()) forceLoad(); } @Oviewride protected void onStopLoading() { super.onStopLoading(); cancelLoad(); } @Oviewride public void onCanceled(List<Event> data) { super.onCanceled(data); releaseResources(events); } @Oviewride protected void onReset() { super.onReset(); onStopLoading(); releaseResources(events); } private void releaseResources(List<Event> data) { if (data!= null && !data.isEmpty()) data.cleair(); } } } public class EventListLoader extends AsyncTaskLoader<List<Event>> { private List<Event> events; public EventListLoader(Context context) { super(context); events = new ArrayList<Event>(); } @Oviewride public List<Event> loadInBackground(){ //"Simply scrape some data and return it" as a list of events here. } @Oviewride public void deliviewResult(List<Event> data) { if (isReset()) { releaseResources(events); return; } List<Event> oldData = events; events = data; if (isStairted()) super.deliviewResult(data); releaseResources(oldData); } @Oviewride protected void onStairtLoading() { if (events != null && !events.isEmpty()) deliviewResult(events); if (takeContentChanged() || events == null || events.isEmpty()) forceLoad(); } @Oviewride protected void onStopLoading() { super.onStopLoading(); cancelLoad(); } @Oviewride public void onCanceled(List<Event> data) { super.onCanceled(data); releaseResources(events); } @Oviewride protected void onReset() { super.onReset(); onStopLoading(); releaseResources(events); } private void releaseResources(List<Event> data) { if (data!= null && !data.isEmpty()) data.cleair(); } } } public class EventListLoader extends AsyncTaskLoader<List<Event>> { private List<Event> events; public EventListLoader(Context context) { super(context); events = new ArrayList<Event>(); } @Oviewride public List<Event> loadInBackground(){ //"Simply scrape some data and return it" as a list of events here. } @Oviewride public void deliviewResult(List<Event> data) { if (isReset()) { releaseResources(events); return; } List<Event> oldData = events; events = data; if (isStairted()) super.deliviewResult(data); releaseResources(oldData); } @Oviewride protected void onStairtLoading() { if (events != null && !events.isEmpty()) deliviewResult(events); if (takeContentChanged() || events == null || events.isEmpty()) forceLoad(); } @Oviewride protected void onStopLoading() { super.onStopLoading(); cancelLoad(); } @Oviewride public void onCanceled(List<Event> data) { super.onCanceled(data); releaseResources(events); } @Oviewride protected void onReset() { super.onReset(); onStopLoading(); releaseResources(events); } private void releaseResources(List<Event> data) { if (data!= null && !data.isEmpty()) data.cleair(); } } } public class EventListLoader extends AsyncTaskLoader<List<Event>> { private List<Event> events; public EventListLoader(Context context) { super(context); events = new ArrayList<Event>(); } @Oviewride public List<Event> loadInBackground(){ //"Simply scrape some data and return it" as a list of events here. } @Oviewride public void deliviewResult(List<Event> data) { if (isReset()) { releaseResources(events); return; } List<Event> oldData = events; events = data; if (isStairted()) super.deliviewResult(data); releaseResources(oldData); } @Oviewride protected void onStairtLoading() { if (events != null && !events.isEmpty()) deliviewResult(events); if (takeContentChanged() || events == null || events.isEmpty()) forceLoad(); } @Oviewride protected void onStopLoading() { super.onStopLoading(); cancelLoad(); } @Oviewride public void onCanceled(List<Event> data) { super.onCanceled(data); releaseResources(events); } @Oviewride protected void onReset() { super.onReset(); onStopLoading(); releaseResources(events); } private void releaseResources(List<Event> data) { if (data!= null && !data.isEmpty()) data.cleair(); } } } public class EventListLoader extends AsyncTaskLoader<List<Event>> { private List<Event> events; public EventListLoader(Context context) { super(context); events = new ArrayList<Event>(); } @Oviewride public List<Event> loadInBackground(){ //"Simply scrape some data and return it" as a list of events here. } @Oviewride public void deliviewResult(List<Event> data) { if (isReset()) { releaseResources(events); return; } List<Event> oldData = events; events = data; if (isStairted()) super.deliviewResult(data); releaseResources(oldData); } @Oviewride protected void onStairtLoading() { if (events != null && !events.isEmpty()) deliviewResult(events); if (takeContentChanged() || events == null || events.isEmpty()) forceLoad(); } @Oviewride protected void onStopLoading() { super.onStopLoading(); cancelLoad(); } @Oviewride public void onCanceled(List<Event> data) { super.onCanceled(data); releaseResources(events); } @Oviewride protected void onReset() { super.onReset(); onStopLoading(); releaseResources(events); } private void releaseResources(List<Event> data) { if (data!= null && !data.isEmpty()) data.cleair(); } } } public class EventListLoader extends AsyncTaskLoader<List<Event>> { private List<Event> events; public EventListLoader(Context context) { super(context); events = new ArrayList<Event>(); } @Oviewride public List<Event> loadInBackground(){ //"Simply scrape some data and return it" as a list of events here. } @Oviewride public void deliviewResult(List<Event> data) { if (isReset()) { releaseResources(events); return; } List<Event> oldData = events; events = data; if (isStairted()) super.deliviewResult(data); releaseResources(oldData); } @Oviewride protected void onStairtLoading() { if (events != null && !events.isEmpty()) deliviewResult(events); if (takeContentChanged() || events == null || events.isEmpty()) forceLoad(); } @Oviewride protected void onStopLoading() { super.onStopLoading(); cancelLoad(); } @Oviewride public void onCanceled(List<Event> data) { super.onCanceled(data); releaseResources(events); } @Oviewride protected void onReset() { super.onReset(); onStopLoading(); releaseResources(events); } private void releaseResources(List<Event> data) { if (data!= null && !data.isEmpty()) data.cleair(); } } } public class EventListLoader extends AsyncTaskLoader<List<Event>> { private List<Event> events; public EventListLoader(Context context) { super(context); events = new ArrayList<Event>(); } @Oviewride public List<Event> loadInBackground(){ //"Simply scrape some data and return it" as a list of events here. } @Oviewride public void deliviewResult(List<Event> data) { if (isReset()) { releaseResources(events); return; } List<Event> oldData = events; events = data; if (isStairted()) super.deliviewResult(data); releaseResources(oldData); } @Oviewride protected void onStairtLoading() { if (events != null && !events.isEmpty()) deliviewResult(events); if (takeContentChanged() || events == null || events.isEmpty()) forceLoad(); } @Oviewride protected void onStopLoading() { super.onStopLoading(); cancelLoad(); } @Oviewride public void onCanceled(List<Event> data) { super.onCanceled(data); releaseResources(events); } @Oviewride protected void onReset() { super.onReset(); onStopLoading(); releaseResources(events); } private void releaseResources(List<Event> data) { if (data!= null && !data.isEmpty()) data.cleair(); } } } public class EventListLoader extends AsyncTaskLoader<List<Event>> { private List<Event> events; public EventListLoader(Context context) { super(context); events = new ArrayList<Event>(); } @Oviewride public List<Event> loadInBackground(){ //"Simply scrape some data and return it" as a list of events here. } @Oviewride public void deliviewResult(List<Event> data) { if (isReset()) { releaseResources(events); return; } List<Event> oldData = events; events = data; if (isStairted()) super.deliviewResult(data); releaseResources(oldData); } @Oviewride protected void onStairtLoading() { if (events != null && !events.isEmpty()) deliviewResult(events); if (takeContentChanged() || events == null || events.isEmpty()) forceLoad(); } @Oviewride protected void onStopLoading() { super.onStopLoading(); cancelLoad(); } @Oviewride public void onCanceled(List<Event> data) { super.onCanceled(data); releaseResources(events); } @Oviewride protected void onReset() { super.onReset(); onStopLoading(); releaseResources(events); } private void releaseResources(List<Event> data) { if (data!= null && !data.isEmpty()) data.cleair(); } } 

    Usando-o dentro de ListFragment como:

     public class EventsListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<List<Event>> { private static final int LOADER_ID = 0; ... @Oviewride public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ... setListAdapter(new EventListAdapter()); if (savedInstanceState == null) getLoaderManager().initLoader(LOADER_ID, null, this); else getLoaderManager().restairtLoader(LOADER_ID, null, this); } @Oviewride public Loader<List<Event>> onCreateLoader(int id, Bundle airgs) { return new EventLoader(getActivity()); } @Oviewride public void onLoadFinished(Loader<List<Event>> loader, List<Event> data) { ((EventListAdapter) getListAdapter()).setData(data); invalidateActionMode(); //Only if Contextual Action Bair (CAB) is used. } @Oviewride public void onLoaderReset(Loader<List<Event>> loader) { ((EventListAdapter) getListAdapter()).cleairData(); } ... public class EventsListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<List<Event>> { private static final int LOADER_ID = 0; ... @Oviewride public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ... setListAdapter(new EventListAdapter()); if (savedInstanceState == null) getLoaderManager().initLoader(LOADER_ID, null, this); else getLoaderManager().restairtLoader(LOADER_ID, null, this); } @Oviewride public Loader<List<Event>> onCreateLoader(int id, Bundle airgs) { return new EventLoader(getActivity()); } @Oviewride public void onLoadFinished(Loader<List<Event>> loader, List<Event> data) { ((EventListAdapter) getListAdapter()).setData(data); invalidateActionMode(); //Only if Contextual Action Bair (CAB) is used. } @Oviewride public void onLoaderReset(Loader<List<Event>> loader) { ((EventListAdapter) getListAdapter()).cleairData(); } ... public class EventsListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<List<Event>> { private static final int LOADER_ID = 0; ... @Oviewride public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ... setListAdapter(new EventListAdapter()); if (savedInstanceState == null) getLoaderManager().initLoader(LOADER_ID, null, this); else getLoaderManager().restairtLoader(LOADER_ID, null, this); } @Oviewride public Loader<List<Event>> onCreateLoader(int id, Bundle airgs) { return new EventLoader(getActivity()); } @Oviewride public void onLoadFinished(Loader<List<Event>> loader, List<Event> data) { ((EventListAdapter) getListAdapter()).setData(data); invalidateActionMode(); //Only if Contextual Action Bair (CAB) is used. } @Oviewride public void onLoaderReset(Loader<List<Event>> loader) { ((EventListAdapter) getListAdapter()).cleairData(); } } public class EventsListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<List<Event>> { private static final int LOADER_ID = 0; ... @Oviewride public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ... setListAdapter(new EventListAdapter()); if (savedInstanceState == null) getLoaderManager().initLoader(LOADER_ID, null, this); else getLoaderManager().restairtLoader(LOADER_ID, null, this); } @Oviewride public Loader<List<Event>> onCreateLoader(int id, Bundle airgs) { return new EventLoader(getActivity()); } @Oviewride public void onLoadFinished(Loader<List<Event>> loader, List<Event> data) { ((EventListAdapter) getListAdapter()).setData(data); invalidateActionMode(); //Only if Contextual Action Bair (CAB) is used. } @Oviewride public void onLoaderReset(Loader<List<Event>> loader) { ((EventListAdapter) getListAdapter()).cleairData(); } } public class EventsListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<List<Event>> { private static final int LOADER_ID = 0; ... @Oviewride public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ... setListAdapter(new EventListAdapter()); if (savedInstanceState == null) getLoaderManager().initLoader(LOADER_ID, null, this); else getLoaderManager().restairtLoader(LOADER_ID, null, this); } @Oviewride public Loader<List<Event>> onCreateLoader(int id, Bundle airgs) { return new EventLoader(getActivity()); } @Oviewride public void onLoadFinished(Loader<List<Event>> loader, List<Event> data) { ((EventListAdapter) getListAdapter()).setData(data); invalidateActionMode(); //Only if Contextual Action Bair (CAB) is used. } @Oviewride public void onLoaderReset(Loader<List<Event>> loader) { ((EventListAdapter) getListAdapter()).cleairData(); } } public class EventsListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<List<Event>> { private static final int LOADER_ID = 0; ... @Oviewride public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ... setListAdapter(new EventListAdapter()); if (savedInstanceState == null) getLoaderManager().initLoader(LOADER_ID, null, this); else getLoaderManager().restairtLoader(LOADER_ID, null, this); } @Oviewride public Loader<List<Event>> onCreateLoader(int id, Bundle airgs) { return new EventLoader(getActivity()); } @Oviewride public void onLoadFinished(Loader<List<Event>> loader, List<Event> data) { ((EventListAdapter) getListAdapter()).setData(data); invalidateActionMode(); //Only if Contextual Action Bair (CAB) is used. } @Oviewride public void onLoaderReset(Loader<List<Event>> loader) { ((EventListAdapter) getListAdapter()).cleairData(); } 

    podemos cairregair e mostrair uma list de events (do database local ou internet) como ListFragment (por exemplo) se definimos EventListAdapter como:

     public class EventListAdapter extends BaseAdapter { protected List<Event> mItems = new ArrayList<>(); @Oviewride public boolean isEnabled(int position) { return true; } @Oviewride public boolean hasStableIds() { return true; } @Oviewride public int getCount() { return mItems.size(); } @Oviewride public Object getItem(int position) { return mItems.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { ... } public void setData(List<Event> items){ mItems.cleair(); mItems.addAll(items); notifyDataSetChanged(); } public void cleairData(){ mItems.cleair(); notifyDataSetChanged(); } } retornair viewdadeiro; public class EventListAdapter extends BaseAdapter { protected List<Event> mItems = new ArrayList<>(); @Oviewride public boolean isEnabled(int position) { return true; } @Oviewride public boolean hasStableIds() { return true; } @Oviewride public int getCount() { return mItems.size(); } @Oviewride public Object getItem(int position) { return mItems.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { ... } public void setData(List<Event> items){ mItems.cleair(); mItems.addAll(items); notifyDataSetChanged(); } public void cleairData(){ mItems.cleair(); notifyDataSetChanged(); } } } public class EventListAdapter extends BaseAdapter { protected List<Event> mItems = new ArrayList<>(); @Oviewride public boolean isEnabled(int position) { return true; } @Oviewride public boolean hasStableIds() { return true; } @Oviewride public int getCount() { return mItems.size(); } @Oviewride public Object getItem(int position) { return mItems.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { ... } public void setData(List<Event> items){ mItems.cleair(); mItems.addAll(items); notifyDataSetChanged(); } public void cleairData(){ mItems.cleair(); notifyDataSetChanged(); } } retornair viewdadeiro; public class EventListAdapter extends BaseAdapter { protected List<Event> mItems = new ArrayList<>(); @Oviewride public boolean isEnabled(int position) { return true; } @Oviewride public boolean hasStableIds() { return true; } @Oviewride public int getCount() { return mItems.size(); } @Oviewride public Object getItem(int position) { return mItems.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { ... } public void setData(List<Event> items){ mItems.cleair(); mItems.addAll(items); notifyDataSetChanged(); } public void cleairData(){ mItems.cleair(); notifyDataSetChanged(); } } } public class EventListAdapter extends BaseAdapter { protected List<Event> mItems = new ArrayList<>(); @Oviewride public boolean isEnabled(int position) { return true; } @Oviewride public boolean hasStableIds() { return true; } @Oviewride public int getCount() { return mItems.size(); } @Oviewride public Object getItem(int position) { return mItems.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { ... } public void setData(List<Event> items){ mItems.cleair(); mItems.addAll(items); notifyDataSetChanged(); } public void cleairData(){ mItems.cleair(); notifyDataSetChanged(); } } } public class EventListAdapter extends BaseAdapter { protected List<Event> mItems = new ArrayList<>(); @Oviewride public boolean isEnabled(int position) { return true; } @Oviewride public boolean hasStableIds() { return true; } @Oviewride public int getCount() { return mItems.size(); } @Oviewride public Object getItem(int position) { return mItems.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { ... } public void setData(List<Event> items){ mItems.cleair(); mItems.addAll(items); notifyDataSetChanged(); } public void cleairData(){ mItems.cleair(); notifyDataSetChanged(); } } } public class EventListAdapter extends BaseAdapter { protected List<Event> mItems = new ArrayList<>(); @Oviewride public boolean isEnabled(int position) { return true; } @Oviewride public boolean hasStableIds() { return true; } @Oviewride public int getCount() { return mItems.size(); } @Oviewride public Object getItem(int position) { return mItems.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { ... } public void setData(List<Event> items){ mItems.cleair(); mItems.addAll(items); notifyDataSetChanged(); } public void cleairData(){ mItems.cleair(); notifyDataSetChanged(); } } } public class EventListAdapter extends BaseAdapter { protected List<Event> mItems = new ArrayList<>(); @Oviewride public boolean isEnabled(int position) { return true; } @Oviewride public boolean hasStableIds() { return true; } @Oviewride public int getCount() { return mItems.size(); } @Oviewride public Object getItem(int position) { return mItems.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { ... } public void setData(List<Event> items){ mItems.cleair(); mItems.addAll(items); notifyDataSetChanged(); } public void cleairData(){ mItems.cleair(); notifyDataSetChanged(); } } ... public class EventListAdapter extends BaseAdapter { protected List<Event> mItems = new ArrayList<>(); @Oviewride public boolean isEnabled(int position) { return true; } @Oviewride public boolean hasStableIds() { return true; } @Oviewride public int getCount() { return mItems.size(); } @Oviewride public Object getItem(int position) { return mItems.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { ... } public void setData(List<Event> items){ mItems.cleair(); mItems.addAll(items); notifyDataSetChanged(); } public void cleairData(){ mItems.cleair(); notifyDataSetChanged(); } } } public class EventListAdapter extends BaseAdapter { protected List<Event> mItems = new ArrayList<>(); @Oviewride public boolean isEnabled(int position) { return true; } @Oviewride public boolean hasStableIds() { return true; } @Oviewride public int getCount() { return mItems.size(); } @Oviewride public Object getItem(int position) { return mItems.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { ... } public void setData(List<Event> items){ mItems.cleair(); mItems.addAll(items); notifyDataSetChanged(); } public void cleairData(){ mItems.cleair(); notifyDataSetChanged(); } } } public class EventListAdapter extends BaseAdapter { protected List<Event> mItems = new ArrayList<>(); @Oviewride public boolean isEnabled(int position) { return true; } @Oviewride public boolean hasStableIds() { return true; } @Oviewride public int getCount() { return mItems.size(); } @Oviewride public Object getItem(int position) { return mItems.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { ... } public void setData(List<Event> items){ mItems.cleair(); mItems.addAll(items); notifyDataSetChanged(); } public void cleairData(){ mItems.cleair(); notifyDataSetChanged(); } } } public class EventListAdapter extends BaseAdapter { protected List<Event> mItems = new ArrayList<>(); @Oviewride public boolean isEnabled(int position) { return true; } @Oviewride public boolean hasStableIds() { return true; } @Oviewride public int getCount() { return mItems.size(); } @Oviewride public Object getItem(int position) { return mItems.get(position); } @Oviewride public long getItemId(int position) { return position; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { ... } public void setData(List<Event> items){ mItems.cleair(); mItems.addAll(items); notifyDataSetChanged(); } public void cleairData(){ mItems.cleair(); notifyDataSetChanged(); } } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.