Example usage for android.database Cursor isAfterLast

List of usage examples for android.database Cursor isAfterLast

Introduction

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

Prototype

boolean isAfterLast();

Source Link

Document

Returns whether the cursor is pointing to the position after the last row.

Usage

From source file:com.granita.tasks.QuickAddDialogFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    mTaskListAdapter.changeCursor(cursor);
    if (cursor != null) {
        if (mSelectedListId == -1) {
            mSelectedListId = mListId;//from w  w  w.  ja  v a  2 s. c o  m
        }
        // set the list that was used the last time the user created an event
        // iterate over all lists and select the one that matches the given id
        cursor.moveToFirst();
        while (!cursor.isAfterLast()) {
            long listId = cursor.getLong(TASK_LIST_PROJECTION_VALUES.id);
            if (listId == mSelectedListId) {
                mListSpinner.setSelection(cursor.getPosition());
                break;
            }
            cursor.moveToNext();
        }
    }
}

From source file:com.amsterdam.marktbureau.makkelijkemarkt.adapters.DagvergunningenAdapter.java

/**
 * Bind the cursor data to the view elements
 * @param view listitem view containing the elements
 * @param context the context//from ww w  . j  av  a 2  s .c  om
 * @param cursor a cursor containing the dagvergunning data
 */
@Override
public void bindView(View view, Context context, Cursor cursor) {
    boolean multipleDagvergunningen = false;

    // get erkenningsnummer for checking multiple dagvergunningen for the same koopman
    String erkenningsnummer = cursor.getString(
            cursor.getColumnIndex(MakkelijkeMarktProvider.Dagvergunning.COL_ERKENNINGSNUMMER_INVOER_WAARDE));

    // get current position, check for multiple dagvergunningen, and restore position again
    int position = cursor.getPosition();
    cursor.moveToFirst();
    while (!cursor.isAfterLast()) {
        if (cursor
                .getString(cursor.getColumnIndex(
                        MakkelijkeMarktProvider.Dagvergunning.COL_ERKENNINGSNUMMER_INVOER_WAARDE))
                .equals(erkenningsnummer) && cursor.getPosition() != position) {
            multipleDagvergunningen = true;
            break;
        }
        cursor.moveToNext();
    }
    cursor.moveToPosition(position);

    // get the viewholder layout containing the view items
    ViewHolder viewHolder = (ViewHolder) view.getTag();

    // koopman foto
    Glide.with(context.getApplicationContext())
            .load(cursor.getString(cursor.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_FOTO_URL)))
            .error(R.drawable.no_koopman_image).into(viewHolder.koopmanFoto);

    // alert !
    String koopmanStatus = cursor.getString(cursor.getColumnIndex("koopman_status"));
    if (multipleDagvergunningen
            || koopmanStatus.equals(context.getString(R.string.koopman_status_verwijderd))) {
        viewHolder.koopmanStatusText.setVisibility(View.VISIBLE);
    } else {
        viewHolder.koopmanStatusText.setVisibility(View.GONE);
    }

    // koopman naam
    String koopmanVoorletters = cursor
            .getString(cursor.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_VOORLETTERS));
    String koopmanAchternaam = cursor
            .getString(cursor.getColumnIndex(MakkelijkeMarktProvider.Koopman.COL_ACHTERNAAM));
    viewHolder.koopmanVoorlettersAchternaamText.setText(koopmanVoorletters + " " + koopmanAchternaam);

    // vervanger aanwezig
    String vervangerErkenningsnummer = cursor.getString(
            cursor.getColumnIndex(MakkelijkeMarktProvider.Dagvergunning.COL_VERVANGER_ERKENNINGSNUMMER));
    if (vervangerErkenningsnummer != null) {
        viewHolder.vervangerAanwezigText.setVisibility(View.VISIBLE);
    } else {
        viewHolder.vervangerAanwezigText.setVisibility(View.GONE);
    }

    // registratietijd
    String registratieDatumtijd = cursor
            .getString(cursor.getColumnIndex(MakkelijkeMarktProvider.Dagvergunning.COL_REGISTRATIE_DATUMTIJD));
    try {
        Date registratieDate = new SimpleDateFormat(context.getString(R.string.date_format_datumtijd),
                Locale.getDefault()).parse(registratieDatumtijd);
        SimpleDateFormat sdf = new SimpleDateFormat(context.getString(R.string.date_format_tijd));
        String registratieTijd = sdf.format(registratieDate);
        viewHolder.dagvergunningRegistratieDatumtijdText.setText(registratieTijd);
    } catch (java.text.ParseException e) {
        viewHolder.dagvergunningRegistratieDatumtijdText.setText("");
    }

    // erkennings nummer
    viewHolder.erkenningsnummerText
            .setText(context.getString(R.string.label_erkenningsnummer) + ": " + erkenningsnummer);

    // sollicitatie nummer
    String sollicitatieNummer = cursor
            .getString(cursor.getColumnIndex(MakkelijkeMarktProvider.Sollicitatie.COL_SOLLICITATIE_NUMMER));
    if (sollicitatieNummer != null && !sollicitatieNummer.equals("")) {
        viewHolder.sollicitatieSollicitatieNummerText.setVisibility(View.VISIBLE);
        viewHolder.sollicitatieSollicitatieNummerText
                .setText(context.getString(R.string.label_sollicitatienummer) + ": " + sollicitatieNummer);
    } else {
        // we need to clear the textview contents because listview items are recycled and may
        // therefor contain data from other dagvergunning
        viewHolder.sollicitatieSollicitatieNummerText.setVisibility(View.GONE);
        viewHolder.sollicitatieSollicitatieNummerText.setText("");
    }

    // sollicitatie status
    String sollicitatieStatus = cursor
            .getString(cursor.getColumnIndex(MakkelijkeMarktProvider.Dagvergunning.COL_STATUS_SOLLICITATIE));
    if (sollicitatieStatus != null && !sollicitatieStatus.equals("?") && !sollicitatieStatus.equals("")) {
        viewHolder.sollicitatieStatusText.setVisibility(View.VISIBLE);
        viewHolder.sollicitatieStatusText.setText(sollicitatieStatus);
        viewHolder.sollicitatieStatusText.setBackgroundColor(ContextCompat.getColor(context,
                Utility.getSollicitatieStatusColor(context, sollicitatieStatus)));
    } else {
        viewHolder.sollicitatieStatusText.setVisibility(View.GONE);
        viewHolder.sollicitatieStatusText.setText("");
    }

    // notitie
    String notitie = cursor.getString(cursor.getColumnIndex(MakkelijkeMarktProvider.Dagvergunning.COL_NOTITIE));
    if (notitie != null && !notitie.equals("")) {
        viewHolder.notitieText.setText(context.getString(R.string.label_notitie) + ": " + notitie);
        Utility.collapseView(viewHolder.notitieText, false);
    } else {
        Utility.collapseView(viewHolder.notitieText, true);
    }

    // totale lengte
    String totaleLengte = cursor
            .getString(cursor.getColumnIndex(MakkelijkeMarktProvider.Dagvergunning.COL_TOTALE_LENGTE));
    viewHolder.dagvergunningTotaleLengteText
            .setText(totaleLengte + " " + context.getString(R.string.length_meter));

    // account naam
    String accountNaam = cursor.getString(cursor.getColumnIndex(MakkelijkeMarktProvider.Account.COL_NAAM));
    viewHolder.accountNaamText.setText(accountNaam);
}

From source file:edu.pdx.cecs.orcycle.NoteUploader.java

