Android Open Source - led-notifier Data Fetcher






From Project

Back to project page led-notifier.

License

The source code is released under:

Apache License

If you think the Android project led-notifier listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ciubotariu_levy.lednotifier;
/* w w  w .ja va  2s.  com*/
import java.util.HashMap;

import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;

import com.ciubotariu_levy.lednotifier.providers.LedContactInfo;
import com.ciubotariu_levy.lednotifier.providers.LedContacts;

public class DataFetcher extends
    AsyncTask<Context, Void, HashMap<String,LedContactInfo>> {
  
  public interface OnDataFetchedListener {
    public void onDataFetched (HashMap <String, LedContactInfo> fetchedData);
  }
  
  private Uri mUri;
  private OnDataFetchedListener mListener;

  public DataFetcher (OnDataFetchedListener listener, Uri uri){
    mListener = listener;
    mUri = uri;
  }
  
  @Override
  protected HashMap<String, LedContactInfo> doInBackground(Context... params) {
    HashMap <String, LedContactInfo> map = new HashMap <String,LedContactInfo> ();
    if (params [0] == null){
      return map;
    }
    String [] projection = new String [] {LedContacts._ID, LedContacts.SYSTEM_CONTACT_LOOKUP_URI, LedContacts.LAST_KNOWN_NAME, LedContacts.LAST_KNOWN_NUMBER, LedContacts.COLOR, LedContacts.VIBRATE_PATTERN,
        LedContacts.RINGTONE_URI};
    Cursor c = params[0].getContentResolver().query(mUri, projection, null, null,null);
    if (c != null && c.moveToFirst()){
      do {
        LedContactInfo info = new LedContactInfo();
        info.id = c.getInt(c.getColumnIndex(LedContacts._ID));
        info.systemLookupUri = c.getString(c.getColumnIndex(LedContacts.SYSTEM_CONTACT_LOOKUP_URI));
        info.lastKnownName = c.getString (c.getColumnIndex(LedContacts.LAST_KNOWN_NAME));
        info.lastKnownNumber = c.getString(c.getColumnIndex(LedContacts.LAST_KNOWN_NUMBER));
        info.color = c.getInt(c.getColumnIndex(LedContacts.COLOR));
        info.vibratePattern = c.getString(c.getColumnIndex(LedContacts.VIBRATE_PATTERN));
        info.ringtoneUri = c.getString(c.getColumnIndex(LedContacts.RINGTONE_URI));
        if (info.ringtoneUri != null && info.ringtoneUri.equalsIgnoreCase("null")){
          info.ringtoneUri = null;
        }
        map.put (String.valueOf(info.systemLookupUri),info);
      }
      while (c.moveToNext());
      c.close();
    }
    return map;
  }
  
  @Override
  protected void onPostExecute (HashMap <String, LedContactInfo> map){
    if (mListener != null){
      mListener.onDataFetched(map);
    }
  }

}




Java Source Code List

com.ciubotariu_levy.lednotifier.AboutActivity.java
com.ciubotariu_levy.lednotifier.AlarmDismissReceiver.java
com.ciubotariu_levy.lednotifier.BoldCheckedView.java
com.ciubotariu_levy.lednotifier.BootBroadcastReceiver.java
com.ciubotariu_levy.lednotifier.CircularColorView.java
com.ciubotariu_levy.lednotifier.ColorDialog.java
com.ciubotariu_levy.lednotifier.ColorVibrateDialog.java
com.ciubotariu_levy.lednotifier.ContactsFragment.java
com.ciubotariu_levy.lednotifier.CustomContactsFragment.java
com.ciubotariu_levy.lednotifier.DataFetcher.java
com.ciubotariu_levy.lednotifier.DefaultColorChooserContainer.java
com.ciubotariu_levy.lednotifier.FastScrollThemedListView.java
com.ciubotariu_levy.lednotifier.LEDCancelReceiver.java
com.ciubotariu_levy.lednotifier.MainActivity.java
com.ciubotariu_levy.lednotifier.NotificationService.java
com.ciubotariu_levy.lednotifier.NotificationUtils.java
com.ciubotariu_levy.lednotifier.ObserverService.java
com.ciubotariu_levy.lednotifier.SMSAppAdapter.java
com.ciubotariu_levy.lednotifier.SMSAppChooserContainer.java
com.ciubotariu_levy.lednotifier.SMSReceiver.java
com.ciubotariu_levy.lednotifier.SectionedCursorAdapter.java
com.ciubotariu_levy.lednotifier.SettingsActivity.java
com.ciubotariu_levy.lednotifier.SmsAppChooserDialog.java
com.ciubotariu_levy.lednotifier.providers.LedContactInfo.java
com.ciubotariu_levy.lednotifier.providers.LedContactProvider.java
com.ciubotariu_levy.lednotifier.providers.LedContacts.java
com.larswerkman.holocolorpicker.ColorPicker.java
com.larswerkman.holocolorpicker.EndColorPicker.java
com.larswerkman.holocolorpicker.LinearColorPicker.java
com.larswerkman.holocolorpicker.OnColorChangedListener.java
com.larswerkman.holocolorpicker.OpacityBar.java
com.larswerkman.holocolorpicker.SVBar.java
com.larswerkman.holocolorpicker.SaturationBar.java
com.larswerkman.holocolorpicker.ValueBar.java
com.makeramen.RoundedDrawable.java
com.makeramen.RoundedTransformationBuilder.java