Skip to content
Snippets Groups Projects
Commit 5d40eaba authored by darshanxyz's avatar darshanxyz
Browse files

Added separate activity for teacher

parent a9cdc8ac
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".MainActivity" /> <activity android:name=".MainActivity" />
<activity android:name=".RollNumber"></activity> <activity android:name=".RollNumber" />
<activity android:name=".TeacherActivity"></activity>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -23,6 +23,9 @@ import com.google.firebase.auth.FirebaseAuth; ...@@ -23,6 +23,9 @@ import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser; import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.GoogleAuthProvider; import com.google.firebase.auth.GoogleAuthProvider;
import java.util.ArrayList;
import java.util.List;
public class Login extends AppCompatActivity implements GoogleApiClient.OnConnectionFailedListener, View.OnClickListener{ public class Login extends AppCompatActivity implements GoogleApiClient.OnConnectionFailedListener, View.OnClickListener{
private GoogleApiClient mGoogleApiClient; private GoogleApiClient mGoogleApiClient;
...@@ -33,6 +36,8 @@ public class Login extends AppCompatActivity implements GoogleApiClient.OnConnec ...@@ -33,6 +36,8 @@ public class Login extends AppCompatActivity implements GoogleApiClient.OnConnec
private static int RC_SIGN_IN = 0; private static int RC_SIGN_IN = 0;
private static String TAG = "MAIN_ACTIVITY"; private static String TAG = "MAIN_ACTIVITY";
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
......
...@@ -117,21 +117,18 @@ public class RollNumber extends AppCompatActivity implements AdapterView.OnItemS ...@@ -117,21 +117,18 @@ public class RollNumber extends AppCompatActivity implements AdapterView.OnItemS
} }
}); });
// SharedPreferences preferences = getSharedPreferences("ActivityPREF", Context.MODE_PRIVATE);
//
// if(preferences.getBoolean("activity_executed", false)){
SharedPreferences preferences = getSharedPreferences("ActivityPREF", Context.MODE_PRIVATE); // Intent intent = new Intent(this, MainActivity.class);
// startActivity(intent);
if(preferences.getBoolean("activity_executed", false)){ // finish();
Intent intent = new Intent(this, MainActivity.class); // }
startActivity(intent); // else {
finish(); // SharedPreferences.Editor edit = preferences.edit();
} // edit.putBoolean("activity_executed", true);
else { // edit.commit();
SharedPreferences.Editor edit = preferences.edit(); // }
edit.putBoolean("activity_executed", true);
edit.commit();
}
} }
...@@ -155,17 +152,28 @@ public class RollNumber extends AppCompatActivity implements AdapterView.OnItemS ...@@ -155,17 +152,28 @@ public class RollNumber extends AppCompatActivity implements AdapterView.OnItemS
} }
int flag = 0;
public void nextAct(View view) { public void nextAct(View view) {
if (TextUtils.isEmpty(rollNumber.getText().toString())) { if (TextUtils.isEmpty(rollNumber.getText().toString())) {
Toast.makeText(this, "Enter Roll Number", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Enter Roll Number", Toast.LENGTH_SHORT).show();
} }
else { else {
for (String email : lst) {
if (email.equals(mAuth.getCurrentUser().getEmail())) {
startActivity(new Intent(this, TeacherActivity.class));
flag = 1;
finish();
break;
}
}
if (flag == 0) {
roll_no.setValue(rollNumber.getText().toString()); roll_no.setValue(rollNumber.getText().toString());
email.setValue(mAuth.getCurrentUser().getEmail()); email.setValue(mAuth.getCurrentUser().getEmail());
startActivity(new Intent(this, MainActivity.class)); startActivity(new Intent(this, MainActivity.class));
finish(); finish();
} }
} }
}
public void signOut(View view) { public void signOut(View view) {
mAuth.signOut(); mAuth.signOut();
......
package com.darshanbshah.odsystem;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import com.google.firebase.auth.FirebaseAuth;
public class TeacherActivity extends AppCompatActivity {
FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_teacher);
mAuth = FirebaseAuth.getInstance();
}
public void signOut(View view) {
mAuth.signOut();
startActivity(new Intent(this, Login.class));
finish();
}
}
<?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:id="@+id/activity_teacher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.darshanbshah.odsystem.TeacherActivity">
<Button
android:text="Logout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="181dp"
android:id="@+id/button2"
android:onClick="signOut" />
</RelativeLayout>
<resources> <resources>
<string name="app_name">OD System</string> <string name="app_name">OD System</string>
<string-array name="advisors"> <string-array name="advisors">
<item>Select Advisor</item>
<item>One</item> <item>One</item>
<item>Two</item> <item>Two</item>
<item>Three</item>
</string-array> </string-array>
</resources> </resources>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment