Example usage for android.database Cursor isClosed

List of usage examples for android.database Cursor isClosed

Introduction

In this page you can find the example usage for android.database Cursor isClosed.

Prototype

boolean isClosed();

Source Link

Document

return true if the cursor is closed

Usage

From source file:fr.shywim.antoinedaniel.ui.fragment.VideoDetailsFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    int id = loader.getId();
    if (cursor.isClosed()) {
        Bundle args = new Bundle();
        args.putString(ARG_VIDEO_ID, mVideoId);
        getLoaderManager().restartLoader(id, args, this);
        return;//  w ww .  jav a2  s.  co  m
    }
    switch (id) {
    case MainActivity.LoaderID.VIDEO_DETAILS_SOUNDS:
        if (cursor.getCount() == 0) {
            ((View) mSoundsCat.getParent()).setVisibility(View.GONE);
            mSoundsSample.setVisibility(View.GONE);
        } else {
            ((View) mSoundsCat.getParent()).setVisibility(View.VISIBLE);
            mSoundsSample.setVisibility(View.VISIBLE);
            mSoundsCat.setText(cursor.getCount() + " Sons");
            displayRandomSounds(mSoundsSample, cursor);
        }
        break;

    case MainActivity.LoaderID.VIDEO_DETAILS_MUSICS:
        if (cursor.getCount() == 0) {
            mMusicsCat.setVisibility(View.GONE);
            mMusicsList.setVisibility(View.GONE);
        } else {
            mMusicsCat.setVisibility(View.VISIBLE);
            mMusicsList.setVisibility(View.VISIBLE);
            mMusicsCat.setText(cursor.getCount() + " Musiques");
            displayMusics(mMusicsList, cursor);
        }
        break;
    }
    cursor.close();
}

From source file:net.news.inrss.fragment.EntriesListFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_share_starred: {
        if (mEntriesCursorAdapter != null) {
            String starredList = "";
            Cursor cursor = mEntriesCursorAdapter.getCursor();
            if (cursor != null && !cursor.isClosed()) {
                int titlePos = cursor.getColumnIndex(EntryColumns.TITLE);
                int linkPos = cursor.getColumnIndex(EntryColumns.LINK);
                if (cursor.moveToFirst()) {
                    do {
                        starredList += cursor.getString(titlePos) + "\n" + cursor.getString(linkPos) + "\n\n";
                    } while (cursor.moveToNext());
                }//from   w  w  w. j  a  v a  2s . c  o m
                startActivity(
                        Intent.createChooser(
                                new Intent(Intent.ACTION_SEND)
                                        .putExtra(Intent.EXTRA_SUBJECT,
                                                getString(R.string.share_favorites_title))
                                        .putExtra(Intent.EXTRA_TEXT, starredList)
                                        .setType(Constants.MIMETYPE_TEXT_PLAIN),
                                getString(R.string.menu_share)));
            }
        }
        return true;
    }
    case R.id.menu_refresh: {
        downloadUnmobilitedEntries();
        startRefresh();
        return true;
    }
    case R.id.menu_all_read: {
        if (mEntriesCursorAdapter != null) {
            mEntriesCursorAdapter.markAllAsRead(mListDisplayDate);

            // If we are on "all items" uri, we can remove the notification here
            if (mUri != null && EntryColumns.CONTENT_URI.equals(mUri) && Constants.NOTIF_MGR != null) {
                Constants.NOTIF_MGR.cancel(0);
            }
        }
        return true;
    }
    case R.id.menu_show_new_entries: {
        if (mNewEntriesNumber == 0) {
            Toast.makeText(mListView.getContext(), R.string.no_new_entries, Toast.LENGTH_LONG).show();
        }
        menu.findItem(R.id.menu_show_new_entries).getIcon().setColorFilter(null);
        mNewEntriesNumber = 0;
        mListDisplayDate = new Date().getTime();

        refreshUI();
        if (mUri != null) {
            restartLoaders();
        }
    }
    }
    return super.onOptionsItemSelected(item);
}

From source file:de.fahrgemeinschaft.RideDetailsFragment.java

