Skip to content

Commit 3fa67f0

Browse files
docs: Documented Skeleton
1 parent 867d5ab commit 3fa67f0

File tree

1 file changed

+61
-1
lines changed
  • skeletonlayoutng/src/main/java/dev/enginecrafter77/skeletonlayoutng

1 file changed

+61
-1
lines changed

skeletonlayoutng/src/main/java/dev/enginecrafter77/skeletonlayoutng/Skeleton.java

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,68 @@
1616
*/
1717
package dev.enginecrafter77.skeletonlayoutng;
1818

19+
import androidx.annotation.AnyThread;
20+
21+
/**
22+
* </p>Skeleton is an interface implemented by all classes facilitating the skeleton behavior.</p>
23+
*
24+
* <p>
25+
* In general, skeletons describe an element optimally with a captivating animation that captures
26+
* the user's attention while the underlying element is getting ready to be displayed with all it's
27+
* actual data. Skeletons should visually adhere to the View structure, so that given all skeletons are
28+
* showing, the actual layout composed from the skeletons is visually similar in structure to the actual
29+
* layout after all the skeletons are hidden. In simplest terms, a skeleton might just be a gray strip
30+
* covering TextView while the data that should be displayed by the TextView is being loaded.
31+
* </p>
32+
*
33+
* <p>
34+
* All skeletons should implement 3 methods. {@link #showSkeleton()}, {@link #hideSkeleton()} and {@link #isActive()}.
35+
* These methods should be used to show the skeleton, hide it, and query it's current state respectively.
36+
* </p>
37+
*
38+
* <p>
39+
* Upon skeleton creation, its state is undefined. Therefore, it is a good practice to call either {@link #showSkeleton()} or {@link #hideSkeleton()}
40+
* before the associated screen is displayed to the user.
41+
* </p>
42+
* @author Enginecrafter77
43+
*/
1944
public interface Skeleton {
20-
public boolean isActive();
45+
/**
46+
* <p>
47+
* This method updates the skeleton so that the associated visual element is no longer visible,
48+
* and instead of it there should be a "skeleton" showing (see the definition of skeleton in {@link Skeleton}).
49+
* Further calls to this method should be idempotent.
50+
* </p>
51+
*
52+
* <p>
53+
* Implementations of this method must take into account that there is no guarantee as to from
54+
* which thread the call might originate. Therefore, it is highly advised to use {@link android.os.Handler}
55+
* for any thread-sensitive work.
56+
* </p>
57+
*/
58+
@AnyThread
2159
public void showSkeleton();
60+
61+
/**
62+
* <p>
63+
* This method updates the skeleton so that the skeleton displayed over the visual element
64+
* is dismissed and the underlying visual element becomes visible once more.
65+
* Further calls to this method should be idempotent.
66+
* </p>
67+
*
68+
* <p>
69+
* Implementations of this method must take into account that there is no guarantee as to from
70+
* which thread the call might originate. Therefore, it is highly advised to use {@link android.os.Handler}
71+
* for any thread-sensitive work.
72+
* </p>
73+
*/
74+
@AnyThread
2275
public void hideSkeleton();
76+
77+
/**
78+
* Queries the state of the skeleton.
79+
* @return True if the skeleton is visible, false otherwise.
80+
*/
81+
@AnyThread
82+
public boolean isActive();
2383
}

0 commit comments

Comments
 (0)