// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/ProfileOverviewPresenter.java
// public interface ProfileOverviewPresenter extends BasePresenter {
// 
//     public void loadProfileData();
// }
// 
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/ProfileOverviewPresenterImpl.java
// public class ProfileOverviewPresenterImpl implements ProfileOverviewPresenter {
// 
//     boolean canceled;
// 
//     private ProfileOverviewView profileOverviewView;
// 
//     private static DecimalFormat decimalFormat = new DecimalFormat("0.##");
// 
//     public ProfileOverviewPresenterImpl(ProfileOverviewView profileOverviewView) {
//         this.profileOverviewView = profileOverviewView;
//     }
// 
//     @Override
//     public void loadProfileData() {
//         canceled = false;
//         profileOverviewView.showProgress();
//         User.getInstance().getUserDonations(findCallback);
//     }
// 
//     private FindCallback<ParseObject> findCallback = new FindCallback<ParseObject>() {
//         @Override
//         public void done(List<ParseObject> parseObjects, ParseException e) {
// 
//             if (parseObjects == null) {
//                 parseObjects = new ArrayList<>();
//             }
// 
//             int donations = parseObjects.size();
//             float liters = donations * User.BLOOD_PER_DONATION_LITERS;
//             float litersNeededForTicket = liters % User.BLOOD_FOR_TICKET_LITERS;
// 
//             int daysToNext = 73; // TODO
// 
//             int achievementNum = 0;
// 
//             if (parseObjects.size() >= 15) {
//                 achievementNum = 4;
//             } else if (parseObjects.size() >= 10) {
//                 achievementNum = 3;
//             } else if (parseObjects.size() >= 5) {
//                 achievementNum = 2;
//             } else if (parseObjects.size() >= 1) {
//                 achievementNum = 1;
//             }
// 
//             profileOverviewView.hideProgress();
//             profileOverviewView.showData(decimalFormat.format(liters), String.valueOf(daysToNext),
//                 String.valueOf(achievementNum), decimalFormat.format(litersNeededForTicket));
//         }
//     };
// 
//     @Override
//     public void cancel() {
//         canceled = true;
//     }
// }
// 
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/ProfileOverviewView.java
// public interface ProfileOverviewView extends BaseView {
// 
//     public void showData(String liters, String daysToNext, String achievements,
//                          String litersToFreeTicket);
// }


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import butterknife.ButterKnife;
import butterknife.InjectView;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.mvp.presenters.ProfileOverviewPresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.ProfileOverviewPresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.ProfileOverviewView;
        return view;
    }

    @Override
    public void showData(String liters, String daysToNext, String achievements,
                         String litersToFreeTicket) {
        textDonatedLitersValue.setText(liters);
        textTicket.setText(litersToFreeTicket);
        textDaysToNext.setText(daysToNext);
        textCurrentAchievements.setText(achievements);
    }

    @Override
    public void showProgress() {
        showProgressBar();
    }

    @Override
    public void hideProgress() {
        hideProgressBar();
    }

    @Override
    public void showError(String message) {
        showDialog(message);
    }

    @Override
    public void onDestroyView() {
        profileOverviewPresenter.cancel();
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/ProfileOverviewPresenter.java
// public interface ProfileOverviewPresenter extends BasePresenter {
// 
//     public void loadProfileData();
// }
// 
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/ProfileOverviewPresenterImpl.java
// public class ProfileOverviewPresenterImpl implements ProfileOverviewPresenter {
// 
//     boolean canceled;
// 
//     private ProfileOverviewView profileOverviewView;
// 
//     private static DecimalFormat decimalFormat = new DecimalFormat("0.##");
// 
//     public ProfileOverviewPresenterImpl(ProfileOverviewView profileOverviewView) {
//         this.profileOverviewView = profileOverviewView;
//     }
// 
//     @Override
//     public void loadProfileData() {
//         canceled = false;
//         profileOverviewView.showProgress();
//         User.getInstance().getUserDonations(findCallback);
//     }
// 
//     private FindCallback<ParseObject> findCallback = new FindCallback<ParseObject>() {
//         @Override
//         public void done(List<ParseObject> parseObjects, ParseException e) {
// 
//             if (parseObjects == null) {
//                 parseObjects = new ArrayList<>();
//             }
// 
//             int donations = parseObjects.size();
//             float liters = donations * User.BLOOD_PER_DONATION_LITERS;
//             float litersNeededForTicket = liters % User.BLOOD_FOR_TICKET_LITERS;
// 
//             int daysToNext = 73; // TODO
// 
//             int achievementNum = 0;
// 
//             if (parseObjects.size() >= 15) {
//                 achievementNum = 4;
//             } else if (parseObjects.size() >= 10) {
//                 achievementNum = 3;
//             } else if (parseObjects.size() >= 5) {
//                 achievementNum = 2;
//             } else if (parseObjects.size() >= 1) {
//                 achievementNum = 1;
//             }
// 
//             profileOverviewView.hideProgress();
//             profileOverviewView.showData(decimalFormat.format(liters), String.valueOf(daysToNext),
//                 String.valueOf(achievementNum), decimalFormat.format(litersNeededForTicket));
//         }
//     };
// 
//     @Override
//     public void cancel() {
//         canceled = true;
//     }
// }
// 
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/ProfileOverviewView.java
// public interface ProfileOverviewView extends BaseView {
// 
//     public void showData(String liters, String daysToNext, String achievements,
//                          String litersToFreeTicket);
// }


// Path: app/src/main/java/hr/foi/rsc/lifeline/fragments/ProfileOverviewFragment.java
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import butterknife.ButterKnife;
import butterknife.InjectView;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.mvp.presenters.ProfileOverviewPresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.ProfileOverviewPresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.ProfileOverviewView;

        return view;
    }

    @Override
    public void showData(String liters, String daysToNext, String achievements,
                         String litersToFreeTicket) {
        textDonatedLitersValue.setText(liters);
        textTicket.setText(litersToFreeTicket);
        textDaysToNext.setText(daysToNext);
        textCurrentAchievements.setText(achievements);
    }

    @Override
    public void showProgress() {
        showProgressBar();
    }

    @Override
    public void hideProgress() {
        hideProgressBar();
    }

    @Override
    public void showError(String message) {
        showDialog(message);
    }

    @Override
    public void onDestroyView() {
        profileOverviewPresenter.cancel();
        super.onDestroyView();