That fuck shit the fascists are using
1package org.tm.archive.components;
2
3import android.content.Context;
4import android.util.AttributeSet;
5import android.view.View;
6
7import androidx.annotation.NonNull;
8import androidx.annotation.Nullable;
9
10import com.google.android.material.tabs.TabLayout;
11
12import java.util.List;
13
14/**
15 * An implementation of {@link TabLayout} that disables taps when the view is disabled.
16 */
17public class ControllableTabLayout extends TabLayout {
18
19 private List<View> touchables;
20
21 private NewTabListener newTabListener;
22
23 public ControllableTabLayout(Context context) {
24 super(context);
25 }
26
27 public ControllableTabLayout(Context context, AttributeSet attrs) {
28 super(context, attrs);
29 }
30
31 public ControllableTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
32 super(context, attrs, defStyleAttr);
33 }
34
35 @Override
36 public void setEnabled(boolean enabled) {
37 if (isEnabled() && !enabled) {
38 touchables = getTouchables();
39 }
40
41 for (View touchable : touchables) {
42 touchable.setClickable(enabled);
43 }
44
45 super.setEnabled(enabled);
46 }
47
48 public void setNewTabListener(@Nullable NewTabListener newTabListener) {
49 this.newTabListener = newTabListener;
50 }
51
52 @Override
53 public @NonNull Tab newTab() {
54 Tab tab = super.newTab();
55
56 if (newTabListener != null) {
57 newTabListener.onNewTab(tab);
58 }
59
60 return tab;
61 }
62
63 /**
64 * Allows implementor to modify tabs when they are created, before they are added to the tab layout.
65 * This is useful for loading custom views, to ensure that time is not spent inflating these views
66 * as the user is switching between pages.
67 */
68 public interface NewTabListener {
69 void onNewTab(@NonNull Tab tab);
70 }
71}