StartService when tab focused
This commit is contained in:
parent
1909522b3d
commit
b0a4681a04
|
@ -328,6 +328,17 @@ public class MainActivity extends AppCompatActivity
|
|||
toot.setVisibility(View.GONE);
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
|
||||
if( tab.getPosition() == 2 && !display_local && display_global){
|
||||
streamingFederatedIntent = new Intent(getApplicationContext(), StreamingFederatedTimelineService.class);
|
||||
startService(streamingFederatedIntent);
|
||||
}else if( tab.getPosition() == 3 && display_local && display_global){
|
||||
streamingFederatedIntent = new Intent(getApplicationContext(), StreamingFederatedTimelineService.class);
|
||||
startService(streamingFederatedIntent);
|
||||
}else{
|
||||
if( streamingFederatedIntent != null)
|
||||
stopService(streamingFederatedIntent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -73,6 +73,11 @@ public class StreamingFederatedTimelineService extends IntentService {
|
|||
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
boolean display_global = sharedpreferences.getBoolean(Helper.SET_DISPLAY_GLOBAL, true);
|
||||
if( !display_global){
|
||||
stopSelf();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -211,8 +211,6 @@ public class MainActivity extends AppCompatActivity
|
|||
streamingIntent = new Intent(this, StreamingService.class);
|
||||
startService(streamingIntent);
|
||||
|
||||
streamingFederatedIntent = new Intent(this, StreamingFederatedTimelineService.class);
|
||||
startService(streamingFederatedIntent);
|
||||
|
||||
if( !broadCastRegistred) {
|
||||
LocalBroadcastManager.getInstance(this).registerReceiver(receive_data, new IntentFilter(Helper.RECEIVE_DATA));
|
||||
|
@ -331,6 +329,17 @@ public class MainActivity extends AppCompatActivity
|
|||
toot.setVisibility(View.GONE);
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
|
||||
if( tab.getPosition() == 2 && !display_local && display_global){
|
||||
streamingFederatedIntent = new Intent(getApplicationContext(), StreamingFederatedTimelineService.class);
|
||||
startService(streamingFederatedIntent);
|
||||
}else if( tab.getPosition() == 3 && display_local && display_global){
|
||||
streamingFederatedIntent = new Intent(getApplicationContext(), StreamingFederatedTimelineService.class);
|
||||
startService(streamingFederatedIntent);
|
||||
}else{
|
||||
if( streamingFederatedIntent != null)
|
||||
stopService(streamingFederatedIntent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue