mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 04:25:18 +00:00
42 lines
967 B
Java
42 lines
967 B
Java
|
package org.thoughtcrime.securesms.components;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.support.design.widget.TabLayout;
|
||
|
import android.util.AttributeSet;
|
||
|
import android.view.View;
|
||
|
|
||
|
import java.util.List;
|
||
|
|
||
|
/**
|
||
|
* An implementation of {@link TabLayout} that disables taps when the view is disabled.
|
||
|
*/
|
||
|
public class ControllableTabLayout extends TabLayout {
|
||
|
|
||
|
private List<View> touchables;
|
||
|
|
||
|
public ControllableTabLayout(Context context) {
|
||
|
super(context);
|
||
|
}
|
||
|
|
||
|
public ControllableTabLayout(Context context, AttributeSet attrs) {
|
||
|
super(context, attrs);
|
||
|
}
|
||
|
|
||
|
public ControllableTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||
|
super(context, attrs, defStyleAttr);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void setEnabled(boolean enabled) {
|
||
|
if (isEnabled() && !enabled) {
|
||
|
touchables = getTouchables();
|
||
|
}
|
||
|
|
||
|
for (View touchable : touchables) {
|
||
|
touchable.setClickable(enabled);
|
||
|
}
|
||
|
|
||
|
super.setEnabled(enabled);
|
||
|
}
|
||
|
}
|