Merge "Update Kotlin sample code for CountDownTimer and Parcelable" am: 598675abef

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1673235

Change-Id: Ia6c7d8965190b905b393d0d51fcaac2f651ef8fb
This commit is contained in:
Jing Ji
2021-04-19 19:28:23 +00:00
committed by Automerger Merge Worker
3 changed files with 53 additions and 9 deletions

View File

@@ -22,7 +22,22 @@ package android.os;
*
* Example of showing a 30 second countdown in a text field:
*
* <pre class="prettyprint">
* <div>
* <div class="ds-selector-tabs"><section><h3 id="kotlin">Kotlin</h3>
* <pre class="prettyprint lang-kotlin">
* object : CountDownTimer(30000, 1000) {
*
* override fun onTick(millisUntilFinished: Long) {
* mTextField.setText("seconds remaining: " + millisUntilFinished / 1000)
* }
*
* override fun onFinish() {
* mTextField.setText("done!")
* }
* }.start()
* </pre>
* </section><section><h3 id="java">Java</h3>
* <pre class="prettyprint lang-java">
* new CountDownTimer(30000, 1000) {
*
* public void onTick(long millisUntilFinished) {
@@ -32,8 +47,8 @@ package android.os;
* public void onFinish() {
* mTextField.setText("done!");
* }
* }.start();
* </pre>
* }.start();
* </pre></section></div></div>
*
* The calls to {@link #onTick(long)} are synchronized to this object so that
* one call to {@link #onTick(long)} won't ever occur before the previous

View File

@@ -623,7 +623,7 @@ public final class Debug
* </tr>
* <tr>
* <td>summary.total-pss</td>
* <td>Total PPS memory usage in kB.</td>
* <td>Total PSS memory usage in kB.</td>
* <td>{@code 1442}</td>
* <td>23</td>
* </tr>

View File

@@ -27,10 +27,39 @@ import java.lang.annotation.RetentionPolicy;
* and restored from a {@link Parcel}. Classes implementing the Parcelable
* interface must also have a non-null static field called <code>CREATOR</code>
* of a type that implements the {@link Parcelable.Creator} interface.
*
*
* <p>A typical implementation of Parcelable is:</p>
*
* <pre>
*
* <div>
* <div class="ds-selector-tabs"><section><h3 id="kotlin">Kotlin</h3>
* <pre class="prettyprint lang-kotlin">
* class MyParcelable private constructor(`in`: Parcel) : Parcelable {
* private val mData: Int = `in`.readInt()
*
* override fun describeContents(): Int {
* return 0
* }
*
* override fun writeToParcel(out: Parcel, flags: Int) {
* out.writeInt(mData)
* }
*
* companion object {
* val CREATOR: Parcelable.Creator&lt;MyParcelable?&gt;
* = object : Parcelable.Creator&lt;MyParcelable?&gt; {
* override fun createFromParcel(`in`: Parcel): MyParcelable? {
* return MyParcelable(`in`)
* }
*
* override fun newArray(size: Int): Array&lt;MyParcelable?&gt; {
* return arrayOfNulls(size)
* }
* }
* }
* }
* </pre>
* </section><section><h3 id="java">Java</h3>
* <pre class="prettyprint lang-java">
* public class MyParcelable implements Parcelable {
* private int mData;
*
@@ -52,11 +81,11 @@ import java.lang.annotation.RetentionPolicy;
* return new MyParcelable[size];
* }
* };
*
*
* private MyParcelable(Parcel in) {
* mData = in.readInt();
* }
* }</pre>
* }</pre></section></div></div>
*/
public interface Parcelable {
/** @hide */