Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
public class MainActivity extends Activity {

private static final String TAG = "ConnectionClass-Sample";
private static final int MAX_SAMPLE_RETRIES = 10;

private ConnectionClassManager mConnectionClassManager;
private DeviceBandwidthSampler mDeviceBandwidthSampler;
Expand Down Expand Up @@ -128,8 +129,7 @@ protected Void doInBackground(String... url) {
@Override
protected void onPostExecute(Void v) {
mDeviceBandwidthSampler.stopSampling();
// Retry for up to 10 times until we find a ConnectionClass.
if (mConnectionClass == ConnectionQuality.UNKNOWN && mTries < 10) {
if (mConnectionClass == ConnectionQuality.UNKNOWN && mTries < MAX_SAMPLE_RETRIES) {
mTries++;
new DownloadImage().execute(mURL);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,8 @@ public void remove(ConnectionClassStateChangeListener listener) {
}

private void notifyListeners() {
int size = mListenerList.size();
for (int i = 0; i < size; i++) {
mListenerList.get(i).onBandwidthStateChange(mCurrentBandwidthConnectionQuality.get());
for (ConnectionClassStateChangeListener stateChangeListener : mListenerList) {
stateChangeListener.onBandwidthStateChange(mCurrentBandwidthConnectionQuality.get());
}
}
}