// Path: app/src/main/java/com/bedrock/padder/helper/WindowHelper.java
// @Nullable
// public static String getStringFromId(String id, Context context) {
//     try {
//         Class res = R.string.class;
//         Field field = res.getField(id);
//         return context.getResources().getString(field.getInt(null));
//     } catch (Exception e) {
//         Log.e("getStringFromId", "Failure to get string from id [" + id + "]");
//         return null;
//     }
//     //from : https://daniel-codes.blogspot.com/2009/12/dynamically-retrieving-resources-in.html
// }


import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;
import com.bedrock.padder.R;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.reward.RewardItem;
import com.google.android.gms.ads.reward.RewardedVideoAd;
import com.google.android.gms.ads.reward.RewardedVideoAdListener;
import static com.bedrock.padder.helper.WindowHelper.getStringFromId;

    private void loadRewardedVideoAd() {
        if (!mRewardedVideoAd.isLoaded()) {
            //mRewardedVideoAd.loadAd(getStringFromId(R.string.admob_unit_id_video, this),
//            new AdRequest.Builder().build());
            mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917",
                    new AdRequest.Builder().build());
        }
    }

    @Override
    public void onRewardedVideoAdLoaded() {
        mRewardedVideoAd.show();
    }

    @Override
    public void onRewardedVideoAdOpened() {
    }

    @Override
    public void onRewardedVideoStarted() {
    }

    @Override
    public void onRewardedVideoAdClosed() {
        finish();
    }

    @Override
    public void onRewarded(RewardItem reward) {
// Path: app/src/main/java/com/bedrock/padder/helper/WindowHelper.java
// @Nullable
// public static String getStringFromId(String id, Context context) {
//     try {
//         Class res = R.string.class;
//         Field field = res.getField(id);
//         return context.getResources().getString(field.getInt(null));
//     } catch (Exception e) {
//         Log.e("getStringFromId", "Failure to get string from id [" + id + "]");
//         return null;
//     }
//     //from : https://daniel-codes.blogspot.com/2009/12/dynamically-retrieving-resources-in.html
// }


// Path: app/src/main/java/com/bedrock/padder/activity/VideoAdActivity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;
import com.bedrock.padder.R;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.reward.RewardItem;
import com.google.android.gms.ads.reward.RewardedVideoAd;
import com.google.android.gms.ads.reward.RewardedVideoAdListener;
import static com.bedrock.padder.helper.WindowHelper.getStringFromId;


    private void loadRewardedVideoAd() {
        if (!mRewardedVideoAd.isLoaded()) {
            //mRewardedVideoAd.loadAd(getStringFromId(R.string.admob_unit_id_video, this),
//            new AdRequest.Builder().build());
            mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917",
                    new AdRequest.Builder().build());
        }
    }

    @Override
    public void onRewardedVideoAdLoaded() {
        mRewardedVideoAd.show();
    }

    @Override
    public void onRewardedVideoAdOpened() {
    }

    @Override
    public void onRewardedVideoStarted() {
    }

    @Override
    public void onRewardedVideoAdClosed() {
        finish();
    }

    @Override
    public void onRewarded(RewardItem reward) {
        Toast.makeText(this, getStringFromId(R.string.ads_video_thanks, this), Toast.LENGTH_LONG).show();