|
1 | | -package com.blogspot.e_kanivets.moneytracker.activity; |
2 | | - |
3 | | -import android.app.Activity; |
4 | | -import android.os.Bundle; |
5 | | -import android.view.View; |
6 | | -import android.view.Window; |
7 | | -import android.widget.Button; |
8 | | -import android.widget.ProgressBar; |
9 | | -import android.widget.TextView; |
10 | | - |
11 | | -import com.blogspot.e_kanivets.moneytracker.R; |
12 | | -import com.blogspot.e_kanivets.moneytracker.util.AppUtils; |
13 | | -import com.vungle.publisher.EventListener; |
14 | | -import com.vungle.publisher.VunglePub; |
15 | | - |
16 | | -/** |
17 | | - * Created by fess on 16.11.2014. |
18 | | - */ |
19 | | -public class ThankAuthorActivity extends Activity { |
20 | | - |
21 | | - // get the VunglePub instance |
22 | | - final VunglePub vunglePub = VunglePub.getInstance(); |
23 | | - |
24 | | - private ProgressBar progressBar; |
25 | | - |
26 | | - private Activity activity; |
27 | | - |
28 | | - private boolean shouldPlay; |
29 | | - |
30 | | - @Override |
31 | | - protected void onCreate(Bundle savedInstanceState) { |
32 | | - super.onCreate(savedInstanceState); |
33 | | - requestWindowFeature(Window.FEATURE_NO_TITLE); |
34 | | - setContentView(R.layout.activity_thank_author); |
35 | | - |
36 | | - activity = this; |
37 | | - shouldPlay = false; |
38 | | - |
39 | | - // initialize the Publisher SDK |
40 | | - final String app_id = "com.blogspot.e_kanivets.moneytracker"; |
41 | | - vunglePub.init(this, app_id); |
42 | | - |
43 | | - final TextView tvContribution = (TextView) findViewById(R.id.tv_contribution); |
44 | | - Button btnWatchVideoAd = (Button) findViewById(R.id.btn_watch_video_ad); |
45 | | - progressBar = (ProgressBar) findViewById(R.id.progressBar); |
46 | | - |
47 | | - tvContribution.setText(Integer.toString(AppUtils.getContribution(activity))); |
48 | | - |
49 | | - btnWatchVideoAd.setOnClickListener(new View.OnClickListener() { |
50 | | - @Override |
51 | | - public void onClick(View view) { |
52 | | - if(vunglePub.isCachedAdAvailable()) { |
53 | | - vunglePub.playAd(); |
54 | | - } else { |
55 | | - progressBar.setVisibility(View.VISIBLE); |
56 | | - shouldPlay = true; |
57 | | - } |
58 | | - } |
59 | | - }); |
60 | | - |
61 | | - vunglePub.setEventListener(new EventListener() { |
62 | | - @Override |
63 | | - public void onAdEnd(boolean b) { |
64 | | - AppUtils.addContribution(activity); |
65 | | - tvContribution.setText(Integer.toString(AppUtils.getContribution(activity))); |
66 | | - } |
67 | | - |
68 | | - @Override |
69 | | - public void onAdStart() { |
70 | | - |
71 | | - } |
72 | | - |
73 | | - @Override |
74 | | - public void onAdUnavailable(String s) { |
75 | | - |
76 | | - } |
77 | | - |
78 | | - @Override |
79 | | - public void onCachedAdAvailable() { |
80 | | - if(shouldPlay) { |
81 | | - vunglePub.playAd(); |
82 | | - shouldPlay = false; |
83 | | - } |
84 | | - progressBar.setVisibility(View.INVISIBLE); |
85 | | - } |
86 | | - |
87 | | - @Override |
88 | | - public void onVideoView(boolean b, int i, int i2) { |
89 | | - |
90 | | - } |
91 | | - }); |
92 | | - } |
93 | | - |
94 | | - @Override |
95 | | - protected void onPause() { |
96 | | - super.onPause(); |
97 | | - vunglePub.onPause(); |
98 | | - } |
99 | | - |
100 | | - @Override |
101 | | - protected void onResume() { |
102 | | - super.onResume(); |
103 | | - vunglePub.onResume(); |
104 | | - } |
105 | | -} |
| 1 | +package com.blogspot.e_kanivets.moneytracker.activity; |
| 2 | + |
| 3 | +import android.app.Activity; |
| 4 | +import android.os.Bundle; |
| 5 | +import android.view.View; |
| 6 | +import android.view.Window; |
| 7 | +import android.widget.Button; |
| 8 | +import android.widget.ProgressBar; |
| 9 | +import android.widget.TextView; |
| 10 | + |
| 11 | +import com.blogspot.e_kanivets.moneytracker.R; |
| 12 | +import com.blogspot.e_kanivets.moneytracker.util.AppUtils; |
| 13 | +import com.vungle.publisher.EventListener; |
| 14 | +import com.vungle.publisher.VunglePub; |
| 15 | + |
| 16 | +/** |
| 17 | + * Created by fess on 16.11.2014. |
| 18 | + */ |
| 19 | +public class ThankAuthorActivity extends Activity { |
| 20 | + |
| 21 | + // get the VunglePub instance |
| 22 | + final VunglePub vunglePub = VunglePub.getInstance(); |
| 23 | + |
| 24 | + private ProgressBar progressBar; |
| 25 | + |
| 26 | + private Activity activity; |
| 27 | + |
| 28 | + private boolean shouldPlay; |
| 29 | + |
| 30 | + @Override |
| 31 | + protected void onCreate(Bundle savedInstanceState) { |
| 32 | + super.onCreate(savedInstanceState); |
| 33 | + requestWindowFeature(Window.FEATURE_NO_TITLE); |
| 34 | + setContentView(R.layout.activity_thank_author); |
| 35 | + |
| 36 | + activity = this; |
| 37 | + shouldPlay = false; |
| 38 | + |
| 39 | + // initialize the Publisher SDK |
| 40 | + final String app_id = "com.blogspot.e_kanivets.moneytracker"; |
| 41 | + vunglePub.init(this, app_id); |
| 42 | + |
| 43 | + final TextView tvContribution = (TextView) findViewById(R.id.tv_contribution); |
| 44 | + Button btnWatchVideoAd = (Button) findViewById(R.id.btn_watch_video_ad); |
| 45 | + progressBar = (ProgressBar) findViewById(R.id.progressBar); |
| 46 | + |
| 47 | + tvContribution.setText(Integer.toString(AppUtils.getContribution(activity))); |
| 48 | + |
| 49 | + btnWatchVideoAd.setOnClickListener(new View.OnClickListener() { |
| 50 | + @Override |
| 51 | + public void onClick(View view) { |
| 52 | + if(vunglePub.isCachedAdAvailable()) { |
| 53 | + vunglePub.playAd(); |
| 54 | + } else { |
| 55 | + progressBar.setVisibility(View.VISIBLE); |
| 56 | + shouldPlay = true; |
| 57 | + } |
| 58 | + } |
| 59 | + }); |
| 60 | + |
| 61 | + vunglePub.setEventListener(new EventListener() { |
| 62 | + @Override |
| 63 | + public void onAdEnd(boolean b) { |
| 64 | + AppUtils.addContribution(activity); |
| 65 | + tvContribution.setText(Integer.toString(AppUtils.getContribution(activity))); |
| 66 | + } |
| 67 | + |
| 68 | + @Override |
| 69 | + public void onAdStart() { |
| 70 | + |
| 71 | + } |
| 72 | + |
| 73 | + @Override |
| 74 | + public void onAdUnavailable(String s) { |
| 75 | + |
| 76 | + } |
| 77 | + |
| 78 | + @Override |
| 79 | + public void onCachedAdAvailable() { |
| 80 | + if(shouldPlay) { |
| 81 | + vunglePub.playAd(); |
| 82 | + shouldPlay = false; |
| 83 | + } |
| 84 | + progressBar.setVisibility(View.INVISIBLE); |
| 85 | + } |
| 86 | + |
| 87 | + @Override |
| 88 | + public void onVideoView(boolean b, int i, int i2) { |
| 89 | + |
| 90 | + } |
| 91 | + }); |
| 92 | + } |
| 93 | + |
| 94 | + @Override |
| 95 | + protected void onPause() { |
| 96 | + super.onPause(); |
| 97 | + vunglePub.onPause(); |
| 98 | + } |
| 99 | + |
| 100 | + @Override |
| 101 | + protected void onResume() { |
| 102 | + super.onResume(); |
| 103 | + vunglePub.onResume(); |
| 104 | + } |
| 105 | +} |
0 commit comments