Skip to content

Commit e81c7b6

Browse files
committed
Changing actionbar title in every category
Signed-off-by: Umair Khan <[email protected]>
1 parent 8d4d91f commit e81c7b6

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

App/src/main/java/in/ac/dtu/subtlenews/MainActivity.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.support.v4.widget.DrawerLayout;
77
import android.support.v7.app.ActionBar;
88
import android.support.v7.app.ActionBarActivity;
9+
import android.util.Log;
910
import android.view.Menu;
1011
import android.view.MenuItem;
1112

@@ -47,30 +48,31 @@ public void onNavigationDrawerItemSelected(int position) {
4748
}
4849

4950
public void onSectionAttached(int number) {
51+
mTitle = "Subtle News";
5052
switch (number) {
5153
case 1:
52-
mTitle = "India";
54+
mTitle = mTitle + "/India";
5355
break;
5456
case 2:
55-
mTitle = "World";
57+
mTitle = mTitle + "/World";
5658
break;
5759
case 3:
58-
mTitle = "Entertainment";
60+
mTitle = mTitle + "/Entertainment";
5961
break;
6062
case 4:
61-
mTitle = "Technology";
63+
mTitle = mTitle + "/Technology";
6264
break;
6365
case 5:
64-
mTitle = "Business";
66+
mTitle = mTitle + "/Business";
6567
break;
6668
case 6:
67-
mTitle = "Science";
69+
mTitle = mTitle + "/Science";
6870
break;
6971
case 7:
70-
mTitle = "Sports";
72+
mTitle = mTitle + "/Sports";
7173
break;
7274
case 8:
73-
mTitle = "Health";
75+
mTitle = mTitle + "/Health";
7476
break;
7577
}
7678
}

App/src/main/java/in/ac/dtu/subtlenews/MainFragment.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
7878
@Override
7979
public void onAttach(Activity activity) {
8080
super.onAttach(activity);
81-
((MainActivity) activity).onSectionAttached(sNumber);
81+
((MainActivity) activity).onSectionAttached(getArguments().getInt(ARG_SECTION_NUMBER));
8282
}
8383

8484
private static final String NEWSFEED_NAME = "summary";
@@ -115,7 +115,7 @@ protected ArrayList<JSONObject> doInBackground(Void... v) {
115115

116116
ArrayList<JSONObject> selectedCategoryList = new ArrayList<JSONObject>();
117117

118-
Log.d(TAG, "jsonString" + jsonString);
118+
//Log.d(TAG, "jsonString" + jsonString);
119119
try {
120120
JSONObject mJSONObject = new JSONObject(jsonString);
121121
JSONArray jsonArray = mJSONObject.getJSONArray(NEWSFEED_NAME);
@@ -129,10 +129,6 @@ protected ArrayList<JSONObject> doInBackground(Void... v) {
129129

130130
}
131131

132-
//for debugging only
133-
for(JSONObject lol : selectedCategoryList){
134-
Log.d(TAG, lol.getString("category"));
135-
}
136132
} catch (Exception e){
137133
e.printStackTrace();
138134
}

0 commit comments

Comments
 (0)