-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ota] add ota view manager to manage ota view
- Loading branch information
1 parent
f7f61cd
commit 2d49be1
Showing
3 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
lib/src/main/java/com/stockholm/common/ota/OtaViewManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.stockholm.common.ota; | ||
|
||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.IntentFilter; | ||
|
||
import com.stockholm.common.IntentExtraKey; | ||
|
||
public class OtaViewManager { | ||
|
||
private Context context; | ||
private boolean showing = false; | ||
private OtaViewReceiver otaViewReceiver; | ||
|
||
public OtaViewManager(Context context) { | ||
this.context = context; | ||
} | ||
|
||
public void registerOtaViewReceiver() { | ||
otaViewReceiver = new OtaViewReceiver(); | ||
context.registerReceiver(otaViewReceiver, new IntentFilter(IntentExtraKey.ACTION_SHOW_OTA_VIEW)); | ||
context.registerReceiver(otaViewReceiver, new IntentFilter(IntentExtraKey.ACTION_CLEAR_OTA_VIEW)); | ||
} | ||
|
||
public void unregisterOtaViewReceiver() { | ||
context.unregisterReceiver(otaViewReceiver); | ||
} | ||
|
||
public boolean isShowing() { | ||
return showing; | ||
} | ||
|
||
private class OtaViewReceiver extends BroadcastReceiver { | ||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
String action = intent.getAction(); | ||
if (action.equals(IntentExtraKey.ACTION_SHOW_OTA_VIEW)) { | ||
showing = true; | ||
} else if (action.equals(IntentExtraKey.ACTION_CLEAR_OTA_VIEW)) { | ||
showing = false; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters