| | |
| | | package com.basic.security.fragment; |
| | | |
| | | import android.os.Handler; |
| | | import android.os.SystemClock; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.FragmentManager; |
| | | import android.support.v4.app.FragmentPagerAdapter; |
| | | import android.view.View; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.basic.security.R; |
| | |
| | | import org.androidannotations.annotations.EFragment; |
| | | import org.androidannotations.annotations.ViewById; |
| | | |
| | | import java.sql.Time; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Timer; |
| | | import java.util.TimerTask; |
| | | |
| | | @EFragment(R.layout.fragment_system_setting_tabs) |
| | | public class SystemSettingTabsFragment extends BaseFragment { |
| | | |
| | | // @ViewById |
| | | // public LinearLayout ll_all_base_setting; |
| | | @ViewById |
| | | TextView base_set, device_set, account_set; |
| | | @ViewById |
| | | View base_set_layout, tv_hint_setting_layout, device_set_layout, account_set_layout; |
| | | @ViewById |
| | | TextView tv_hint_setting;//, tv_basic_message , tv_time_setting; |
| | | private List<Fragment> fragmentList = new ArrayList<>(); |
| | | |
| | | private int currentPage = 0; |
| | | private boolean isFromOtherTabs = false; |
| | | |
| | | @AfterViews |
| | | void initSomething() { |
| | | |
| | | } |
| | | |
| | | // private SettingAdapter adapter; |
| | | |
| | | |
| | | @ViewById |
| | | TextView base_set, device_set, colony_set, account_set; |
| | | @ViewById |
| | | View base_set_layout, device_set_layout, colony_set_layout, account_set_layout; |
| | | @ViewById |
| | | public LinearLayout ll_all_base_setting; |
| | | @ViewById |
| | | TextView tv_basic_message, tv_hint_setting, tv_time_setting; |
| | | |
| | | // @ViewById |
| | | // ViewPager view_pager; |
| | | |
| | | // @AfterViews |
| | | // void init_data() { |
| | | // fragmentList.clear(); |
| | | // fragmentList.add(new BaseSettingFragment_()); |
| | | // fragmentList.add(new DeviceSettingFragment_()); |
| | | // fragmentList.add(new ColonySettingFragment_()); |
| | | // fragmentList.add(new AccountSettingFragment_()); |
| | | // fragmentList.add(mainActivity().fragment_base_setting); |
| | | // fragmentList.add(mainActivity().fragment_device_setting); |
| | | // fragmentList.add(mainActivity().fragment_colony_setting); |
| | | // fragmentList.add(mainActivity().fragment_account_setting); |
| | | // fragmentList.add(BaseSettingFragment.newInstance()); |
| | | // fragmentList.add(DeviceSettingFragment.newInstance()); |
| | | // fragmentList.add(ClusterSettingFragment.newInstance()); |
| | | // fragmentList.add(AccountSettingFragment.newInstance()); |
| | | // adapter = new SettingAdapter(getChildFragmentManager(), fragmentList); |
| | | |
| | | // view_pager.setAdapter(adapter); |
| | | // adapter.notifyDataSetChanged(); |
| | | // |
| | | // view_pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { |
| | | // @Override |
| | | // public void onPageScrolled(int i, float v, int i1) { |
| | | // |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onPageSelected(int i) { |
| | | // resetColor(currentPage); |
| | | // currentPage = i; |
| | | // changeColor(currentPage); |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onPageScrollStateChanged(int i) { |
| | | // |
| | | // } |
| | | // }); |
| | | // } |
| | | // |
| | | // |
| | | // private class SettingAdapter extends FragmentPagerAdapter { |
| | | // |
| | | // private List<Fragment> fragment_list; |
| | | // |
| | | // SettingAdapter(FragmentManager fm, List<Fragment> fragment_list) { |
| | | // super(fm); |
| | | // this.fragment_list = fragment_list; |
| | | // } |
| | | // |
| | | // @Override |
| | | // public Fragment getItem(int position) { |
| | | // return fragment_list.get(position); |
| | | // } |
| | | // |
| | | // @Override |
| | | // public int getCount() { |
| | | // return fragment_list.size(); |
| | | // } |
| | | // } |
| | | |
| | | @Override |
| | | public void show() { |
| | | super.show(); |
| | | // ll_all_base_setting.setVisibility(View.GONE); |
| | | // if (Constants.useAlf) { |
| | | // colony_set_layout.setVisibility(View.GONE); |
| | | // colony_set.setVisibility(View.GONE); |
| | | // } |
| | | } |
| | | |
| | | @Override |
| | | public void hide() { |
| | | super.hide(); |
| | | } |
| | |
| | | resetColor(currentPage); |
| | | currentPage = 0; |
| | | changeColor(currentPage); |
| | | ll_all_base_setting.setVisibility(View.VISIBLE); |
| | | // ll_all_base_setting.setVisibility(View.VISIBLE); |
| | | mainActivity().showFragment(mainActivity().fragment_base_setting); |
| | | final Handler handler = new Handler(); |
| | | TimerTask timerTask = new TimerTask(){ |
| | | @Override |
| | | public void run() { |
| | | handler.post(new Runnable(){ |
| | | @Override |
| | | public void run() { |
| | | ll_all_base_setting.setVisibility(View.GONE); |
| | | // TimerTask timerTask = new TimerTask() { |
| | | // public void run() { |
| | | // handler.post(() -> ll_all_base_setting.setVisibility(View.GONE)); |
| | | // } |
| | | // }; |
| | | // Timer timer = new Timer(); |
| | | // timer.schedule(timerTask, 1000); |
| | | } |
| | | }); |
| | | } |
| | | }; |
| | | Timer timer = new Timer(); |
| | | timer.schedule(timerTask,1000); |
| | | } |
| | | |
| | | private boolean isFromOtherTabs = false; |
| | | |
| | | @Click |
| | | void base_set() { |
| | | resetColor(currentPage); |
| | | currentPage = 0; |
| | | changeColor(currentPage); |
| | | // view_pager.setCurrentItem(0); |
| | | if (isFromOtherTabs) { |
| | | mainActivity().showFragment(mainActivity().fragment_base_setting); |
| | | isFromOtherTabs = false; |
| | | } else { |
| | | if (ll_all_base_setting.getVisibility() == View.VISIBLE) { |
| | | ll_all_base_setting.setVisibility(View.GONE); |
| | | } else { |
| | | ll_all_base_setting.setVisibility(View.VISIBLE); |
| | | // if (ll_all_base_setting.getVisibility() == View.VISIBLE) { |
| | | // ll_all_base_setting.setVisibility(View.GONE); |
| | | // } else { |
| | | // ll_all_base_setting.setVisibility(View.VISIBLE); |
| | | // } |
| | | } |
| | | } |
| | | |
| | | @Click |
| | | void tv_hint_setting() { |
| | | isFromOtherTabs = true; |
| | | hideAllSettingPopup(); |
| | | resetColor(currentPage); |
| | | currentPage = 1; |
| | | changeColor(currentPage); |
| | | mainActivity().showFragment(mainActivity().fragment_hint_tab); |
| | | } |
| | | |
| | | @Click |
| | |
| | | isFromOtherTabs = true; |
| | | hideAllSettingPopup(); |
| | | resetColor(currentPage); |
| | | currentPage = 1; |
| | | currentPage = 2; |
| | | changeColor(currentPage); |
| | | // view_pager.setCurrentItem(1); |
| | | mainActivity().showFragment(mainActivity().fragment_device_setting); |
| | | } |
| | | |
| | | @Click |
| | | void colony_set() { |
| | | isFromOtherTabs = true; |
| | | hideAllSettingPopup(); |
| | | resetColor(currentPage); |
| | | currentPage = 2; |
| | | changeColor(currentPage); |
| | | // view_pager.setCurrentItem(2); |
| | | mainActivity().showFragment(mainActivity().fragment_cluster_setting); |
| | | } |
| | | // @Click |
| | | // void colony_set() { |
| | | // isFromOtherTabs = true; |
| | | // hideAllSettingPopup(); |
| | | // resetColor(currentPage); |
| | | // currentPage = 3; |
| | | // changeColor(currentPage); |
| | | // mainActivity().showFragment(mainActivity().fragment_cluster_setting); |
| | | // } |
| | | |
| | | |
| | | @Click |
| | | void account_set() { |
| | | isFromOtherTabs = true; |
| | | hideAllSettingPopup(); |
| | | resetColor(currentPage); |
| | | currentPage = 3; |
| | | currentPage = 4; |
| | | changeColor(currentPage); |
| | | // view_pager.setCurrentItem(3); |
| | | mainActivity().showFragment(mainActivity().fragment_account_setting); |
| | | } |
| | | |
| | | // public void beforeShowFragment() { |
| | | // changeColor(currentPage); |
| | | // @Click |
| | | // void tv_basic_message() { |
| | | // hideAllSettingPopup(); |
| | | // showFragment(mainActivity().fragment_base_setting); |
| | | // } |
| | | @Click |
| | | void tv_basic_message() { |
| | | hideAllSettingPopup(); |
| | | showFragment(mainActivity().fragment_base_setting); |
| | | } |
| | | |
| | | @Click |
| | | void tv_hint_setting() { |
| | | hideAllSettingPopup(); |
| | | ((HintTabFragment) mainActivity().fragment_hint_tab).wait_face_station.setChecked(true); |
| | | showFragment(mainActivity().fragment_hint_tab); |
| | | } |
| | | // @Click |
| | | // void tv_hint_setting() { |
| | | // hideAllSettingPopup(); |
| | | // ((HintTabFragment) mainActivity().fragment_hint_tab).wait_face_station.setChecked(true); |
| | | // showFragment(mainActivity().fragment_hint_tab); |
| | | // } |
| | | |
| | | @Click |
| | | void tv_time_setting() { |
| | | hideAllSettingPopup(); |
| | | showFragment(mainActivity().fragment_time_rule); |
| | | } |
| | | // @Click |
| | | // void tv_time_setting() { |
| | | // hideAllSettingPopup(); |
| | | // showFragment(mainActivity().fragment_time_rule); |
| | | // } |
| | | |
| | | private void resetColor(int i) { |
| | | switch (i) { |
| | |
| | | base_set_layout.setVisibility(View.GONE); |
| | | break; |
| | | case 1: |
| | | tv_hint_setting.setTextColor(getResources().getColor(R.color.colorWhite)); |
| | | tv_hint_setting_layout.setVisibility(View.GONE); |
| | | break; |
| | | case 2: |
| | | device_set.setTextColor(getResources().getColor(R.color.colorWhite)); |
| | | device_set_layout.setVisibility(View.GONE); |
| | | break; |
| | | case 2: |
| | | colony_set.setTextColor(getResources().getColor(R.color.colorWhite)); |
| | | colony_set_layout.setVisibility(View.GONE); |
| | | break; |
| | | case 3: |
| | | // colony_set.setTextColor(getResources().getColor(R.color.colorWhite)); |
| | | // colony_set_layout.setVisibility(View.GONE); |
| | | break; |
| | | case 4: |
| | | account_set.setTextColor(getResources().getColor(R.color.colorWhite)); |
| | | account_set_layout.setVisibility(View.GONE); |
| | | break; |
| | |
| | | base_set_layout.setVisibility(View.VISIBLE); |
| | | break; |
| | | case 1: |
| | | tv_hint_setting.setTextColor(getResources().getColor(R.color.press_setting_text_color)); |
| | | tv_hint_setting_layout.setVisibility(View.VISIBLE); |
| | | break; |
| | | case 2: |
| | | device_set.setTextColor(getResources().getColor(R.color.press_setting_text_color)); |
| | | device_set_layout.setVisibility(View.VISIBLE); |
| | | break; |
| | | case 2: |
| | | colony_set.setTextColor(getResources().getColor(R.color.press_setting_text_color)); |
| | | colony_set_layout.setVisibility(View.VISIBLE); |
| | | break; |
| | | case 3: |
| | | // colony_set.setTextColor(getResources().getColor(R.color.press_setting_text_color)); |
| | | // colony_set_layout.setVisibility(View.VISIBLE); |
| | | break; |
| | | case 4: |
| | | account_set.setTextColor(getResources().getColor(R.color.press_setting_text_color)); |
| | | account_set_layout.setVisibility(View.VISIBLE); |
| | | break; |
| | |
| | | } |
| | | |
| | | public void hideAllSettingPopup() { |
| | | if (ll_all_base_setting.getVisibility() == View.VISIBLE) { |
| | | ll_all_base_setting.setVisibility(View.GONE); |
| | | } |
| | | // if (ll_all_base_setting.getVisibility() == View.VISIBLE) { |
| | | // ll_all_base_setting.setVisibility(View.GONE); |
| | | // } |
| | | } |
| | | } |