List of usage examples for android.widget LinearLayout setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:net.dewep.intranetepitech.ui.landing.LandingActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.ui_landing_view_pager); // ViewPager variables PagerAdapter pagerAdapter;/* ww w. j a v a 2 s . c o m*/ // View of this activity LinearLayout landingConnection; LinearLayout landingAbout; // Initial ViewPager mPager = (ViewPager) findViewById(R.id.landing_fragment); pagerAdapter = new LandingSlidePagerAdapter(getSupportFragmentManager()); mPager.setAdapter(pagerAdapter); mPager.setOnPageChangeListener(this); // Set Animation mPager.setPageTransformer(true, new DepthPageTransformer()); // Get views mLandingLogo = (LinearLayout) findViewById(R.id.landing_logo); landingConnection = (LinearLayout) findViewById(R.id.landing_connection); mLandingConnectionProgressbar = (ProgressBar) findViewById(R.id.landing_connection_progressbar); mLandingConnectionError = (ImageView) findViewById(R.id.landing_connection_error); landingAbout = (LinearLayout) findViewById(R.id.landing_about); // SetOnClickListener of the links in the menu mLandingLogo.setOnClickListener(this); landingConnection.setOnClickListener(this); landingAbout.setOnClickListener(this); // Initial Activity mLandingLogo.setVisibility(View.GONE); mLandingConnectionError.setVisibility(View.GONE); mLandingConnectionProgressbar.setVisibility(View.GONE); this.testConnection(false); }
From source file:com.equinox.prodriver.Activities.RegisterDriverActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register_driver); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from w w w.j a v a 2s.c om getSupportActionBar().setDisplayHomeAsUpEnabled(true); context = this; appBarLayout = (AppBarLayout) findViewById(R.id.app_bar); appBarLayout.setExpanded(false, true); mainScrollView = (NestedScrollView) findViewById(R.id.content_register_driver); mainScrollView.setSmoothScrollingEnabled(true); selectorsLayouts = new ArrayList<>(); editDriver = new Driver(); preferredPlace = new PrologixPlace(); if (currentDriver == null) { getSupportActionBar().setTitle(getString(R.string.title_activity_register_driver)); if (savedInstanceState != null && savedInstanceState.getBoolean("EDITING")) { editDriver = tempDriver; if (editDriver == null) editDriver = new Driver(); } vehiclesList = new ArrayList<>(); } else { getSupportActionBar().setTitle(getString(R.string.title_activity_update_driver)); editDriver = currentDriver.clone(); if (editDriver.getPreferredAddress() != null) { preferredPlace.setAddress( driverGson.fromJson(driverGson.toJson(editDriver.getPreferredAddress()), GeoAddress.class)); preferredPlace.setLocation( driverGson.fromJson(driverGson.toJson(editDriver.getPreferredLocation()), LatLng.class)); } } storagePermission = new PermissionManager(this); if (!storagePermission.checkReadStoragePermission()) storagePermission.getReadStoragePermission(); registerEmailHeaderFragment = RegisterEmailHeaderFragment.newInstance(editDriver); vehicleIndicator = (ImageView) findViewById(R.id.driver_vehicle_indicator); if (editDriver.getVehicles() == null) editDriver.setVehicles(new ArrayList<Vehicle>()); vehicleRecyclerAdapter = new VehicleRecyclerAdapter(context, editDriver.getVehicles(), false); if (!editDriver.getVehicles().isEmpty()) setIndicator(context, vehicleIndicator, true); if (!editDriver.getVehicles().contains(createVehicle)) { editDriver.getVehicles().add(new Vehicle()); //TODO remove this.. just for testing only /*String vehicleId = "SA-3184VLB"; DriverTask driverTask = new DriverTask(vehicleFetcher, "en"); driverTask.getVehicle.execute(vehicleId);*/ } vehicleListView = (RecyclerView) findViewById(R.id.vehicle_list_view); vehicleListView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)); vehicleListView.setHasFixedSize(true); vehicleListView.setAdapter(vehicleRecyclerAdapter); vehicleListView.setNestedScrollingEnabled(false); licenseIndicator = (ImageView) findViewById(R.id.license_info_indicator); licenseValueNumber = (TextView) findViewById(R.id.license_info_number); licenseValueExpiry = (TextView) findViewById(R.id.license_info_expiry); licenseImage = (ImageView) findViewById(R.id.license_image); licenseImageLoaded = (NetworkImageView) findViewById(R.id.license_image_loaded); licenseInfoLayout = (RelativeLayout) findViewById(R.id.license_info_layout); if (editDriver.getLicenseNumber() != null) { setIndicator(context, licenseIndicator, true); licenseValueNumber.setText(editDriver.getLicenseNumber()); licenseValueExpiry.setText(StringManipulation.getFormattedDate(editDriver.getLicenseExpiry())); if (editDriver.getLicenseImage() != null) licenseImageLoaded.setImageUrl(editDriver.getLicenseImage(), DataHolder.getInstance().getImageLoader()); } if (photo1 != null) licenseImage.setImageBitmap(photo1); licenseInfoLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent scanIdIntent = new Intent(context, CameraVisionActivity.class); scanIdIntent.putExtra("source", REQUEST_DRIVER_LICENSE); startActivity(scanIdIntent); } }); residenceIndicator = (ImageView) findViewById(R.id.residence_info_indicator); residenceValueNumber = (TextView) findViewById(R.id.residence_info_number); residenceValueExpiry = (TextView) findViewById(R.id.residence_info_expiry); residenceValueLegalName = (TextView) findViewById(R.id.residence_info_legal_name); residenceImage = (ImageView) findViewById(R.id.residence_image); residenceImageLoaded = (NetworkImageView) findViewById(R.id.residence_image_loaded); residenceInfoLayout = (RelativeLayout) findViewById(R.id.residence_info_layout); if (editDriver.getResidenceNumber() != null) { setIndicator(context, residenceIndicator, true); residenceValueNumber.setText(editDriver.getResidenceNumber()); residenceValueLegalName.setText(editDriver.getLegalName()); if (editDriver.getResidenceImage() != null) residenceImageLoaded.setImageUrl(editDriver.getResidenceImage(), DataHolder.getInstance().getImageLoader()); } if (photo2 != null) residenceImage.setImageBitmap(photo2); residenceInfoLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent scanIdIntent = new Intent(context, CameraVisionActivity.class); scanIdIntent.putExtra(SOURCE, REQUEST_RESIDENCE_ID); startActivity(scanIdIntent); } }); nationalityIndicator = (ImageView) findViewById(R.id.nationality_indicator); nationalityValue = (TextView) findViewById(R.id.nationality_value); nationalityLayout = (RelativeLayout) findViewById(R.id.nationality_layout); nationalityProgressLayout = (LinearLayout) findViewById(R.id.nationality_progress_layout); final RelativeLayout nationalitySelector = (RelativeLayout) findViewById(R.id.nationality_selector); selectorsLayouts.add(nationalitySelector); nationalitySelectorContent = (LinearLayout) findViewById(R.id.nationality_selector_content); countryTask = new CountryTask(countryListHandler, "en"); countryTask.getCountryList.execute("en"); if (editDriver.getNationality() != null) { setIndicator(context, nationalityIndicator, true); nationalityValue.setText(editDriver.getNationality().getCountryName()); } nationalityAuto = (InstantAutoComplete) findViewById(R.id.nationality_auto); nationalityLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); if (nationalitySelector.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, nationalitySelector); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, nationalityLayout.getTop()); nationalityAuto.showDropDown(); } }, 1000); } if (countryTask.getCountryList.getStatus().equals(AsyncTask.Status.RUNNING)) { nationalityProgressLayout.setVisibility(View.VISIBLE); nationalitySelectorContent.setVisibility(View.GONE); } LinearLayout okayButton = (LinearLayout) findViewById(R.id.nationality_okay_button); okayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (editDriver.getNationality() != null) { setIndicator(context, nationalityIndicator, true); nationalityValue.setText(editDriver.getNationality().getCountryName()); addressLayout.postDelayed(new Runnable() { @Override public void run() { addressLayout.performClick(); } }, 1000); } else { setIndicator(context, nationalityIndicator, false); nationalitySelector.setVisibility(View.GONE); } } }); LinearLayout cancelButton = (LinearLayout) findViewById(R.id.nationality_cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { nationalitySelector.setVisibility(View.GONE); } }); } }); addressIndicator = (ImageView) findViewById(R.id.preferred_address_indicator); addressValue = (TextView) findViewById(R.id.preferred_address_value); addressLayout = (RelativeLayout) findViewById(R.id.preferred_address_layout); if (editDriver.getPreferredAddress() != null) { setIndicator(context, addressIndicator, true); preferredPlace.setAddress(transform(editDriver.getPreferredAddress())); preferredPlace.setLocation(transform(editDriver.getPreferredLocation())); addressValue.setText(preferredPlace.getAddress().getFullAddress()); } addressChooser = (FrameLayout) findViewById(R.id.preferred_address_chooser); selectorsLayouts.add(addressChooser); addressLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); try { if (addressChooser.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, addressChooser); getSupportFragmentManager().beginTransaction() .replace(R.id.preferred_address_chooser, PlaceChooserFragment.newInstance(preferredPlace, placeChooseHandler)) .commit(); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, addressLayout.getTop()); } }, 1500); } else { addressChooser.setVisibility(View.GONE); getSupportFragmentManager().popBackStack(); } } catch (Resources.NotFoundException | OutOfMemoryError ignored) { } } }); final ImageView phoneIndicator = (ImageView) findViewById(R.id.driver_phone_indicator); final TextView phoneValue = (TextView) findViewById(R.id.driver_phone_value); if (editDriver.getPhoneNumber() != null) { setIndicator(context, phoneIndicator, true); phoneValue.setText(editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "")); } final LinearLayout phoneSelector = (LinearLayout) findViewById(R.id.driver_phone_selector); selectorsLayouts.add(phoneSelector); phoneLayout = (RelativeLayout) findViewById(R.id.driver_phone_layout); phoneLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); if (phoneSelector.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, phoneSelector); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, phoneLayout.getTop()); } }, 1000); } final EditText input = (EditText) findViewById(R.id.phone_number); if (editDriver.getPhoneNumber() != null) input.setText(editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "")); TextView phoneCode = (TextView) findViewById(R.id.country_code); phoneCode.setText(currentCountry.getPhoneCode()); NetworkImageView countryFlag = (NetworkImageView) findViewById(R.id.country_flag); countryFlag.setImageUrl(currentCountry.getFlag(), DataHolder.getInstance().getImageLoader()); LinearLayout okayButton = (LinearLayout) findViewById(R.id.driver_phone_okay_button); okayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!input.getText().toString().isEmpty()) { String phoneNumberEdit = currentCountry.getPhoneCode() + input.getText().toString().replaceAll(" ", ""); editDriver.setPhoneNumber(phoneNumberEdit); phoneValue.setText(phoneNumberEdit); setIndicator(context, phoneIndicator, true); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, dobLayout.getTop()); } }, 1000); } else { phoneValue.setText(getString(R.string.driver_phone_hint)); setIndicator(context, phoneIndicator, false); } phoneSelector.setVisibility(View.GONE); } }); LinearLayout cancelButton = (LinearLayout) findViewById(R.id.driver_phone_cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { phoneSelector.setVisibility(View.GONE); } }); } }); dobValue = (TextView) findViewById(R.id.driver_dob_value); if (editDriver.getDob() != null) dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob())); dobLayout = (RelativeLayout) findViewById(R.id.driver_dob_layout); dobLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Calendar calendar = Calendar.getInstance(); if (editDriver.getDob() != null) { dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob())); calendar.setTimeInMillis(editDriver.getDob()); } DatePickerDialog datePickerDialog = DatePickerDialog .newInstance(new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) { calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, monthOfYear); calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); editDriver.setDob(calendar.getTimeInMillis()); dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob())); } }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); datePickerDialog.show(getFragmentManager(), "Datepickerdialog"); } }); final TextView genderValue = (TextView) findViewById(R.id.driver_gender_value); if (editDriver.getGender() != null) genderValue.setText( editDriver.getGender() ? getString(R.string.male_option) : getString(R.string.female_option)); final LinearLayout genderSelector = (LinearLayout) findViewById(R.id.driver_gender_selector); selectorsLayouts.add(genderSelector); final RelativeLayout genderLayout = (RelativeLayout) findViewById(R.id.driver_gender_layout); genderLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); if (genderSelector.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, genderSelector); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, genderLayout.getTop()); } }, 1000); } else genderSelector.setVisibility(View.GONE); final int checkedPos = editDriver.getGender() == null ? -1 : (editDriver.getGender() ? R.id.driver_gender_male : R.id.driver_gender_female); final RadioGroup insuranceRadioGroup = (RadioGroup) findViewById(R.id.driver_gender_radio_group); if (checkedPos != -1) insuranceRadioGroup.check(checkedPos); LinearLayout okayButton = (LinearLayout) findViewById(R.id.driver_gender_okay_button); okayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switch (insuranceRadioGroup.getCheckedRadioButtonId()) { case R.id.driver_gender_male: editDriver.setGender(true); genderValue.setText(getString(R.string.male_option)); break; case R.id.driver_gender_female: editDriver.setGender(false); genderValue.setText(getString(R.string.female_option)); break; default: break; } mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, 0); } }, 500); appBarLayout.postDelayed(new Runnable() { @Override public void run() { appBarLayout.setExpanded(true, true); } }, 1500); } }); LinearLayout cancelButton = (LinearLayout) findViewById(R.id.driver_gender_cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { genderSelector.setVisibility(View.GONE); } }); } }); //TODO image analyis on IDs (license) and cross check with profile photo1, or maybe selfie uploadCount = new AtomicInteger(0); saveDriverAction = (FloatingActionButton) findViewById(R.id.fab_save_id); saveDriverAction.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { boolean error = false; hideKeyboard(context); if (editDriver.getVehicles().size() == 1) { setIndicator(context, vehicleIndicator, false); error = true; } if (licenseImage.getDrawable() == null || editDriver.getLicenseExpiry() == null || editDriver.getLicenseNumber() == null) { setIndicator(context, licenseIndicator, false); error = true; } if (residenceImage.getDrawable() == null || editDriver.getResidenceNumber() == null) { setIndicator(context, residenceIndicator, false); error = true; } if (editDriver.getNationality() == null) { setIndicator(context, nationalityIndicator, false); error = true; } if (editDriver.getPreferredAddress() == null) { setIndicator(context, addressIndicator, false); error = true; } if (editDriver.getPhoneNumber() == null || editDriver.getPhoneNumber().isEmpty()) { setIndicator(context, phoneIndicator, false); error = true; } if (user == null && !registerEmailHeaderFragment.setCustomerValues()) error = true; if (error) Snackbar.make(view, getString(R.string.incorrect_driver_data_message), Snackbar.LENGTH_LONG) .show(); else if (user != null) { signUpAnalytics(user.getProviderId()); editDriver.getVehicles().remove(editDriver.getVehicles().size() - 1); uploadImage("driver_license_snapshot", "image_" + editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "") + "_" + editDriver.getLicenseNumber() + ".jpg", ((BitmapDrawable) licenseImage.getDrawable()).getBitmap(), REQUEST_DRIVER_LICENSE); uploadImage("driver_residence_snapshot", "image_" + editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "") + "_" + editDriver.getResidenceNumber() + ".jpg", ((BitmapDrawable) residenceImage.getDrawable()).getBitmap(), REQUEST_RESIDENCE_ID); crossFade(context, findViewById(R.id.driver_progress_layout), findViewById(R.id.driver_main_layout), null); //TODO verify registration details for duplicate, correctness, etc } } }); imageUploadStatus = (TextSwitcher) findViewById(R.id.image_upload_status); imageUploadStatus.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { TextView switcherTextView = new TextView(getApplicationContext()); switcherTextView.setTextSize(16); switcherTextView.setTypeface(null, Typeface.BOLD); switcherTextView.setText(getString(R.string.uploading_images)); switcherTextView.setTextColor(getResources().getColor(R.color.colorAccent)); return switcherTextView; } }); Animation animationOut = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right); Animation animationIn = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left); imageUploadStatus.setOutAnimation(animationOut); imageUploadStatus.setInAnimation(animationIn); }
From source file:edu.ptu.navpattern.tooltip.Tooltip.java
private View getContentView(final Builder builder) { GradientDrawable drawable = new GradientDrawable(); drawable.setColor(builder.mBackgroundColor); drawable.setCornerRadius(builder.mCornerRadius); LinearLayout vgContent = new LinearLayout(builder.mContext); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { vgContent.setBackground(drawable); } else {// ww w . ja va2 s. c o m //noinspection deprecation vgContent.setBackgroundDrawable(drawable); } int padding = (int) builder.mPadding; vgContent.setPadding(padding, padding, padding, padding); vgContent.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams textViewParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0); textViewParams.gravity = Gravity.CENTER; textViewParams.topMargin = 1; vgContent.setLayoutParams(textViewParams); vgContent.setDividerDrawable(vgContent.getResources().getDrawable(R.drawable.divider_line)); vgContent.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); if (builder.itemText != null && builder.itemText.length > 0) { for (int i = 0; i < builder.itemText.length; i++) { TextView textView = new TextView(builder.mContext); textView.setText(builder.itemText[i]); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 44); textView.setTextColor(0xffffffff); textView.setGravity(Gravity.CENTER_VERTICAL); if (builder.itemLogo != null && builder.itemLogo.length > i) { Drawable drawableLeft = builder.mContext.getResources().getDrawable(builder.itemLogo[i]); /// ??,??. // drawableLeft.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); // textView.setCompoundDrawables(drawableLeft, null, null, null); // textView.setCompoundDrawablePadding(4); // textView.setBackgroundDrawable(drawableLeft); LinearLayout linearLayout = new LinearLayout(builder.mContext); linearLayout.setMinimumHeight((int) dpToPx(44f)); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setGravity(Gravity.CENTER_VERTICAL); ImageView icon = new ImageView(builder.mContext); icon.setImageDrawable(drawableLeft); linearLayout.addView(icon); linearLayout.addView(textView); vgContent.addView(linearLayout); final int position = i; linearLayout.setClickable(false); linearLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (builder.mOnItemClickListener != null) { builder.mOnItemClickListener.onClick(position); } mTouchListener.onTouch(v, MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, v.getLeft() + 5, v.getTop() + 5, 0)); } }); } else { vgContent.addView(textView); final int position = i; textView.setClickable(false); textView.setMinimumHeight((int) dpToPx(44f)); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (builder.mOnItemClickListener != null) { builder.mOnItemClickListener.onClick(position); } mTouchListener.onTouch(v, null); } }); } } } mArrowView = new ImageView(builder.mContext); mArrowView.setImageDrawable(builder.mArrowDrawable); LinearLayout.LayoutParams arrowLayoutParams; if (mGravity == Gravity.TOP || mGravity == Gravity.BOTTOM) { arrowLayoutParams = new LinearLayout.LayoutParams((int) builder.mArrowWidth, (int) builder.mArrowHeight, 0); } else { arrowLayoutParams = new LinearLayout.LayoutParams((int) builder.mArrowHeight, (int) builder.mArrowWidth, 0); } arrowLayoutParams.gravity = Gravity.CENTER; mArrowView.setLayoutParams(arrowLayoutParams); mContentView = new LinearLayout(builder.mContext); mContentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); mContentView.setOrientation(mGravity == Gravity.START || mGravity == Gravity.END ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL); padding = (int) dpToPx(5); switch (mGravity) { case Gravity.START: mContentView.setPadding(0, 0, padding, 0); break; case Gravity.TOP: case Gravity.BOTTOM: mContentView.setPadding(padding, 0, padding, 0); break; case Gravity.END: mContentView.setPadding(padding, 0, 0, 0); break; } if (mGravity == Gravity.TOP || mGravity == Gravity.START) { mContentView.addView(vgContent); mContentView.addView(mArrowView); } else { mContentView.addView(mArrowView); mContentView.addView(vgContent); } if (builder.isCancelable || builder.isDismissOnClick) { mContentView.setOnTouchListener(mTouchListener); } return mContentView; }
From source file:eu.power_switch.gui.fragment.configure_scene.ConfigureSceneDialogPage1NameFragment.java
private void addReceiversToLayout() { String inflaterString = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(inflaterString); try {/*from w w w. jav a 2s.c o m*/ for (Room room : DatabaseHandler.getRooms(SmartphonePreferencesHandler.getCurrentApartmentId())) { LinearLayout roomLayout = new LinearLayout(getActivity()); roomLayout.setOrientation(LinearLayout.VERTICAL); roomLayout.setPadding(0, 8, 0, 8); linearLayout_selectableReceivers.addView(roomLayout); TextView roomName = new TextView(getActivity()); roomName.setText(room.getName()); roomName.setTextColor( ThemeHelper.getThemeAttrColor(getActivity(), android.R.attr.textColorPrimary)); roomLayout.addView(roomName); for (Receiver receiver : room.getReceivers()) { LinearLayout receiverLayout = new LinearLayout(getActivity()); receiverLayout.setOrientation(LinearLayout.HORIZONTAL); roomLayout.addView(receiverLayout); final CheckBox checkBox = (CheckBox) inflater.inflate(R.layout.simple_checkbox, receiverLayout, false); checkBox.setTag(R.string.room, room); checkBox.setTag(R.string.receiver, receiver); receiverLayout.addView(checkBox); checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { checkValidity(); } }); receiverCheckboxList.add(checkBox); TextView textView_receiverName = new TextView(getActivity()); textView_receiverName.setText(receiver.getName()); receiverLayout.addView(textView_receiverName); receiverLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { checkBox.setChecked(!checkBox.isChecked()); } }); } } } catch (Exception e) { StatusMessageHandler.showErrorMessage(getActivity(), e); } }
From source file:de.enlightened.peris.ForumSettingsFragment.java
private void setupSignatureButton(final SharedPreferences appPreferences) { //Signature button final LinearLayout forumSettingTagline = (LinearLayout) getActivity() .findViewById(R.id.forum_setting_tagline); if (this.application.getSession().getServer().serverUserName.contentEquals("0")) { forumSettingTagline.setVisibility(View.GONE); } else {// w ww . j a v a 2 s . co m final LinearLayout forumSettingTaglineBodyBuilder = (LinearLayout) getActivity() .findViewById(R.id.forum_setting_tagline_body_builder); final boolean useShading = appPreferences.getBoolean("use_shading", false); final boolean useOpenSans = appPreferences.getBoolean("use_opensans", false); final int fontSize = appPreferences.getInt("font_size", 16); final Typeface opensans = Typeface.createFromAsset(getActivity().getAssets(), "fonts/opensans.ttf"); BBCodeParser.parseCode(getActivity(), forumSettingTaglineBodyBuilder, this.application.getSession().getServer().serverTagline, opensans, useOpenSans, useShading, null, fontSize, false, "#333333", this.application); forumSettingTagline.setOnClickListener(new View.OnClickListener() { @Override @SuppressWarnings("checkstyle:requirethis") public void onClick(final View v) { final Intent myIntent = new Intent(getActivity(), NewPost.class); final Bundle bundle = new Bundle(); bundle.putString("postid", "0"); bundle.putString("parent", "0"); bundle.putString("category", "0"); bundle.putString("subforum_id", (String) "0"); bundle.putString("original_text", (String) ""); bundle.putString("boxTitle", (String) "Signature Editor"); bundle.putString("picture", (String) "0"); bundle.putString("color", (String) application.getSession().getServer().serverColor); bundle.putString("subject", (String) ""); bundle.putString("post_type", NewPost.Type.Tagline.name()); myIntent.putExtras(bundle); startActivity(myIntent); } }); } }
From source file:com.simadanesh.isatis.ScreenSlideActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); CommonPlace.manehCodes = ManehCodeDA.getInstance(this).getAll(); CommonPlace.inspectionCodes = InspectionCodeDA.getInstance(this).getAll(); CommonPlace.CurrentRegisterFields = RegisterFieldDA.getInstance(this).getAll("fldPartitionCode=?", "", new String[] { CommonPlace.currentCityPartition.getFldPartitionCode() }); LoadValidationCriterias();/*from www. ja va 2s. c o m*/ Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread paramThread, Throwable paramThrowable) { Log.e("Alert", "Lets See if it Works !!!" + paramThrowable.toString()); } }); Utility.InitializeDefatultSettings(this); CommonPlace.slideActivity = this; getActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.activity_screen_slide); mtextProgress = (TextView) findViewById(R.id.txtProgress); Utility.applyFont(findViewById(R.id.reading_page)); LinearLayout taskbarLayout = (LinearLayout) findViewById(R.id.taskbarpanel); taskbarLayout.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Button btnCamera = (Button) findViewById(R.id.btnCamera); if (btnCamera.getTextSize() > 0) { btnCamera.setTextSize(0); } else { btnCamera.setTextSize(20); } } }); progressbar = (ProgressBar) findViewById(R.id.reading_progress); progressbar.setProgress(0); Button btnSubmit = (Button) findViewById(R.id.btnSubmit); btnSubmit.setOnClickListener(new View.OnClickListener() { Dialog mydialog; public void onClick(View v) { ShowSubmitDialog(); } }); Button btnCamera = (Button) findViewById(R.id.btnCamera); btnCamera.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dispatchTakePictureIntentOrShowPicture(); } }); Button btnInspection = (Button) findViewById(R.id.btnInspection); btnInspection.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ShowInspectionDialog(); } }); Button btnonlineControl = (Button) findViewById(R.id.btnOnline_control); btnonlineControl.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ShowOnlineControl(); } }); Button btnOnlineCalculation = (Button) findViewById(R.id.btnCalculation); btnOnlineCalculation.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ShowOnlineCalculation(); } }); // Instantiate a ViewPager and a PagerAdapter. mPager = (ViewPager) findViewById(R.id.pager); mPagerAdapter = new ScreenSlidePagerAdapter(getFragmentManager()); mPager.setAdapter(mPagerAdapter); mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When changing pages, reset the action bar actions since they are dependent // on which page is currently active. An alternative approach is to have each // fragment expose actions itself (rather than the activity exposing actions), // but for simplicity, the activity provides the actions in this sample. invalidateOptionsMenu(); } }); try { // int last = mSavedBundle.getInt("Reading-" + CommonPlace.currentReadingList.getId()); // mPager.setCurrentItem(last); } catch (Exception ex) { ex.toString(); } final Handler handler1 = new Handler(); try { final int pos = Integer.parseInt(CommonPlace.currentReadingList.Position); handler1.postDelayed(new Runnable() { @Override public void run() { mPager.setCurrentItem(pos); } }, 500); } catch (Exception ex) { } }
From source file:com.avcall.app.ui.SettingsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;/*from w ww .java2s.c om*/ rl_switch_notification = (RelativeLayout) getView().findViewById(R.id.rl_switch_notification); rl_switch_sound = (RelativeLayout) getView().findViewById(R.id.rl_switch_sound); rl_switch_vibrate = (RelativeLayout) getView().findViewById(R.id.rl_switch_vibrate); rl_switch_speaker = (RelativeLayout) getView().findViewById(R.id.rl_switch_speaker); rl_switch_delete_msg_when_exit_group = (RelativeLayout) getView() .findViewById(R.id.rl_switch_delete_msg_when_exit_group); notifiSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_notification); soundSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_sound); vibrateSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_vibrate); speakerSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_speaker); switch_delete_msg_when_exit_group = (EaseSwitchButton) getView() .findViewById(R.id.switch_delete_msg_when_exit_group); LinearLayout llChange = (LinearLayout) getView().findViewById(R.id.ll_change); logoutBtn = (Button) getView().findViewById(R.id.btn_logout); if (!TextUtils.isEmpty(EMClient.getInstance().getCurrentUser())) { logoutBtn.setText( getString(R.string.button_logout) + "(" + EMClient.getInstance().getCurrentUser() + ")"); } textview1 = (TextView) getView().findViewById(R.id.textview1); textview2 = (TextView) getView().findViewById(R.id.textview2); blacklistContainer = (LinearLayout) getView().findViewById(R.id.ll_black_list); userProfileContainer = (LinearLayout) getView().findViewById(R.id.ll_user_profile); settingsModel = AvcallHelper.getInstance().getModel(); chatOptions = EMClient.getInstance().getOptions(); blacklistContainer.setOnClickListener(this); userProfileContainer.setOnClickListener(this); rl_switch_notification.setOnClickListener(this); rl_switch_sound.setOnClickListener(this); rl_switch_vibrate.setOnClickListener(this); rl_switch_speaker.setOnClickListener(this); logoutBtn.setOnClickListener(this); rl_switch_delete_msg_when_exit_group.setOnClickListener(this); llChange.setOnClickListener(this); // the vibrate and sound notification are allowed or not? if (settingsModel.getSettingMsgNotification()) { notifiSwitch.openSwitch(); } else { notifiSwitch.closeSwitch(); } // sound notification is switched on or not? if (settingsModel.getSettingMsgSound()) { soundSwitch.openSwitch(); } else { soundSwitch.closeSwitch(); } // vibrate notification is switched on or not? if (settingsModel.getSettingMsgVibrate()) { vibrateSwitch.openSwitch(); } else { vibrateSwitch.closeSwitch(); } // the speaker is switched on or not? if (settingsModel.getSettingMsgSpeaker()) { speakerSwitch.openSwitch(); } else { speakerSwitch.closeSwitch(); } // delete messages when exit group? if (settingsModel.isDeleteMessagesAsExitGroup()) { switch_delete_msg_when_exit_group.openSwitch(); } else { switch_delete_msg_when_exit_group.closeSwitch(); } }
From source file:com.prey.activities.CheckPasswordActivity.java
@Override protected void onResume() { super.onResume(); bindPasswordControls();/* w w w . ja v a 2 s . c o m*/ TextView device_ready_h2_text = (TextView) findViewById(R.id.device_ready_h2_text); final TextView textForgotPassword = (TextView) findViewById(R.id.link_forgot_password); Button password_btn_login = (Button) findViewById(R.id.password_btn_login); EditText password_pass_txt = (EditText) findViewById(R.id.password_pass_txt); TextView textView1 = (TextView) findViewById(R.id.textView1); TextView textView2 = (TextView) findViewById(R.id.textView2); Typeface titilliumWebRegular = Typeface.createFromAsset(getAssets(), "fonts/Titillium_Web/TitilliumWeb-Regular.ttf"); Typeface titilliumWebBold = Typeface.createFromAsset(getAssets(), "fonts/Titillium_Web/TitilliumWeb-Bold.ttf"); Typeface magdacleanmonoRegular = Typeface.createFromAsset(getAssets(), "fonts/MagdaClean/magdacleanmono-regular.ttf"); textView1.setTypeface(magdacleanmonoRegular); textView2.setTypeface(magdacleanmonoRegular); device_ready_h2_text.setTypeface(titilliumWebRegular); textForgotPassword.setTypeface(titilliumWebBold); password_btn_login.setTypeface(titilliumWebBold); password_pass_txt.setTypeface(magdacleanmonoRegular); try { textForgotPassword.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { String url = PreyConfig.getPreyConfig(getApplicationContext()).getPreyPanelUrl(); Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse(url)); startActivity(browserIntent); } catch (Exception e) { } } }); } catch (Exception e) { } TextView textView5_1 = (TextView) findViewById(R.id.textView5_1); TextView textView5_2 = (TextView) findViewById(R.id.textView5_2); textView5_1.setTypeface(magdacleanmonoRegular); textView5_2.setTypeface(titilliumWebBold); TextView textViewUninstall = (TextView) findViewById(R.id.textViewUninstall); LinearLayout linearLayoutTour = (LinearLayout) findViewById(R.id.linearLayoutTour); textViewUninstall.setTypeface(titilliumWebBold); if (PreyConfig.getPreyConfig(getApplication()).getProtectTour()) { linearLayoutTour.setVisibility(View.GONE); textViewUninstall.setVisibility(View.VISIBLE); textViewUninstall.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url = PreyConfig.getPreyConfig(getApplication()).getPreyUninstallUrl(); Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse(url)); startActivity(browserIntent); finish(); } }); } else { linearLayoutTour.setVisibility(View.VISIBLE); textViewUninstall.setVisibility(View.GONE); try { linearLayoutTour.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getApplication(), TourActivity1.class); Bundle b = new Bundle(); b.putInt("id", 1); intent.putExtras(b); startActivity(intent); finish(); } }); } catch (Exception e) { } } boolean showLocation = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { boolean canAccessFineLocation = PreyPermission.canAccessFineLocation(this); boolean canAccessCoarseLocation = PreyPermission.canAccessCoarseLocation(this); boolean canAccessCamera = PreyPermission.canAccessCamera(this); boolean canAccessReadPhoneState = PreyPermission.canAccessReadPhoneState(this); boolean canAccessReadExternalStorage = PreyPermission.canAccessReadExternalStorage(this); if (!canAccessFineLocation || !canAccessCoarseLocation || !canAccessCamera || !canAccessReadPhoneState || !canAccessReadExternalStorage) { AlertDialog.Builder builder = new AlertDialog.Builder(this); final FrameLayout frameView = new FrameLayout(this); builder.setView(frameView); final AlertDialog alertDialog = builder.create(); LayoutInflater inflater = alertDialog.getLayoutInflater(); View dialoglayout = inflater.inflate(R.layout.warning, frameView); TextView warning_title = (TextView) dialoglayout.findViewById(R.id.warning_title); TextView warning_body = (TextView) dialoglayout.findViewById(R.id.warning_body); warning_title.setTypeface(magdacleanmonoRegular); warning_body.setTypeface(titilliumWebBold); Button button_ok = (Button) dialoglayout.findViewById(R.id.button_ok); Button button_close = (Button) dialoglayout.findViewById(R.id.button_close); button_ok.setTypeface(titilliumWebBold); button_close.setTypeface(titilliumWebBold); final Activity thisActivity = this; button_ok.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PreyLogger.d("askForPermission"); askForPermission(); alertDialog.dismiss(); } }); button_close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PreyLogger.d("close ask"); alertDialog.dismiss(); } }); alertDialog.show(); showLocation = false; } else { showLocation = true; } } else { showLocation = true; } if (showLocation) { LocationManager mlocManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); boolean isGpsEnabled = mlocManager.isProviderEnabled(LocationManager.GPS_PROVIDER); boolean isNetworkEnabled = mlocManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); if (isGpsEnabled || isNetworkEnabled) { PreyLogger.d("isGpsEnabled || isNetworkEnabled"); } else { PreyLogger.d("no gps ni red"); AlertDialog.Builder builder = new AlertDialog.Builder(this); final AlertDialog alertDialog = builder.create(); TextView textview = new TextView(this); textview.setText(getString(R.string.location_settings)); textview.setMaxLines(10); textview.setTextSize(18F); textview.setPadding(20, 0, 20, 20); textview.setTextColor(Color.BLACK); builder.setView(textview); builder.setPositiveButton(getString(R.string.go_to_settings), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialoginterface, int i) { dialoginterface.dismiss(); Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivityForResult(intent, 0); return; } }); builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialoginterface, int i) { dialoginterface.dismiss(); } }); builder.create().show(); } } }
From source file:com.cypress.cysmart.BLEServiceFragments.SensorHubService.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.sensor_hub, container, false); LinearLayout parent = (LinearLayout) rootView.findViewById(R.id.parent_sensorhub); parent.setOnClickListener(new OnClickListener() { @Override/*from www .j a v a2s.co m*/ public void onClick(View v) { } }); accX = (TextView) rootView.findViewById(R.id.acc_x_value); accY = (TextView) rootView.findViewById(R.id.acc_y_value); accZ = (TextView) rootView.findViewById(R.id.acc_z_value); BAT = (TextView) rootView.findViewById(R.id.bat_value); STEMP = (TextView) rootView.findViewById(R.id.temp_value); mProgressDialog = new ProgressDialog(getActivity()); Spressure = (TextView) rootView.findViewById(R.id.pressure_value); // Locate device button listener Button locateDevice = (Button) rootView.findViewById(R.id.locate_device); locateDevice.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Button btn = (Button) v; String buttonText = btn.getText().toString(); String startText = getResources().getString(R.string.sen_hub_locate); String stopText = getResources().getString(R.string.sen_hub_locate_stop); if (buttonText.equalsIgnoreCase(startText)) { btn.setText(stopText); if (mWriteAlertCharacteristic != null) { byte[] convertedBytes = convertingTobyteArray(IMM_HIGH_ALERT); BluetoothLeService.writeCharacteristicNoresponse(mWriteAlertCharacteristic, convertedBytes); } } else { btn.setText(startText); if (mWriteAlertCharacteristic != null) { byte[] convertedBytes = convertingTobyteArray(IMM_NO_ALERT); BluetoothLeService.writeCharacteristicNoresponse(mWriteAlertCharacteristic, convertedBytes); } } } }); final ImageButton acc_more = (ImageButton) rootView.findViewById(R.id.acc_more); final ImageButton stemp_more = (ImageButton) rootView.findViewById(R.id.stemp_more); final ImageButton spressure_more = (ImageButton) rootView.findViewById(R.id.spressure_more); final LinearLayout acc_layLayout = (LinearLayout) rootView.findViewById(R.id.acc_context_menu); final LinearLayout stemp_layLayout = (LinearLayout) rootView.findViewById(R.id.stemp_context_menu); final LinearLayout spressure_layLayout = (LinearLayout) rootView.findViewById(R.id.spressure_context_menu); // expand listener acc_more.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (acc_layLayout.getVisibility() != View.VISIBLE) { acc_more.setRotation(90); CustomSlideAnimation a = new CustomSlideAnimation(acc_layLayout, CustomSlideAnimation.EXPAND); a.setHeight(height); acc_layLayout.startAnimation(a); acc_scan_interval = (EditText) rootView.findViewById(R.id.acc_sensor_scan_interval); if (ACCSensorScanCharacteristic != null) { acc_scan_interval.setText(ACCSensorScanCharacteristic); } acc_sensortype = (TextView) rootView.findViewById(R.id.acc_sensor_type); if (ACCSensorTypeCharacteristic != null) { acc_sensortype.setText(ACCSensorTypeCharacteristic); } acc_scan_interval.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { int myNum = 0; try { myNum = Integer.parseInt(acc_scan_interval.getText().toString()); } catch (NumberFormatException nfe) { nfe.printStackTrace(); } byte[] convertedBytes = convertingTobyteArray(Integer.toString(myNum)); BluetoothLeService.writeCharacteristicNoresponse(mReadACCSensorScanCharacteristic, convertedBytes); } return false; } }); Spinner spinner_filterconfiguration = (Spinner) rootView .findViewById(R.id.acc_filter_configuration); // Create an ArrayAdapter using the string array and a // default // spinner layout ArrayAdapter<CharSequence> adapter_filterconfiguration = ArrayAdapter.createFromResource( getActivity(), R.array.filter_configuration_alert_array, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices // appears adapter_filterconfiguration .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner spinner_filterconfiguration.setAdapter(adapter_filterconfiguration); } else { acc_more.setRotation(-90); acc_scan_interval.setText(""); acc_sensortype.setText(""); CustomSlideAnimation a = new CustomSlideAnimation(acc_layLayout, CustomSlideAnimation.COLLAPSE); height = a.getHeight(); acc_layLayout.startAnimation(a); } } }); // expand listener stemp_more.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (stemp_layLayout.getVisibility() != View.VISIBLE) { stemp_more.setRotation(90); CustomSlideAnimation a = new CustomSlideAnimation(stemp_layLayout, CustomSlideAnimation.EXPAND); a.setHeight(height); stemp_layLayout.startAnimation(a); stemp_scan_interval = (EditText) rootView.findViewById(R.id.stemp_sensor_scan_interval); if (STEMPSensorScanCharacteristic != null) { stemp_scan_interval.setText(STEMPSensorScanCharacteristic); } stemp_sensortype = (TextView) rootView.findViewById(R.id.stemp_sensor_type); if (STEMPSensorTypeCharacteristic != null) { stemp_sensortype.setText(STEMPSensorTypeCharacteristic); } stemp_scan_interval.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { int myNum = 0; try { myNum = Integer.parseInt(stemp_scan_interval.getText().toString()); } catch (NumberFormatException nfe) { nfe.printStackTrace(); } byte[] convertedBytes = convertingTobyteArray(Integer.toString(myNum)); BluetoothLeService.writeCharacteristicNoresponse(mReadSTEMPSensorScanCharacteristic, convertedBytes); } return false; } }); } else { stemp_more.setRotation(-90); stemp_scan_interval.setText(""); stemp_sensortype.setText(""); CustomSlideAnimation a = new CustomSlideAnimation(stemp_layLayout, CustomSlideAnimation.COLLAPSE); height = a.getHeight(); stemp_layLayout.startAnimation(a); } } }); // expand listener spressure_more.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (spressure_layLayout.getVisibility() != View.VISIBLE) { spressure_more.setRotation(90); CustomSlideAnimation a = new CustomSlideAnimation(spressure_layLayout, CustomSlideAnimation.EXPAND); a.setHeight(height); spressure_layLayout.startAnimation(a); spressure_scan_interval = (EditText) rootView.findViewById(R.id.spressure_sensor_scan_interval); if (SPRESSURESensorScanCharacteristic != null) { spressure_scan_interval.setText(SPRESSURESensorScanCharacteristic); } spressure_sensortype = (TextView) rootView.findViewById(R.id.spressure_sensor_type); if (SPRESSURESensorTypeCharacteristic != null) { spressure_sensortype.setText(SPRESSURESensorTypeCharacteristic); } spressure_scan_interval.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { int myNum = 0; try { myNum = Integer.parseInt(stemp_scan_interval.getText().toString()); } catch (NumberFormatException nfe) { nfe.printStackTrace(); } byte[] convertedBytes = convertingTobyteArray(Integer.toString(myNum)); BluetoothLeService.writeCharacteristicNoresponse( mReadSPRESSURESensorScanCharacteristic, convertedBytes); } return false; } }); Spinner spinner_filterconfiguration = (Spinner) rootView .findViewById(R.id.spressure_filter_configuration); // Create an ArrayAdapter using the string array and a // default // spinner layout ArrayAdapter<CharSequence> adapter_filterconfiguration = ArrayAdapter.createFromResource( getActivity(), R.array.filter_configuration_alert_array, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices // appears adapter_filterconfiguration .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner spinner_filterconfiguration.setAdapter(adapter_filterconfiguration); spressure_threshold_value = (EditText) rootView.findViewById(R.id.spressure_threshold); spressure_threshold_value.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { int myNum = 0; try { myNum = Integer.parseInt(spressure_threshold_value.getText().toString()); } catch (NumberFormatException nfe) { nfe.printStackTrace(); } byte[] convertedBytes = convertingTobyteArray(Integer.toString(myNum)); BluetoothLeService.writeCharacteristicNoresponse( mReadSPRESSUREThresholdCharacteristic, convertedBytes); } return false; } }); } else { spressure_more.setRotation(-90); spressure_scan_interval.setText(""); spressure_sensortype.setText(""); spressure_threshold_value.setText(""); CustomSlideAnimation a = new CustomSlideAnimation(spressure_layLayout, CustomSlideAnimation.COLLAPSE); height = a.getHeight(); spressure_layLayout.startAnimation(a); } } }); ImageButton acc_graph = (ImageButton) rootView.findViewById(R.id.acc_graph); setupAccChart(rootView); acc_graph.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mACCGraphLayoutParent.getVisibility() != View.VISIBLE) { mACCGraphLayoutParent.setVisibility(View.VISIBLE); } else { mACCGraphLayoutParent.setVisibility(View.GONE); } } }); ImageButton stemp_graph = (ImageButton) rootView.findViewById(R.id.temp_graph); setupTempGraph(rootView); stemp_graph.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mTemperatureGraphLayoutParent.getVisibility() != View.VISIBLE) { mTemperatureGraphLayoutParent.setVisibility(View.VISIBLE); } else { mTemperatureGraphLayoutParent.setVisibility(View.GONE); } } }); ImageButton spressure_graph = (ImageButton) rootView.findViewById(R.id.pressure_graph); setupPressureGraph(rootView); spressure_graph.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mPressureGraphLayoutParent.getVisibility() != View.VISIBLE) { mPressureGraphLayoutParent.setVisibility(View.VISIBLE); } else { mPressureGraphLayoutParent.setVisibility(View.GONE); } } }); setHasOptionsMenu(true); return rootView; }
From source file:de.enlightened.peris.SettingsFragment.java
private void setupUserCard() { if (this.getActivity() == null) { return;//from w w w .jav a2 s. co m } final LinearLayout userLayout = (LinearLayout) getActivity().findViewById(R.id.settings_user_box); if (this.application.getSession().getServer().serverUserId == null) { userLayout.setVisibility(View.GONE); } else { final ImageView ivAvatar = (ImageView) getActivity().findViewById(R.id.settings_user_avatar); final TextView tvUsername = (TextView) getActivity().findViewById(R.id.settings_user_name); final ImageView ivLogout = (ImageView) getActivity().findViewById(R.id.settings_user_logout); tvUsername.setText(this.application.getSession().getServer().serverUserName); if (this.application.getSession().getServer().serverAvatar.contains("http")) { ImageLoader.getInstance().displayImage(this.application.getSession().getServer().serverAvatar, ivAvatar); } else { ivAvatar.setImageResource(R.drawable.no_avatar); } ivLogout.setOnClickListener(new View.OnClickListener() { @Override @SuppressWarnings("checkstyle:requirethis") public void onClick(final View v) { logOut(); } }); userLayout.setOnClickListener(new View.OnClickListener() { @Override @SuppressWarnings("checkstyle:requirethis") public void onClick(final View v) { loadMyWall(); } }); } }