That fuck shit the fascists are using
at master 89 lines 2.6 kB view raw
1package org.tm.archive.components; 2 3import android.content.Context; 4import android.util.AttributeSet; 5import android.view.View; 6import android.widget.TextView; 7 8import androidx.annotation.NonNull; 9import androidx.annotation.Nullable; 10import androidx.constraintlayout.widget.ConstraintLayout; 11 12import org.tm.archive.R; 13 14/** 15 * Bottom navigation bar shown in the {@link org.tm.archive.conversation.ConversationActivity} 16 * when the user is searching within a conversation. Shows details about the results and allows the 17 * user to move between them. 18 */ 19public class ConversationSearchBottomBar extends ConstraintLayout { 20 21 private View searchDown; 22 private View searchUp; 23 private TextView searchPositionText; 24 private View progressWheel; 25 26 private EventListener eventListener; 27 28 29 public ConversationSearchBottomBar(Context context) { 30 super(context); 31 } 32 33 public ConversationSearchBottomBar(Context context, AttributeSet attrs) { 34 super(context, attrs); 35 } 36 37 @Override 38 protected void onFinishInflate() { 39 super.onFinishInflate(); 40 41 this.searchUp = findViewById(R.id.conversation_search_up); 42 this.searchDown = findViewById(R.id.conversation_search_down); 43 this.searchPositionText = findViewById(R.id.conversation_search_position); 44 this.progressWheel = findViewById(R.id.conversation_search_progress_wheel); 45 } 46 47 public void setData(int position, int count) { 48 progressWheel.setVisibility(GONE); 49 50 searchUp.setOnClickListener(v -> { 51 if (eventListener != null) { 52 eventListener.onSearchMoveUpPressed(); 53 } 54 }); 55 56 searchDown.setOnClickListener(v -> { 57 if (eventListener != null) { 58 eventListener.onSearchMoveDownPressed(); 59 } 60 }); 61 62 if (count > 0) { 63 searchPositionText.setText(getResources().getString(R.string.ConversationActivity_search_position, position + 1, count)); 64 } else { 65 searchPositionText.setText(R.string.ConversationActivity_no_results); 66 } 67 68 setViewEnabled(searchUp, position < (count - 1)); 69 setViewEnabled(searchDown, position > 0); 70 } 71 72 public void showLoading() { 73 progressWheel.setVisibility(VISIBLE); 74 } 75 76 private void setViewEnabled(@NonNull View view, boolean enabled) { 77 view.setEnabled(enabled); 78 view.setAlpha(enabled ? 1f : 0.25f); 79 } 80 81 public void setEventListener(@Nullable EventListener eventListener) { 82 this.eventListener = eventListener; 83 } 84 85 public interface EventListener { 86 void onSearchMoveUpPressed(); 87 void onSearchMoveDownPressed(); 88 } 89}