MainActivity.java
4.4 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
package com.hh.xuetubao;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.RadioButton;
import com.hh.xuetubao.activity.pratice.PracticeActivity;
import com.hh.xuetubao.activity.study.StudyActivity;
import com.hh.xuetubao.activity.work.JobHuntActivity;
import com.hh.xuetubao.fragment.HomeFragment;
import com.hh.xuetubao.fragment.MineFragment;
import com.hh.xuetubao.fragment.PraticeWrongFragment;
import com.hh.xuetubao.model.MainModel;
import com.hh.xuetubao.mvp.BaseMvpActivity;
import com.hh.xuetubao.mvp.CommonPresenter;
import com.hh.xuetubao.mvp.ICommonView;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* 主页面
*/
public class MainActivity extends BaseMvpActivity<CommonPresenter, MainModel> implements ICommonView, View.OnClickListener {
@BindView(R.id.rl_home)
RadioButton rlHome;
@BindView(R.id.rl_study)
RadioButton rlStudy;
@BindView(R.id.rl_job)
RadioButton rlJob;
@BindView(R.id.rl_biancheng)
RadioButton rlBiancheng;
@BindView(R.id.rl_mine)
RadioButton rlMine;
private FragmentTransaction transaction;
private MineFragment mineFragment;
private HomeFragment homeFragment;
private PraticeWrongFragment wrongFragment;
int selectTag = 3;
@Override
public void initView() {
/* //添加变色标志
this.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
//导航栏颜色
getWindow().setNavigationBarColor(Color.parseColor("#fcfcfc"));
//状态栏颜色
getWindow().setStatusBarColor(Color.parseColor("#fcfcfc"));*/
homeFragment = new HomeFragment();
wrongFragment = new PraticeWrongFragment();
transaction = getSupportFragmentManager().beginTransaction();
transaction.add(R.id.frame, homeFragment);
// transaction.show(homeFragment);
transaction.commit();
rlHome.setChecked(true);
rlHome.setOnClickListener(this);
rlStudy.setOnClickListener(this);
rlJob.setOnClickListener(this);
rlBiancheng.setOnClickListener(this);
rlMine.setOnClickListener(this);
}
@Override
public int initLayout() {
return R.layout.activity_mine;
}
@Override
public void initData() {
}
@Override
public CommonPresenter getPresenter() {
return new CommonPresenter();
}
@Override
public MainModel getModel() {
return new MainModel();
}
@Override
public void getData(Object o, int api, int intent) {
}
@Override
public void onComplete(int api) {
}
@Override
public void onError(Throwable e, int api) {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
@Override
public void onClick(View v) {
transaction = getSupportFragmentManager().beginTransaction();
mineFragment = new MineFragment();
homeFragment = new HomeFragment();
switch (v.getId()) {
case R.id.rl_home:
transaction.replace(R.id.frame, homeFragment);
transaction.commit();
selectTag = 0;
break;
case R.id.rl_study:
startActivity(new Intent(this, StudyActivity.class));
rlStudy.setChecked(true);
selectTag = 0;
MainActivity.this.finish();
break;
case R.id.rl_job:
startActivity(new Intent(this, JobHuntActivity.class));
rlJob.setChecked(true);
selectTag = 0;
MainActivity.this.finish();
break;
case R.id.rl_biancheng:
startActivity(new Intent(this, PracticeActivity.class));
rlBiancheng.setChecked(true);
selectTag = 0;
MainActivity.this.finish();
break;
case R.id.rl_mine:
transaction.replace(R.id.frame, mineFragment, "1");
transaction.commit();
rlMine.setChecked(true);
selectTag = 4;
break;
}
}
@Override
protected void onResume() {
super.onResume();
}
}