.getReplicationProgress() always in 99%

I have an Android app that downloads a lot of data from a CouchBase DB, for that reason I have implemented an loader , the problem I have is that the porcentage is always on 99% . In order to know whose the progress is going I have this code:

int percent =  CouchbaseManager.getInstance().getReplicationTotal()*100 /CouchbaseManager.getInstance().getReplicationProgress();
                        Log.i(Constans.TAG, TAG_LOCAL + "Syncing: " + CouchbaseManager.getInstance()
                                .getReplicationProgress() + "/"
                                + CouchbaseManager.getInstance().getReplicationTotal()
                                + ", " + percent + "%"); 

where > getReplicationProgress() is:

 public int getReplicationTotal(){
        if (pullmaster != null && pullwork != null && pushwork != null){
            return pullmaster.getCompletedChangesCount() + pullwork.getCompletedChangesCount()+pushwork.getCompletedChangesCount();
        }
        return 0;
    }

and

getReplicationProgress() is

  public int getReplicationProgress(){

        if (pullmaster != null && pullwork != null && pushwork != null){
            return pullmaster.getChangesCount() + pullwork.getChangesCount() + pushwork.getChangesCount();
        }
        return 0;
    }

Anyone has the same problem

It looks like you have the ratio reversed. You want getReplicationProgress/getReplicationTotal.

Thanks a lot @hod.greeley

sorry but doing getReplicationProgress/getReplicationTotal, I am getting

(just a few seconds in my Logcat)

05-23 21:20:51.234 LoginActivity Syncing: 42288/42088, 1%
05-23 21:20:51.234 I/SagiraAgroApp: STATUS COUCH REPLICATION_ACTIVE
05-23 21:20:51.234STATUS CHANGE IN MASTER: PULL replication event. Source: Replication{http://xx.x/_xx, pull} Total changes: 42166 Completed changes: 41968
05-23 21:20:51.234: LoginActivity Syncing: 42288/42088, 1%
05-23 21:20:51.234STATUS COUCH REPLICATION_ACTIVE
05-23 21:20:51.234STATUS CHANGE IN MASTER: PULL replication event. Source: Replication{http://xxxxxx, pull} Total changes: 42167 Completed changes: 41968
05-23 21:20:51.234: LoginActivity Syncing: 42288/42088, 1%
05-23 21:20:51.234 STATUS COUCH REPLICATION_ACTIVE

1% is never overtake

That does look strange. Are you calculating the percent in a callback (see here)?

Also, I’m not sure why your code is returning 1%, when the count shown is 42288/42088. That’s actually > 100%. So at least two things seem wrong. Somehow you’re getting a completed count greater than the total changes count, and your calculation is only showing that as 1%.

Can you repost your updated code, and include how you call the first block you have listed (where it does the actual logging)?

The thing is I have a three Replication objects : two pulls and one push.
so in order to get the the total and the progress I have a couple of methods , they are not implementated inside the push or pull changelistener

this is my method for the progress

  public int getReplicationProgress() {
        if (pullmaster != null && pullwork != null && pushwork != null) {
            return pullmaster.getChangesCount() + pullwork.getChangesCount() + pushwork.getChangesCount();
        }
        return 0;
    }

and in order to get the total what I do is

public int getReplicationTotal() {
        if (pullmaster != null && pullwork != null && pushwork != null) {
            return pullmaster.getCompletedChangesCount() + pullwork.getCompletedChangesCount() + pushwork.getCompletedChangesCount();
        }
        return 0;
    }