Tools: context=


Download 1.5 Mb.
bet3/5
Sana27.03.2023
Hajmi1.5 Mb.
#1300986
1   2   3   4   5
Bog'liq
apk

/**
* Calculates the totalTime value from all elements in
* the current ToDay
*/
public void recalculateTotalTime() {
totalTime=0;
for (ToDayElement element: childToDayElements) {
totalTime=totalTime + element.getTimeEstimate();
}
}


/** Overriding of original toString() because its natural
* implementation is no bueno!
*
* @return ToDay
*/
@Override
public String toString() {
return "ToDay{" +
"childToDayElements=" + childToDayElements +
", completionTokens='" + completionTokens+
", uuid=" + uuid +
", name='" + name +
", totalTime=" + totalTime +
'}';
}

public String pingStats() {


return "Number of Elements: " + this.getChildCount() +
"\n Estimated Time: " + this.getFormattedTime() +
"\n Times completed: " + this.getCompletionTokens();
}

public ArrayList buildStatsExportList() {


ArrayList temp = new ArrayList<>();

temp.add(this.getName());


temp.add(String.valueOf(this.getChildCount()));
temp.add(String.valueOf(this.getHours()));
temp.add(String.valueOf(this.getMinutes()));
temp.add(String.valueOf(this.getCompletionTokens()));
temp.add(
String.valueOf(
AppUtils.calcHours(
this.getLifeTimeInToDay()
)
)
);
return temp;
}

public void addToLifeTimeStats(int statToAdd) {


lifeTimeInToDay = lifeTimeInToDay + statToAdd;
}
/* ~~~~~~~~~~~~ PARCEL IMPLEMENTATION ~~~~~~~~~~*/
// Parcel Implementation to pass data from the Stream to the Sandbox about
// the current ToDay object.
// Still need to make method to calculate the total time for the ToDay based on elements
// The order of READING and WRITING is important (Read and write in same order)
private ToDay(Parcel in) {
String[] data = new String[4];
// data[0] = name
// data[1] = totalTime
// data[2] = uuid
// data[3] = completionTokens

in.readStringArray(data);


this.name = data[0];
this.totalTime = Integer.parseInt(data[1]);
this.uuid = data[2];
this.completionTokens = Integer.parseInt(data[3]);
in.readList(childToDayElements,getClass().getClassLoader());

/* Similar implementation:


this.name = parcel.readString();
this.totalTime= parcel.readString();
this.ToDayManagerIndex = parcel.readString();
this.childToDayElements = parcel.readArrayList(null);
*/

}

@Override


public int describeContents() {
return 0;
}

@Override


public void writeToParcel(Parcel destination, int flags) {
/* Similar implementation:
dest.writeString(this.name);
dest.writeString(this.totalTime);
dest.writeString(this.ToDayManagerIndex);
dest.writeList(childToDayElements);
*/
destination.writeStringArray(
new String[] {
this.name,
String.valueOf(this.totalTime),
this.uuid,
String.valueOf(this.completionTokens)

}
);


destination.writeList(this.childToDayElements);
// Writes the childToDayElements to the parcel
}

public static final Parcelable.Creator CREATOR =


new Parcelable.Creator() {

@Override


public ToDay createFromParcel(Parcel source) {
return new ToDay(source);
//Using Parcelable constructor
}

@Override


public ToDay[] newArray(int size) {
return new ToDay[size];
}
};

public ToDayElement find(ToDayElement elementToFind) {


return this.childToDayElements.get(
this.childToDayElements.indexOf(elementToFind)
);
}

}

package mn.today;



import android.content.Context;
import android.content.res.TypedArray;
import android.support.v4.content.ContextCompat;


Download 1.5 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling