Skip to content

Commit 0499b87

Browse files
Merge pull request #50 from sukhbir-singh/master
added quiz to app
2 parents 8805eab + 580cfa5 commit 0499b87

File tree

10 files changed

+235
-83
lines changed

10 files changed

+235
-83
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,27 @@
142142
</activity>
143143

144144
<activity android:name=".Notification.NotificationActivity"></activity>
145+
145146
<activity android:name=".Notification.Notification2"
146147
android:parentActivityName=".Notification.NotificationActivity"/>
147148

148-
149-
150149
<activity
151150
android:name=".Activity.ContributorsActivity"
152151
android:parentActivityName=".Activity.MainActivity">
153152
</activity>
154153

154+
<activity android:name=".Activity.QuizQuestionActivity" >
155+
<meta-data
156+
android:name="android.support.PARENT_ACTIVITY"
157+
android:value="com.nith.appteam.nimbus.Activity.QuizActivity" />
158+
</activity>
159+
160+
<activity android:name=".Activity.InformationActivity" >
161+
<meta-data
162+
android:name="android.support.PARENT_ACTIVITY"
163+
android:value="com.nith.appteam.nimbus.Activity.QuizActivity" />
164+
</activity>
165+
155166
</application>
156167

157168
</manifest>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.nith.appteam.nimbus.Activity;
2+
3+
import android.os.Bundle;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.support.v7.widget.Toolbar;
6+
import android.view.View;
7+
import android.widget.Button;
8+
9+
import com.nith.appteam.nimbus.R;
10+
11+
public class InformationActivity extends AppCompatActivity {
12+
13+
@Override
14+
protected void onCreate(Bundle savedInstanceState) {
15+
super.onCreate(savedInstanceState);
16+
setContentView(R.layout.activity_information);
17+
18+
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
19+
20+
setSupportActionBar(toolbar);
21+
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
22+
}
23+
}

app/src/main/java/com/nith/appteam/nimbus/Activity/MainActivity.java

Lines changed: 94 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ public class MainActivity extends AppCompatActivity {
5454
private ImageView imgNavHeaderBg, imgProfile;
5555
private TextView txtName, txtSubName;
5656
Toolbar toolbar;
57-
private LinearLayout NewsFeedLayout,TeamLayout;
57+
private LinearLayout quiz_layout, gallery_layout,
58+
map_layout, newsfeed_layout, coreteam_layout ,
59+
aboutnimbus_layout , teams_layout, feedback_layout;
5860

5961
//public static int navItemIndex = 0;
6062

@@ -69,27 +71,17 @@ protected void onCreate(Bundle savedInstanceState) {
6971
setContentView(R.layout.activity_main);
7072

7173
initCollapsingToolbar();
72-
toolbar = (Toolbar) findViewById(R.id.toolbar);
73-
setSupportActionBar(toolbar);
74-
Log.v("Checking UserId:", "" + sharedPref.getUserId());
74+
init();
7575

76-
//Code to deal with the NavigationDrawer
77-
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
78-
navigationView = (NavigationView) findViewById(R.id.nvView);
79-
80-
navHeader = navigationView.getHeaderView(0);
81-
txtName = (TextView) navHeader.findViewById(R.id.name);
82-
txtSubName = (TextView) navHeader.findViewById(R.id.subname);
83-
imgNavHeaderBg = (ImageView) navHeader.findViewById(R.id.img_header_bg);
84-
imgProfile = (ImageView) navHeader.findViewById(R.id.img_profile);
76+
Log.v("Checking UserId:", "" + sharedPref.getUserId());
8577

8678
loadNavHeader();
8779
setUpNavigationView();
8880
//Ends here
8981

9082
//Code to deal with the ViewPager.
91-
viewPager = (ViewPager)findViewById(R.id.main_view_pager);
9283
imageAdapter=new SlidingImageAdapter(MainActivity.this);
84+
9385
if(new Connection(this).isInternet()){
9486
getPagerData();
9587
profileBasicInfo(sharedPref.getUserId());
@@ -100,29 +92,8 @@ protected void onCreate(Bundle savedInstanceState) {
10092
viewPager.setPadding(100,120,100,120);
10193
viewPager.setPageMargin(60);
10294

95+
clickListenersMainMenu();
10396

104-
NewsFeedLayout= (LinearLayout) findViewById(R.id.newsFeed_layout);
105-
NewsFeedLayout.setOnClickListener(new View.OnClickListener() {
106-
@Override
107-
public void onClick(View v) {
108-
startActivity(new Intent(MainActivity.this,NewsFeedActivity.class));
109-
}
110-
});
111-
112-
TeamLayout= (LinearLayout) findViewById(R.id.teamLayout);
113-
TeamLayout.setOnClickListener(new View.OnClickListener() {
114-
@Override
115-
public void onClick(View v) {
116-
startActivity(new Intent(MainActivity.this,TeamActivity.class));
117-
}
118-
});
119-
//Ends Here
120-
121-
//Handling the Recycler View
122-
123-
//Ends Here
124-
125-
bottomNavigationView= (BottomNavigationView) findViewById(R.id.bottom_navigation);
12697
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
12798
@Override
12899
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
@@ -145,6 +116,93 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
145116

146117
}
147118

119+
public void init(){
120+
toolbar = (Toolbar) findViewById(R.id.toolbar);
121+
setSupportActionBar(toolbar);
122+
123+
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
124+
navigationView = (NavigationView) findViewById(R.id.nvView);
125+
126+
navHeader = navigationView.getHeaderView(0);
127+
txtName = (TextView) navHeader.findViewById(R.id.name);
128+
txtSubName = (TextView) navHeader.findViewById(R.id.subname);
129+
imgNavHeaderBg = (ImageView) navHeader.findViewById(R.id.img_header_bg);
130+
imgProfile = (ImageView) navHeader.findViewById(R.id.img_profile);
131+
132+
viewPager = (ViewPager)findViewById(R.id.main_view_pager);
133+
134+
quiz_layout= (LinearLayout) findViewById(R.id.quiz_layout);
135+
gallery_layout= (LinearLayout) findViewById(R.id.gallery_layout);
136+
map_layout= (LinearLayout) findViewById(R.id.map_layout);
137+
newsfeed_layout= (LinearLayout) findViewById(R.id.newsfeed_layout);
138+
coreteam_layout= (LinearLayout) findViewById(R.id.coreteam_layout);
139+
aboutnimbus_layout= (LinearLayout) findViewById(R.id.aboutnimbus_layout);
140+
teams_layout= (LinearLayout) findViewById(R.id.teams_layout);
141+
feedback_layout= (LinearLayout) findViewById(R.id.feedback_layout);
142+
143+
bottomNavigationView= (BottomNavigationView) findViewById(R.id.bottom_navigation);
144+
145+
}
146+
147+
public void clickListenersMainMenu(){
148+
quiz_layout.setOnClickListener(new View.OnClickListener() {
149+
@Override
150+
public void onClick(View v) {
151+
startActivity(new Intent(MainActivity.this,QuizActivity.class));
152+
}
153+
});
154+
155+
gallery_layout.setOnClickListener(new View.OnClickListener() {
156+
@Override
157+
public void onClick(View v) {
158+
159+
}
160+
});
161+
162+
map_layout.setOnClickListener(new View.OnClickListener() {
163+
@Override
164+
public void onClick(View v) {
165+
166+
}
167+
});
168+
169+
newsfeed_layout.setOnClickListener(new View.OnClickListener() {
170+
@Override
171+
public void onClick(View v) {
172+
startActivity(new Intent(MainActivity.this,NewsFeedActivity.class));
173+
}
174+
});
175+
176+
coreteam_layout.setOnClickListener(new View.OnClickListener() {
177+
@Override
178+
public void onClick(View v) {
179+
startActivity(new Intent(MainActivity.this,TeamActivity.class));
180+
}
181+
});
182+
183+
aboutnimbus_layout.setOnClickListener(new View.OnClickListener() {
184+
@Override
185+
public void onClick(View v) {
186+
187+
}
188+
});
189+
190+
teams_layout.setOnClickListener(new View.OnClickListener() {
191+
@Override
192+
public void onClick(View v) {
193+
194+
}
195+
});
196+
197+
feedback_layout.setOnClickListener(new View.OnClickListener() {
198+
@Override
199+
public void onClick(View v) {
200+
201+
}
202+
});
203+
204+
}
205+
148206
private void initCollapsingToolbar() {
149207
final CollapsingToolbarLayout collapsingToolbar =
150208
(CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);

app/src/main/java/com/nith/appteam/nimbus/Activity/QuizActivity.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,21 @@ protected void onCreate(Bundle savedInstanceState) {
3030

3131
enter_quiz=(Button)findViewById(R.id.enter_quiz);
3232
instructions_button=(Button)findViewById(R.id.quiz_instructions_link);
33-
leaderboard=(Button)findViewById(R.id.leaderboard_link);
3433

3534
enter_quiz.setOnClickListener(new View.OnClickListener() {
3635
@Override
3736
public void onClick(View view) {
38-
if(sp.getInstructionsReadStatus()){
3937
startActivity(new Intent(QuizActivity.this,QuizQuestionActivity.class));
40-
}else{
41-
Toast.makeText(QuizActivity.this,"Read Quiz Instructions first",Toast.LENGTH_LONG).show();
42-
}
4338
}
4439
});
4540

4641
instructions_button.setOnClickListener(new View.OnClickListener() {
4742
@Override
4843
public void onClick(View view) {
49-
//startActivity(new Intent(QuizActivity.this,InformationActivity.class));
50-
}
51-
});
52-
leaderboard.setOnClickListener(new View.OnClickListener() {
53-
@Override
54-
public void onClick(View view) {
55-
//startActivity(new Intent(QuizActivity.this,LeaderBoardActivity.class));
44+
startActivity(new Intent(QuizActivity.this,InformationActivity.class));
5645
}
5746
});
47+
5848
}
5949

6050
}

app/src/main/java/com/nith/appteam/nimbus/Activity/QuizQuestionActivity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ public int getCount() {
194194
if (status == 503) {
195195
Toast.makeText(QuizQuestionActivity.this, "Server Down", Toast.LENGTH_SHORT).show();
196196
}
197-
198197
}
199198

200199
}

app/src/main/java/com/nith/appteam/nimbus/Utils/ApiInterface.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,11 @@ public interface ApiInterface {
5959
@FormUrlEncoded
6060
Call<FbLoginFragment.UserSentResponse> sendFbUserData(@Field("name") String name,@Field("email") String email,@Field("pic_url")String picUrl);
6161

62-
@FormUrlEncoded
63-
@POST("quiz/questions")
64-
Call<QuizQuestionsModel> getQuiz(@Field("id") String id);
62+
@POST("quiz/get/{id}")
63+
Call<QuizQuestionsModel> getQuiz(@Path("id") String id);
6564

66-
@FormUrlEncoded
67-
@POST("quiz/score")
68-
Call<UpdateScoreModel> updateScore(@Field("id") String id, @Field("score") int score);
65+
@POST("quiz/update/{id}")
66+
Call<UpdateScoreModel> updateScore(@Path("id") String id, @Query("score") int score);
6967

7068
@FormUrlEncoded
7169
@POST("newsfeed/post/{student_id}")
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
xmlns:app="http://schemas.android.com/apk/res-auto"
5+
android:id="@+id/activity_information"
6+
android:layout_width="match_parent"
7+
android:layout_height="match_parent"
8+
android:orientation="vertical">
9+
10+
<android.support.v7.widget.Toolbar
11+
android:id="@+id/toolbar"
12+
android:layout_width="match_parent"
13+
android:layout_height="?attr/actionBarSize"
14+
android:background="?attr/colorPrimary"
15+
android:titleTextColor="#FFF"
16+
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
17+
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
18+
19+
<ScrollView
20+
android:layout_width="match_parent"
21+
android:layout_height="match_parent">
22+
23+
<LinearLayout
24+
android:orientation="vertical"
25+
android:layout_width="match_parent"
26+
android:layout_height="match_parent">
27+
28+
<TextView
29+
android:lineSpacingExtra="8dp"
30+
android:padding="15dp"
31+
android:text="@string/quiz_instruction"
32+
android:textSize="20sp"
33+
android:layout_width="match_parent"
34+
android:layout_height="wrap_content" />
35+
36+
<TextView
37+
android:layout_gravity="center_horizontal"
38+
android:padding="10dp"
39+
android:textSize="30sp"
40+
android:text="BEST OF LUCK!!!"
41+
android:layout_marginBottom="5dp"
42+
android:layout_width="wrap_content"
43+
android:layout_height="wrap_content" />
44+
45+
</LinearLayout>
46+
47+
</ScrollView>
48+
49+
</LinearLayout>

0 commit comments

Comments
 (0)