@Override
public void onViewCreated(View layout, Bundle savedInstanceState) {
    super.onViewCreated(layout, savedInstanceState);
    left_arrow = layout.findViewById(R.id.left_arrow);
    right_arrow = layout.findViewById(R.id.right_arrow);
    pager = (ViewPager) layout.findViewById(R.id.pager);
    pager.setAdapter(new BasePagerAdapter() {

        @Override//from w  ww .j  a v  a 2  s.c o m
        public int getCount() {
            if (getCursor() == null)
                return 0;
            else
                return getCursor().getCount();
        }

        @Override
        protected View getView(Object position, View v, ViewGroup parent) {
            if (v == null) {
                v = getActivity().getLayoutInflater().inflate(R.layout.view_ride_details, null, false);
                v.findViewById(R.id.btn_contact).setOnClickListener(RideDetailsFragment.this);
            }
            Cursor cursor = getCursor();
            if (cursor.isClosed())
                return v;
            RideView view = (RideView) v;

            if (view.content.getChildCount() > 5)
                view.content.removeViews(1, view.content.getChildCount() - 5);
            cursor.moveToPosition((Integer) position);

            view.url = null;

            view.from_place.setText(cursor.getString(COLUMNS.FROM_ADDRESS));
            view.to_place.setText(cursor.getString(COLUMNS.TO_ADDRESS));

            view.row.bind(cursor, getActivity());
            view.reoccur.setDays(Ride.getDetails(cursor));
            if (view.reoccur.isReoccuring())
                view.reoccur.setVisibility(View.VISIBLE);
            else
                view.reoccur.setVisibility(View.GONE);

            if (cursor.getString(COLUMNS.MODE).equals(Mode.CAR.name())) {
                view.transport_mode.setImageResource(R.drawable.icn_mode_car);
            } else {
                view.transport_mode.setImageResource(R.drawable.icn_mode_train);
            }
            try {
                view.details.setText(Ride.getDetails(cursor).getString(FahrgemeinschaftConnector.COMMENT));
            } catch (JSONException e) {
                e.printStackTrace();
            }

            getActivity().getSupportLoaderManager().initLoader((int) cursor.getLong(0), null, view);

            view.avatar.setImageResource(R.drawable.icn_view_user);
            view.name.setText(EMPTY);
            view.last_login.setText(EMPTY);
            view.reg_date.setText(EMPTY);
            view.name_loading.setVisibility(View.VISIBLE);
            view.name.setVisibility(View.GONE);
            view.last_login.setVisibility(View.GONE);
            view.reg_date.setVisibility(View.GONE);

            if (isMyRide(cursor)) {
                if ((isFuture(cursor.getLong(COLUMNS.DEPARTURE)) && isActive(cursor)) || isReoccuring(cursor)) {
                    view.streifenhoernchen.setVisibility(View.GONE);
                } else {
                    view.streifenhoernchen.setVisibility(View.VISIBLE);
                }
            } else {
                view.streifenhoernchen.setVisibility(View.GONE);
            }

            if (cursor.getString(COLUMNS.WHO).equals(EMPTY)) {
                String user = PreferenceManager.getDefaultSharedPreferences(getActivity())
                        .getString(CONTACT.USER, EMPTY);
                queue.add(new ProfileRequest(user, view, RideDetailsFragment.this));
                view.userId = user;
            } else {
                queue.add(new ProfileRequest(cursor.getString(COLUMNS.WHO), view, RideDetailsFragment.this));
                view.userId = cursor.getString(COLUMNS.WHO);
            }
            view.visible = Util.isVisible(NAME, Ride.getDetails(cursor));
            view.content.setOnTouchListener(RideDetailsFragment.this);
            return view;
        }

        @Override
        protected Object getItem(int position) {
            return position;
        }
    });
    pager.requestFocus();
    pulseSwipeArrows();
}

From source file:me.myatminsoe.myansms.SMSdroid.java

@Override
public void onCreate() {
    try {//  w  w w  . j  a v  a 2 s.  co m
        Class.forName("android.os.AsyncTask");
    } catch (Throwable ignore) {
    }

    super.onCreate();
    Log.i(TAG, "init SMSdroid v" + BuildConfig.VERSION_NAME + " (" + BuildConfig.VERSION_CODE + ")");

    // check for default app only when READ_SMS was granted
    // this may need a second launch on Android 6.0 though
    if (hasPermission(this, Manifest.permission.READ_SMS)) {
        final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(this);
        int state = PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
        if (p.getBoolean(PreferencesActivity.PREFS_ACTIVATE_SENDER, true)) {
            try {
                Cursor c = getContentResolver().query(SenderActivity.URI_SENT, PROJECTION, null, null,
                        "_id LIMIT 1");
                if (c == null) {
                    Log.i(TAG, "disable .Sender: cursor=null");
                } else if (SmsManager.getDefault() == null) {
                    Log.i(TAG, "disable .Sender: SmsManager=null");
                } else {
                    state = PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
                    Log.d(TAG, "enable .Sender");
                }
                if (c != null && !c.isClosed()) {
                    c.close();
                }
            } catch (IllegalArgumentException | SQLiteException e) {

            }
        } else {
            Log.i(TAG, "disable .Sender");
        }
        getPackageManager().setComponentEnabledSetting(new ComponentName(this, SenderActivity.class), state,
                PackageManager.DONT_KILL_APP);
    } else {
        Log.w(TAG, "ignore .Sender state, READ_SMS permission is missing to check default app");
    }
}

From source file:de.ub0r.android.smsdroid.SMSdroid.java

@Override
public void onCreate() {
    try {/*  w w w.jav a 2s .  c o m*/
        Class.forName("android.os.AsyncTask");
    } catch (Throwable ignore) {
    }

    super.onCreate();
    Log.i(TAG, "init SMSdroid v" + BuildConfig.VERSION_NAME + " (" + BuildConfig.VERSION_CODE + ")");

    // check for default app only when READ_SMS was granted
    // this may need a second launch on Android 6.0 though
    if (hasPermission(this, Manifest.permission.READ_SMS)) {
        final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(this);
        int state = PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
        if (p.getBoolean(PreferencesActivity.PREFS_ACTIVATE_SENDER, true)) {
            try {
                Cursor c = getContentResolver().query(SenderActivity.URI_SENT, PROJECTION, null, null,
                        "_id LIMIT 1");
                if (c == null) {
                    Log.i(TAG, "disable .Sender: cursor=null");
                } else if (SmsManager.getDefault() == null) {
                    Log.i(TAG, "disable .Sender: SmsManager=null");
                } else {
                    state = PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
                    Log.d(TAG, "enable .Sender");
                }
                if (c != null && !c.isClosed()) {
                    c.close();
                }
            } catch (IllegalArgumentException | SQLiteException e) {
                Log.e(TAG, "disable .Sender: ", e.getMessage(), e);
            }
        } else {
            Log.i(TAG, "disable .Sender");
        }
        getPackageManager().setComponentEnabledSetting(new ComponentName(this, SenderActivity.class), state,
                PackageManager.DONT_KILL_APP);
    } else {
        Log.w(TAG, "ignore .Sender state, READ_SMS permission is missing to check default app");
    }
}

From source file:com.google.android.apps.mytracks.ImportActivity.java

private String getNameFromContentUri(Uri contentUri) {

    final String name;

    final Cursor returnCursor = this.getContentResolver().query(contentUri, null, null, null, null);

    if (returnCursor != null && returnCursor.moveToFirst()) {

        int columnIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);

        if (columnIndex != -1) {

            name = returnCursor.getString(columnIndex);

        } else {// w w w . j  a va  2 s . c o m

            name = contentUri.getLastPathSegment();

        }

    } else {

        name = null;

    }

    if (returnCursor != null && !returnCursor.isClosed()) {

        returnCursor.close();

    }

    return name;

}

From source file:com.concentricsky.android.khanacademy.app.ManageDownloadsActivity.java

@Override
protected void onStop() {
    getActionBar().setListNavigationCallbacks(null, null);

    gridView.setMultiChoiceModeListener(null);
    gridView.setOnItemClickListener(null);
    Adapter adapter = (Adapter) gridView.getAdapter();
    if (adapter != null) {
        Cursor cursor = adapter.getCursor();
        if (cursor != null && !cursor.isClosed()) {
            cursor.close();//from   w  w  w.j  a v a2s  .c om
        }
        adapter.renderer.stop();
        adapter.renderer.clearCache();
    }
    gridView.setAdapter(null);

    if (displayOptionsAdapter != null) {
        Cursor cursor = displayOptionsAdapter.getCursor();
        if (cursor != null && !cursor.isClosed()) {
            cursor.close();
        }
    }

    broadcastManager.unregisterReceiver(receiver);
    super.onStop();
}

