Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit fadc3d4

Browse files
committed
fix npe in GCM registration and enable ads
1 parent 6f8c667 commit fadc3d4

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

app/src/main/java/com/otaupdater/AdsFragment.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import android.view.View;
2424
import android.view.ViewGroup;
2525

26+
import com.google.android.gms.ads.AdRequest;
2627
import com.google.android.gms.ads.AdView;
2728
import com.otaupdater.utils.Config;
2829

@@ -47,12 +48,11 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
4748
View view = inflater.inflate(R.layout.ads, container, false);
4849

4950
if (!this.isDetached()) {
50-
// adView = (AdView) view.findViewById(R.id.ad_view);
51-
// AdRequest adReq = new AdRequest.Builder()
52-
// .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
53-
// .addTestDevice("A462D6D0A148B8607AC0EA1173E32B11")
54-
// .build();
55-
// adView.loadAd(adReq);
51+
adView = (AdView) view.findViewById(R.id.ad_view);
52+
AdRequest adReq = new AdRequest.Builder()
53+
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
54+
.build();
55+
adView.loadAd(adReq);
5656
}
5757

5858
return view;

app/src/main/java/com/otaupdater/utils/Utils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public void onSuccess(String message, JSONObject respObj) {
279279
try {
280280
if (PropUtils.isRomOtaEnabled()) {
281281
RomInfo info = RomInfo.FACTORY.fromJSON(respObj.getJSONObject(RomInfo.KEY_NAME));
282-
if (info.isUpdate()) {
282+
if (info != null && info.isUpdate()) {
283283
cfg.storeRomUpdate(info);
284284
if (cfg.getShowNotif()) {
285285
info.showUpdateNotif(ctx);
@@ -294,7 +294,7 @@ public void onSuccess(String message, JSONObject respObj) {
294294

295295
if (PropUtils.isKernelOtaEnabled()) {
296296
KernelInfo info = KernelInfo.FACTORY.fromJSON(respObj.getJSONObject(KernelInfo.KEY_NAME));
297-
if (info.isUpdate()) {
297+
if (info != null && info.isUpdate()) {
298298
cfg.storeKernelUpdate(info);
299299
if (cfg.getShowNotif()) {
300300
info.showUpdateNotif(ctx);

app/src/main/res/layout/ads.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
android:layout_width="wrap_content"
77
android:layout_height="match_parent">
88

9-
<!--<com.google.android.gms.ads.AdView-->
10-
<!--android:id="@+id/ad_view"-->
11-
<!--android:layout_width="match_parent"-->
12-
<!--android:layout_height="wrap_content"-->
13-
<!--ads:adUnitId="ca-app-pub-0361534644858126/7580389175"-->
14-
<!--ads:adSize="SMART_BANNER" />-->
9+
<com.google.android.gms.ads.AdView
10+
android:id="@+id/ad_view"
11+
android:layout_width="match_parent"
12+
android:layout_height="wrap_content"
13+
ads:adUnitId="ca-app-pub-0361534644858126/7580389175"
14+
ads:adSize="SMART_BANNER" />
1515

16-
</LinearLayout>
16+
</LinearLayout>

0 commit comments

Comments
 (0)