in Android/app/src/fda/java/com/harvard/studyappmodule/StudyActivity.java [453:684]
private void initializeXmlId() {
infoIcon = (RelativeLayout) findViewById(R.id.mInfoIcon);
editTxt = (AppCompatTextView) findViewById(R.id.editBtnLabel);
editTxt.setVisibility(View.GONE);
titleFdaListens = (AppCompatTextView) findViewById(R.id.mTitleFDAListens);
title = (AppCompatTextView) findViewById(R.id.mTitle);
sidebarTitle = (AppCompatTextView) findViewById(R.id.mSidebarTitle);
notificationBtn = (RelativeLayout) findViewById(R.id.mNotificationBtn);
editBtnLayout = (RelativeLayout) findViewById(R.id.editBtnLayout);
drawer = (DrawerLayout) findViewById(R.id.activity_study);
homeLayout = (LinearLayout) findViewById(R.id.mHomeLayout);
homeLabel = (AppCompatTextView) findViewById(R.id.mHomeLabel);
resourcesLayout = (LinearLayout) findViewById(R.id.mResourcesLayout);
resourceLabel = (AppCompatTextView) findViewById(R.id.mResourceLabel);
reachoutLayout = (LinearLayout) findViewById(R.id.mReachoutLayout);
reachoutLabel = (AppCompatTextView) findViewById(R.id.mReachoutLabel);
signInProfileLayout = (LinearLayout) findViewById(R.id.mSignInProfileLayout);
signinImg = (AppCompatImageView) findViewById(R.id.signinImg);
signinLabel = (AppCompatTextView) findViewById(R.id.mSigninLabel);
signoutImg = (AppCompatImageView) findViewById(R.id.signoutImg);
newUsrReachoutLayout = (LinearLayout) findViewById(R.id.mNewUsrReachoutLayout);
newUsrReachoutImg = (AppCompatImageView) findViewById(R.id.mNewUsrReachoutImg);
notificationIcon = (AppCompatImageView) findViewById(R.id.mNotificationIcon);
notificatioStatus = (AppCompatImageView) findViewById(R.id.notificatioStatus);
newUsrReachoutLabel = (AppCompatTextView) findViewById(R.id.mNewUsrReachoutLabel);
signUpLabel = (AppCompatTextView) findViewById(R.id.mSignUpLabel);
signOutLayout = (RelativeLayout) findViewById(R.id.mSignOutLayout);
signOutLabel = (AppCompatTextView) findViewById(R.id.mSignOutLabel);
filter = (RelativeLayout) findViewById(R.id.mFilter);
searchBtn = (RelativeLayout) findViewById(R.id.mSearchBtn);
searchToolBarLayout = (RelativeLayout) findViewById(R.id.mSearchToolBarLayout);
toolBarLayout = (RelativeLayout) findViewById(R.id.mToolBarLayout);
cancel = (AppCompatTextView) findViewById(R.id.mCancel);
clearLayout = (RelativeLayout) findViewById(R.id.mClearLayout);
searchEditText = (AppCompatEditText) findViewById(R.id.mSearchEditText);
TextView version = (TextView) findViewById(R.id.version);
setVersion(version);
RelativeLayout backBtn = (RelativeLayout) findViewById(R.id.backBtn);
backBtn.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle eventProperties = new Bundle();
eventProperties.putString(
CustomFirebaseAnalytics.Param.BUTTON_CLICK_REASON,
getString(R.string.study_side_menu));
analyticsInstance.logEvent(
CustomFirebaseAnalytics.Event.ADD_BUTTON_CLICK, eventProperties);
checkSignOrSignOutScenario();
openDrawer();
try {
AppController.getHelperHideKeyboard(StudyActivity.this);
} catch (Exception e) {
Logger.log(e);
}
}
});
filter.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle eventProperties = new Bundle();
eventProperties.putString(
CustomFirebaseAnalytics.Param.BUTTON_CLICK_REASON,
getString(R.string.filter_clicked));
analyticsInstance.logEvent(
CustomFirebaseAnalytics.Event.ADD_BUTTON_CLICK, eventProperties);
AppController.getHelperSharedPreference()
.writePreference(StudyActivity.this, "toolbarClicked", "true");
Intent intent = new Intent(StudyActivity.this, FilterActivity.class);
startActivityForResult(intent, 999);
}
});
searchBtn.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle eventProperties = new Bundle();
eventProperties.putString(
CustomFirebaseAnalytics.Param.BUTTON_CLICK_REASON,
getString(R.string.study_search));
analyticsInstance.logEvent(
CustomFirebaseAnalytics.Event.ADD_BUTTON_CLICK, eventProperties);
toolBarLayout.setVisibility(View.GONE);
searchToolBarLayout.setVisibility(View.VISIBLE);
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
searchEditText.setText("");
// forcecfully set focus
searchEditText.post(
new Runnable() {
@Override
public void run() {
searchEditText.requestFocus();
try {
InputMethodManager imm =
(InputMethodManager)
getSystemService(getApplicationContext().INPUT_METHOD_SERVICE);
imm.toggleSoftInput(
InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
} catch (Exception e) {
Logger.log(e);
}
}
});
}
});
searchEditText.addTextChangedListener(
new TextWatcher() {
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.length() > 0) {
clearLayout.setVisibility(View.VISIBLE);
} else {
clearLayout.setVisibility(View.INVISIBLE);
studyFragment.setStudyFilteredStudyList();
}
}
});
searchEditText.setOnEditorActionListener(
new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
if (searchEditText.getText().length() > 0) {
studyFragment.searchFromFilteredStudyList(
searchEditText.getText().toString().trim());
hideKeyboard();
} else {
Toast.makeText(
StudyActivity.this,
getResources().getString(R.string.please_enter_key),
Toast.LENGTH_LONG)
.show();
}
return true;
}
return false;
}
});
clearLayout.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle eventProperties = new Bundle();
eventProperties.putString(
CustomFirebaseAnalytics.Param.BUTTON_CLICK_REASON,
getString(R.string.study_search_clear));
analyticsInstance.logEvent(
CustomFirebaseAnalytics.Event.ADD_BUTTON_CLICK, eventProperties);
searchEditText.setText("");
clearLayout.setVisibility(View.INVISIBLE);
studyFragment.setStudyFilteredStudyList();
}
});
cancel.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle eventProperties = new Bundle();
eventProperties.putString(
CustomFirebaseAnalytics.Param.BUTTON_CLICK_REASON,
getString(R.string.study_search_cancel));
analyticsInstance.logEvent(
CustomFirebaseAnalytics.Event.ADD_BUTTON_CLICK, eventProperties);
searchEditText.setText("");
setToolBarEnable();
hideKeyboard();
studyFragment.setStudyFilteredStudyList();
}
});
notificationBtn.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle eventProperties = new Bundle();
eventProperties.putString(
CustomFirebaseAnalytics.Param.BUTTON_CLICK_REASON,
getString(R.string.study_notification));
analyticsInstance.logEvent(
CustomFirebaseAnalytics.Event.ADD_BUTTON_CLICK, eventProperties);
AppController.getHelperSharedPreference()
.writePreference(StudyActivity.this, "toolbarClicked", "true");
Intent intent = new Intent(StudyActivity.this, NotificationActivity.class);
startActivityForResult(intent, NOTIFICATION_RESULT);
}
});
drawer.addDrawerListener(
new DrawerLayout.DrawerListener() {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {}
@Override
public void onDrawerOpened(View drawerView) {
checkSignOrSignOutScenario();
}
@Override
public void onDrawerClosed(View drawerView) {}
@Override
public void onDrawerStateChanged(int newState) {}
});
infoIcon.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle eventProperties = new Bundle();
eventProperties.putString(
CustomFirebaseAnalytics.Param.BUTTON_CLICK_REASON, getString(R.string.study_info));
analyticsInstance.logEvent(
CustomFirebaseAnalytics.Event.ADD_BUTTON_CLICK, eventProperties);
SetDialogHelper.setNeutralDialog(
StudyActivity.this,
getResources().getString(R.string.registration_message),
false,
getResources().getString(R.string.ok),
getResources().getString(R.string.why_register));
}
});
}