Rename some constants
This commit is contained in:
@@ -68,10 +68,10 @@ public class UpdatesActivity extends AppCompatActivity {
|
||||
mBroadcastReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (UpdaterController.UPDATE_STATUS_ACTION.equals(intent.getAction())) {
|
||||
if (UpdaterController.ACTION_UPDATE_STATUS.equals(intent.getAction())) {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
} else if (UpdaterController.PROGRESS_ACTION.equals(intent.getAction())) {
|
||||
String downloadId = intent.getStringExtra(UpdaterController.DOWNLOAD_ID_EXTRA);
|
||||
} else if (UpdaterController.ACTION_DOWNLOAD_PROGRESS.equals(intent.getAction())) {
|
||||
String downloadId = intent.getStringExtra(UpdaterController.EXTRA_DOWNLOAD_ID);
|
||||
mAdapter.notifyItemChanged(downloadId);
|
||||
}
|
||||
}
|
||||
@@ -86,8 +86,8 @@ public class UpdatesActivity extends AppCompatActivity {
|
||||
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(UpdaterController.UPDATE_STATUS_ACTION);
|
||||
intentFilter.addAction(UpdaterController.PROGRESS_ACTION);
|
||||
intentFilter.addAction(UpdaterController.ACTION_UPDATE_STATUS);
|
||||
intentFilter.addAction(UpdaterController.ACTION_DOWNLOAD_PROGRESS);
|
||||
LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, intentFilter);
|
||||
}
|
||||
|
||||
|
@@ -38,9 +38,9 @@ import java.util.Set;
|
||||
|
||||
public class UpdaterController implements UpdaterControllerInt {
|
||||
|
||||
public static final String PROGRESS_ACTION = "progress_action";
|
||||
public static final String UPDATE_STATUS_ACTION = "update_status_change_action";
|
||||
public static final String DOWNLOAD_ID_EXTRA = "download_id_extra";
|
||||
public static final String ACTION_DOWNLOAD_PROGRESS = "action_download_progress";
|
||||
public static final String ACTION_UPDATE_STATUS = "action_update_status_change";
|
||||
public static final String EXTRA_DOWNLOAD_ID = "extra_download_id";
|
||||
|
||||
private final String TAG = "UpdaterController";
|
||||
|
||||
@@ -91,15 +91,15 @@ public class UpdaterController implements UpdaterControllerInt {
|
||||
|
||||
private void notifyUpdateChange(String downloadId) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(UPDATE_STATUS_ACTION);
|
||||
intent.putExtra(DOWNLOAD_ID_EXTRA, downloadId);
|
||||
intent.setAction(ACTION_UPDATE_STATUS);
|
||||
intent.putExtra(EXTRA_DOWNLOAD_ID, downloadId);
|
||||
mBroadcastManager.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
private void notifyDownloadProgress(String downloadId) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(PROGRESS_ACTION);
|
||||
intent.putExtra(DOWNLOAD_ID_EXTRA, downloadId);
|
||||
intent.setAction(ACTION_DOWNLOAD_PROGRESS);
|
||||
intent.putExtra(EXTRA_DOWNLOAD_ID, downloadId);
|
||||
mBroadcastManager.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
|
@@ -83,12 +83,12 @@ public class UpdaterService extends Service {
|
||||
mBroadcastReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String downloadId = intent.getStringExtra(UpdaterController.DOWNLOAD_ID_EXTRA);
|
||||
if (UpdaterController.UPDATE_STATUS_ACTION.equals(intent.getAction())) {
|
||||
String downloadId = intent.getStringExtra(UpdaterController.EXTRA_DOWNLOAD_ID);
|
||||
if (UpdaterController.ACTION_UPDATE_STATUS.equals(intent.getAction())) {
|
||||
UpdateDownload update = mUpdaterController.getUpdate(downloadId);
|
||||
mNotificationBuilder.setContentTitle(update.getName());
|
||||
handleUpdateStatusChange(update);
|
||||
} else if (UpdaterController.PROGRESS_ACTION.equals(intent.getAction())) {
|
||||
} else if (UpdaterController.ACTION_DOWNLOAD_PROGRESS.equals(intent.getAction())) {
|
||||
UpdateDownload update = mUpdaterController.getUpdate(downloadId);
|
||||
int progress = update.getProgress();
|
||||
mNotificationBuilder.setProgress(100, progress, false);
|
||||
@@ -109,8 +109,8 @@ public class UpdaterService extends Service {
|
||||
}
|
||||
};
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(UpdaterController.PROGRESS_ACTION);
|
||||
intentFilter.addAction(UpdaterController.UPDATE_STATUS_ACTION);
|
||||
intentFilter.addAction(UpdaterController.ACTION_DOWNLOAD_PROGRESS);
|
||||
intentFilter.addAction(UpdaterController.ACTION_UPDATE_STATUS);
|
||||
LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, intentFilter);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user