Skip to content

Commit

Permalink
add content loader view banner
Browse files Browse the repository at this point in the history
  • Loading branch information
eriffanani committed Jun 21, 2022
1 parent fefedd3 commit 7dea576
Show file tree
Hide file tree
Showing 24 changed files with 698 additions and 362 deletions.
5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@
import java.util.ArrayList;
import java.util.List;

public class ContentLoader extends FrameLayout {
public class ContentLoaderFrameLayout extends FrameLayout {

private Animation animLoader;
private Animation animContentShow;
private Animation animContentHide;
private final List<View> childViews = new ArrayList<>();
private int duration = 0;

public ContentLoader(@NonNull Context context) {
public ContentLoaderFrameLayout(@NonNull Context context) {
super(context);
init(context, null, 0, 0);
}

public ContentLoader(@NonNull Context context, @Nullable AttributeSet attrs) {
public ContentLoaderFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context, attrs, 0, 0);
}

public ContentLoader(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
public ContentLoaderFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, null, defStyleAttr, 0);
}

public ContentLoader(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
public ContentLoaderFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context, attrs, defStyleAttr, defStyleRes);
}
Expand All @@ -48,12 +48,12 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr, int def
animContentHide = AnimationUtils.loadAnimation(context, R.anim.anim_loader_hide_content);
if (attrs != null) {
TypedArray typedArray = context.getTheme().obtainStyledAttributes(
attrs, R.styleable.ContentLoader, defStyleAttr, defStyleRes
attrs, R.styleable.ContentLoaderFrameLayout, defStyleAttr, defStyleRes
);
boolean autoStart;
try {
autoStart = typedArray.getBoolean(R.styleable.ContentLoader_android_autoStart, false);
duration = typedArray.getInt(R.styleable.ContentLoader_android_duration, 600);
autoStart = typedArray.getBoolean(R.styleable.ContentLoaderFrameLayout_android_autoStart, false);
duration = typedArray.getInt(R.styleable.ContentLoaderFrameLayout_android_duration, 600);
animLoader.setDuration(duration);
} finally {
typedArray.recycle();
Expand All @@ -64,19 +64,19 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr, int def
}
}

void start() {
public void start() {
if (!isShown())
setVisibility(VISIBLE);
if (duration > 200)
playAnim();
}

void startAndHideContent(View contentView) {
public void startAndHideContent(View contentView) {
start();
contentView.setVisibility(GONE);
}

void startAndHideContent(View contentView, boolean smooth) {
public void startAndHideContent(View contentView, boolean smooth) {
start();
if (smooth) {
animContentHide.setAnimationListener(new Animation.AnimationListener() {
Expand All @@ -91,7 +91,7 @@ public void onAnimationRepeat(Animation animation) {}
}
}

void stop() {
public void stop() {
for (View child: childViews) {
if (child != null) {
if (child.getAnimation() != null) {
Expand All @@ -112,12 +112,12 @@ public void onAnimationRepeat(Animation animation) {}
startAnimation(animHideLoader);
}

void stopAndShowContent(View contentView) {
public void stopAndShowContent(View contentView) {
stop();
contentView.setVisibility(VISIBLE);
}

void stopAndShowContent(View contentView, boolean smooth) {
public void stopAndShowContent(View contentView, boolean smooth) {
stopAndShowContent(contentView);
if (smooth) {
contentView.startAnimation(animContentShow);
Expand Down

This file was deleted.

Loading

0 comments on commit 7dea576

Please sign in to comment.