From 5ee2fb3bc9fd96a992d2734e15f1476a2a1be10b Mon Sep 17 00:00:00 2001 From: miguelf03kai Date: Sat, 6 Jan 2024 18:31:07 -0300 Subject: [PATCH] Revert "Included feature no internet connection handler" This reverts commit c0a4028830748604d7c0e710f1823ded72843eba. --- .idea/vcs.xml | 2 +- app/src/main/AndroidManifest.xml | 1 - app/src/main/ic_no_connection-web.png | Bin 13393 -> 0 bytes .../miguelf03kai/weatherapp/MainActivity.java | 247 +++++++----------- .../weatherapp/utils/Connection.java | 16 -- app/src/main/res/layout/activity_main.xml | 36 --- .../main/res/mipmap-hdpi/ic_no_connection.png | Bin 1005 -> 0 bytes .../main/res/mipmap-mdpi/ic_no_connection.png | Bin 708 -> 0 bytes .../res/mipmap-xhdpi/ic_no_connection.png | Bin 1421 -> 0 bytes .../res/mipmap-xxhdpi/ic_no_connection.png | Bin 2389 -> 0 bytes .../res/mipmap-xxxhdpi/ic_no_connection.png | Bin 3442 -> 0 bytes 11 files changed, 95 insertions(+), 207 deletions(-) delete mode 100644 app/src/main/ic_no_connection-web.png delete mode 100644 app/src/main/java/com/miguelf03kai/weatherapp/utils/Connection.java delete mode 100644 app/src/main/res/mipmap-hdpi/ic_no_connection.png delete mode 100644 app/src/main/res/mipmap-mdpi/ic_no_connection.png delete mode 100644 app/src/main/res/mipmap-xhdpi/ic_no_connection.png delete mode 100644 app/src/main/res/mipmap-xxhdpi/ic_no_connection.png delete mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_no_connection.png diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 6564d52..94a25f7 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 53e3bae..90005f9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,7 +6,6 @@ - 3`F{V1@BMQ3dcL0Hv7V28IBm`Q3}-H$0RVsjt*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ccH&oY36hy2xJ8(p)jJOGw6 z4(pmkqd6>h)%zj<{K!DiiwwFpgSavQ!)++G719F5`(m;3Q_53H0I;A1_gU2E+QO=s z2D|`(V^zdR+`D(%doZe_^;7ib6#*G;^@C-K#D`BMckFt6Z`?y;FoFxXkFFQq)}ZLw3nXeD$OX$n|4sQv9ibaDhJm`K zBc&v_Vi|sI5)Dqp)YPM^mFI5YOpvwPtI+xYer;P{#39<@YDqdFYA;Z_LgS@L_3&9J f!1@2@^Kd7SXVl2NSE=hB87cH#O_jpiX2Jgl{mwfa diff --git a/app/src/main/java/com/miguelf03kai/weatherapp/MainActivity.java b/app/src/main/java/com/miguelf03kai/weatherapp/MainActivity.java index dde3225..2aa97e2 100644 --- a/app/src/main/java/com/miguelf03kai/weatherapp/MainActivity.java +++ b/app/src/main/java/com/miguelf03kai/weatherapp/MainActivity.java @@ -5,9 +5,6 @@ import android.location.Geocoder; import android.location.Location; import android.location.LocationManager; -import android.net.ConnectivityManager; -import android.net.NetworkInfo; -import android.os.Handler; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; @@ -16,7 +13,6 @@ import android.util.Log; import android.view.View; import android.view.WindowManager; -import android.widget.Button; import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.RelativeLayout; @@ -31,7 +27,6 @@ import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.miguelf03kai.weatherapp.cards.CardView; -import com.miguelf03kai.weatherapp.utils.Connection; import com.miguelf03kai.weatherapp.utils.Formatter; import com.miguelf03kai.weatherapp.apis.WeatherAPI; import com.miguelf03kai.weatherapp.utils.Localization; @@ -41,7 +36,6 @@ import org.json.JSONException; import org.json.JSONObject; -import java.sql.ResultSetMetaData; import java.util.ArrayList; import java.util.Locale; @@ -52,13 +46,7 @@ public class MainActivity extends AppCompatActivity { private ImageView conditionIconImageView, backgroundImageView; private TextView degreeTextView, conditionTextView, cityTextView, regionTextView, countryTextView, localTimeTextView; private SearchView searchView; - private RelativeLayout contentRelativeLayout, noConnectionRelativeLayout; - - private Button btnTryAgain; - ConnectivityManager connectivityManager; - boolean connected; - - Handler handler; + private RelativeLayout contentRelativeLayout; ArrayList time, temp, speed, image; @@ -91,7 +79,6 @@ protected void onCreate(Bundle savedInstanceState) { loaderProgressBar = (ProgressBar)findViewById(R.id.loaderProgressBar); contentRelativeLayout = (RelativeLayout)findViewById(R.id.contentRelativeLayout); - noConnectionRelativeLayout = (RelativeLayout)findViewById(R.id.noConnectionRelativeLayout); searchView = (SearchView)findViewById(R.id.searchView); degreeTextView = (TextView)findViewById(R.id.deqreeTextView); conditionTextView = (TextView)findViewById(R.id.conditionTextView); @@ -102,10 +89,6 @@ protected void onCreate(Bundle savedInstanceState) { backgroundImageView = (ImageView)findViewById(R.id.backgroundImageView); localTimeTextView = (TextView)findViewById(R.id.localTimeTextView); - btnTryAgain = (Button)findViewById(R.id.button); - - handler = new Handler(); - recyclerView = (RecyclerView)findViewById(R.id.cardsRecycleView); recyclerView.setHasFixedSize(true); layoutManagerRecycleView = new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false); @@ -119,10 +102,27 @@ protected void onCreate(Bundle savedInstanceState) { // Used for controlling location updates locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); - // Request location permissions from device and access location - getLocation(); + // Check permission for location api + if(ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != + PackageManager.PERMISSION_GRANTED && + ActivityCompat.checkSelfPermission(this,android.Manifest.permission. + ACCESS_COARSE_LOCATION) != + PackageManager.PERMISSION_GRANTED){ + // Ask for permission + ActivityCompat.requestPermissions(MainActivity.this, + new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION, + android.Manifest.permission.ACCESS_COARSE_LOCATION}, + PERMISSION_CODE); + } - checkConnection(); + try { + /* This takes last location provided by network, if not have no information about location, + will be returned null */ + location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + } + catch (Exception ex){ + Log.i("PERMISSION ERROR", ex.getMessage()); + } if(location != null) cityName = localization.getCityName(location.getLongitude(), location.getLatitude(), @@ -139,7 +139,6 @@ public boolean onQueryTextSubmit(String query) { contentRelativeLayout.setVisibility(View.GONE); loaderProgressBar.setVisibility(View.VISIBLE); - cityName = query; getAndShowWeatherData(weatherAPI.requestUrl(query)); return false; } @@ -149,16 +148,6 @@ public boolean onQueryTextChange(String newText) { return false; } }); - - btnTryAgain.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - noConnectionRelativeLayout.setVisibility(View.GONE); - loaderProgressBar.setVisibility(View.VISIBLE); - getLocation(); - getAndShowWeatherData(weatherAPI.requestUrl(cityName)); - } - }); } // Handle user choice @@ -175,131 +164,83 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in } } - void getLocation(){ - // Check permission for location api - if(ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != - PackageManager.PERMISSION_GRANTED && - ActivityCompat.checkSelfPermission(this,android.Manifest.permission. - ACCESS_COARSE_LOCATION) != - PackageManager.PERMISSION_GRANTED){ - // Ask for permission - ActivityCompat.requestPermissions(MainActivity.this, - new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION, - android.Manifest.permission.ACCESS_COARSE_LOCATION}, - PERMISSION_CODE); - } + void getAndShowWeatherData(String url){ + RequestQueue queue = Volley.newRequestQueue(MainActivity.this); + formatter = new Formatter(); - try { - /* This takes last location provided by network, if not have no information about location, - will be returned null */ - location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); - } - catch (Exception ex){ - Log.i("PERMISSION ERROR", ex.getMessage()); - } - } + JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, + new Response.Listener() { + @Override + public void onResponse(JSONObject response) { + // Hide progress bar. + loaderProgressBar.setVisibility(View.GONE); + // Show app content + contentRelativeLayout.setVisibility(View.VISIBLE); + try { + // Get JSON objects from server response + JSONObject location = response.getJSONObject("location"); + JSONObject current = response.getJSONObject("current"); + JSONObject forecastday = response.getJSONObject("forecast").getJSONArray("forecastday") + .getJSONObject(0); + JSONArray hour = forecastday.getJSONArray("hour"); + + // Setting data to all views. + cityTextView.setText(location.getString("name")); + degreeTextView.setText(current.getString("temp_c")+"°c"); + conditionTextView.setText(current.getJSONObject("condition").getString("text")); + regionTextView.setText(location.getString("region")); + countryTextView.setText(location.getString("country")); + localTimeTextView.setText(formatter.dateTimeFormatting(location.getString("localtime"))); + + // Load the image from url using picasso library. + if(current.getInt("is_day") == 0) + Picasso.with(MainActivity.this).load(nightBG).into(backgroundImageView); + else + Picasso.with(MainActivity.this).load(dayBG).into(backgroundImageView); + + Picasso.with(MainActivity.this).load("https:"+current.getJSONObject("condition") + .getString("icon")) + .into(conditionIconImageView); + + time = new ArrayList<>(); + temp = new ArrayList<>(); + speed = new ArrayList<>(); + image = new ArrayList<>(); + + for(int i = 0;i < hour.length();i++){ + JSONObject hourObj = hour.getJSONObject(i); + String timeObj = hourObj.getString("time"); + String temperature = hourObj.getString("temp_c"); + String imageObj = "https:"+hourObj.getJSONObject("condition").getString("icon"); + String wind = hourObj.getString("wind_kph"); + + time.add(timeObj); + temp.add(temperature); + speed.add(wind); + image.add(imageObj); + } + + adapterRecycleView = new CardView(time, temp, speed, image); + recyclerView.setAdapter(adapterRecycleView); + + } catch (JSONException e) { + + e.printStackTrace(); + } + } + }, new Response.ErrorListener() { - void checkConnection() { - // ConnectivityManager for connection checking - connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); - // Check the internet connection - connected = Connection.checkConnection(connectivityManager); - Log.i("ACCESS NETWORK STATE", "Connected: " + connected); - } + @Override + public void onErrorResponse(VolleyError error) { - void getAndShowWeatherData(final String url){ - checkConnection(); - - handler = new Handler(); - handler.postDelayed(new Runnable() { - public void run() { - if(connected){ - RequestQueue queue = Volley.newRequestQueue(MainActivity.this); - formatter = new Formatter(); - - JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, - new Response.Listener() { - @Override - public void onResponse(JSONObject response) { - // Hide progress bar. - loaderProgressBar.setVisibility(View.GONE); - // Show app content - contentRelativeLayout.setVisibility(View.VISIBLE); - try { - // Get JSON objects from server response - JSONObject location = response.getJSONObject("location"); - JSONObject current = response.getJSONObject("current"); - JSONObject forecastday = response.getJSONObject("forecast").getJSONArray("forecastday") - .getJSONObject(0); - JSONArray hour = forecastday.getJSONArray("hour"); - - // Setting data to all views. - cityTextView.setText(location.getString("name")); - degreeTextView.setText(current.getString("temp_c")+"°c"); - conditionTextView.setText(current.getJSONObject("condition").getString("text")); - regionTextView.setText(location.getString("region")); - countryTextView.setText(location.getString("country")); - localTimeTextView.setText(formatter.dateTimeFormatting(location.getString("localtime"))); - - // Load the image from url using picasso library. - if(current.getInt("is_day") == 0) - Picasso.with(MainActivity.this).load(nightBG).into(backgroundImageView); - else - Picasso.with(MainActivity.this).load(dayBG).into(backgroundImageView); - - Picasso.with(MainActivity.this).load("https:"+current.getJSONObject("condition") - .getString("icon")) - .into(conditionIconImageView); - - time = new ArrayList<>(); - temp = new ArrayList<>(); - speed = new ArrayList<>(); - image = new ArrayList<>(); - - for(int i = 0;i < hour.length();i++){ - JSONObject hourObj = hour.getJSONObject(i); - String timeObj = hourObj.getString("time"); - String temperature = hourObj.getString("temp_c"); - String imageObj = "https:"+hourObj.getJSONObject("condition").getString("icon"); - String wind = hourObj.getString("wind_kph"); - - time.add(timeObj); - temp.add(temperature); - speed.add(wind); - image.add(imageObj); - } - - adapterRecycleView = new CardView(time, temp, speed, image); - recyclerView.setAdapter(adapterRecycleView); - - } catch (JSONException e) { - - e.printStackTrace(); - } - } - }, new Response.ErrorListener() { - - @Override - public void onErrorResponse(VolleyError error) { - loaderProgressBar.setVisibility(View.GONE); - contentRelativeLayout.setVisibility(View.VISIBLE); - Toast.makeText(MainActivity.this, "No matching location found.", Toast.LENGTH_LONG).show(); - } - }); - - queue.add(jsonObjectRequest); - } - else{ - loaderProgressBar.setVisibility(View.GONE); - noConnectionRelativeLayout.setVisibility(View.VISIBLE); - Toast.makeText(getApplicationContext(), "Unable to get weather information.", Toast.LENGTH_LONG).show(); - } + loaderProgressBar.setVisibility(View.GONE); + contentRelativeLayout.setVisibility(View.VISIBLE); + + Toast.makeText(MainActivity.this, "No matching location found.", Toast.LENGTH_LONG).show(); } - }, 2000); //2 seconds - } + }); + + queue.add(jsonObjectRequest); - @Override - protected void onResume() { - super.onResume(); } } diff --git a/app/src/main/java/com/miguelf03kai/weatherapp/utils/Connection.java b/app/src/main/java/com/miguelf03kai/weatherapp/utils/Connection.java deleted file mode 100644 index c29cbb2..0000000 --- a/app/src/main/java/com/miguelf03kai/weatherapp/utils/Connection.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.miguelf03kai.weatherapp.utils; - -import android.net.ConnectivityManager; -import android.net.NetworkInfo; - -public class Connection { - - // Check if the device have internet connection - public static boolean checkConnection(ConnectivityManager connectivityManager){ - boolean connected = (connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) - .getState() == NetworkInfo.State.CONNECTED || connectivityManager - .getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED); - - return connected; - } -} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 01335ad..2e28d77 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -168,40 +168,4 @@ - - - - - - -