That fuck shit the fascists are using
at master 84 lines 2.8 kB view raw
1package org.tm.archive.maps; 2 3import android.content.Context; 4import android.location.Location; 5import android.text.TextUtils; 6import android.util.AttributeSet; 7import android.view.View; 8import android.widget.ProgressBar; 9import android.widget.TextView; 10 11import androidx.annotation.NonNull; 12import androidx.annotation.Nullable; 13import androidx.coordinatorlayout.widget.CoordinatorLayout; 14 15import com.google.android.material.bottomsheet.BottomSheetBehavior; 16 17import org.tm.archive.R; 18 19import java.util.Locale; 20 21final class SingleAddressBottomSheet extends CoordinatorLayout { 22 23 private TextView placeNameTextView; 24 private TextView placeAddressTextView; 25 private ProgressBar placeProgressBar; 26 private BottomSheetBehavior<View> bottomSheetBehavior; 27 28 public SingleAddressBottomSheet(@NonNull Context context) { 29 super(context); 30 init(); 31 } 32 33 public SingleAddressBottomSheet(@NonNull Context context, @Nullable AttributeSet attrs) { 34 super(context, attrs); 35 init(); 36 } 37 38 public SingleAddressBottomSheet(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 39 super(context, attrs, defStyleAttr); 40 init(); 41 } 42 43 private void init() { 44 CoordinatorLayout rootView = (CoordinatorLayout) inflate(getContext(), R.layout.activity_map_bottom_sheet_view, this); 45 46 bottomSheetBehavior = BottomSheetBehavior.from(rootView.findViewById(R.id.root_bottom_sheet)); 47 bottomSheetBehavior.setHideable(true); 48 bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); 49 50 bindViews(); 51 } 52 53 private void bindViews() { 54 placeNameTextView = findViewById(R.id.text_view_place_name); 55 placeAddressTextView = findViewById(R.id.text_view_place_address); 56 placeProgressBar = findViewById(R.id.progress_bar_place); 57 } 58 59 public void showLoading() { 60 bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); 61 placeNameTextView.setText(""); 62 placeAddressTextView.setText(""); 63 placeProgressBar.setVisibility(View.VISIBLE); 64 } 65 66 public void showResult(double latitude, double longitude, String addressToShortString, String addressToString) { 67 bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); 68 placeProgressBar.setVisibility(View.GONE); 69 70 if (TextUtils.isEmpty(addressToString)) { 71 String longString = Location.convert(longitude, Location.FORMAT_DEGREES); 72 String latString = Location.convert(latitude, Location.FORMAT_DEGREES); 73 74 placeNameTextView.setText(String.format(Locale.getDefault(), "%s %s", latString, longString)); 75 } else { 76 placeNameTextView.setText(addressToShortString); 77 placeAddressTextView.setText(addressToString); 78 } 79 } 80 81 public void hide() { 82 bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); 83 } 84}