private JSONArray getNoteResponsesJSON(long noteId) throws JSONException {

    // Create a JSON array to hold all of the answers
    JSONArray jsonAnswers = new JSONArray();

    mDb.openReadOnly();//from ww  w. j a v  a2 s .  co m
    try {
        Cursor answers = mDb.fetchNoteAnswers(noteId);

        int questionId = answers.getColumnIndex(DbAdapter.K_NOTE_ANSWER_QUESTION_ID);
        int answerId = answers.getColumnIndex(DbAdapter.K_NOTE_ANSWER_ANSWER_ID);
        int otherText = answers.getColumnIndex(DbAdapter.K_NOTE_ANSWER_OTHER_TEXT);
        String text;

        // Cycle thru the database entries
        while (!answers.isAfterLast()) {

            // For each row, construct a JSON object
            JSONObject json = new JSONObject();

            try {
                // Place values into the JSON object
                json.put(FID_QUESTION_ID, answers.getInt(questionId));
                json.put(FID_ANSWER_ID, answers.getInt(answerId));

                if (null != (text = answers.getString(otherText))) {
                    text = text.trim();
                    if (!text.equals("")) {
                        json.put(FID_ANSWER_OTHER_TEXT, text);
                    }
                }
                // Place JSON objects into the JSON array
                jsonAnswers.put(json);
            } catch (Exception ex) {
                Log.e(MODULE_TAG, ex.getMessage());
            }
            // Move to next row
            answers.moveToNext();
        }
        answers.close();
    } catch (Exception ex) {
        Log.e(MODULE_TAG, ex.getMessage());
    } finally {
        mDb.close();
    }
    return jsonAnswers;
}

From source file:edu.stanford.mobisocial.dungbeetle.MessagingManagerThread.java

private List<Long> getFeedSubscribers(Uri feedUri) {
    if (feedUri == null) {
        throw new NullPointerException("Feed cannot be null");
    }//from   w  ww . j  av a  2s .  com
    String feedName = feedUri.getLastPathSegment();
    switch (Feed.typeOf(feedUri)) {
    case FRIEND:
        String personId = Feed.friendIdForFeed(feedUri);
        if (personId == null) {
            return new ArrayList<Long>(0);
        }
        String table = Contact.TABLE;
        String[] columns = new String[] { Contact._ID };
        String selection = Contact.PERSON_ID + " = ?";
        String[] selectionArgs = new String[] { personId };
        String groupBy = null;
        String having = null;
        String orderBy = null;
        Cursor c = mHelper.getReadableDatabase().query(table, columns, selection, selectionArgs, groupBy,
                having, orderBy);
        if (c == null || !c.moveToFirst()) {
            Log.w(TAG, "Could not find user for id " + personId);
            return new ArrayList<Long>(0);
        }
        return Collections.singletonList(c.getLong(0));
    case APP:
        // Currently, we send app messages to all users, which are registered
        // as subscribers to the "friend" feed. The subscribers model needs to
        // be reworked, and further the "app" feed needs further thinking.
        // Messages should be lossy, and encryption should not require keys
        // for each recipient.
        feedName = "friend";
        // No break:
    case GROUP:
        Cursor subs = mHelper.querySubscribers(feedName);
        List<Long> recipientIds = new ArrayList<Long>(subs.getCount());
        subs.moveToFirst();
        while (!subs.isAfterLast()) {
            long id = subs.getLong(subs.getColumnIndexOrThrow(Subscriber.CONTACT_ID));
            recipientIds.add(id);
            subs.moveToNext();
        }
        subs.close();
        return recipientIds;
    default:
        Log.w(TAG, "unmatched feed type for " + feedUri);
        return new ArrayList<Long>();
    }
}

From source file:com.nonninz.robomodel.RoboManager.java

public long[] getSelectedModelIds(String selection, String[] selectionArgs, String groupBy, String having,
        String orderBy) {//from w  ww . jav a 2 s.  c  om
    final SQLiteDatabase db = mDatabaseManager.openOrCreateDatabase(getDatabaseName());

    final String columns[] = new String[] { BaseColumns._ID };
    Cursor query;

    /*
     * Try the query. If the Table doesn't exist, fix the DB and re-run the query.
     */
    try {
        query = db.query(getTableName(), columns, selection, selectionArgs, groupBy, having, orderBy);
    } catch (final SQLiteException e) {
        prepareTable(db);
        query = db.query(getTableName(), columns, selection, selectionArgs, groupBy, having, orderBy);
    }

    final int columnIndex = query.getColumnIndex(BaseColumns._ID);
    final long result[] = new long[query.getCount()];
    for (query.moveToFirst(); !query.isAfterLast(); query.moveToNext()) {
        result[query.getPosition()] = query.getLong(columnIndex);
    }

    return result;
}

From source file:org.mariotaku.twidere.util.DataStoreUtils.java

public static int getActivitiesCount(@NonNull final Context context, final Uri uri, final Expression extraWhere,
        final String[] extraWhereArgs, final long since, String sinceColumn, boolean followingOnly,
        @Nullable UserKey[] accountKeys) {
    if (accountKeys == null) {
        accountKeys = getActivatedAccountKeys(context);
    }/*from  ww w .  java 2 s  .  co  m*/
    Expression[] expressions;
    if (extraWhere != null) {
        expressions = new Expression[4];
        expressions[3] = extraWhere;
    } else {
        expressions = new Expression[3];
    }
    expressions[0] = Expression.inArgs(new Column(Activities.ACCOUNT_KEY), accountKeys.length);
    expressions[1] = Expression.greaterThanArgs(sinceColumn);
    expressions[2] = buildActivityFilterWhereClause(getTableNameByUri(uri), null);
    final Expression selection = Expression.and(expressions);
    String[] selectionArgs;
    if (extraWhereArgs != null) {
        selectionArgs = new String[accountKeys.length + 1 + extraWhereArgs.length];
        System.arraycopy(extraWhereArgs, 0, selectionArgs, accountKeys.length + 1, extraWhereArgs.length);
    } else {
        selectionArgs = new String[accountKeys.length + 1];
    }
    for (int i = 0; i < accountKeys.length; i++) {
        selectionArgs[i] = accountKeys[i].toString();
    }
    selectionArgs[accountKeys.length] = String.valueOf(since);
    // If followingOnly option is on, we have to iterate over items
    if (followingOnly) {
        final ContentResolver resolver = context.getContentResolver();
        final String[] projection = new String[] { Activities.SOURCES };
        final Cursor cur = resolver.query(uri, projection, selection.getSQL(), selectionArgs, null);
        if (cur == null)
            return -1;
        try {
            final JsonMapper<UserFollowState> mapper;
            try {
                mapper = LoganSquareMapperFinder.mapperFor(UserFollowState.class);
            } catch (LoganSquareMapperFinder.ClassLoaderDeadLockException e) {
                return -1;
            }
            int total = 0;
            cur.moveToFirst();
            while (!cur.isAfterLast()) {
                final String string = cur.getString(0);
                if (TextUtils.isEmpty(string))
                    continue;
                boolean hasFollowing = false;
                try {
                    for (UserFollowState state : mapper.parseList(string)) {
                        if (state.is_following) {
                            hasFollowing = true;
                            break;
                        }
                    }
                } catch (IOException e) {
                    continue;
                }
                if (hasFollowing) {
                    total++;
                }
                cur.moveToNext();
            }
            return total;
        } finally {
            cur.close();
        }
    }
    return queryCount(context, uri, selection.getSQL(), selectionArgs);
}

From source file:in.lovelacetech.qrib.ui.MainActivity.java

/**
 * we do everything after loader is finish loading
 * first we clear the map and adding user location
 *
 * we are using cursor loader advantages here
 * it loads again if provider is changing
 * that's why we only adding/removing marker on load finished
 *//* w  w  w  .ja  va 2 s .  c  o  m*/
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    // clear map
    mMap.clear();

    // set up again because the map is clear
    setUserLocation();

    // do nothing when cursor is empty
    if (data.getCount() == 0)
        return;

    if (mMarkers == null) {
        mMarkers = new ArrayMap<>(data.getCount());
    } else {
        // set to null first before setting new size
        mMarkers.clear();
        mMarkers = new ArrayMap<>(data.getCount());
    }

    // setup event marker here
    for (data.moveToFirst(); !data.isAfterLast(); data.moveToNext()) {
        MarkItem mark = MarkItem.getInstance(data);
        Marker marker = setUpMark(mark);
        mMarkers.put(marker, mark);
    }
}

