-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Splash screen to load data before seeing MainActivity.
- Loading branch information
Showing
10 changed files
with
117 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
app/src/main/java/com/evan/parknbark/maps/usersFragment.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
app/src/main/java/com/evan/parknbark/utilities/SplashScreenActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.evan.parknbark.utilities; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.fragment.app.DialogFragment; | ||
import androidx.fragment.app.FragmentManager; | ||
|
||
import android.content.Context; | ||
import android.graphics.Color; | ||
import android.os.Bundle; | ||
import android.os.Handler; | ||
import android.util.Log; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import com.evan.parknbark.R; | ||
import com.google.android.gms.tasks.OnCompleteListener; | ||
import com.google.android.gms.tasks.Task; | ||
import com.google.firebase.auth.FirebaseAuth; | ||
import com.google.firebase.auth.FirebaseUser; | ||
import com.google.firebase.firestore.DocumentReference; | ||
import com.google.firebase.firestore.DocumentSnapshot; | ||
import com.google.firebase.firestore.FirebaseFirestore; | ||
|
||
import gr.net.maroulis.library.EasySplashScreen; | ||
|
||
public class SplashScreenActivity extends BaseActivity { | ||
|
||
@Override | ||
public void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
//Create a bundle to pass to the next activity | ||
Bundle bundle = new Bundle(); | ||
|
||
db = FirebaseFirestore.getInstance(); | ||
mAuth = FirebaseAuth.getInstance(); | ||
FirebaseUser firebaseUser = mAuth.getCurrentUser(); | ||
if (firebaseUser != null) { | ||
DocumentReference docRef = db.collection("users").document(firebaseUser.getUid()); | ||
docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() { | ||
@Override | ||
public void onComplete(@NonNull Task<DocumentSnapshot> task) { | ||
if (task.isSuccessful()) { | ||
User user = task.getResult().toObject(User.class); | ||
//if user is logged in, put the permission into bundle | ||
//else, do nothing | ||
bundle.putString("current_user_permission", user.getPermission()); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
|
||
EasySplashScreen config = new EasySplashScreen(this) | ||
.withFullScreen() | ||
.withTargetActivity(MainActivity.class) //go to main activity | ||
.withBundleExtras(bundle) //send bundle, either user logged in or nah | ||
.withBackgroundColor(Color.parseColor("#e1f5fe")) | ||
.withHeaderText("Welcome to") | ||
.withLogo(R.mipmap.app_logo1_foreground); //TODO: adjust logo dimensions | ||
|
||
View easySplashScreen = config.create(); | ||
setContentView(easySplashScreen); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters