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

Commit

Permalink
fix npe in GCM registration and enable ads
Browse files Browse the repository at this point in the history
  • Loading branch information
vetruvet committed Jul 29, 2014
1 parent 6f8c667 commit fadc3d4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions app/src/main/java/com/otaupdater/AdsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import android.view.View;
import android.view.ViewGroup;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.otaupdater.utils.Config;

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

if (!this.isDetached()) {
// adView = (AdView) view.findViewById(R.id.ad_view);
// AdRequest adReq = new AdRequest.Builder()
// .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
// .addTestDevice("A462D6D0A148B8607AC0EA1173E32B11")
// .build();
// adView.loadAd(adReq);
adView = (AdView) view.findViewById(R.id.ad_view);
AdRequest adReq = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
adView.loadAd(adReq);
}

return view;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/otaupdater/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public void onSuccess(String message, JSONObject respObj) {
try {
if (PropUtils.isRomOtaEnabled()) {
RomInfo info = RomInfo.FACTORY.fromJSON(respObj.getJSONObject(RomInfo.KEY_NAME));
if (info.isUpdate()) {
if (info != null && info.isUpdate()) {
cfg.storeRomUpdate(info);
if (cfg.getShowNotif()) {
info.showUpdateNotif(ctx);
Expand All @@ -294,7 +294,7 @@ public void onSuccess(String message, JSONObject respObj) {

if (PropUtils.isKernelOtaEnabled()) {
KernelInfo info = KernelInfo.FACTORY.fromJSON(respObj.getJSONObject(KernelInfo.KEY_NAME));
if (info.isUpdate()) {
if (info != null && info.isUpdate()) {
cfg.storeKernelUpdate(info);
if (cfg.getShowNotif()) {
info.showUpdateNotif(ctx);
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/res/layout/ads.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
android:layout_width="wrap_content"
android:layout_height="match_parent">

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

</LinearLayout>
</LinearLayout>

0 comments on commit fadc3d4

Please sign in to comment.