Skip to content

Commit f6b9263

Browse files
committed
Done
1 parent 118d281 commit f6b9263

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

.idea/misc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/example/testret/UI/main/MainActivity.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
import android.location.LocationManager;
1010
import android.os.Bundle;
1111
import android.os.Looper;
12+
import android.view.View;
1213
import android.view.WindowManager;
14+
import android.widget.ProgressBar;
1315
import android.widget.TextView;
14-
import android.widget.Toast;
1516

1617
import androidx.appcompat.app.AppCompatActivity;
1718
import androidx.core.app.ActivityCompat;
@@ -45,6 +46,7 @@ public class MainActivity extends AppCompatActivity {
4546
private HourlyAdapter hourlyAdapter;
4647
private LocationRequest locationRequest;
4748
private LocationCallback locationCallback;
49+
private ProgressBar progressBar;
4850
private TextView locationTxt, pressureTxt, windTxt, precipitationTxt, CurrentDay, humidityTxt, sunriseTxt, sunsetTxt, FeelLikeTxt, currentWeatherTxt;
4951

5052
@Override
@@ -76,6 +78,7 @@ private void buildAlertMessageNoGps() {
7678
.setPositiveButton(getString(R.string.okay), (dialog, id) -> startActivityForResult(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS), 333));
7779
final AlertDialog alert = builder.create();
7880
alert.show();
81+
_GetCurrentUserPermission();
7982
}
8083

8184
private void _view() {
@@ -90,6 +93,7 @@ private void _view() {
9093
currentWeatherTxt = findViewById(R.id.currentWeatherTxt);
9194
FeelLikeTxt = findViewById(R.id.FeelLikeTxt);
9295
CurrentDay = findViewById(R.id.CurrentDay);
96+
progressBar = findViewById(R.id.progressBar);
9397
findViewById(R.id.textView2).setOnClickListener(v -> startActivity(new Intent(getApplicationContext(), Next7Days.class)));
9498
}
9599

@@ -173,6 +177,7 @@ private void _FindUserLocation() {
173177
fusedLocationProviderClient.getLastLocation()
174178
.addOnFailureListener(Throwable::printStackTrace)
175179
.addOnSuccessListener(location -> {if (location != null) {
180+
progressBar.setVisibility(View.VISIBLE);
176181
String MyLocation = UserUtils.getAddressFromLocation(getApplicationContext(), location);
177182
locationTxt.setText(MyLocation);
178183
String APP_ID = "ae82f77ec5397be4e9eca95799584087";
@@ -182,7 +187,8 @@ private void _FindUserLocation() {
182187
APP_ID);
183188
postViewModel.getCurrentDailyForecastsMutableLiveData().observe(this, currentTemp -> {
184189
try {
185-
sunsetTxt.setText(new StringBuilder().append(UserUtils.getDateHHMMFromNumber(currentTemp.getSunset())).append(" pm"));
190+
progressBar.setVisibility(View.GONE);
191+
sunsetTxt.setText(new StringBuilder().append(UserUtils.getDateHHMMFromNumber(currentTemp.getSunset())).append(" h"));
186192
sunriseTxt.setText(new StringBuilder().append(UserUtils.getDateHHMMFromNumber(currentTemp.getSunrise())).append(" am"));
187193
currentWeatherTxt.setText(new StringBuilder().append(UserUtils.getDegreeToCelsius(currentTemp.getTemp())).append(" °C"));
188194
FeelLikeTxt.setText(new StringBuilder().append("Feels like ").append(UserUtils.getDegreeToCelsius(currentTemp.getFeels_like())).append(" °C"));

app/src/main/res/layout/activity_main3.xml

+15-2
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,28 @@
6262
android:textSize="12sp" />
6363
</LinearLayout>
6464

65+
<ProgressBar
66+
android:id="@+id/progressBar"
67+
style="@android:style/Widget.ProgressBar.Small"
68+
android:layout_width="0dp"
69+
android:layout_height="wrap_content"
70+
android:layout_marginTop="8dp"
71+
android:backgroundTint="#FFFFFFFF"
72+
app:layout_constraintEnd_toEndOf="parent"
73+
app:layout_constraintHorizontal_bias="0.0"
74+
app:layout_constraintStart_toStartOf="parent"
75+
app:layout_constraintTop_toBottomOf="@+id/linearLayout"
76+
tools:visibility="gone" />
77+
6578
<LinearLayout
6679
android:id="@+id/linearLayout3"
6780
android:layout_width="match_parent"
6881
android:layout_height="wrap_content"
69-
android:layout_marginTop="24dp"
82+
android:layout_marginTop="16dp"
7083
android:orientation="vertical"
7184
app:layout_constraintEnd_toEndOf="parent"
7285
app:layout_constraintStart_toStartOf="parent"
73-
app:layout_constraintTop_toBottomOf="@+id/linearLayout">
86+
app:layout_constraintTop_toBottomOf="@+id/progressBar">
7487

7588
<TextView
7689
android:id="@+id/currentWeatherTxt"

app/src/main/res/layout/activity_next7_days.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<ScrollView
3-
xmlns:android="http://schemas.android.com/apk/res/android"
2+
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
43
xmlns:app="http://schemas.android.com/apk/res-auto"
54
xmlns:tools="http://schemas.android.com/tools"
65
android:layout_width="match_parent"
76
android:layout_height="match_parent"
8-
android:background="@drawable/rain_bg"
7+
android:background="@drawable/bg_night"
98
tools:context=".UI.main.Next7Days">
9+
1010
<LinearLayout
1111
android:layout_width="match_parent"
1212
android:layout_height="wrap_content"

0 commit comments

Comments
 (0)