MainActivity.java
6.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
package com.lotus.town.clean;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.OvershootInterpolator;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.lotus.town.R;
import com.lotus.town.widget.RoundRelativeLayout;
import com.sdk.Sdk;
import com.ss.android.common.applog.TeaAgent;
import com.umeng.analytics.MobclickAgent;
import java.util.List;
public class MainActivity extends Activity implements View.OnClickListener {
RelativeLayout mCleanPhone;
RoundRelativeLayout mVirusCheck;
RoundRelativeLayout mPhoneFast;
TextView mMainWord;
TextView mSubWord;
TextView mRedDesc;
ImageView mRedView;
RelativeLayout mMoveId;
LinearLayout mHomeStatusTitle;
LinearLayout mSecondStatusTitle;
public static boolean isOppo() {
String manufacturer = Build.MANUFACTURER;
if ("OPPO".equalsIgnoreCase(manufacturer)) {
return true;
}
return false;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
// if(isOppo()){
// MonitorService.invokeMp3(this, true);
// }
initListener();
setAnim2();
setAnim3(mRedView);
mRedDesc.setVisibility(View.GONE);
mRedView.setVisibility(View.GONE);
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// IconUtils.checkIconStatus(MainActivity.this);
// }
// },2000);
// LaunchIconUtil.getInstance().addGhostHomeShortcut(this, R.drawable.booster,"加速,",MainActivity.class);
}
private void setAnim3(View view){
TranslateAnimation animation = new TranslateAnimation(0, 0, 0, -5);
animation.setInterpolator(new OvershootInterpolator());
animation.setDuration(1000);
animation.setFillAfter(true);// True:图片停在动画结束位置
animation.setDuration(1000);
animation.setRepeatCount(Animation.INFINITE);
animation.setRepeatMode(Animation.INFINITE);
view.startAnimation(animation);
}
private void setAnim2() {
AnimationSet as = new AnimationSet(true);
//缩放动画,以中心从1.4倍放大到1.8倍
ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 1.3f, 1f, 1.3f,
ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
//渐变动画
AlphaAnimation alphaAnimation = new AlphaAnimation(1f, 0f);
scaleAnimation.setDuration(1200);
scaleAnimation.setRepeatCount(Animation.INFINITE);
alphaAnimation.setRepeatCount(Animation.INFINITE);
as.setDuration(1200);
as.addAnimation(scaleAnimation);
as.addAnimation(alphaAnimation);
mMoveId.startAnimation(as);
}
private void initView(){
mCleanPhone = findViewById(R.id.clean_phone);
mVirusCheck = findViewById(R.id.virus_check);
mPhoneFast = findViewById(R.id.phone_faster);
// mHomeStatusTitle = findViewById(R.id.home_status_title);
mSecondStatusTitle = findViewById(R.id.second_status_title);
mMainWord = findViewById(R.id.main_word);
mSubWord = findViewById(R.id.sub_word);
mMoveId = findViewById(R.id.move_id);
mRedDesc = findViewById(R.id.red_desc);
mRedView = findViewById(R.id.red_pack);
}
private void initListener(){
mCleanPhone.setOnClickListener(this);
mVirusCheck.setOnClickListener(this);
mPhoneFast.setOnClickListener(this);
mRedView.setOnClickListener(this);
}
@Override
protected void onPause() {
super.onPause();
TeaAgent.onPause(this);
MobclickAgent.onPause(this);
Sdk.isInMain = false;
}
private long time;
private Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
if(msg.what == 0){
mRedDesc.setText(getTimeString(time)+"后可领取红包");
time = time - 1000;
handler.sendEmptyMessageDelayed(0,950);
}
}
};
private String getTimeString(long time){
String result = "";
if(time <=60000){
result = time/1000 +"秒";
} else if(time >60000 && time <60*60*1000){
//70000 10000
result = time/60/1000 +"分钟"+time%(60*1000)/(1000) +"秒";
} else if(time >= 60*60*1000){
//60 * 60 *1000 3600000
result = time/(60*60*1000) +"小时"+time%(60*60*1000)/60/1000 +"分";
}
return result;
}
@Override
protected void onResume() {
super.onResume();
TeaAgent.onResume(this);
MobclickAgent.onResume(this);
}
public static boolean isApplicationBroughtToBackground(final Context context) {
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> tasks = am.getRunningTasks(1);
if (!tasks.isEmpty()) {
ComponentName topActivity = tasks.get(0).topActivity;
if (!topActivity.getPackageName().equals(context.getPackageName())) {
return true;
}
}
return false;
}
@Override
protected void onDestroy() {
super.onDestroy();
Sdk.isInMain = false;
}
@Override
public void onClick(View v) {
gotoWorkPage(v.getId());
}
private void gotoWorkPage(int id){
if(id == R.id.clean_phone){
Intent i = new Intent();
i.setClass(this,CleanActivity.class);
this.startActivity(i);
} else if(id == R.id.virus_check){
Intent i = new Intent();
i.setClass(this,VirusActivity.class);
this.startActivity(i);
} else if(id == R.id.phone_faster){
Intent i = new Intent();
i.setClass(this,BoosterActivity.class);
this.startActivity(i);
}
}
}