Search in sources :

Example 1 with WeatherActivity

use of com.a5corp.weather.activity.WeatherActivity in project Weather by Sparker0i.

the class WeatherFragment method updateWeatherData.

private void updateWeatherData(final String city, final String lat, final String lon) {
    wt = new FetchWeather(context());
    if (citys == null)
        handler.postDelayed(new Runnable() {

            @Override
            public void run() {
                fabProgressCircle.show();
            }
        }, 50);
    new Thread() {

        public void run() {
            try {
                if (lat == null && lon == null) {
                    json = wt.execute(citys != null ? citys : city).get();
                } else if (city == null) {
                    json = wt.execute(lat, lon).get();
                }
            } catch (InterruptedException iex) {
                Log.e("InterruptedException", "iex");
            } catch (ExecutionException eex) {
                Log.e("ExecutionException", "eex");
            }
            if (pd.isShowing())
                pd.dismiss();
            if (json == null) {
                preferences.setCity(preferences.getLastCity());
                handler.post(new Runnable() {

                    public void run() {
                        GlobalActivity.i = 1;
                        if (!preferences.getLaunched()) {
                            FirstStart();
                        } else {
                            if (citys == null)
                                fabProgressCircle.hide();
                            cc = new CheckConnection(context());
                            if (!cc.isNetworkAvailable()) {
                                showNoInternet();
                            } else {
                                if (pd.isShowing())
                                    pd.dismiss();
                                showInputDialog();
                            }
                        }
                    }
                });
            } else {
                handler.post(new Runnable() {

                    public void run() {
                        preferences.setLaunched();
                        renderWeather(json);
                        if (!preferences.getv3TargetShown())
                            showTargets();
                        if (pd.isShowing())
                            pd.dismiss();
                        if (citys == null) {
                            preferences.setLastCity(json.day.getName() + "," + json.day.getSys().getCountry());
                            ((WeatherActivity) activity()).createShortcuts();
                            progress();
                        } else
                            preferences.setLastCity(preferences.getLastCity());
                        NotificationService.enqueueWork(context(), new Intent(context(), WeatherActivity.class));
                    }
                });
            }
        }
    }.start();
}
Also used : FetchWeather(com.a5corp.weather.internet.FetchWeather) Intent(android.content.Intent) WeatherActivity(com.a5corp.weather.activity.WeatherActivity) ExecutionException(java.util.concurrent.ExecutionException) CheckConnection(com.a5corp.weather.internet.CheckConnection)

Example 2 with WeatherActivity

use of com.a5corp.weather.activity.WeatherActivity in project Weather by Sparker0i.

the class MapsFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    rootView = inflater.inflate(R.layout.fragment_maps, container, false);
    webView = (WebView) rootView.findViewById(R.id.webView);
    prefs = new Prefs(getContext());
    ((WeatherActivity) getActivity()).hideFab();
    loadMap();
    return rootView;
}
Also used : WeatherActivity(com.a5corp.weather.activity.WeatherActivity) Prefs(com.a5corp.weather.preferences.Prefs)

Aggregations

WeatherActivity (com.a5corp.weather.activity.WeatherActivity)2 Intent (android.content.Intent)1 CheckConnection (com.a5corp.weather.internet.CheckConnection)1 FetchWeather (com.a5corp.weather.internet.FetchWeather)1 Prefs (com.a5corp.weather.preferences.Prefs)1 ExecutionException (java.util.concurrent.ExecutionException)1