@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_candidate_detail); ButterKnife.bind(this); // actionbar setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); assert actionBar != null; actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(""); typefaceTitle = FontCache.getTypefaceTitle(this); typefacelight = FontCache.getTypefaceTitle(this); isUnicode = UserPrefUtils.getInstance(this).getTextPref().equals(Config.UNICODE); mListener = new AppBarLayout.OnOffsetChangedListener() { @Override public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { if (collapsingAvatarToolbar.getHeight() + verticalOffset < 2 * ViewCompat.getMinimumHeight(collapsingAvatarToolbar)) { MixUtils.toggleVisibilityWithAnim(cardView, 1000, false); } else { MixUtils.toggleVisibilityWithAnim(cardView, 1000, true); } } }; appbar.addOnOffsetChangedListener(mListener); candidate = (Candidate) getIntent().getSerializableExtra(Config.CANDIDATE); candidateSearchResult = (CandidateSearchResult) getIntent().getSerializableExtra("searchResult"); if (candidate != null) { Glide.with(this) .load(candidate.getParty().getPartyFlag()) .bitmapTransform(new BlurTransformation(getApplicationContext(), 8, 1)) .into(partyImage); Glide.with(this) .load(candidate.getPhotoUrl()) .diskCacheStrategy(DiskCacheStrategy.ALL) .bitmapTransform(new CropCircleTransformation(this)) .placeholder(R.drawable.profile_placeholder) .into(candidateImage); candidateName.setText(candidate.getName()); Glide.with(this) .load(candidate.getParty().getPartyFlag()) .diskCacheStrategy(DiskCacheStrategy.ALL) .into(mCandidatePartyFlag); if (candidate.getConstituency().getAMPCODE() == null) { upperHouseView.setVisibility(View.GONE); } else { upperHouseView.setVisibility(View.VISIBLE); upperHouse.setText( MixUtils.amConstituencyName( candidate.getConstituency().getName(), candidate.getConstituency().getNumber())); } mCandidateConstituency.setText(candidate.getConstituency().getName()); mCandidateDateOfBirth.setText( MixUtils.convertToBurmese(String.valueOf(candidate.getBirthDateString()))); mCandidateEducation.setText(candidate.getEducation()); mCandidateFather.setText(candidate.getFather().getName()); mCandidateMother.setText(candidate.getMother().getName()); mCandidateOccupation.setText(candidate.getOccupation()); mCandidateRace.setText(candidate.getEthnicity()); mCandidateReligion.setText(candidate.getReligion()); mCandidateLegalSlature.setText(candidate.getLegislature()); mCandidateParty.setText(candidate.getParty().getPartyName()); mCandidateAddress.setText(candidate.getWardVillage()); RESTService mRESTService = RESTClient.getService(this); if (candidate.getMpid() == null) { // mCompareCandidate.setCardBackgroundColor(getResources().getColor(R.color.accent_color_error)); // mCandidateCompareResult.setText(getResources().getString(R.string.first_time_candidate)); mQuestionHeaderTv.setVisibility(View.GONE); mMotionHeaderTv.setVisibility(View.GONE); mCandidateQuestionCard.setVisibility(View.GONE); mCandidateMotionCard.setVisibility(View.GONE); } else { Call<JsonObject> questionMotionCall = mRESTService.getQuestionAndMotion(candidate.getMpid()); questionMotionCall.enqueue( new RestCallback<JsonObject>() { @Override public void onResponse(Response<JsonObject> response) { if (response.code() == 200) { int motionCount = response.body().get("motions_count").getAsInt(); JsonArray motions = response.body().get("motions").getAsJsonArray(); int questionCount = response.body().get("questions_count").getAsInt(); JsonArray questions = response.body().get("questions").getAsJsonArray(); makeMotionChart(motionCount, motions); makeQuestionChart(questionCount, questions); } } }); } } else { // TODO fetch Candidate by ID /* RESTService mRESTService = RESTClient.getService(this); Map<String, String> amyotharParams = new HashMap<>(); amyotharParams.put(Config.WITH, "party"); Call<JsonObject> candidateCall = mRESTService.getCandidate("7abd75a22042fe8e3faf931d710949fe", amyotharParams); candidateCall.enqueue(new RestCallback<JsonObject>() { @Override public void onResponse(Response<JsonObject> response) { } });*/ } mCompareCandidate.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(CandidateDetailActivity.this, CandidateListActivity.class); i.putExtra(Config.CANDIDATE, candidate); startActivity(i); } }); setTypeFace(); }
@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; }