Skip to content

Commit a1eff90

Browse files
sauravtomArnav Gupta
authored andcommitted
update categories, cleanup code
Signed-off-by: Arnav Gupta <[email protected]>
1 parent 7f64318 commit a1eff90

File tree

4 files changed

+16
-22
lines changed

4 files changed

+16
-22
lines changed

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,27 @@ public void onNavigationDrawerItemSelected(int position) {
4949
public void onSectionAttached(int number) {
5050
switch (number) {
5151
case 1:
52-
mTitle = "Sports";
52+
mTitle = "India";
5353
break;
5454
case 2:
55-
mTitle = "Entertainment";
55+
mTitle = "World";
5656
break;
5757
case 3:
58-
mTitle = "Business";
58+
mTitle = "Entertainment";
5959
break;
6060
case 4:
6161
mTitle = "Technology";
6262
break;
6363
case 5:
64-
mTitle = "World";
64+
mTitle = "Business";
6565
break;
6666
case 6:
6767
mTitle = "Science";
6868
break;
6969
case 7:
70+
mTitle = "Sports";
71+
break;
72+
case 8:
7073
mTitle = "Health";
7174
break;
7275
}
@@ -102,18 +105,13 @@ public boolean onOptionsItemSelected(MenuItem item) {
102105
switch (id){
103106
case R.id.action_refresh:
104107
new UpdateNews(MainActivity.this).execute();
108+
MainFragment mainFragment = (MainFragment) getSupportFragmentManager().findFragmentById(R.id.container);
109+
mainFragment.updateView();
105110
return true;
106111
case R.id.action_settings:
107112
return true;
108113
}
109114
return super.onOptionsItemSelected(item);
110115
}
111116

112-
/**
113-
* A placeholder fragment containing a simple view.
114-
*/
115-
public static class PlaceholderFragment extends Fragment {
116-
117-
}
118-
119117
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
6868
// TextView textView = (TextView) rootView.findViewById(R.id.section_label);
6969
// textView.setText(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)));
7070

71-
new ReadFromJSON().execute();
71+
updateView();
7272

7373
sNumber = getArguments().getInt(ARG_SECTION_NUMBER);
7474

@@ -89,6 +89,10 @@ public void onAttach(Activity activity) {
8989
private static final String TAG_LINK = "link";
9090
private static final String TAG_DATE = "date";
9191

92+
public void updateView(){
93+
new ReadFromJSON().execute();
94+
}
95+
9296

9397

9498
private class ReadFromJSON extends AsyncTask<Void, Void, ArrayList<JSONObject>> {

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,7 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
101101
getActionBar().getThemedContext(),
102102
android.R.layout.simple_list_item_1,
103103
android.R.id.text1,
104-
new String[]{
105-
"Sports",
106-
"Entertainment",
107-
"Business",
108-
"Technology",
109-
"World",
110-
"Science",
111-
"Health"
112-
}));
104+
Utils.categoryMap));
113105
mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
114106
return mDrawerListView;
115107
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
public class Utils {
88

9-
public static String[] categoryMap = {"Sports", "Entertainment", "Business", "Technology" , "World" , "Science" , "Health"};
9+
public static String[] categoryMap = {"India", "World", "Entertainment" , "Technology", "Business","Science" , "Sports", "Health"};
1010

1111
}

0 commit comments

Comments
 (0)