@@ -123,7 +123,7 @@ class OneSignalPrefs {
123
123
}
124
124
125
125
public static class WritePrefHandlerThread extends HandlerThread {
126
- private Handler mHandler ;
126
+ private @ Nullable Handler mHandler ;
127
127
128
128
private static final int WRITE_CALL_DELAY_TO_BUFFER_MS = 200 ;
129
129
private long lastSyncTime = 0L ;
@@ -136,9 +136,11 @@ public static class WritePrefHandlerThread extends HandlerThread {
136
136
protected void onLooperPrepared () {
137
137
super .onLooperPrepared ();
138
138
139
- // Getting handler here as onLooperPrepared guarantees getLooper() will not return null
139
+ // Getting handler here as onLooperPrepared guarantees getLooper() will be non- null
140
140
mHandler = new Handler (getLooper ());
141
- scheduleFlushToDiskJob ();
141
+
142
+ // Kicks off our first flush, startDelayedWrite will schedule all flushes after that
143
+ scheduleFlushToDisk ();
142
144
}
143
145
144
146
private synchronized void startDelayedWrite () {
@@ -148,7 +150,7 @@ private synchronized void startDelayedWrite() {
148
150
return ;
149
151
150
152
startThread ();
151
- scheduleFlushToDiskJob ();
153
+ scheduleFlushToDisk ();
152
154
}
153
155
154
156
private boolean threadStartCalled ;
@@ -160,7 +162,7 @@ private void startThread() {
160
162
threadStartCalled = true ;
161
163
}
162
164
163
- private synchronized void scheduleFlushToDiskJob () {
165
+ private synchronized void scheduleFlushToDisk () {
164
166
// Could be null if looper thread just started
165
167
if (mHandler == null )
166
168
return ;
0 commit comments