导航菜单

页面标题

页面副标题

Tasker v6.5.11 - GeoCoder.java 源代码

正在查看: Tasker v6.5.11 应用的 GeoCoder.java JAVA 源代码文件

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


package net.dinglisch.android.taskerm;

import android.content.Intent;
import android.location.Address;
import android.location.Geocoder;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import java.io.IOException;
import java.util.List;
import java.util.Locale;

public class GeoCoder extends MyActivity {
    private EditText v;
    private ListView w;
    private f x = null;
    private AsyncTask<String, Integer, List<Address>> y = null;

    class a implements AdapterView.OnItemClickListener {
        a() {
        }

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
            Address address = (Address) adapterView.getItemAtPosition(i);
            GeoCoder.this.l0(address.getLatitude(), address.getLongitude());
        }
    }

    class b implements TextWatcher {
        b() {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            GeoCoder.this.m0(editable.toString());
        }

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }
    }

    class c extends f {
        c() {
            super();
        }

        @Override
        public void a(List<Address> list) {
            if (GeoCoder.this.isFinishing() || GeoCoder.this.w == null) {
                return;
            }
            GeoCoder.this.w.setAdapter((ListAdapter) GeoCoder.this.new e(list));
            GeoCoder.this.o0();
        }
    }

    class d extends AsyncTask<String, Integer, List<Address>> {
        d() {
        }

        private boolean c() {
            return (GeoCoder.this.isFinishing() || isCancelled()) ? false : true;
        }

        @Override
        public List<Address> doInBackground(String... strArr) {
            if (c()) {
                try {
                    return new Geocoder(GeoCoder.this, Locale.getDefault()).getFromLocationName(strArr[0], 10);
                } catch (IOException e) {
                    r7.H("GC", "doInBackground", e);
                }
            }
            return null;
        }

        @Override
        public void onPostExecute(List<Address> list) {
            if (list == null || !c() || GeoCoder.this.x == null) {
                return;
            }
            GeoCoder.this.x.a(list);
        }
    }

    public class e extends BaseAdapter {
        private List<Address> i;
        LayoutInflater q;

        class a {
            TextView a;

            a() {
            }
        }

        public e(List<Address> list) {
            this.q = null;
            this.i = list;
            for (int size = list.size() - 1; size >= 0; size--) {
                Address address = this.i.get(size);
                if (!address.hasLatitude() || !address.hasLongitude()) {
                    this.i.remove(size);
                }
            }
            this.q = LayoutInflater.from(GeoCoder.this);
        }

        @Override
        public final int getCount() {
            return this.i.size();
        }

        @Override
        public final Object getItem(int i) {
            return this.i.get(i);
        }

        @Override
        public final long getItemId(int i) {
            return i;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {
            a aVar;
            if (view == null) {
                view = this.q.inflate(2131493240, (ViewGroup) null);
                aVar = new a();
                aVar.a = (TextView) view.findViewById(2131297590);
                view.setTag(aVar);
            } else {
                aVar = (a) view.getTag();
            }
            Address address = this.i.get(i);
            int maxAddressLineIndex = address.getMaxAddressLineIndex();
            StringBuilder sb = new StringBuilder();
            try {
                if (maxAddressLineIndex == 0) {
                    sb.append(address.getAddressLine(0));
                } else {
                    for (int i2 = 0; i2 < maxAddressLineIndex; i2++) {
                        if (sb.length() > 0) {
                            sb.append('\n');
                        }
                        sb.append(address.getAddressLine(i2));
                    }
                }
            } catch (Exception e) {
                r7.H("GC", "loc: getView", e);
            }
            if (sb.length() == 0) {
                sb.append("???");
            }
            aVar.a.setText(sb.toString());
            return view;
        }
    }

    public abstract class f {
        public f() {
        }

        public abstract void a(List<Address> list);
    }

    public void l0(double d2, double d3) {
        Intent intent = new Intent();
        intent.putExtra("lat", d2);
        intent.putExtra("lng", d3);
        setResult(-1, intent);
        finish();
    }

    private void n0() {
        this.w = (ListView) findViewById(2131297057);
        this.v = (EditText) findViewById(2131296345);
        this.w.setOnItemClickListener(new a());
        this.v.addTextChangedListener(new b());
    }

    public void o0() {
        if (this.w.getCount() == 0) {
            this.w.setVisibility(8);
        } else {
            this.w.setVisibility(0);
        }
    }

    public void m0(String str) {
        p0();
        if (str.length() <= 0) {
            this.w.setAdapter((ListAdapter) null);
            return;
        }
        if (this.x == null) {
            this.x = new c();
        }
        d dVar = new d();
        this.y = dVar;
        dVar.execute(str);
    }

    @Override
    public void onCreate(Bundle bundle) {
        setResult(0);
        super.Q(bundle);
        setContentView(2131493239);
        n0();
        o0();
        dq.c3(this, this.v, true, -1, 300L);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.x = null;
        this.w = null;
        this.v = null;
        p0();
    }

    public void p0() {
        AsyncTask<String, Integer, List<Address>> asyncTask = this.y;
        if (asyncTask != null) {
            asyncTask.cancel(true);
            this.y = null;
        }
    }
}