Пример #1
0
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle saveInstanceState) {
    View view = inflater.inflate(R.layout.ishas_fragment, parent, false);
    mEditText = (EditText) view.findViewById(R.id.ishas_fragment_edit);
    mButton = (Button) view.findViewById(R.id.ishas_fragment_button);
    textView = (TextView) view.findViewById(R.id.ishas_fragment_title);
    addnewHas = (Button) view.findViewById(R.id.ishas_fragment_add);
    addnewHas.setVisibility(View.VISIBLE);
    textView.setText(getActivity().getResources().getText(R.string.ishas));

    if (mDetailInformation.getHasDate() == null) {
      mButton.setText(TimeTool.DateToYYMMDD(new Date()));
    } else {
      mButton.setText(TimeTool.DateToYYMMDD(mDetailInformation.getHasDate()));
    }
    mButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (mDetailInformation.getHasDate() == null) {
              mDateDialogFragment = DateDialogFragment.getInstance(new Date());
            } else {
              mDateDialogFragment = DateDialogFragment.getInstance(mDetailInformation.getHasDate());
            }
            mDateDialogFragment.show(
                getActivity().getSupportFragmentManager(), DateDialogFragment.TAG);
            mDateDialogFragment.setTargetFragment(IsHasFragment.this, QUEST_DATA);
          }
        });

    mEditText.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

          @Override
          public void afterTextChanged(Editable editable) {
            if (editable.toString().equals("")) {
              mDetailInformation.setNumber(0);
            } else {
              mDetailInformation.setNumber(Integer.valueOf(editable.toString()));
            }
          }
        });

    addnewHas.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            detailInformation.getmDetailLPinformation().add(mDetailInformation);
            detailInformation.setIsHave(true);
            detailInformation.setMating(false);
            detailInformation.setPregnant(false);
          }
        });
    return view;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    TimeTool.setNowDate(new Date());
    readDataToDisk = ReadDataToDisk.getInstance(MainInterfaceActivity.this);

    top_bn01 = (ImageButton) findViewById(R.id.activity_main_return);
    top_bn02 = (ImageButton) findViewById(R.id.activity_main_landing);
    bottom_deatil = (ImageButton) findViewById(R.id.activity_main_detail);
    bottom_mony = (ImageButton) findViewById(R.id.activity_main_mony);
    bottom_circle = (ImageButton) findViewById(R.id.activity_main_circle);
    bottom_myself = (ImageButton) findViewById(R.id.activity_main_myself);
    ton_bnfinsh = (Button) findViewById(R.id.activity_main_finish);
    mViewPage = (ViewPager) findViewById(R.id.activity_main_pageview);
    mFragmentManager = getSupportFragmentManager();

    top_bn02.setOnClickListener(this);
    ton_bnfinsh.setOnClickListener(this);

    mFragmentStatePagerAdapter =
        new FragmentStatePagerAdapter(mFragmentManager) {
          @Override
          public Fragment getItem(int position) {
            if (position == 0) {
              if (DataList.getmDetailInformations().isEmpty()) {
                return WaringFragment.getInstacne(0);
              } else {
                return new IndivListFragment();
              }
            } else if (position == 1) {
              if (DataList.getmDetailLPinformation().isEmpty()) {
                return WaringFragment.getInstacne(1);
              } else {
                return new IndivListLPFragment();
              }
            } else {
              return WaringFragment.getInstacne(1);
            }
          }

          @Override
          public int getItemPosition(Object object) {
            return POSITION_NONE;
          }

          @Override
          public int getCount() {
            return 2;
          }
        };

    mViewPage.setAdapter(mFragmentStatePagerAdapter);
    /*if(DataList.getmDetailInformations().isEmpty()){
        mViewPage.setCurrentItem(1);
    }*/

  }
Пример #3
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode != AppCompatActivity.RESULT_OK) {
     return;
   }
   if (requestCode == QUEST_DATA) {
     Date date = (Date) data.getSerializableExtra(DateDialogFragment.RETURN_INFORMATION);
     mDetailInformation.setHasDate(date);
     mButton.setText(TimeTool.DateToYYMMDD(mDetailInformation.getHasDate()));
   }
 }
 @Override
 public void onResume() {
   super.onResume();
   DataList.getmDetailInformations().clear();
   DataList.getmDetailLPinformation().clear();
   try {
     readDataToDisk.ReadBPData();
     readDataToDisk.ReadLPData();
   } catch (Exception e) {
     Log.e(TAG, "onCreate: " + e.toString());
   }
   mFragmentStatePagerAdapter.notifyDataSetChanged();
   TimeTool.setNowDate(new Date());
 }