Remove serviceIntent

This commit is contained in:
Adeel 2019-08-23 17:11:35 +05:00
parent f05e254043
commit eee5d727c6

View File

@ -85,7 +85,6 @@ public class ZimHostActivity extends BaseActivity implements
private static final int LOCATION_SETTINGS_PERMISSION_RESULT = 101; private static final int LOCATION_SETTINGS_PERMISSION_RESULT = 101;
public static final String SELECTED_ZIM_PATHS_KEY = "selected_zim_paths"; public static final String SELECTED_ZIM_PATHS_KEY = "selected_zim_paths";
private static final String IP_STATE_KEY = "ip_state_key"; private static final String IP_STATE_KEY = "ip_state_key";
Intent serviceIntent;
private Task<LocationSettingsResponse> task; private Task<LocationSettingsResponse> task;
ProgressDialog progressDialog; ProgressDialog progressDialog;
@ -139,8 +138,6 @@ public class ZimHostActivity extends BaseActivity implements
} }
}; };
serviceIntent = new Intent(this, HotspotService.class);
startServerButton.setOnClickListener(v -> { startServerButton.setOnClickListener(v -> {
//Get the path of ZIMs user has selected //Get the path of ZIMs user has selected
if (!ServerUtils.isServerStarted) { if (!ServerUtils.isServerStarted) {
@ -206,7 +203,8 @@ public class ZimHostActivity extends BaseActivity implements
} }
private void bindService() { private void bindService() {
bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE); bindService(new Intent(this, HotspotService.class), serviceConnection,
Context.BIND_AUTO_CREATE);
} }
private void unbindService() { private void unbindService() {
@ -420,9 +418,8 @@ public class ZimHostActivity extends BaseActivity implements
@Override public void onSuccess(String s) { @Override public void onSuccess(String s) {
progressDialog.dismiss(); progressDialog.dismiss();
serviceIntent.putStringArrayListExtra(SELECTED_ZIM_PATHS_KEY, selectedBooksPath); startService(createHotspotIntent(ACTION_START_SERVER).putStringArrayListExtra(
serviceIntent.setAction(ACTION_START_SERVER); SELECTED_ZIM_PATHS_KEY, selectedBooksPath));
startService(serviceIntent);
Log.d(TAG, "onSuccess: " + s); Log.d(TAG, "onSuccess: " + s);
} }
@ -436,9 +433,8 @@ public class ZimHostActivity extends BaseActivity implements
}); });
} }
Intent createHotspotIntent(String ACTION) { Intent createHotspotIntent(String action) {
serviceIntent.setAction(ACTION); return new Intent(this, HotspotService.class).setAction(action);
return serviceIntent;
} }
void mobileDataDialog() { void mobileDataDialog() {