AudioDialogActivity.java
2.19 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
package com.cnlive.downloadfile;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import com.cnlive.downloadfile.download.limit.DownLoadService;
import com.cnlive.downloadfile.download.limit.DownloadInfo;
import com.cnlive.downloadfile.download.util.NetWorkUtil;
public class AudioDialogActivity extends Activity implements View.OnClickListener {
private TextView btn_left,btn_right;
private String inType;
private DownloadInfo info;
public static void startActivity(Context context, String inType, DownloadInfo info) {
if (!NetWorkUtil.isAppOnForeground(context)) return;
Intent intent = new Intent(context, AudioDialogActivity.class);
intent.putExtra("inType", inType);
intent.putExtra("info",info);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_audio_dialog);
initIntent(getIntent());
btn_left = findViewById(R.id.btn_left);
btn_right = findViewById(R.id.btn_right);
btn_left.setOnClickListener(this);
btn_right.setOnClickListener(this);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
initIntent(intent);
}
private void initIntent(Intent intent) {
inType = intent.getStringExtra("inType");
info = (DownloadInfo) intent.getSerializableExtra("info");
}
private void notifyService(String action) {
Intent intent = new Intent(this, DownLoadService.class);
intent.setAction(action);
intent.putExtra("fileUrl", info);
intent.putExtra("isNet","isNet");
startService(intent);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.btn_left:
finish();
break;
case R.id.btn_right:
notifyService(inType);
finish();
break;
}
}
}