From aa95375919f276e09a23f993735b5a975f0be88c Mon Sep 17 00:00:00 2001 From: darshanxyz <darshanxyz@gmail.com> Date: Mon, 24 Apr 2017 01:17:09 +0530 Subject: [PATCH] RollNumber activity is no longer an issue! --- .../darshanbshah/odsystem/MainActivity.java | 2 +- .../com/darshanbshah/odsystem/RollNumber.java | 37 +++++++++++++------ app/src/main/res/layout/list_item.xml | 3 +- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/darshanbshah/odsystem/MainActivity.java b/app/src/main/java/com/darshanbshah/odsystem/MainActivity.java index 90027b3..22b5fcb 100644 --- a/app/src/main/java/com/darshanbshah/odsystem/MainActivity.java +++ b/app/src/main/java/com/darshanbshah/odsystem/MainActivity.java @@ -261,7 +261,7 @@ public class MainActivity extends AppCompatActivity { // recepient = list1.get(0); // - + Toast.makeText(this, "OD has been requested", Toast.LENGTH_SHORT).show(); Log.e("DATA: ", reasonString + ", " + fromDate + ", " + toDate + ", " + full); } diff --git a/app/src/main/java/com/darshanbshah/odsystem/RollNumber.java b/app/src/main/java/com/darshanbshah/odsystem/RollNumber.java index ebcae5c..c591c4d 100644 --- a/app/src/main/java/com/darshanbshah/odsystem/RollNumber.java +++ b/app/src/main/java/com/darshanbshah/odsystem/RollNumber.java @@ -1,5 +1,6 @@ package com.darshanbshah.odsystem; +import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -51,6 +52,7 @@ public class RollNumber extends AppCompatActivity implements AdapterView.OnItemS DatabaseReference advisor; HashMap <String,String> adv_map = new HashMap <String, String>(); + ProgressDialog dialog; @Override protected void onCreate(Bundle savedInstanceState) { @@ -93,6 +95,10 @@ public class RollNumber extends AppCompatActivity implements AdapterView.OnItemS advisors.setAdapter(adapter); advisors.setOnItemSelectedListener(this); + dialog = new ProgressDialog(this); + dialog.setMessage("Please Wait"); + dialog.show(); + adv.addChildEventListener(new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String s) { @@ -100,6 +106,24 @@ public class RollNumber extends AppCompatActivity implements AdapterView.OnItemS lst.add(String.valueOf(dsp.getValue())); Log.e("EMAILS: ", String.valueOf(dsp.getValue())); } + if (lst.contains(mAuth.getCurrentUser().getEmail())) { + startActivity(new Intent(getApplicationContext(), TeacherActivity.class)); + } + else { + SharedPreferences preferences = getSharedPreferences("ActivityPREF", Context.MODE_PRIVATE); + + if(preferences.getBoolean("activity_executed", false)){ + Intent intent = new Intent(RollNumber.this, MainActivity.class); + startActivity(intent); + finish(); + dialog.hide(); + } + else { + SharedPreferences.Editor edit = preferences.edit(); + edit.putBoolean("activity_executed", true); + edit.commit(); + } + } } @Override @@ -123,18 +147,7 @@ public class RollNumber extends AppCompatActivity implements AdapterView.OnItemS } }); -// SharedPreferences preferences = getSharedPreferences("ActivityPREF", Context.MODE_PRIVATE); -// -// if(preferences.getBoolean("activity_executed", false)){ -// Intent intent = new Intent(this, MainActivity.class); -// startActivity(intent); -// finish(); -// } -// else { -// SharedPreferences.Editor edit = preferences.edit(); -// edit.putBoolean("activity_executed", true); -// edit.commit(); -// } + } diff --git a/app/src/main/res/layout/list_item.xml b/app/src/main/res/layout/list_item.xml index 55b7a51..6211816 100644 --- a/app/src/main/res/layout/list_item.xml +++ b/app/src/main/res/layout/list_item.xml @@ -61,7 +61,8 @@ <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" - android:layout_height="wrap_content"> + android:layout_height="wrap_content" + android:layout_marginBottom="10dp"> <TextView android:text="To: " -- GitLab