导航菜单

页面标题

页面副标题

Hyouka private v5.8.9 - MapLocationPicker.java 源代码

正在查看: Hyouka private v5.8.9 应用的 MapLocationPicker.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.beint.project.screens.sms;

import android.R;
import android.annotation.SuppressLint;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.beint.project.core.services.impl.SignalingService;
import com.beint.project.core.utils.ZangiPermissionUtils;
import com.beint.project.huawei.map.ZMap;
import com.beint.project.huawei.map.ZMapKitDelegate;
import com.beint.project.huawei.map.ZOnCameraIdleListener;
import com.beint.project.huawei.map.ZOnMapCameraMoveStartedListener;
import com.beint.project.huawei.map.ZOnMapClickListener;
import com.beint.project.screens.ConversationManager;
import com.beint.project.utils.ProjectUtils;
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;

public class MapLocationPicker extends AppModeNotifierActivity implements View.OnClickListener, ZMapKitDelegate {
    static final String TAG = "com.beint.project.screens.sms.MapLocationPicker";
    private Location currentLocation;
    e5.d mCurrLocationMarker;
    private ZMap mMap;
    private ImageView markerImage;
    private FloatingActionButton myLocationButton;
    private LocationManager myLocationManager;
    private FloatingActionButton sendLocationButton;
    private TextView sendLocationTextView;
    private TextView targetlocation;
    private double latitude = 0.0d;
    private double longitude = 0.0d;
    private String addres = "";
    private float markerTranslationY = ProjectUtils.dpToPx(8);
    private long markerTranslationDuration = 140;
    private boolean afterMyLocationButtonClick = true;
    private View.OnClickListener myLocationButtonListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (MapLocationPicker.this.mMap != null) {
                MapLocationPicker.this.afterMyLocationButtonClick = true;
                MapLocationPicker.this.mMap.animateCamera(MapLocationPicker.this.latitude, MapLocationPicker.this.longitude, MapLocationPicker.this.mMap.getMaxZoomLevel() - 3.0f);
                try {
                    if (SignalingService.INSTANCE.isRegistered()) {
                        List<Address> fromLocation = new Geocoder(MapLocationPicker.this, Locale.getDefault()).getFromLocation(MapLocationPicker.this.latitude, MapLocationPicker.this.longitude, 1);
                        if (fromLocation == null || fromLocation.size() <= 0) {
                            MapLocationPicker.this.targetlocation.setText(MapLocationPicker.this.getText(2131886483));
                        } else {
                            Address address = fromLocation.get(0);
                            StringBuilder sb = new StringBuilder("");
                            MapLocationPicker.this.sendLocationTextView.setText(MapLocationPicker.this.getText(2131887344));
                            MapLocationPicker mapLocationPicker = MapLocationPicker.this;
                            sb.append(address.getAddressLine(0));
                            sb.append(MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR);
                            mapLocationPicker.addres = sb.toString();
                            MapLocationPicker.this.targetlocation.setText(MapLocationPicker.this.addres);
                        }
                    } else {
                        MapLocationPicker.this.targetlocation.setText(MapLocationPicker.this.getText(2131886483));
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                    MapLocationPicker.this.targetlocation.setText(MapLocationPicker.this.getText(2131886483));
                }
            }
        }
    };

    private void animateMarker(float f) {
        this.markerImage.animate().setDuration(this.markerTranslationDuration).translationYBy(f).start();
    }

    @SuppressLint({"MissingPermission"})
    private void init() {
        ZMap zMap = new ZMap(this, 2131362957);
        this.mMap = zMap;
        zMap.getMapAsync(this);
        this.myLocationButton.setOnClickListener(this.myLocationButtonListener);
    }

    public void lambda$onCreate$0(ArrayList arrayList, boolean z) {
        if (z) {
            init();
        } else {
            finish();
        }
    }

    public void lambda$onMapReady$2(double d, double d7) {
        ZMap zMap = this.mMap;
        zMap.animateCamera(d, d7, zMap.getMaxZoomLevel() - 3.0f);
    }

    public void lambda$onMapReady$3() {
        animateMarker(this.markerTranslationY);
    }

    public void lambda$onMapReady$4() {
        animateMarker(-this.markerTranslationY);
    }

    public void lambda$setOnCameraIdleListener$1() {
        try {
            double latitude = this.mMap.getLatitude();
            double longitude = this.mMap.getLongitude();
            if (SignalingService.INSTANCE.isRegistered()) {
                List<Address> fromLocation = new Geocoder(this, Locale.getDefault()).getFromLocation(latitude, longitude, 1);
                if (fromLocation == null || fromLocation.size() <= 0) {
                    this.targetlocation.setText(getText(2131886483));
                } else {
                    String str = "" + fromLocation.get(0).getAddressLine(0) + MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR;
                    this.addres = str;
                    this.targetlocation.setText(str);
                    if (this.afterMyLocationButtonClick) {
                        this.afterMyLocationButtonClick = false;
                        this.sendLocationTextView.setText(getText(2131887344));
                    } else {
                        this.sendLocationTextView.setText(getText(2131887373));
                    }
                }
            } else {
                this.targetlocation.setText(getText(2131886483));
            }
        } catch (IOException e) {
            e.printStackTrace();
            this.targetlocation.setText(getText(2131886483));
        }
    }

    @SuppressLint({"MissingPermission"})
    private Location loadLocation() {
        List<String> providers = this.myLocationManager.getProviders(true);
        if (providers == null) {
            return null;
        }
        Location location = this.currentLocation;
        long time = location == null ? 0L : location.getTime();
        Iterator<String> it = providers.iterator();
        while (it.hasNext()) {
            Location lastKnownLocation = this.myLocationManager.getLastKnownLocation(it.next());
            if (lastKnownLocation != null && lastKnownLocation.getTime() > time) {
                this.currentLocation = lastKnownLocation;
                time = lastKnownLocation.getTime();
            }
        }
        return this.currentLocation;
    }

    private void setOnCameraIdleListener() {
        this.mMap.setOnCameraIdleListener(new ZOnCameraIdleListener() {
            public final void onCameraIdle() {
                MapLocationPicker.this.lambda$setOnCameraIdleListener$1();
            }
        });
    }

    @Override
    public void onClick(View view) {
        if (view.getId() != 2131363599) {
            return;
        }
        sendLocationClickFunctional();
    }

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(2131558573);
        View findViewById = findViewById(2131363849);
        if (findViewById != null) {
            findViewById.setVisibility(8);
        }
        this.myLocationManager = (LocationManager) getSystemService("location");
        setSupportActionBar(findViewById(2131363848));
        getSupportActionBar().v(false);
        getSupportActionBar().q(true);
        getSupportActionBar().r(true);
        getSupportActionBar().w(2131886804);
        this.targetlocation = (TextView) findViewById(2131363781);
        this.sendLocationTextView = (TextView) findViewById(2131363600);
        this.myLocationButton = (FloatingActionButton) findViewById(2131363090);
        this.markerImage = (ImageView) findViewById(2131362962);
        FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(2131363599);
        this.sendLocationButton = floatingActionButton;
        floatingActionButton.setOnClickListener(this);
        if (ZangiPermissionUtils.hasPermission(this, 1005, true, new ZangiPermissionUtils.OnPermissionResult() {
            public final void onResult(ArrayList arrayList, boolean z) {
                MapLocationPicker.this.lambda$onCreate$0(arrayList, z);
            }
        })) {
            init();
        }
        ConversationManager conversationManager = ConversationManager.INSTANCE;
        if (conversationManager.getActivity() != null) {
            conversationManager.setMapLocationPickerActivity(new WeakReference<>(this));
        }
    }

    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(2131689489, menu);
        return super/*android.app.Activity*/.onCreateOptionsMenu(menu);
    }

    public void onLocationChanged(Location location) {
    }

    public void onMapReady() {
        Location loadLocation = loadLocation();
        if (loadLocation != null) {
            this.latitude = loadLocation.getLatitude();
            this.longitude = loadLocation.getLongitude();
        }
        ZMap zMap = this.mMap;
        if (zMap != null) {
            zMap.moveCamera(this.latitude, this.longitude, zMap.getMaxZoomLevel() - 3.0f);
            this.mMap.setMyLocationEnabled(true);
            this.mMap.setMyLocationButtonEnabled(false);
            try {
                if (SignalingService.INSTANCE.isRegistered()) {
                    List<Address> fromLocation = new Geocoder(this, Locale.getDefault()).getFromLocation(this.latitude, this.longitude, 1);
                    if (fromLocation == null || fromLocation.size() <= 0) {
                        this.targetlocation.setText(getText(2131886483));
                    } else {
                        String str = "" + fromLocation.get(0).getAddressLine(0) + MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR;
                        this.addres = str;
                        this.targetlocation.setText(str);
                    }
                } else {
                    this.targetlocation.setText(getText(2131886483));
                }
            } catch (IOException e) {
                e.printStackTrace();
                this.targetlocation.setText(getText(2131886483));
            }
            setOnCameraIdleListener();
            this.mMap.setOnMapClickListener(new ZOnMapClickListener() {
                public final void onMapClick(double d, double d7) {
                    MapLocationPicker.this.lambda$onMapReady$2(d, d7);
                }
            });
            this.mMap.setOnCameraIdleListener(new ZOnCameraIdleListener() {
                public final void onCameraIdle() {
                    MapLocationPicker.this.lambda$onMapReady$3();
                }
            });
            this.mMap.setOnCameraMoveStartedListener(new ZOnMapCameraMoveStartedListener() {
                public final void setOnCameraMoveStartedListener() {
                    MapLocationPicker.this.lambda$onMapReady$4();
                }
            });
        }
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        switch (menuItem.getItemId()) {
            case R.id.home:
                finish();
                break;
            case 2131362652:
                this.mMap.setMapType(4);
                break;
            case 2131362956:
                this.mMap.setMapType(1);
                break;
            case 2131363487:
                this.mMap.setMapType(2);
                break;
        }
        return super/*android.app.Activity*/.onOptionsItemSelected(menuItem);
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    public void sendLocationClickFunctional() {
        double latitude;
        double longitude;
        ZMap zMap = this.mMap;
        if (zMap != null) {
            if (zMap.getLatitude() == 0.0d) {
                latitude = this.latitude;
                longitude = this.longitude;
            } else {
                latitude = this.mMap.getLatitude();
                longitude = this.mMap.getLongitude();
            }
            ConversationManager.INSTANCE.sendLocation(latitude, longitude);
        }
        finish();
    }
}