@Test public void receiveSyncErrorIntent() { Intent intent = EpgSyncJobService.createSyncErrorIntent(TEST_INPUT, 42); mReceiver.onReceive(null, intent); Assert.assertEquals("finished", false, mSyncListener.mFinished); Assert.assertEquals("errorCode", 42, mSyncListener.mErrorCode); }
@Override public void onReceive(Context context, final Intent intent) { if (mFinishedScan) { return; } String syncStatusChangedInputId = intent.getStringExtra(EpgSyncJobService.BUNDLE_KEY_INPUT_ID); if (syncStatusChangedInputId != null && syncStatusChangedInputId.equals(mInputId)) { String syncStatus = intent.getStringExtra(EpgSyncJobService.SYNC_STATUS); if (syncStatus.equals(EpgSyncJobService.SYNC_STARTED)) { if (DEBUG) { Log.d(TAG, "Sync status: Started"); } } else if (syncStatus.equals(EpgSyncJobService.SYNC_SCANNED)) { int channelsScanned = intent.getIntExtra(EpgSyncJobService.BUNDLE_KEY_CHANNELS_SCANNED, 0); int channelCount = intent.getIntExtra(EpgSyncJobService.BUNDLE_KEY_CHANNEL_COUNT, 0); mSyncListener.onScanStepCompleted(channelsScanned, channelCount); String channelDisplayName = intent.getStringExtra( EpgSyncJobService.BUNDLE_KEY_SCANNED_CHANNEL_DISPLAY_NAME); String channelDisplayNumber = intent.getStringExtra( EpgSyncJobService.BUNDLE_KEY_SCANNED_CHANNEL_DISPLAY_NUMBER); if (DEBUG) { Log.d(TAG, "Sync status: Channel Scanned"); Log.d(TAG, "Scanned " + channelsScanned + " out of " + channelCount); } mSyncListener.onScannedChannel(channelDisplayName, channelDisplayNumber); } else if (syncStatus.equals(EpgSyncJobService.SYNC_FINISHED)) { if (DEBUG) { Log.d(TAG, "Sync status: Finished"); } mFinishedScan = true; mSyncListener.onScanFinished(); } else if (syncStatus.equals(EpgSyncJobService.SYNC_ERROR)) { int errorCode = intent.getIntExtra(EpgSyncJobService.BUNDLE_KEY_ERROR_REASON, 0); if (DEBUG) { Log.d(TAG, "Error occurred: " + errorCode); } mSyncListener.onScanError(errorCode); } } }
SyncStatusBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, final Intent intent) { if (mFinishedScan) { return; } String syncStatusChangedInputId = intent.getStringExtra(EpgSyncJobService.BUNDLE_KEY_INPUT_ID); if (syncStatusChangedInputId != null && syncStatusChangedInputId.equals(mInputId)) { String syncStatus = intent.getStringExtra(EpgSyncJobService.SYNC_STATUS); if (syncStatus.equals(EpgSyncJobService.SYNC_STARTED)) { if (DEBUG) { Log.d(TAG, "Sync status: Started"); } } else if (syncStatus.equals(EpgSyncJobService.SYNC_SCANNED)) { int channelsScanned = intent.getIntExtra(EpgSyncJobService.BUNDLE_KEY_CHANNELS_SCANNED, 0); int channelCount = intent.getIntExtra(EpgSyncJobService.BUNDLE_KEY_CHANNEL_COUNT, 0); mSyncListener.onScanStepCompleted(channelsScanned, channelCount); String channelDisplayName = intent.getStringExtra( EpgSyncJobService.BUNDLE_KEY_SCANNED_CHANNEL_DISPLAY_NAME); String channelDisplayNumber = intent.getStringExtra( EpgSyncJobService.BUNDLE_KEY_SCANNED_CHANNEL_DISPLAY_NUMBER); if (DEBUG) { Log.d(TAG, "Sync status: Channel Scanned"); Log.d(TAG, "Scanned " + channelsScanned + " out of " + channelCount); } mSyncListener.onScannedChannel(channelDisplayName, channelDisplayNumber); } else if (syncStatus.equals(EpgSyncJobService.SYNC_FINISHED)) { if (DEBUG) { Log.d(TAG, "Sync status: Finished"); } mFinishedScan = true; mSyncListener.onScanFinished(); } else if (syncStatus.equals(EpgSyncJobService.SYNC_ERROR)) { int errorCode = intent.getIntExtra(EpgSyncJobService.BUNDLE_KEY_ERROR_REASON, 0); if (DEBUG) { Log.d(TAG, "Error occurred: " + errorCode); } mSyncListener.onScanError(errorCode); } } } }
SyncStatusBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, final Intent intent) { if (mFinishedScan) { return; } String syncStatusChangedInputId = intent.getStringExtra(EpgSyncJobService.BUNDLE_KEY_INPUT_ID); if (syncStatusChangedInputId != null && syncStatusChangedInputId.equals(mInputId)) { String syncStatus = intent.getStringExtra(EpgSyncJobService.SYNC_STATUS); if (syncStatus.equals(EpgSyncJobService.SYNC_STARTED)) { if (DEBUG) { Log.d(TAG, "Sync status: Started"); } } else if (syncStatus.equals(EpgSyncJobService.SYNC_SCANNED)) { int channelsScanned = intent.getIntExtra(EpgSyncJobService.BUNDLE_KEY_CHANNELS_SCANNED, 0); int channelCount = intent.getIntExtra(EpgSyncJobService.BUNDLE_KEY_CHANNEL_COUNT, 0); mSyncListener.onScanStepCompleted(channelsScanned, channelCount); String channelDisplayName = intent.getStringExtra( EpgSyncJobService.BUNDLE_KEY_SCANNED_CHANNEL_DISPLAY_NAME); String channelDisplayNumber = intent.getStringExtra( EpgSyncJobService.BUNDLE_KEY_SCANNED_CHANNEL_DISPLAY_NUMBER); if (DEBUG) { Log.d(TAG, "Sync status: Channel Scanned"); Log.d(TAG, "Scanned " + channelsScanned + " out of " + channelCount); } mSyncListener.onScannedChannel(channelDisplayName, channelDisplayNumber); } else if (syncStatus.equals(EpgSyncJobService.SYNC_FINISHED)) { if (DEBUG) { Log.d(TAG, "Sync status: Finished"); } mFinishedScan = true; mSyncListener.onScanFinished(); } else if (syncStatus.equals(EpgSyncJobService.SYNC_ERROR)) { int errorCode = intent.getIntExtra(EpgSyncJobService.BUNDLE_KEY_ERROR_REASON, 0); if (DEBUG) { Log.d(TAG, "Error occurred: " + errorCode); } mSyncListener.onScanError(errorCode); } } } SyncStatusBroadcastReceiver(String inputId, SyncListener syncListener); }
SyncStatusBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, final Intent intent) { if (mFinishedScan) { return; } String syncStatusChangedInputId = intent.getStringExtra(EpgSyncJobService.BUNDLE_KEY_INPUT_ID); if (syncStatusChangedInputId != null && syncStatusChangedInputId.equals(mInputId)) { String syncStatus = intent.getStringExtra(EpgSyncJobService.SYNC_STATUS); if (syncStatus.equals(EpgSyncJobService.SYNC_STARTED)) { if (DEBUG) { Log.d(TAG, "Sync status: Started"); } } else if (syncStatus.equals(EpgSyncJobService.SYNC_SCANNED)) { int channelsScanned = intent.getIntExtra(EpgSyncJobService.BUNDLE_KEY_CHANNELS_SCANNED, 0); int channelCount = intent.getIntExtra(EpgSyncJobService.BUNDLE_KEY_CHANNEL_COUNT, 0); mSyncListener.onScanStepCompleted(channelsScanned, channelCount); String channelDisplayName = intent.getStringExtra( EpgSyncJobService.BUNDLE_KEY_SCANNED_CHANNEL_DISPLAY_NAME); String channelDisplayNumber = intent.getStringExtra( EpgSyncJobService.BUNDLE_KEY_SCANNED_CHANNEL_DISPLAY_NUMBER); if (DEBUG) { Log.d(TAG, "Sync status: Channel Scanned"); Log.d(TAG, "Scanned " + channelsScanned + " out of " + channelCount); } mSyncListener.onScannedChannel(channelDisplayName, channelDisplayNumber); } else if (syncStatus.equals(EpgSyncJobService.SYNC_FINISHED)) { if (DEBUG) { Log.d(TAG, "Sync status: Finished"); } mFinishedScan = true; mSyncListener.onScanFinished(); } else if (syncStatus.equals(EpgSyncJobService.SYNC_ERROR)) { int errorCode = intent.getIntExtra(EpgSyncJobService.BUNDLE_KEY_ERROR_REASON, 0); if (DEBUG) { Log.d(TAG, "Error occurred: " + errorCode); } mSyncListener.onScanError(errorCode); } } } SyncStatusBroadcastReceiver(String inputId, SyncListener syncListener); @Override void onReceive(Context context, final Intent intent); }
SyncStatusBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, final Intent intent) { if (mFinishedScan) { return; } String syncStatusChangedInputId = intent.getStringExtra(EpgSyncJobService.BUNDLE_KEY_INPUT_ID); if (syncStatusChangedInputId != null && syncStatusChangedInputId.equals(mInputId)) { String syncStatus = intent.getStringExtra(EpgSyncJobService.SYNC_STATUS); if (syncStatus.equals(EpgSyncJobService.SYNC_STARTED)) { if (DEBUG) { Log.d(TAG, "Sync status: Started"); } } else if (syncStatus.equals(EpgSyncJobService.SYNC_SCANNED)) { int channelsScanned = intent.getIntExtra(EpgSyncJobService.BUNDLE_KEY_CHANNELS_SCANNED, 0); int channelCount = intent.getIntExtra(EpgSyncJobService.BUNDLE_KEY_CHANNEL_COUNT, 0); mSyncListener.onScanStepCompleted(channelsScanned, channelCount); String channelDisplayName = intent.getStringExtra( EpgSyncJobService.BUNDLE_KEY_SCANNED_CHANNEL_DISPLAY_NAME); String channelDisplayNumber = intent.getStringExtra( EpgSyncJobService.BUNDLE_KEY_SCANNED_CHANNEL_DISPLAY_NUMBER); if (DEBUG) { Log.d(TAG, "Sync status: Channel Scanned"); Log.d(TAG, "Scanned " + channelsScanned + " out of " + channelCount); } mSyncListener.onScannedChannel(channelDisplayName, channelDisplayNumber); } else if (syncStatus.equals(EpgSyncJobService.SYNC_FINISHED)) { if (DEBUG) { Log.d(TAG, "Sync status: Finished"); } mFinishedScan = true; mSyncListener.onScanFinished(); } else if (syncStatus.equals(EpgSyncJobService.SYNC_ERROR)) { int errorCode = intent.getIntExtra(EpgSyncJobService.BUNDLE_KEY_ERROR_REASON, 0); if (DEBUG) { Log.d(TAG, "Error occurred: " + errorCode); } mSyncListener.onScanError(errorCode); } } } SyncStatusBroadcastReceiver(String inputId, SyncListener syncListener); @Override void onReceive(Context context, final Intent intent);  }