From source file:com.example.android.sampletvinput.MainFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
        final int loaderId = loader.getId();

        if (loaderId == CATEGORY_LOADER) {

            // Every time we have to re-get the category loader, we must re-create the sidebar.
            mCategoryRowAdapter.clear();

            // Iterate through each category entry and add it to the ArrayAdapter.
            while (!data.isAfterLast()) {

                int categoryIndex = data.getColumnIndex(VideoContract.VideoEntry.COLUMN_CATEGORY);
                String category = data.getString(categoryIndex);

                // Create header for this category.
                HeaderItem header = new HeaderItem(category);

                int videoLoaderId = category.hashCode(); // Create unique int from category.
                CursorObjectAdapter existingAdapter = mVideoCursorAdapters.get(videoLoaderId);
                if (existingAdapter == null) {

                    // Map video results from the database to Video objects.
                    CursorObjectAdapter videoCursorAdapter = new CursorObjectAdapter(new CardPresenter());
                    videoCursorAdapter.setMapper(new VideoCursorMapper());
                    mVideoCursorAdapters.put(videoLoaderId, videoCursorAdapter);

                    ListRow row = new ListRow(header, videoCursorAdapter);
                    mCategoryRowAdapter.add(row);

                    // Start loading the videos from the database for a particular category.
                    Bundle args = new Bundle();
                    args.putString(VideoContract.VideoEntry.COLUMN_CATEGORY, category);
                    getLoaderManager().initLoader(videoLoaderId, args, this);
                } else {
                    ListRow row = new ListRow(header, existingAdapter);
                    mCategoryRowAdapter.add(row);
                }/*www.j  av  a  2  s.  c  om*/

                data.moveToNext();
            }

            // Create a row for this special case with more samples.
            /*
                            HeaderItem gridHeader = new HeaderItem(getString(R.string.more_samples));
                            GridItemPresenter gridPresenter = new GridItemPresenter(this);
                            ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(gridPresenter);
                            gridRowAdapter.add(getString(R.string.grid_view));
                            gridRowAdapter.add(getString(R.string.guidedstep_first_title));
                            gridRowAdapter.add(getString(R.string.error_fragment));
                            gridRowAdapter.add(getString(R.string.personal_settings));
                            ListRow row = new ListRow(gridHeader, gridRowAdapter);
                            mCategoryRowAdapter.add(row);
            */

            startEntranceTransition(); // TODO: Move startEntranceTransition to after all
            // cursors have loaded.
        } else {
            // The CursorAdapter contains a Cursor pointing to all videos.
            mVideoCursorAdapters.get(loaderId).changeCursor(data);
        }
    } else {
        // Start an Intent to fetch the videos.
        Intent serviceIntent = new Intent(getActivity(), FetchVideoService.class);
        getActivity().startService(serviceIntent);
    }
}

