17
17
import fr .free .nrw .commons .ViewPagerAdapter ;
18
18
import fr .free .nrw .commons .contributions .MainActivity ;
19
19
import fr .free .nrw .commons .di .CommonsDaggerSupportFragment ;
20
+ import fr .free .nrw .commons .kvstore .JsonKvStore ;
20
21
import fr .free .nrw .commons .theme .BaseActivity ;
21
22
import fr .free .nrw .commons .utils .ActivityUtils ;
22
23
import java .util .ArrayList ;
23
24
import java .util .List ;
25
+ import javax .inject .Inject ;
26
+ import javax .inject .Named ;
24
27
25
28
public class ExploreFragment extends CommonsDaggerSupportFragment {
26
29
@@ -35,6 +38,9 @@ public class ExploreFragment extends CommonsDaggerSupportFragment {
35
38
ViewPagerAdapter viewPagerAdapter ;
36
39
private ExploreListRootFragment featuredRootFragment ;
37
40
private ExploreListRootFragment mobileRootFragment ;
41
+ @ Inject
42
+ @ Named ("default_preferences" )
43
+ public JsonKvStore applicationKvStore ;
38
44
39
45
public void setScroll (boolean canScroll ){
40
46
viewPager .setCanScroll (canScroll );
@@ -95,20 +101,21 @@ public void setTabs() {
95
101
viewPagerAdapter .notifyDataSetChanged ();
96
102
}
97
103
98
- public void onBackPressed () {
104
+ public boolean onBackPressed () {
99
105
if (tabLayout .getSelectedTabPosition () == 0 ) {
100
- if (featuredRootFragment .backPressed ()){
101
- // Event is handled by the Fragment we need not do anything.
102
- return ;
106
+ if (featuredRootFragment .backPressed ()) {
107
+ ((BaseActivity ) getActivity ()).getSupportActionBar ()
108
+ .setDisplayHomeAsUpEnabled (false );
109
+ return true ;
103
110
}
104
111
} else {
105
- if (mobileRootFragment .backPressed ()){
106
- // Event is handled by the Fragment we need not do anything.
107
- return ;
112
+ if (mobileRootFragment .backPressed ()) {
113
+ ((BaseActivity ) getActivity ()).getSupportActionBar ()
114
+ .setDisplayHomeAsUpEnabled (false );
115
+ return true ;
108
116
}
109
117
}
110
- // Event is not handled by the fragment ( i.e performed back action ) therefore change action bar.
111
- ((BaseActivity )getActivity ()).getSupportActionBar ().setDisplayHomeAsUpEnabled (false );
118
+ return false ;
112
119
}
113
120
114
121
/**
0 commit comments