...
|
...
|
@@ -10,15 +10,21 @@ import android.view.LayoutInflater; |
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.GridView;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.ListView;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
import com.hh.xuetubao.MyServer;
|
|
|
import com.hh.xuetubao.R;
|
|
|
import com.hh.xuetubao.Utils.BaseObsever;
|
|
|
import com.hh.xuetubao.Utils.GridViewNesting;
|
|
|
import com.hh.xuetubao.Utils.HttpUtils;
|
|
|
import com.hh.xuetubao.Utils.ListViewNesting;
|
|
|
import com.hh.xuetubao.Utils.NetConfig;
|
|
|
import com.hh.xuetubao.Utils.SharedPrefrenceUtils;
|
|
|
import com.hh.xuetubao.activity.pratice.PracticeActivity;
|
|
|
import com.hh.xuetubao.activity.pratice.PriacticeDistActivity;
|
|
|
import com.hh.xuetubao.activity.study.CourseDetailActivity_Video;
|
|
|
import com.hh.xuetubao.activity.study.StudyActivity;
|
|
|
import com.hh.xuetubao.activity.work.CompanyActivity;
|
...
|
...
|
@@ -26,6 +32,7 @@ import com.hh.xuetubao.activity.work.CompanyDetailActivity; |
|
|
import com.hh.xuetubao.adapter.GridHomeHotAdapter;
|
|
|
import com.hh.xuetubao.adapter.HomeCompanyAdapter;
|
|
|
import com.hh.xuetubao.adapter.HomeQuestionAdapter;
|
|
|
import com.hh.xuetubao.bean.AnswerBean;
|
|
|
import com.hh.xuetubao.bean.CompanyBean;
|
|
|
import com.hh.xuetubao.bean.FreeCourseBean;
|
|
|
import com.hh.xuetubao.bean.QuestionBankLstBean;
|
...
|
...
|
@@ -46,6 +53,8 @@ import java.util.List; |
|
|
import butterknife.BindView;
|
|
|
import butterknife.ButterKnife;
|
|
|
import butterknife.Unbinder;
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
|
|
|
/**
|
|
|
* 首页
|
...
|
...
|
@@ -55,11 +64,10 @@ public class HomeFragment extends BaseMvpFragment<CommonPresenter, LearnModel> i |
|
|
|
|
|
|
|
|
@BindView(R.id.grid_hotLesson)
|
|
|
GridView gridHotLesson;
|
|
|
GridViewNesting gridHotLesson;
|
|
|
@BindView(R.id.list_question)
|
|
|
ListViewNesting listQuestion;
|
|
|
@BindView(R.id.list_company)
|
|
|
ListView listCompany;
|
|
|
|
|
|
@BindView(R.id.img_top)
|
|
|
Banner banner;
|
|
|
@BindView(R.id.tv_more_ke)
|
...
|
...
|
@@ -70,6 +78,8 @@ public class HomeFragment extends BaseMvpFragment<CommonPresenter, LearnModel> i |
|
|
TextView tvMoreTi;
|
|
|
@BindView(R.id.lin_title)
|
|
|
LinearLayout linTitle;
|
|
|
@BindView(R.id.list_company)
|
|
|
ListViewNesting listCompany;
|
|
|
private Unbinder unbinder;
|
|
|
private List<FreeCourseBean.bean> hotList = new ArrayList<>();
|
|
|
private List<QuestionBankLstBean.QuestionBankbean> questionList = new ArrayList<>();
|
...
|
...
|
@@ -79,6 +89,7 @@ public class HomeFragment extends BaseMvpFragment<CommonPresenter, LearnModel> i |
|
|
private HomeCompanyAdapter companyAdapter;
|
|
|
private Intent intent;
|
|
|
private List<Drawable> imageList = new ArrayList<>();
|
|
|
private String accountOid;
|
|
|
|
|
|
@Override
|
|
|
public int getLayoutId() {
|
...
|
...
|
@@ -94,6 +105,8 @@ public class HomeFragment extends BaseMvpFragment<CommonPresenter, LearnModel> i |
|
|
linTitle.setFocusableInTouchMode(true);
|
|
|
linTitle.requestFocus();
|
|
|
|
|
|
accountOid = SharedPrefrenceUtils.getString(getActivity(), "AccountOid");
|
|
|
|
|
|
hotAdapter = new GridHomeHotAdapter(hotList, getActivity());
|
|
|
gridHotLesson.setAdapter(hotAdapter);
|
|
|
gridHotLesson.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
...
|
...
|
@@ -110,9 +123,11 @@ public class HomeFragment extends BaseMvpFragment<CommonPresenter, LearnModel> i |
|
|
listQuestion.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
intent = new Intent(getActivity(), PracticeActivity.class);
|
|
|
/*intent = new Intent(getActivity(), PracticeActivity.class);
|
|
|
intent.putExtra("catalogOid", questionList.get(position).getCatalogOid());
|
|
|
startActivity(intent);
|
|
|
startActivity(intent);*/
|
|
|
doRequestTwo(questionList.get(position).getCatalogOid(),accountOid,questionList.get(position).getCatalogName());
|
|
|
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
@@ -143,13 +158,13 @@ public class HomeFragment extends BaseMvpFragment<CommonPresenter, LearnModel> i |
|
|
@Override
|
|
|
public void OnBannerClick(int position) {
|
|
|
switch (position) {
|
|
|
case 0: // 题库
|
|
|
Intent intent = new Intent(getActivity(),PracticeActivity.class);
|
|
|
intent.putExtra("tag","1");
|
|
|
case 0: // 题库
|
|
|
Intent intent = new Intent(getActivity(), PracticeActivity.class);
|
|
|
intent.putExtra("tag", "1");
|
|
|
startActivity(intent);
|
|
|
break;
|
|
|
case 1:
|
|
|
Intent intent1 = new Intent(getActivity(),StudyActivity.class);
|
|
|
Intent intent1 = new Intent(getActivity(), StudyActivity.class);
|
|
|
startActivity(intent1);
|
|
|
break;
|
|
|
}
|
...
|
...
|
@@ -168,6 +183,30 @@ public class HomeFragment extends BaseMvpFragment<CommonPresenter, LearnModel> i |
|
|
|
|
|
}
|
|
|
|
|
|
private void doRequestTwo(final String catalogOid, String accountOid, final String title) {
|
|
|
MyServer mServers = HttpUtils.getInstance().getServer(NetConfig.shuaTiUrl);
|
|
|
mServers.GetRandomQuestions(catalogOid, Integer.valueOf(10), accountOid)
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
.subscribe(new BaseObsever() {
|
|
|
@Override
|
|
|
public void onNext(Object value) {
|
|
|
super.onNext(value);
|
|
|
AnswerBean bean = (AnswerBean) value;
|
|
|
if (bean.isIsSuccess()) {
|
|
|
Intent intent = new Intent(getActivity(), PriacticeDistActivity.class);
|
|
|
intent.putExtra("CatalogOid", catalogOid);
|
|
|
SharedPrefrenceUtils.saveString(getActivity(), "PraticeTitle", title);
|
|
|
getActivity().startActivity(intent);
|
|
|
} else {
|
|
|
Toast.makeText(getActivity(), "当前账号无权限,请拨打电话xxxxxxxxxx", Toast.LENGTH_SHORT).show();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void initData() {
|
|
|
LearnModel model = new LearnModel();
|
...
|
...
|
@@ -198,6 +237,12 @@ public class HomeFragment extends BaseMvpFragment<CommonPresenter, LearnModel> i |
|
|
List<FreeCourseBean.bean> beanLessonLst = bean.getLessonLst();
|
|
|
hotList.addAll(beanLessonLst);
|
|
|
hotAdapter.notifyDataSetChanged();
|
|
|
|
|
|
if(beanLessonLst.size()>4){
|
|
|
tvMoreKe.setVisibility(View.VISIBLE);
|
|
|
}else{
|
|
|
tvMoreKe.setVisibility(View.GONE);
|
|
|
}
|
|
|
}
|
|
|
if (api == 2 && intent == 1) {
|
|
|
QuestionBankLstBean bean = (QuestionBankLstBean) o;
|
...
|
...
|
@@ -206,7 +251,7 @@ public class HomeFragment extends BaseMvpFragment<CommonPresenter, LearnModel> i |
|
|
questionList.addAll(bankLst);
|
|
|
questionAdapter.notifyDataSetChanged();
|
|
|
|
|
|
if (bankLst.size() > 4) {
|
|
|
if (bankLst.size() > 3) {
|
|
|
tvMoreTi.setVisibility(View.VISIBLE);
|
|
|
} else {
|
|
|
tvMoreTi.setVisibility(View.GONE);
|
...
|
...
|
@@ -218,7 +263,7 @@ public class HomeFragment extends BaseMvpFragment<CommonPresenter, LearnModel> i |
|
|
companyList.addAll(companyListBeans);
|
|
|
companyAdapter.notifyDataSetChanged();
|
|
|
|
|
|
if (companyListBeans.size() > 4) {
|
|
|
if (companyListBeans.size() > 3) {
|
|
|
tvMoreQiye.setVisibility(View.VISIBLE);
|
|
|
} else {
|
|
|
tvMoreQiye.setVisibility(View.GONE);
|
...
|
...
|
|