From source file:org.tigase.mobile.chat.ChatHistoryFragment.java

private void copyMessageBody(final long id) {
    ClipboardManager clipMan = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
    Cursor cc = null;
    try {/*from  w w w  . java 2 s. c  om*/
        cc = getChatEntry(id);
        String t = cc.getString(cc.getColumnIndex(ChatTableMetaData.FIELD_BODY));
        clipMan.setText(t);
    } finally {
        if (cc != null && !cc.isClosed())
            cc.close();
    }

}

From source file:com.aware.utils.WebserviceHelper.java

@Override
protected void onHandleIntent(Intent intent) {

    WEBSERVER = Aware.getSetting(getApplicationContext(), Aware_Preferences.WEBSERVICE_SERVER);
    DEVICE_ID = Aware.getSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID);
    DEBUG = Aware.getSetting(getApplicationContext(), Aware_Preferences.DEBUG_FLAG).equals("true");
    DATABASE_TABLE = intent.getStringExtra(EXTRA_TABLE);
    TABLES_FIELDS = intent.getStringExtra(EXTRA_FIELDS);
    CONTENT_URI = Uri.parse(intent.getStringExtra(EXTRA_CONTENT_URI));

    //Fixed: not using webservices
    if (WEBSERVER.length() == 0)
        return;//from ww  w  .j av  a  2s .c o m

    if (intent.getAction().equals(ACTION_AWARE_WEBSERVICE_SYNC_TABLE)) {

        //Check if we should do this only over Wi-Fi
        boolean wifi_only = Aware.getSetting(getApplicationContext(), Aware_Preferences.WEBSERVICE_WIFI_ONLY)
                .equals("true");
        if (wifi_only) {
            ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo active_network = cm.getActiveNetworkInfo();
            if (active_network != null && active_network.getType() != ConnectivityManager.TYPE_WIFI) {
                if (DEBUG) {
                    Log.i("AWARE", "User not connected to Wi-Fi, skipping data sync.");
                }
                return;
            }
        }

        //Check first if we have database table remotely, otherwise create it!
        ArrayList<NameValuePair> fields = new ArrayList<NameValuePair>();
        fields.add(new BasicNameValuePair(Aware_Preferences.DEVICE_ID, DEVICE_ID));
        fields.add(new BasicNameValuePair(EXTRA_FIELDS, TABLES_FIELDS));

        //Create table if doesn't exist on the remote webservice server
        HttpResponse response = new Https(getApplicationContext())
                .dataPOST(WEBSERVER + "/" + DATABASE_TABLE + "/create_table", fields);
        if (response != null && response.getStatusLine().getStatusCode() == 200) {
            if (DEBUG) {
                HttpResponse copy = response;
                try {
                    if (DEBUG)
                        Log.d(Aware.TAG, EntityUtils.toString(copy.getEntity()));
                } catch (ParseException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            String[] columnsStr = new String[] {};
            Cursor columnsDB = getContentResolver().query(CONTENT_URI, null, null, null, null);
            if (columnsDB != null && columnsDB.moveToFirst()) {
                columnsStr = columnsDB.getColumnNames();
                if (DEBUG)
                    Log.d(Aware.TAG, "Total records on " + DATABASE_TABLE + ": " + columnsDB.getCount());
            }
            if (columnsDB != null && !columnsDB.isClosed())
                columnsDB.close();

            try {
                ArrayList<NameValuePair> request = new ArrayList<NameValuePair>();
                request.add(new BasicNameValuePair(Aware_Preferences.DEVICE_ID, DEVICE_ID));

                //check the latest entry in remote database
                HttpResponse latest = new Https(getApplicationContext())
                        .dataPOST(WEBSERVER + "/" + DATABASE_TABLE + "/latest", request);
                if (latest == null)
                    return;

                String data = "[]";
                try {
                    data = EntityUtils.toString(latest.getEntity());
                } catch (IllegalStateException e) {
                    Log.d(Aware.TAG, "Unable to connect to webservices...");
                }

                if (DEBUG) {
                    Log.d(Aware.TAG, "Webservice response: " + data);
                }

                //If in a study, get from joined date onwards
                String study_condition = "";
                if (Aware.getSetting(getApplicationContext(), "study_id").length() > 0
                        && Aware.getSetting(getApplicationContext(), "study_start").length() > 0) {
                    String study_start = Aware.getSetting(getApplicationContext(), "study_start");
                    study_condition = " AND timestamp > " + Long.parseLong(study_start);
                }
                if (DATABASE_TABLE.equalsIgnoreCase("aware_device"))
                    study_condition = "";

                JSONArray remoteData = new JSONArray(data);

                Cursor context_data;
                if (remoteData.length() == 0) {
                    if (exists(columnsStr, "double_end_timestamp")) {
                        context_data = getContentResolver().query(CONTENT_URI, null,
                                "double_end_timestamp != 0" + study_condition, null, "timestamp ASC");
                    } else if (exists(columnsStr, "double_esm_user_answer_timestamp")) {
                        context_data = getContentResolver().query(CONTENT_URI, null,
                                "double_esm_user_answer_timestamp != 0" + study_condition, null,
                                "timestamp ASC");
                    } else {
                        context_data = getContentResolver().query(CONTENT_URI, null, "1" + study_condition,
                                null, "timestamp ASC");
                    }
                } else {
                    long last = 0;
                    if (exists(columnsStr, "double_end_timestamp")) {
                        last = remoteData.getJSONObject(0).getLong("double_end_timestamp");
                        context_data = getContentResolver().query(CONTENT_URI, null,
                                "timestamp > " + last + " AND double_end_timestamp != 0" + study_condition,
                                null, "timestamp ASC");
                    } else if (exists(columnsStr, "double_esm_user_answer_timestamp")) {
                        last = remoteData.getJSONObject(0).getLong("double_esm_user_answer_timestamp");
                        context_data = getContentResolver().query(
                                CONTENT_URI, null, "timestamp > " + last
                                        + " AND double_esm_user_answer_timestamp != 0" + study_condition,
                                null, "timestamp ASC");
                    } else {
                        last = remoteData.getJSONObject(0).getLong("timestamp");
                        context_data = getContentResolver().query(CONTENT_URI, null,
                                "timestamp > " + last + study_condition, null, "timestamp ASC");
                    }
                }

                JSONArray context_data_entries = new JSONArray();
                if (context_data != null && context_data.moveToFirst()) {
                    if (DEBUG)
                        Log.d(Aware.TAG, "Uploading " + context_data.getCount() + " from " + DATABASE_TABLE);

                    do {
                        JSONObject entry = new JSONObject();

                        String[] columns = context_data.getColumnNames();
                        for (String c_name : columns) {

                            //Skip local database ID
                            if (c_name.equals("_id"))
                                continue;

                            if (c_name.equals("timestamp") || c_name.contains("double")) {
                                entry.put(c_name, context_data.getDouble(context_data.getColumnIndex(c_name)));
                            } else if (c_name.contains("float")) {
                                entry.put(c_name, context_data.getFloat(context_data.getColumnIndex(c_name)));
                            } else if (c_name.contains("long")) {
                                entry.put(c_name, context_data.getLong(context_data.getColumnIndex(c_name)));
                            } else if (c_name.contains("blob")) {
                                entry.put(c_name, context_data.getBlob(context_data.getColumnIndex(c_name)));
                            } else if (c_name.contains("integer")) {
                                entry.put(c_name, context_data.getInt(context_data.getColumnIndex(c_name)));
                            } else {
                                entry.put(c_name, context_data.getString(context_data.getColumnIndex(c_name)));
                            }
                        }
                        context_data_entries.put(entry);

                        if (context_data_entries.length() == 1000) {
                            request = new ArrayList<NameValuePair>();
                            request.add(new BasicNameValuePair(Aware_Preferences.DEVICE_ID, DEVICE_ID));
                            request.add(new BasicNameValuePair("data", context_data_entries.toString()));
                            new Https(getApplicationContext())
                                    .dataPOST(WEBSERVER + "/" + DATABASE_TABLE + "/insert", request);

                            context_data_entries = new JSONArray();
                        }
                    } while (context_data.moveToNext());

                    if (context_data_entries.length() > 0) {
                        request = new ArrayList<NameValuePair>();
                        request.add(new BasicNameValuePair(Aware_Preferences.DEVICE_ID, DEVICE_ID));
                        request.add(new BasicNameValuePair("data", context_data_entries.toString()));
                        new Https(getApplicationContext())
                                .dataPOST(WEBSERVER + "/" + DATABASE_TABLE + "/insert", request);
                    }
                } else {
                    if (DEBUG)
                        Log.d(Aware.TAG,
                                "Nothing new in " + DATABASE_TABLE + "!" + " URI=" + CONTENT_URI.toString());
                }

                if (context_data != null && !context_data.isClosed())
                    context_data.close();

            } catch (ParseException e) {
                e.printStackTrace();
            } catch (JSONException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    //Clear database table remotely
    if (intent.getAction().equals(ACTION_AWARE_WEBSERVICE_CLEAR_TABLE)) {
        ArrayList<NameValuePair> request = new ArrayList<NameValuePair>();
        request.add(new BasicNameValuePair(Aware_Preferences.DEVICE_ID, DEVICE_ID));
        new Https(getApplicationContext()).dataPOST(WEBSERVER + "/" + DATABASE_TABLE + "/clear_table", request);
    }
}

From source file:com.wildplot.android.ankistats.Intervals.java

public boolean calculateIntervals(int type) {
    mType = type;/* w  w w  .j  av  a  2s .  c  om*/
    double all = 0, avg = 0, max_ = 0;
    mType = type;
    mBackwards = true;

    mTitle = R.string.stats_review_intervals;
    mAxisTitles = new int[] { type, R.string.stats_cards, R.string.stats_percentage };

    mValueLabels = new int[] { R.string.stats_cards_intervals };
    mColors = new int[] { R.color.stats_interval };
    int num = 0;
    String lim = "";
    int chunk = 0;
    switch (type) {
    case Utils.TYPE_MONTH:
        num = 31;
        chunk = 1;
        lim = " and grp <= 30";
        break;
    case Utils.TYPE_YEAR:
        num = 52;
        chunk = 7;
        lim = " and grp <= 52";
        break;
    case Utils.TYPE_LIFE:
        num = -1;
        chunk = 30;
        lim = "";
        break;
    }

    ArrayList<double[]> list = new ArrayList<double[]>();
    Cursor cur = null;
    try {
        cur = mAnkiDb.getDatabase()
                .rawQuery("select ivl / " + chunk + " as grp, count() from cards " + "where did in "
                        + _limitWholeOnly() + " and queue = 2 " + lim + " " + "group by grp " + "order by grp",
                        null);
        while (cur.moveToNext()) {
            list.add(new double[] { cur.getDouble(0), cur.getDouble(1) });
        }
        if (cur != null && !cur.isClosed()) {
            cur.close();
        }
        cur = mAnkiDb.getDatabase().rawQuery("select count(), avg(ivl), max(ivl) from cards where did in "
                + _limitWholeOnly() + " and queue = 2", null);
        cur.moveToFirst();
        all = cur.getDouble(0);
        avg = cur.getDouble(1);
        max_ = cur.getDouble(2);

    } finally {
        if (cur != null && !cur.isClosed()) {
            cur.close();
        }
    }

    // small adjustment for a proper chartbuilding with achartengine
    if (list.size() == 0 || list.get(0)[0] > 0) {
        list.add(0, new double[] { 0, 0, 0 });
    }
    if (num == -1 && list.size() < 2) {
        num = 31;
    }
    if (type != Utils.TYPE_LIFE && list.get(list.size() - 1)[0] < num) {
        list.add(new double[] { num, 0 });
    } else if (type == Utils.TYPE_LIFE && list.size() < 2) {
        list.add(new double[] { Math.max(12, list.get(list.size() - 1)[0] + 1), 0 });
    }

    mSeriesList = new double[2][list.size()];
    for (int i = 0; i < list.size(); i++) {
        double[] data = list.get(i);
        mSeriesList[0][i] = data[0]; // grp
        mSeriesList[1][i] = data[1]; // cnt
        if (mSeriesList[1][i] > mMaxCards)
            mMaxCards = (int) Math.round(data[1]);
    }
    mCumulative = Utils.createCumulative(mSeriesList);
    for (int i = 0; i < list.size(); i++) {
        mCumulative[1][i] /= all / 100;
    }

    mMaxElements = list.size() - 1;
    mAverage = Utils.fmtTimeSpan((int) Math.round(avg * 86400));
    mLongest = Utils.fmtTimeSpan((int) Math.round(max_ * 86400));
    return list.size() > 0;
}