From source file:com.money.manager.ex.fragment.HomeFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    MainActivity mainActivity = null;/* ww w  . j a va2 s.  c  om*/
    if (getActivity() != null && getActivity() instanceof MainActivity)
        mainActivity = (MainActivity) getActivity();

    switch (loader.getId()) {
    case ID_LOADER_USER_NAME:
        if (data != null && data.moveToFirst()) {
            while (data.isAfterLast() == false) {
                String infoValue = data.getString(data.getColumnIndex(infoTable.INFONAME));
                // save into preferences username and basecurrency id
                if (Constants.INFOTABLE_USERNAME.equalsIgnoreCase(infoValue)) {
                    application.setUserName(data.getString(data.getColumnIndex(infoTable.INFOVALUE)));
                } else if (Constants.INFOTABLE_BASECURRENCYID.equalsIgnoreCase(infoValue)) {
                    //application.setBaseCurrencyId(data.getInt(data.getColumnIndex(infoTable.INFOVALUE)));
                }
                data.moveToNext();
            }
        }
        // show username
        if (!TextUtils.isEmpty(application.getUserName()))
            ((SherlockFragmentActivity) getActivity()).getSupportActionBar()
                    .setSubtitle(application.getUserName());
        // set user name on drawer
        if (mainActivity != null)
            mainActivity.setDrawableUserName(application.getUserName());

        break;

    case ID_LOADER_ACCOUNT_BILLS:
        double curTotal = 0, curReconciled = 0;
        AccountBillsAdapter adapter = null;

        linearHome.setVisibility(data != null && data.getCount() > 0 ? View.VISIBLE : View.GONE);
        linearWelcome.setVisibility(linearHome.getVisibility() == View.GONE ? View.VISIBLE : View.GONE);

        // cycle cursor
        if (data != null && data.moveToFirst()) {
            while (data.isAfterLast() == false) {
                curTotal += data.getDouble(data.getColumnIndex(QueryAccountBills.TOTALBASECONVRATE));
                curReconciled += data.getDouble(data.getColumnIndex(QueryAccountBills.RECONCILEDBASECONVRATE));
                data.moveToNext();
            }
            // create adapter
            adapter = new AccountBillsAdapter(getActivity(), data);
        }
        // write accounts total
        txtTotalAccounts.setText(currencyUtils.getBaseCurrencyFormatted(curTotal));
        // manage footer listview
        if (linearFooter == null) {
            linearFooter = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.item_account_bills,
                    null);
            // textview into layout
            txtFooterSummary = (TextView) linearFooter.findViewById(R.id.textVievItemAccountTotal);
            txtFooterSummaryReconciled = (TextView) linearFooter
                    .findViewById(R.id.textVievItemAccountTotalReconciled);
            // set text
            TextView txtTextSummary = (TextView) linearFooter.findViewById(R.id.textVievItemAccountName);
            txtTextSummary.setText(R.string.summary);
            // invisibile image
            ImageView imgSummary = (ImageView) linearFooter.findViewById(R.id.imageViewAccountType);
            imgSummary.setVisibility(View.INVISIBLE);
            // set color textview
            txtTextSummary.setTextColor(Color.GRAY);
            txtFooterSummary.setTextColor(Color.GRAY);
            txtFooterSummaryReconciled.setTextColor(Color.GRAY);
        }
        // remove footer
        lstAccountBills.removeFooterView(linearFooter);
        // set text
        txtFooterSummary.setText(txtTotalAccounts.getText());
        txtFooterSummaryReconciled.setText(currencyUtils.getBaseCurrencyFormatted(curReconciled));
        // add footer
        lstAccountBills.addFooterView(linearFooter, null, false);
        // set adapter and shown
        lstAccountBills.setAdapter(adapter);
        setListViewAccountBillsVisible(true);
        // set total accounts in drawer
        if (mainActivity != null) {
            mainActivity.setDrawableTotalAccounts(txtTotalAccounts.getText().toString());
        }
        break;

    case ID_LOADER_BILL_DEPOSITS:
        mainActivity.setDrawableRepeatingTransactions(data != null ? data.getCount() : 0);
        break;

    case ID_LOADER_INCOME_EXPENSES:
        double income = 0, expenses = 0;
        if (data != null && data.moveToFirst()) {
            while (!data.isAfterLast()) {
                expenses = data.getDouble(data.getColumnIndex(QueryReportIncomeVsExpenses.Expenses));
                income = data.getDouble(data.getColumnIndex(QueryReportIncomeVsExpenses.Income));
                //move to next record
                data.moveToNext();
            }
        }
        TextView txtIncome = (TextView) getActivity().findViewById(R.id.textViewIncome);
        TextView txtExpenses = (TextView) getActivity().findViewById(R.id.textViewExpenses);
        TextView txtDifference = (TextView) getActivity().findViewById(R.id.textViewDifference);
        // set value
        if (txtIncome != null)
            txtIncome.setText(currencyUtils.getCurrencyFormatted(currencyUtils.getBaseCurrencyId(), income));
        if (txtExpenses != null)
            txtExpenses.setText(
                    currencyUtils.getCurrencyFormatted(currencyUtils.getBaseCurrencyId(), Math.abs(expenses)));
        if (txtDifference != null)
            txtDifference.setText(currencyUtils.getCurrencyFormatted(currencyUtils.getBaseCurrencyId(),
                    income - Math.abs(expenses)));
        // manage progressbar
        final ProgressBar barIncome = (ProgressBar) getActivity().findViewById(R.id.progressBarIncome);
        final ProgressBar barExpenses = (ProgressBar) getActivity().findViewById(R.id.progressBarExpenses);

        if (barIncome != null && barExpenses != null) {
            barIncome.setMax((int) (Math.abs(income) + Math.abs(expenses)));
            barExpenses.setMax((int) (Math.abs(income) + Math.abs(expenses)));

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
                ObjectAnimator animationIncome = ObjectAnimator.ofInt(barIncome, "progress",
                        (int) Math.abs(income));
                animationIncome.setDuration(1000); // 0.5 second
                animationIncome.setInterpolator(new DecelerateInterpolator());
                animationIncome.start();

                ObjectAnimator animationExpenses = ObjectAnimator.ofInt(barExpenses, "progress",
                        (int) Math.abs(expenses));
                animationExpenses.setDuration(1000); // 0.5 second
                animationExpenses.setInterpolator(new DecelerateInterpolator());
                animationExpenses.start();
            } else {
                barIncome.setProgress((int) Math.abs(income));
                barExpenses.setProgress((int) Math.abs(expenses));
            }
        }
    }
}

