예제 #1
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_home, container, false);
    ButterKnife.bind(this, view);
    setTypeFace();
    alarm = new AlarmManagerBroadcastReceiver();
    alarm.SetAlarm(getActivity());
    try {
      new CountDownTimer(MixUtils.calculateTimeLeftToVote(), 1000) {
        @Override
        public void onTick(long millisUntilFinished) {

          HashMap<String, String> values = MixUtils.formatTime(millisUntilFinished);
          String monthDay = MixUtils.convertToBurmese(values.get("month_day"));
          String hourMinute = MixUtils.convertToBurmese(values.get("hour_minute"));
          monthDayLeft.setText(monthDay);
          hourMinuteLeft.setText(hourMinute);
          if (monthDay.isEmpty()) {
            monthDayLeft.setVisibility(View.GONE);
          }
        }

        @Override
        public void onFinish() {
          // toVote.setText("ပြောင်းလဲရန်");
          monthDayLeft.setText("အခ\u103Bိန\u103Aရောက\u103Aပ\u103Cီ");
          monthDayLeft.setVisibility(View.VISIBLE);
          hourMinuteLeft.setVisibility(View.GONE);
        }
      }.start();
    } catch (ParseException e) {
      e.printStackTrace();
    }
    faqImg.setColorFilter(getResources().getColor(R.color.white));
    faqImg.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Intent faqIntent = new Intent(getActivity(), FaqListActivity.class);
            startActivity(faqIntent);
          }
        });

    UserPrefUtils userPrefUtils = new UserPrefUtils(getActivity());
    if (userPrefUtils.isValid()) {
      backdrop.setCardBackgroundColor(getResources().getColor(R.color.accent_color));
      txt_cardview_vote_check.setTextColor(Color.WHITE);
      valid_sign.setImageDrawable(getResources().getDrawable(R.drawable.ic_mark));
    } else {
      backdrop.setCardBackgroundColor(Color.parseColor("#FFC107"));
      valid_sign.setImageDrawable(getResources().getDrawable(R.drawable.ic_exclamation_mark));
      txt_cardview_vote_check.setTextColor(Color.WHITE);
    }
    return view;
  }
예제 #2
0
  @OnClick(R.id.cardview_vote_check)
  public void showVoteResult(CardView textView) {
    final UserPrefUtils userPrefUtils = new UserPrefUtils(getActivity());
    boolean ok = userPrefUtils.isValid();

    VoterCheckDialog dialog = new VoterCheckDialog((MainActivity) getActivity(), this);
    // Set uni or zg for dialog
    dialog.unicode(isUnicode);

    if (ok) {
      dialog.showValid(getActivity().getLayoutInflater());
    } else {
      dialog.showInvalid(getActivity().getLayoutInflater());
    }
  }
예제 #3
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_sign_up, container, false);
    ButterKnife.bind(this, rootView);

    // search township view
    initRecyclerView();
    initEditText();
    UserPrefUtils userPrefUtils = UserPrefUtils.getInstance(getContext());
    isValid = userPrefUtils.isValid();
    isFirstTimeOrSkip = userPrefUtils.isSKIP();

    mainView.setVisibility(View.VISIBLE);
    now = Calendar.getInstance();
    defaultYear = now.get(Calendar.YEAR) - maxAgeforVote;
    defaultMonth = now.get(Calendar.MONTH);
    defaultDate = now.get(Calendar.DAY_OF_MONTH);

    if (isUnicode) {
      toCheckMae.setTypeface(typefaceTitle);
      checkButton.setTypeface(typefacelight);
      myanmarTextPlease.setTypeface(typefacelight);
      skip_card_button.setTypeface(typefacelight);
      mUserName.setHint(getString(R.string.name_uni));
      mFatherName.setHint(getString(R.string.father_name_uni));
    } else {

      MMTextUtils.getInstance(getContext())
          .prepareMultipleViews(
              toCheckMae,
              checkButton,
              myanmarTextPlease,
              skip_card_button,
              mDateOfBirth,
              mDOBLabel,
              mTownship);
      mUserName.setHint(getString(R.string.name_zg));
      mFatherName.setHint(getString(R.string.father_name_zg));
    }
    if (isFirstTimeOrSkip) {
      mainView.setVisibility(View.GONE);
      contenFragment.setVisibility(View.VISIBLE);
      HomeFragment homeFragment = new HomeFragment();
      FragmentManager fm = getActivity().getSupportFragmentManager();
      FragmentTransaction transaction = fm.beginTransaction();
      transaction.replace(R.id.contentFragment, homeFragment);
      transaction.commit();
    }
    if (userPrefUtils.getTownship() != null && userPrefUtils.getTownship().length() > 0) {
      DataUtils.Township township =
          new Gson().fromJson(userPrefUtils.getTownship(), DataUtils.Township.class);
      mTownship.setText(township.getTowhshipNameBurmese());
      mTownship.setTextColor(getResources().getColor(R.color.primary_text_color));
      if (!isUnicode) MMTextUtils.getInstance(getActivity()).prepareSingleView(mTownship);
    }
    if (userPrefUtils.getUserName() != null && userPrefUtils.getUserName().length() > 0) {
      mUserName.setText(userPrefUtils.getUserName());
      if (!isUnicode) MMTextUtils.getInstance(getActivity()).prepareSingleView(mUserName);
    }
    if (userPrefUtils.getFatherName() != null && userPrefUtils.getFatherName().length() > 0) {
      mFatherName.setText(userPrefUtils.getFatherName());
      if (!isUnicode) MMTextUtils.getInstance(getActivity()).prepareSingleView(mFatherName);
    }
    if (userPrefUtils.getBirthDate() != null && userPrefUtils.getBirthDate().length() > 0) {
      mDateOfBirth.setText(userPrefUtils.getBirthDate());
    }
    if (userPrefUtils.getNrc() != null && userPrefUtils.getNrc().length() > 0) {
      String nrcLong = userPrefUtils.getNrc();
      try {
        String nrc1 = nrcLong.split("/")[0];
        mNrcNo.setText(nrc1);
      } catch (Exception e) {

      }
      try {
        String nrc2 = nrcLong.split("/")[1].split("\\(နိုင်\\)")[0];
        mNrcTownShip.setText(nrc2);
      } catch (Exception e) {

      }
      try {
        String nrc3 = nrcLong.split("/")[1].split("\\(နိုင်\\)")[1];
        mNrcValue.setText(nrc3);
      } catch (Exception e) {

      }
    }
    return rootView;
  }