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
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
android:theme="@style/AppTheme.NoActionBar"
tools:targetApi="n">
<activity
android:name=".GlobalActivity"
android:name=".SplashScreen.SplashScreen"
android:screenOrientation="portrait"
android:label="@string/app_name">
<intent-filter>
Expand Down Expand Up @@ -111,6 +111,7 @@
android:name="android.appwidget.provider"
android:resource="@xml/small_widget" />
</receiver>
<activity android:name=".GlobalActivity"></activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.a5corp.weather.SplashScreen;

import android.content.Intent;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;

import com.a5corp.weather.GlobalActivity;
import com.a5corp.weather.R;

import androidx.appcompat.app.AppCompatActivity;

public class SplashScreen extends AppCompatActivity {
private TextView tv;
private ImageView iv;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
tv = findViewById(R.id.tv);
iv = findViewById(R.id.iv);
Animation myanim = AnimationUtils.loadAnimation(this , R.anim.mytransition);
tv.startAnimation(myanim);
iv.startAnimation(myanim);
final Intent i = new Intent(this, GlobalActivity.class);
Copy link
Owner

@Sparker0i Sparker0i Dec 19, 2018

Choose a reason for hiding this comment

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

Oh no, this can't be accepted. Simply doing a sleep() will only increase the time taken to display the weather data.

As I had said in #27 , GlobalActivity.java must be the splash screen. In this you check whether the city has been set or not. If not, it goes to Enter City screen. If it has been set, GlobalActivity.java will load the weather data in this splash screen and send the data received to the WeatherActivity, where the WeatherFragment should parse it.


Thread myThread = new Thread(){
@Override
public void run() {
try {
sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
finally {
startActivity(i);
finish();
}
}
};
myThread.start();
}
}
7 changes: 7 additions & 0 deletions app/src/main/res/anim/mytransition.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="2000" >

</alpha>
32 changes: 32 additions & 0 deletions app/src/main/res/layout/activity_splash_screen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SplashScreen.SplashScreen"
android:background="@color/colorPrimaryDark">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">

<ImageView
android:layout_gravity="center"
android:layout_width="200dp"
android:layout_height="200dp"
android:id="@+id/iv"
android:src="@mipmap/ic_launcher_foreground" />

<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Weather"
android:textSize="23sp"
android:textStyle="bold"
android:layout_gravity="center"
android:textColor="@color/white"/>
</LinearLayout>
</RelativeLayout>