From source file:mobisocial.musubi.ui.fragments.FeedViewFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mInputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    mObserver = new ContentObserver(new Handler(mActivity.getMainLooper())) {
        @Override//from w  w w .  j  a v  a 2s.c  o m
        public void onChange(boolean selfChange) {
            if (mObjects == null || mObjects.getCursor() == null || !isAdded()) {
                return;
            }

            // XXX Move this to WizardStepHandler-- register a content observer
            // there only when required.
            if (WizardStepHandler.isCurrentTask(mActivity, WizardStepHandler.TASK_EDIT_PICTURE)) {
                Cursor c = mObjects.getCursor();
                ObjectManager om = new ObjectManager(App.getDatabaseSource(mActivity));
                AppManager am = new AppManager(App.getDatabaseSource(mActivity));
                if (c.moveToFirst()) {
                    while (!c.isAfterLast()) {
                        long objId = c.getLong(c.getColumnIndexOrThrow(MObject.COL_ID));
                        MObject obj = om.getObjectForId(objId);
                        if (obj != null && am.getAppIdentifier(obj.appId_).startsWith("musubi.sketch")) {
                            WizardStepHandler.accomplishTask(mActivity, WizardStepHandler.TASK_EDIT_PICTURE);
                            break;
                        }
                        c.moveToNext();
                    }
                }
            }

            if (DBG)
                Log.d(TAG, "-- contentObserver observed change");
            getLoaderManager().restartLoader(0, getLoaderArgs(mTotal), FeedViewFragment.this);
        }
    };

    if (savedInstanceState != null) {
        mTotal = savedInstanceState.getInt(EXTRA_NUM_ITEMS);
        Log.d(TAG, "setting total from instance: " + mTotal);
    } else {
        Log.d(TAG, "using total " + mTotal);
    }

    if (DBG)
        Log.d(TAG, "-- onCreated");
    getLoaderManager().initLoader(0, getLoaderArgs(mTotal), this);
}