Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
</intent-filter>
</activity>
<activity android:name=".activities.MainActivity" />
<activity android:name=".activities.SplashActivity"/>
<activity android:name=".activities.BaseActivity" />

<service
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.ardovic.weatherappprototype.activities;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;

import androidx.appcompat.app.AppCompatActivity;

import com.ardovic.weatherappprototype.R;

public class SplashActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);

SharedPreferences pref = getSharedPreferences("first_launch", MODE_PRIVATE);

boolean first = pref.getBoolean("first", true);

if (first) {

new Handler().postDelayed(() -> {

pref.edit().putBoolean("first", false).apply();

startActivity(new Intent(SplashActivity.this, MainActivity.class));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of SplashActivity.this, just use this.

finish();

}, 3000);

} else {
startActivity(new Intent(SplashActivity.this, MainActivity.class));
finish();
}
}
}
51 changes: 51 additions & 0 deletions app/src/main/res/layout/activity_splash.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#2196F3">

<ImageView
android:id="@+id/logo"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="120dp"
android:src="@mipmap/ic_launcher"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Open Weather Android"
android:textStyle="bold"
android:textSize="28sp"
android:textColor="#FFFFFF"
android:layout_below="@id/logo"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"/>

<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="120dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Loading city database...\nThis happens only on first launch."
android:textColor="#FFFFFF"
android:textSize="16sp"
android:gravity="center"
android:layout_above="@id/progress"
android:layout_centerHorizontal="true"/>

<ProgressBar
android:id="@+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="120dp"/>

</RelativeLayout>
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
buildscript {

repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'com.google.gms:google-services:4.3.8'
}
}

allprojects {
repositories {
google()
mavencentral()
mavenCentral()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Oct 18 16:25:36 IST 2020
#Sun Jun 14 23:14:45 IST 2026
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':app'
include ':app'