List of usage examples for android.widget RelativeLayout BELOW
int BELOW
To view the source code for android.widget RelativeLayout BELOW.
Click Source Link
From source file:com.repkap11.repcast.activities.LocalPlayerActivity.java
private void updateMetadata(boolean visible) { Point displaySize;//from w ww . j a v a 2 s .com if (!visible) { mDescriptionView.setVisibility(View.GONE); mTitleView.setVisibility(View.GONE); mAuthorView.setVisibility(View.GONE); displaySize = Utils.getDisplaySize(this); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(displaySize.x, displaySize.y + getSupportActionBar().getHeight()); lp.addRule(RelativeLayout.CENTER_IN_PARENT); mVideoView.setLayoutParams(lp); mVideoView.invalidate(); } else { MediaMetadata mm = mSelectedMedia.getMetadata(); mDescriptionView.setText(mSelectedMedia.getCustomData().optString(VideoProvider.KEY_DESCRIPTION)); mTitleView.setText(mm.getString(MediaMetadata.KEY_TITLE)); mAuthorView.setText(mm.getString(MediaMetadata.KEY_SUBTITLE)); mDescriptionView.setVisibility(View.VISIBLE); mTitleView.setVisibility(View.VISIBLE); mAuthorView.setVisibility(View.VISIBLE); displaySize = Utils.getDisplaySize(this); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(displaySize.x, (int) (displaySize.x * mAspectRatio)); lp.addRule(RelativeLayout.BELOW, R.id.toolbar); //lp.addRule(RelativeLayout.ALIGN_PARENT_TOP); mVideoView.setLayoutParams(lp); mVideoView.invalidate(); } }
From source file:com.wit.and.dialog.internal.BaseDialog.java
/** * <p>/*www .j a v a 2s . co m*/ * Corrects the dialog view (if is instance of <code>RelativeLayout</code>). * This actually place the dialog main views (title, body, buttons) into * correct place. If you decide override this for better dialog view * performance it is necessary to call <code>super</code> here. * </p> * * @param requestedCorrection Requested operation for correction in the dialog view as * relative layout. * @param dialogView Inflated dialog view. */ protected void onCorrectLayout(DialogLayoutCorrection requestedCorrection, View dialogView) { // Save call state. this.bCalled = true; // Perform only if we have valid body view. if (mBodyView == null || mLayoutCorrection == requestedCorrection || !(dialogView instanceof RelativeLayout)) return; // Create layout parameters for body and buttons view. RelativeLayout.LayoutParams bodyParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams buttonsParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); if (mBodyView.getLayoutParams() != null) { bodyParams = new RelativeLayout.LayoutParams(mBodyView.getLayoutParams()); } if (mButtonsView != null && mButtonsView.getLayoutParams() != null) { buttonsParams = new RelativeLayout.LayoutParams(mButtonsView.getLayoutParams()); } // Default merge. DialogLayoutCorrection helper = this.mLayoutCorrection; this.mLayoutCorrection = requestedCorrection; // Merge actual state of the relative layout correction. switch (requestedCorrection) { case WITH_TITLE_AND_BUTTONS: case WITHOUT_BOTH: break; case WITH_TITLE: if (helper == DialogLayoutCorrection.WITH_BUTTONS) { this.mLayoutCorrection = DialogLayoutCorrection.WITH_TITLE_AND_BUTTONS; } break; case WITHOUT_TITLE: if (helper == DialogLayoutCorrection.WITH_BUTTONS) { this.mLayoutCorrection = DialogLayoutCorrection.WITH_TITLE_AND_BUTTONS; } else if (helper == DialogLayoutCorrection.WITHOUT_BUTTONS) { this.mLayoutCorrection = DialogLayoutCorrection.WITHOUT_BOTH; } break; case WITH_BUTTONS: if (helper == DialogLayoutCorrection.WITH_TITLE_AND_BUTTONS) { return; } else if (helper == DialogLayoutCorrection.WITH_TITLE) { this.mLayoutCorrection = DialogLayoutCorrection.WITH_TITLE_AND_BUTTONS; } break; case WITHOUT_BUTTONS: if (helper == DialogLayoutCorrection.WITHOUT_TITLE) { this.mLayoutCorrection = DialogLayoutCorrection.WITHOUT_BOTH; } break; } // We just will set new parameters to the body view, which can depends // on the title or buttons view existence in the layout but in some // situations we don't have for example title view in the dialog view // (if the title text is empty). switch (mLayoutCorrection) { case WITH_TITLE_AND_BUTTONS: if (mTitleView != null) { bodyParams.addRule(RelativeLayout.BELOW, mTitleView.getId()); } buttonsParams.addRule(RelativeLayout.BELOW, mBodyView.getId()); break; case WITHOUT_TITLE: case WITH_BUTTONS: bodyParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); buttonsParams.addRule(RelativeLayout.BELOW, mBodyView.getId()); break; case WITHOUT_BUTTONS: case WITH_TITLE: if (mTitleView != null) { bodyParams.addRule(RelativeLayout.BELOW, mTitleView.getId()); } break; case WITHOUT_BOTH: bodyParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); break; } if (DEBUG) Log.d(TAG, "Dialog layout corrected to state " + mLayoutCorrection); // Set new parameters to the body view. mBodyView.setLayoutParams(bodyParams); // Set new parameters to the buttons view if we have it. if (mButtonsView != null) { mButtonsView.setLayoutParams(buttonsParams); } }
From source file:com.customdatepicker.time.TimePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { int viewRes = mVersion == Version.VERSION_1 ? R.layout.mdtp_time_picker_dialog : R.layout.mdtp_time_picker_dialog_v2; View view = inflater.inflate(viewRes, container, false); KeyboardListener keyboardListener = new KeyboardListener(); view.findViewById(R.id.mdtp_time_picker_dialog).setOnKeyListener(keyboardListener); // If an accent color has not been set manually, get it from the context if (mAccentColor == -1) { mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity()); }//w w w . jav a 2s .c om // if theme mode has not been set by java code, check if it is specified in Style.xml if (!mThemeDarkChanged) { mThemeDark = Utils.isDarkTheme(getActivity(), mThemeDark); } Resources res = getResources(); Context context = getActivity(); mHourPickerDescription = res.getString(R.string.mdtp_hour_picker_description); mSelectHours = res.getString(R.string.mdtp_select_hours); mMinutePickerDescription = res.getString(R.string.mdtp_minute_picker_description); mSelectMinutes = res.getString(R.string.mdtp_select_minutes); mSecondPickerDescription = res.getString(R.string.mdtp_second_picker_description); mSelectSeconds = res.getString(R.string.mdtp_select_seconds); mSelectedColor = ContextCompat.getColor(context, R.color.mdtp_white); mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_accent_color_focused); mHourView = (TextView) view.findViewById(R.id.mdtp_hours); mHourView.setOnKeyListener(keyboardListener); mHourSpaceView = (TextView) view.findViewById(R.id.mdtp_hour_space); mMinuteSpaceView = (TextView) view.findViewById(R.id.mdtp_minutes_space); mMinuteView = (TextView) view.findViewById(R.id.mdtp_minutes); mMinuteView.setOnKeyListener(keyboardListener); mSecondSpaceView = (TextView) view.findViewById(R.id.mdtp_seconds_space); mSecondView = (TextView) view.findViewById(R.id.mdtp_seconds); mSecondView.setOnKeyListener(keyboardListener); mAmTextView = (TextView) view.findViewById(R.id.mdtp_am_label); mAmTextView.setOnKeyListener(keyboardListener); mPmTextView = (TextView) view.findViewById(R.id.mdtp_pm_label); mPmTextView.setOnKeyListener(keyboardListener); mAmPmLayout = view.findViewById(R.id.mdtp_ampm_layout); String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0]; mPmText = amPmTexts[1]; mHapticFeedbackController = new HapticFeedbackController(getActivity()); if (mTimePicker != null) { mInitialTime = new Timepoint(mTimePicker.getHours(), mTimePicker.getMinutes(), mTimePicker.getSeconds()); } mInitialTime = roundToNearest(mInitialTime); mTimePicker = (RadialPickerLayout) view.findViewById(R.id.mdtp_time_picker); mTimePicker.setOnValueSelectedListener(this); mTimePicker.setOnKeyListener(keyboardListener); mTimePicker.initialize(getActivity(), this, mInitialTime, mIs24HourMode); int currentItemShowing = HOUR_INDEX; if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) { currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING); } setCurrentItemShowing(currentItemShowing, false, true, true); mTimePicker.invalidate(); mHourView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(HOUR_INDEX, true, false, true); tryVibrate(); } }); mMinuteView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(MINUTE_INDEX, true, false, true); tryVibrate(); } }); mSecondView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { setCurrentItemShowing(SECOND_INDEX, true, false, true); tryVibrate(); } }); mOkButton = (Button) view.findViewById(R.id.mdtp_ok); mOkButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mInKbMode && isTypedTimeFullyLegal()) { finishKbMode(false); } else { tryVibrate(); } notifyOnDateListener(); dismiss(); } }); mOkButton.setOnKeyListener(keyboardListener); mOkButton.setTypeface(TypefaceHelper.get(context, "Roboto-Medium")); if (mOkString != null) mOkButton.setText(mOkString); else mOkButton.setText(mOkResid); mCancelButton = (Button) view.findViewById(R.id.mdtp_cancel); mCancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); if (getDialog() != null) getDialog().cancel(); } }); mCancelButton.setTypeface(TypefaceHelper.get(context, "Roboto-Medium")); if (mCancelString != null) mCancelButton.setText(mCancelString); else mCancelButton.setText(mCancelResid); mCancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE); // Enable or disable the AM/PM view. if (mIs24HourMode) { mAmPmLayout.setVisibility(View.GONE); } else { OnClickListener listener = new OnClickListener() { @Override public void onClick(View v) { // Don't do anything if either AM or PM are disabled if (isAmDisabled() || isPmDisabled()) return; tryVibrate(); int amOrPm = mTimePicker.getIsCurrentlyAmOrPm(); if (amOrPm == AM) { amOrPm = PM; } else if (amOrPm == PM) { amOrPm = AM; } mTimePicker.setAmOrPm(amOrPm); } }; mAmTextView.setVisibility(View.GONE); mPmTextView.setVisibility(View.VISIBLE); mAmPmLayout.setOnClickListener(listener); if (mVersion == Version.VERSION_2) { mAmTextView.setText(mAmText); mPmTextView.setText(mPmText); mAmTextView.setVisibility(View.VISIBLE); } updateAmPmDisplay(mInitialTime.isAM() ? AM : PM); } // Disable seconds picker if (!mEnableSeconds) { mSecondView.setVisibility(View.GONE); view.findViewById(R.id.mdtp_separator_seconds).setVisibility(View.GONE); } // Disable minutes picker if (!mEnableMinutes) { mMinuteSpaceView.setVisibility(View.GONE); view.findViewById(R.id.mdtp_separator).setVisibility(View.GONE); } // Center stuff depending on what's visible boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; // Landscape layout is radically different if (isLandscape) { if (!mEnableMinutes && !mEnableSeconds) { // Just the hour // Put the hour above the center RelativeLayout.LayoutParams paramsHour = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); paramsHour.addRule(RelativeLayout.ABOVE, R.id.mdtp_center_view); paramsHour.addRule(RelativeLayout.CENTER_HORIZONTAL); mHourSpaceView.setLayoutParams(paramsHour); if (mIs24HourMode) { // Hour + Am/Pm indicator // Put the am / pm indicator next to the hour RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); paramsAmPm.addRule(RelativeLayout.RIGHT_OF, R.id.mdtp_hour_space); mAmPmLayout.setLayoutParams(paramsAmPm); } } else if (!mEnableSeconds && mIs24HourMode) { // Hour + Minutes // Put the separator above the center RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.CENTER_HORIZONTAL); paramsSeparator.addRule(RelativeLayout.ABOVE, R.id.mdtp_center_view); TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator); separatorView.setLayoutParams(paramsSeparator); } else if (!mEnableSeconds) { // Hour + Minutes + Am/Pm indicator // Put separator above the center RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.CENTER_HORIZONTAL); paramsSeparator.addRule(RelativeLayout.ABOVE, R.id.mdtp_center_view); TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator); separatorView.setLayoutParams(paramsSeparator); // Put the am/pm indicator below the separator RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); paramsAmPm.addRule(RelativeLayout.CENTER_IN_PARENT); paramsAmPm.addRule(RelativeLayout.BELOW, R.id.mdtp_center_view); mAmPmLayout.setLayoutParams(paramsAmPm); } else if (mIs24HourMode) { // Hour + Minutes + Seconds // Put the separator above the center RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.CENTER_HORIZONTAL); paramsSeparator.addRule(RelativeLayout.ABOVE, R.id.mdtp_seconds_space); TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator); separatorView.setLayoutParams(paramsSeparator); // Center the seconds RelativeLayout.LayoutParams paramsSeconds = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); paramsSeconds.addRule(RelativeLayout.CENTER_IN_PARENT); mSecondSpaceView.setLayoutParams(paramsSeconds); } else { // Hour + Minutes + Seconds + Am/Pm Indicator // Put the seconds on the center RelativeLayout.LayoutParams paramsSeconds = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); paramsSeconds.addRule(RelativeLayout.CENTER_IN_PARENT); mSecondSpaceView.setLayoutParams(paramsSeconds); // Put the separator above the seconds RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.CENTER_HORIZONTAL); paramsSeparator.addRule(RelativeLayout.ABOVE, R.id.mdtp_seconds_space); TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator); separatorView.setLayoutParams(paramsSeparator); // Put the Am/Pm indicator below the seconds RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); paramsAmPm.addRule(RelativeLayout.CENTER_HORIZONTAL); paramsAmPm.addRule(RelativeLayout.BELOW, R.id.mdtp_seconds_space); mAmPmLayout.setLayoutParams(paramsAmPm); } } else if (mIs24HourMode && !mEnableSeconds && mEnableMinutes) { // center first separator RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT); TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator); separatorView.setLayoutParams(paramsSeparator); } else if (!mEnableMinutes && !mEnableSeconds) { // center the hour RelativeLayout.LayoutParams paramsHour = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsHour.addRule(RelativeLayout.CENTER_IN_PARENT); mHourSpaceView.setLayoutParams(paramsHour); if (!mIs24HourMode) { RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsAmPm.addRule(RelativeLayout.RIGHT_OF, R.id.mdtp_hour_space); paramsAmPm.addRule(RelativeLayout.ALIGN_BASELINE, R.id.mdtp_hour_space); mAmPmLayout.setLayoutParams(paramsAmPm); } } else if (mEnableSeconds) { // link separator to minutes final View separator = view.findViewById(R.id.mdtp_separator); RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.LEFT_OF, R.id.mdtp_minutes_space); paramsSeparator.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); separator.setLayoutParams(paramsSeparator); if (!mIs24HourMode) { // center minutes RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsMinutes.addRule(RelativeLayout.CENTER_IN_PARENT); mMinuteSpaceView.setLayoutParams(paramsMinutes); } else { // move minutes to right of center RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsMinutes.addRule(RelativeLayout.RIGHT_OF, R.id.mdtp_center_view); mMinuteSpaceView.setLayoutParams(paramsMinutes); } } mAllowAutoAdvance = true; setHour(mInitialTime.getHour(), true); setMinute(mInitialTime.getMinute()); setSecond(mInitialTime.getSecond()); // Set up for keyboard mode. mDoublePlaceholderText = res.getString(R.string.mdtp_time_placeholder); mDeletedKeyFormat = res.getString(R.string.mdtp_deleted_key); mPlaceholderText = mDoublePlaceholderText.charAt(0); mAmKeyCode = mPmKeyCode = -1; generateLegalTimesTree(); if (mInKbMode) { mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES); tryStartingKbMode(-1); mHourView.invalidate(); } else if (mTypedTimes == null) { mTypedTimes = new ArrayList<>(); } // Set the title (if any) TextView timePickerHeader = (TextView) view.findViewById(R.id.mdtp_time_picker_header); if (!mTitle.isEmpty()) { timePickerHeader.setVisibility(TextView.VISIBLE); timePickerHeader.setText(mTitle.toUpperCase(Locale.getDefault())); } // Set the theme at the end so that the initialize()s above don't counteract the theme. timePickerHeader.setBackgroundColor(Utils.darkenColor(mAccentColor)); view.findViewById(R.id.mdtp_time_display_background).setBackgroundColor(mAccentColor); view.findViewById(R.id.mdtp_time_display).setBackgroundColor(mAccentColor); // Button text can have a different color if (mOkColor != -1) mOkButton.setTextColor(mOkColor); else mOkButton.setTextColor(mAccentColor); if (mCancelColor != -1) mCancelButton.setTextColor(mCancelColor); else mCancelButton.setTextColor(mAccentColor); if (getDialog() == null) { view.findViewById(R.id.mdtp_done_background).setVisibility(View.GONE); } int circleBackground = ContextCompat.getColor(context, R.color.mdtp_circle_background); int backgroundColor = ContextCompat.getColor(context, R.color.mdtp_background_color); int darkBackgroundColor = ContextCompat.getColor(context, R.color.mdtp_light_gray); int lightGray = ContextCompat.getColor(context, R.color.mdtp_light_gray); mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground); view.findViewById(R.id.mdtp_time_picker_dialog) .setBackgroundColor(mThemeDark ? darkBackgroundColor : backgroundColor); return view; }
From source file:com.google.sample.cast.refplayer.Synchronization.java
/** * Setting the Previewing mode(Editing mode) clip bar (orange) *//*w ww. j a v a 2s .co m*/ private void setPreviewClip() { if (pseekBar != null) { pseekBar.setVisibility(View.GONE); } prev_start_p_ForPreview = prev_start_p; prev_end_p_ForPreview = prev_end_p; pseekBar = new RangeSeekBar(prev_start_p_ForPreview, prev_end_p_ForPreview, this); pseekBar.setOnRangeSeekBarChangeListener(new OnRangeSeekBarChangeListener<Integer>() { @Override public void onRangeSeekBarValuesChanged(RangeSeekBar<?> bar, Integer start_p, Integer end_p) { // handle changed range values Log.i(TAG, "Selected new range values: MIN=" + start_p + ", MAX=" + end_p); mClipDuration.setText(" " + com.google.android.libraries.cast.companionlibrary.utils.Utils .formatMillis(prev_end_p_ForPreview - prev_start_p_ForPreview) + " "); playpause = false; mPlayPause.setImageDrawable(getResources().getDrawable(R.drawable.ic_av_play_dark)); if (start_p != prev_start_p_ForPreview) { mVideoView.seekTo(start_p); mVideoView.start(); SystemClock.sleep(100); mVideoView.pause(); prev_start_p_ForPreview = start_p; prev_start_p = start_p; } if (end_p != prev_end_p_ForPreview) { mVideoView.seekTo(end_p); mVideoView.start(); SystemClock.sleep(100); mVideoView.pause(); prev_end_p_ForPreview = end_p; prev_end_p = end_p; } } }); // add RangeSeekBar to pre-defined layout RelativeLayout layout = (RelativeLayout) findViewById(R.id.synchronization); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, pseekBar.getId()); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, pseekBar.getId()); params.addRule(RelativeLayout.BELOW, mVideoView.getId()); pseekBar.setVisibility(View.VISIBLE); layout.addView(pseekBar, params); }
From source file:knayi.delevadriver.JobDetailActivity.java
private void getDataFromServer(String jobid) { progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); if (jobid == null) { jobid = ""; }/*from w ww . ja v a2 s . co m*/ AvaliableJobsAPI.getInstance().getService().getJobDetail(jobid, sPref.getString(Config.TOKEN, ""), new Callback<String>() { @Override public void success(String s, Response response) { Log.i("Output Data", s.toString()); try { JSONObject jsonobject = new JSONObject(s); if (!jsonobject.isNull("data")) { JSONObject jsonobj = jsonobject.getJSONObject("data"); jobitem = new JobItem(); if (!jsonobj.isNull("_id")) jobitem.set_id(jsonobj.getString("_id")); JSONObject requesterobj = jsonobj.getJSONObject("requester"); if (requesterobj != null) { if (!requesterobj.isNull("name")) { jobitem.set_requester_name(requesterobj.getString("name")); } else { jobitem.set_requester_name("none"); } if (!requesterobj.isNull("email")) { jobitem.set_requester_email(requesterobj.getString("email")); } else { jobitem.set_requester_email("none"); } if (!requesterobj.isNull("mobile_number")) jobitem.set_requester_mobile_number( requesterobj.getString("mobile_number")); if (!requesterobj.isNull("address")) jobitem.set_requester_address(requesterobj.getString("address")); /* if(requesterobj.getString("business_type") != null) jobitem.set_requester_business_type(requesterobj.getString("business_type")); */ if (!requesterobj.isNull("business_address")) jobitem.set_requester_business_address( requesterobj.getString("business_address")); JSONArray requester_pictures = requesterobj.getJSONArray("pictures"); List<String> pic_list = new ArrayList<String>(); for (int j = 0; j < requester_pictures.length(); j++) { JSONObject obj = requester_pictures.getJSONObject(j); if (!obj.isNull("path")) pic_list.add(obj.getString("path")); } } /*if(!jsonobj.isNull("type")) jobitem.set_type(jsonobj.getString("type")); else jobitem.set_type("None");*/ if (!jsonobj.isNull("address")) jobitem.set_address(jsonobj.getString("address")); else jobitem.set_address("None"); if (!jsonobj.isNull("receiver_name")) jobitem.set_receiver_name(jsonobj.getString("receiver_name")); else jobitem.set_receiver_name("None"); if (!jsonobj.isNull("receiver_contact")) jobitem.set_receiver_contact(jsonobj.getString("receiver_contact")); else jobitem.set_receiver_contact("None"); if (!jsonobj.isNull("size")) { jobitem.set_size(jsonobj.getString("size")); } else { jobitem.set_size("None"); } if (!jsonobj.isNull("weight")) { jobitem.set_weight(jsonobj.getString("weight")); } else { jobitem.set_weight("None"); } if (!jsonobj.isNull("sensitivity")) { jobitem.set_sensitivity(jsonobj.getString("sensitivity")); } else { jobitem.set_sensitivity("None"); } if (!jsonobj.isNull("pickup_time")) { jobitem.set_pickuptime(jsonobj.getString("pickup_time")); } else { jobitem.set_pickuptime("None"); } if (!jsonobj.isNull("duration_text")) { jobitem.set_duration(jsonobj.getString("duration_text")); } else { jobitem.set_duration("None"); } if (!jsonobj.isNull("post_code")) jobitem.set_post_code(jsonobj.getString("post_code")); if (!jsonobj.isNull("pickup_ll")) { jobitem.set_pickup_lon((Double) jsonobj.getJSONArray("pickup_ll").get(0)); jobitem.set_pickup_lat((Double) jsonobj.getJSONArray("pickup_ll").get(1)); } if (!jsonobj.isNull("address_ll")) { jobitem.set_address_lon((Double) jsonobj.getJSONArray("address_ll").get(0)); jobitem.set_address_lat((Double) jsonobj.getJSONArray("address_ll").get(1)); } if (!jsonobj.isNull("type_express")) { jobitem.setIsExpress(String.valueOf(jsonobj.getBoolean("type_express"))); } if (!jsonobj.isNull("type_refigerated")) { jobitem.setIsRefrigerated( String.valueOf(jsonobj.getBoolean("type_refigerated"))); } //jobitem.set_reports(jsonobj.getString("reports")); //jobitem.set_rejectMessage(jsonobj.getString("rejectMessage")); if (!jsonobj.isNull("status")) jobitem.set_status(jsonobj.getString("status")); else jobitem.set_status("None"); if (!jsonobj.isNull("pictures")) { JSONArray pictures = jsonobj.getJSONArray("pictures"); List<String> pic_list1 = new ArrayList<String>(); for (int j = 0; j < pictures.length(); j++) { JSONObject obj = pictures.getJSONObject(j); if (obj.getString("path") != null) pic_list1.add(obj.getString("path")); } if (pic_list1.size() > 0) { jobitem.set_pictures(pic_list1.get(0)); imageprogress.setVisibility(View.VISIBLE); Picasso.with(JobDetailActivity.this) .load(APIConfig.DOMAIN_URL + pic_list1.get(0)) .into(imageView, new com.squareup.picasso.Callback() { @Override public void onSuccess() { imageprogress.setVisibility(View.INVISIBLE); } @Override public void onError() { } }); } } if (!jsonobj.isNull("price")) { jobitem.set_price(jsonobj.getString("price")); totalprice = Double.parseDouble(jsonobj.getString("price")); } else { jobitem.set_price("None"); } if (!jsonobj.isNull("createAt")) jobitem.set_createAt(jsonobj.getString("createAt")); else { jobitem.set_createAt("None"); } } } catch (JSONException jsonexception) { jsonexception.printStackTrace(); Log.i("APIData", "error"); } if (Integer.parseInt(jobitem.get_weight()) <= 10) { weightpos = 0; weightPricelist = Arrays.asList(new Double[] { 0.00, 4.00, 8.00 }); weightlist = Arrays.asList(new String[] { "le10kg", "le20kg", "le30kg" }); weightshowlist = Arrays.asList(new String[] { "Less than and equal 10 kg", "Less than and equal 20 kg", "Less than and equal 30 kg" }); } else if (Integer.parseInt(jobitem.get_weight()) <= 20) { weightpos = 1; weightPricelist = Arrays.asList(new Double[] { -4.00, 0.00, 4.00 }); weightlist = Arrays.asList(new String[] { "le10kg", "le20kg", "le30kg" }); weightshowlist = Arrays.asList(new String[] { "Less than and equal 10 kg", "Less than and equal 20 kg", "Less than and equal 30 kg" }); } else if (Integer.parseInt(jobitem.get_weight()) <= 30) { weightpos = 2; weightPricelist = Arrays.asList(new Double[] { -8.00, -4.00, 0.00 }); weightlist = Arrays.asList(new String[] { "le10kg", "le20kg", "le30kg" }); weightshowlist = Arrays.asList(new String[] { "Less than and equal 10 kg", "Less than and equal 20 kg", "Less than and equal 30 kg" }); } //Log.i("Weight", String.valueOf(Integer.parseInt(jobitem.get_weight()))); /*String type = jobitem.get_type(); if(type.equals("other")){ typepos = 0; jobtype.setText("Type: Other"); //typepricelist = Arrays.asList(new Double[]{0.00, 3.00, 3.00}); }else if(type.equals("express")){ typepos = 1; jobtype.setText("Type: Express"); //typepricelist = Arrays.asList(new Double[]{-3.00, 0.00, 0.00}); }else if(type.equals("freezen")){ typepos = 2; jobtype.setText("Type: Refrigerated"); //typepricelist = Arrays.asList(new Double[]{-3.00, 0.00, 0.00}); }else{ jobtype.setText("Type: None"); //typepricelist = Arrays.asList(new Double[]{0.00, 0.00, 0.00}); }*/ //jobtype.setText(jobitem.get_requester_name()); if (!jobitem.get_pickuptime().equals("None")) { String str = jobitem.get_pickuptime(); String datestr = str.substring(0, 10); String timestr = str.substring(11, 16); pickuptime.setText("Pick Up Time: " + timestr); pickupdate.setText("Pick Up Date: " + datestr); } else { pickuptime.setText("Pick Up Time: " + jobitem.get_pickuptime()); pickupdate.setText("Pick Up Date: " + jobitem.get_pickuptime()); } if (jobitem.get_price() != null) { jobprice.setText("SGD$ " + jobitem.get_price()); } else { jobprice.setText("None"); } if (jobitem.get_address() != null) { deliveryaddress.setText("Delivery Address: " + jobitem.get_address()); } else { deliveryaddress.setText("None"); } /*if(jobitem.get_createAt() != null) { String date = getDateFromtimeFormat(jobitem.get_createAt()); jobcreatetime.setText("" + date); } else jobcreatetime.setText("not include"); */ //requestername.setText("" + jobitem.get_requester()); //requesterbusinesstype.setText("" + jobitem.get_requester_business_type()); if (jobitem.get_requester_mobile_number() != null) { requesterphone.setText("Contact: " + jobitem.get_requester_mobile_number()); } else { requesterphone.setText("None"); } if (jobitem.get_requester_name() != null) { requestername.setText("Name: " + jobitem.get_requester_name()); } else { requestername.setText("None"); } if (jobitem.get_requester_address() != null) { requesteraddress.setText("Pick Up Address: " + jobitem.get_requester_address()); } else { requesteraddress.setText("None"); } if (jobitem.get_receiver_name() != null) { receivername.setText("Name: " + jobitem.get_receiver_name()); } else { receivername.setText("None"); } if (jobitem.get_receiver_contact() != null) { receivercontact.setText("Contact: " + jobitem.get_receiver_contact()); } else { receivercontact.setText("None"); } /*if(jobitem.get_size() != null) { size.setText("Size: " + jobitem.get_size()); }else{ size.setText("None"); }*/ if (jobitem.get_weight() != null) { weight.setText("Weight: " + jobitem.get_weight() + " Kg"); } else { weight.setText("None"); } if (jobitem.get_sensitivity() != null) { sensitivity.setText("Sensitivity: " + jobitem.get_sensitivity()); } else { sensitivity.setText("None"); } /*if(jobitem.get_duration() != null) { duration.setText("" + jobitem.get_duration()); }else{ duration.setText("None"); }*/ String status = jobitem.get_status(); if (status == null) { job_bid.setText("None"); } else if (status.equals(Config.PENDING)) { jobstatus.setText("Status: Pending"); bitLayout.setVisibility(View.VISIBLE); job_reject.setVisibility(View.INVISIBLE); job_bid.setText("Bid"); job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); } else if (jobitem.get_status().equals(Config.BID)) { jobstatus.setText("Status: Bid"); bitLayout.setVisibility(View.VISIBLE); job_bid.setText("Agree"); job_reject.setText("Reject"); job_report.setVisibility(View.VISIBLE); } else if (jobitem.get_status().equals(Config.ACTIVE)) { jobstatus.setText("Status: Active"); bitLayout.setVisibility(View.VISIBLE); job_bid.setText("Finished"); RelativeLayout.LayoutParams p = (RelativeLayout.LayoutParams) bitLayout .getLayoutParams(); p.addRule(RelativeLayout.BELOW, R.id.jobdetail_showmap_layout); bitLayout.setLayoutParams(p); job_reject.setVisibility(View.INVISIBLE); job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); } else if (jobitem.get_status().equals(Config.FINISH)) { jobstatus.setText("Status: Finish"); bitLayout.setVisibility(View.GONE); job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); relativeLayout.removeView(viewforPlacing1); } else if (jobitem.get_status().equals(Config.DELETE)) { jobstatus.setText("Status: Delete"); bitLayout.setVisibility(View.GONE); job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); relativeLayout.removeView(viewforPlacing1); } else if (jobitem.get_status().equals(Config.POST)) { jobstatus.setText("Status: Post"); bitLayout.setVisibility(View.GONE); job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); relativeLayout.removeView(viewforPlacing1); } else if (jobitem.get_status().equals(Config.PROCESS)) { jobstatus.setText("Status: Process"); bitLayout.setVisibility(View.VISIBLE); job_bid.setText("Finished"); job_reject.setVisibility(View.INVISIBLE); job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); } progress.setVisibility(View.GONE); progress_background.setVisibility(View.GONE); } @Override public void failure(RetrofitError error) { progress.setVisibility(View.GONE); progress_background.setVisibility(View.GONE); if (error.getBody() == null) { Toast.makeText(JobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT) .show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err").getString("message"); Toast.makeText(JobDetailActivity.this, errcode, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } Intent intent = new Intent(JobDetailActivity.this, DrawerMainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); JobDetailActivity.this.finish(); } }); }
From source file:com.aimfire.demo.CameraActivity.java
private void adjustUIControls(int rotation) { RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mCaptureButton.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0); layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); mCaptureButton.setLayoutParams(layoutParams); mCaptureButton.setRotation(rotation); layoutParams = (RelativeLayout.LayoutParams) mPvButton.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0); layoutParams.addRule(RelativeLayout.ABOVE, 0); layoutParams.addRule(RelativeLayout.BELOW, R.id.capture_button); mPvButton.setLayoutParams(layoutParams); mPvButton.setRotation(rotation);/*from ww w .j ava2s . c o m*/ /* layoutParams = (RelativeLayout.LayoutParams)mFbButton.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0); layoutParams.addRule(RelativeLayout.ABOVE, R.id.capture_button); layoutParams.addRule(RelativeLayout.BELOW, 0); mFbButton.setLayoutParams(layoutParams); mFbButton.setRotation(rotation); */ layoutParams = (RelativeLayout.LayoutParams) mExitButton.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 0); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); mExitButton.setLayoutParams(layoutParams); mExitButton.setRotation(rotation); layoutParams = (RelativeLayout.LayoutParams) mView3DButton.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); mView3DButton.setLayoutParams(layoutParams); mView3DButton.setRotation(rotation); layoutParams = (RelativeLayout.LayoutParams) mModeButton.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.LEFT_OF, 0); layoutParams.addRule(RelativeLayout.RIGHT_OF, 0); mModeButton.setLayoutParams(layoutParams); mModeButton.setRotation(rotation); layoutParams = (RelativeLayout.LayoutParams) mLevelButton.getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0); mLevelButton.setLayoutParams(layoutParams); mLevelButton.setRotation(rotation); CustomToast.setRotation(rotation); }
From source file:info.tellmetime.TellmetimeActivity.java
private void resizeClock() { final LinearLayout mClock = (LinearLayout) findViewById(R.id.clock); // Set width of #mClock layout to the screen's shorter edge size, so clock is not // expanded in landscape mode, but has rather somewhat a square shape. RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.CENTER_IN_PARENT); lp.width = mShorterEdge;//w w w . j a v a 2 s .c om mClock.setLayoutParams(lp); final float mItemSize = mShorterEdge / mClock.getChildCount(); final int mRowMargin = (int) -(mItemSize / 2.2); // Scale text size according to shorter edge and set spacing between rows. for (int i = 0; i < mClock.getChildCount(); i++) { LinearLayout row = (LinearLayout) mClock.getChildAt(i); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) row.getLayoutParams(); params.bottomMargin = mRowMargin; row.setLayoutParams(params); for (int j = 0; j < row.getChildCount(); j++) ((TextView) row.getChildAt(j)).setTextSize(TypedValue.COMPLEX_UNIT_PX, mItemSize); } LinearLayout lastRow = (LinearLayout) mClock.getChildAt(mClock.getChildCount() - 1); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) lastRow.getLayoutParams(); params.bottomMargin = 0; lastRow.setLayoutParams(params); TextView twenty = (TextView) findViewById(R.id.twenty); params = (LinearLayout.LayoutParams) twenty.getLayoutParams(); params.leftMargin = 0; twenty.setLayoutParams(params); // Inflates minutes indicators and attaches them to main view. FrameLayout minutesLayout = (FrameLayout) findViewById(R.id.minutes_indicators); minutesLayout.removeAllViews(); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); final boolean isLandscape = getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; inflater.inflate(isLandscape ? R.layout.minutes_land : R.layout.minutes_portrait, minutesLayout); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, isLandscape ? FrameLayout.LayoutParams.MATCH_PARENT : FrameLayout.LayoutParams.WRAP_CONTENT); if (!isLandscape) { layoutParams.addRule(RelativeLayout.BELOW, R.id.clock); layoutParams.topMargin = (int) -TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize / 3, getResources().getDisplayMetrics()); } minutesLayout.setLayoutParams(layoutParams); ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots); for (int i = 0; i < minutesDots.getChildCount(); i++) ((TextView) minutesDots.getChildAt(i)).setTextSize(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize); }
From source file:kr.wdream.ui.Components.PasscodeView.java
private void checkFingerprint() { Activity parentActivity = (Activity) getContext(); if (Build.VERSION.SDK_INT >= 23 && parentActivity != null && UserConfig.useFingerprint && !ApplicationLoader.mainInterfacePaused) { try {// ww w . ja v a 2 s.c o m if (fingerprintDialog != null && fingerprintDialog.isShowing()) { return; } } catch (Exception e) { FileLog.e("tmessages", e); } try { FingerprintManagerCompat fingerprintManager = FingerprintManagerCompat .from(ApplicationLoader.applicationContext); if (fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) { RelativeLayout relativeLayout = new RelativeLayout(getContext()); relativeLayout.setPadding(AndroidUtilities.dp(24), AndroidUtilities.dp(16), AndroidUtilities.dp(24), AndroidUtilities.dp(8)); TextView fingerprintTextView = new TextView(getContext()); fingerprintTextView.setTextColor(0xff939393); fingerprintTextView.setId(id_fingerprint_textview); fingerprintTextView.setTextAppearance(android.R.style.TextAppearance_Material_Subhead); fingerprintTextView.setText(LocaleController.getString("FingerprintInfo", kr.wdream.storyshop.R.string.FingerprintInfo)); relativeLayout.addView(fingerprintTextView); RelativeLayout.LayoutParams layoutParams = LayoutHelper .createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_START); fingerprintTextView.setLayoutParams(layoutParams); fingerprintImageView = new ImageView(getContext()); fingerprintImageView.setImageResource(kr.wdream.storyshop.R.drawable.ic_fp_40px); fingerprintImageView.setId(id_fingerprint_imageview); relativeLayout.addView(fingerprintImageView, LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, 20, 0, 0, RelativeLayout.ALIGN_PARENT_START, RelativeLayout.BELOW, id_fingerprint_textview)); fingerprintStatusTextView = new TextView(getContext()); fingerprintStatusTextView.setGravity(Gravity.CENTER_VERTICAL); fingerprintStatusTextView.setText(LocaleController.getString("FingerprintHelp", kr.wdream.storyshop.R.string.FingerprintHelp)); fingerprintStatusTextView.setTextAppearance(android.R.style.TextAppearance_Material_Body1); fingerprintStatusTextView.setTextColor(0x42000000); relativeLayout.addView(fingerprintStatusTextView); layoutParams = LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT); layoutParams.setMarginStart(AndroidUtilities.dp(16)); layoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, id_fingerprint_imageview); layoutParams.addRule(RelativeLayout.ALIGN_TOP, id_fingerprint_imageview); layoutParams.addRule(RelativeLayout.END_OF, id_fingerprint_imageview); fingerprintStatusTextView.setLayoutParams(layoutParams); AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(LocaleController.getString("AppName", kr.wdream.storyshop.R.string.AppName)); builder.setView(relativeLayout); builder.setNegativeButton( LocaleController.getString("Cancel", kr.wdream.storyshop.R.string.Cancel), null); builder.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (cancellationSignal != null) { selfCancelled = true; cancellationSignal.cancel(); cancellationSignal = null; } } }); if (fingerprintDialog != null) { try { if (fingerprintDialog.isShowing()) { fingerprintDialog.dismiss(); } } catch (Exception e) { FileLog.e("tmessages", e); } } fingerprintDialog = builder.show(); cancellationSignal = new CancellationSignal(); selfCancelled = false; fingerprintManager.authenticate(null, 0, cancellationSignal, new FingerprintManagerCompat.AuthenticationCallback() { @Override public void onAuthenticationError(int errMsgId, CharSequence errString) { if (!selfCancelled) { showFingerprintError(errString); } } @Override public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) { showFingerprintError(helpString); } @Override public void onAuthenticationFailed() { showFingerprintError(LocaleController.getString("FingerprintNotRecognized", kr.wdream.storyshop.R.string.FingerprintNotRecognized)); } @Override public void onAuthenticationSucceeded( FingerprintManagerCompat.AuthenticationResult result) { try { if (fingerprintDialog.isShowing()) { fingerprintDialog.dismiss(); } } catch (Exception e) { FileLog.e("tmessages", e); } fingerprintDialog = null; processDone(true); } }, null); } } catch (Throwable e) { //ignore } } }
From source file:ir.besteveryeverapp.ui.Components.PasscodeView.java
private void checkFingerprint() { Activity parentActivity = (Activity) getContext(); if (Build.VERSION.SDK_INT >= 23 && parentActivity != null && UserConfig.useFingerprint && !ApplicationLoader.mainInterfacePaused) { try {// ww w . java2 s. co m if (fingerprintDialog != null && fingerprintDialog.isShowing()) { return; } } catch (Exception e) { FileLog.e("tmessages", e); } try { FingerprintManagerCompat fingerprintManager = FingerprintManagerCompat .from(ApplicationLoader.applicationContext); if (fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) { RelativeLayout relativeLayout = new RelativeLayout(getContext()); relativeLayout.setPadding(AndroidUtilities.dp(24), AndroidUtilities.dp(16), AndroidUtilities.dp(24), AndroidUtilities.dp(8)); TextView fingerprintTextView = new TextView(getContext()); fingerprintTextView.setTypeface(FontManager.instance().getTypeface()); fingerprintTextView.setTextColor(0xff939393); fingerprintTextView.setId(id_fingerprint_textview); fingerprintTextView.setTextAppearance(android.R.style.TextAppearance_Material_Subhead); fingerprintTextView .setText(LocaleController.getString("FingerprintInfo", R.string.FingerprintInfo)); relativeLayout.addView(fingerprintTextView); RelativeLayout.LayoutParams layoutParams = LayoutHelper .createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_START); fingerprintTextView.setLayoutParams(layoutParams); fingerprintImageView = new ImageView(getContext()); fingerprintImageView.setImageResource(R.drawable.ic_fp_40px); fingerprintImageView.setId(id_fingerprint_imageview); relativeLayout.addView(fingerprintImageView, LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, 20, 0, 0, RelativeLayout.ALIGN_PARENT_START, RelativeLayout.BELOW, id_fingerprint_textview)); fingerprintStatusTextView = new TextView(getContext()); fingerprintStatusTextView.setTypeface(FontManager.instance().getTypeface()); fingerprintStatusTextView.setGravity(Gravity.CENTER_VERTICAL); fingerprintStatusTextView .setText(LocaleController.getString("FingerprintHelp", R.string.FingerprintHelp)); fingerprintStatusTextView.setTextAppearance(android.R.style.TextAppearance_Material_Body1); fingerprintStatusTextView.setTextColor(0x42000000); relativeLayout.addView(fingerprintStatusTextView); layoutParams = LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT); layoutParams.setMarginStart(AndroidUtilities.dp(16)); layoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, id_fingerprint_imageview); layoutParams.addRule(RelativeLayout.ALIGN_TOP, id_fingerprint_imageview); layoutParams.addRule(RelativeLayout.END_OF, id_fingerprint_imageview); fingerprintStatusTextView.setLayoutParams(layoutParams); AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setView(relativeLayout); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (cancellationSignal != null) { selfCancelled = true; cancellationSignal.cancel(); cancellationSignal = null; } } }); if (fingerprintDialog != null) { try { if (fingerprintDialog.isShowing()) { fingerprintDialog.dismiss(); } } catch (Exception e) { FileLog.e("tmessages", e); } } fingerprintDialog = builder.show(); cancellationSignal = new CancellationSignal(); selfCancelled = false; fingerprintManager.authenticate(null, 0, cancellationSignal, new FingerprintManagerCompat.AuthenticationCallback() { @Override public void onAuthenticationError(int errMsgId, CharSequence errString) { if (!selfCancelled) { showFingerprintError(errString); } } @Override public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) { showFingerprintError(helpString); } @Override public void onAuthenticationFailed() { showFingerprintError(LocaleController.getString("FingerprintNotRecognized", R.string.FingerprintNotRecognized)); } @Override public void onAuthenticationSucceeded( FingerprintManagerCompat.AuthenticationResult result) { try { if (fingerprintDialog.isShowing()) { fingerprintDialog.dismiss(); } } catch (Exception e) { FileLog.e("tmessages", e); } fingerprintDialog = null; processDone(true); } }, null); } } catch (Throwable e) { //ignore } } }
From source file:com.goftagram.telegram.ui.Components.PasscodeView.java
private void checkFingerprint() { Activity parentActivity = (Activity) getContext(); if (Build.VERSION.SDK_INT >= 23 && parentActivity != null && UserConfig.useFingerprint && !ApplicationLoader.mainInterfacePaused) { try {/*from w ww .java 2 s . co m*/ if (fingerprintDialog != null && fingerprintDialog.isShowing()) { return; } } catch (Exception e) { FileLog.e("tmessages", e); } try { FingerprintManagerCompat fingerprintManager = FingerprintManagerCompat .from(ApplicationLoader.applicationContext); if (fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) { RelativeLayout relativeLayout = new RelativeLayout(getContext()); relativeLayout.setPadding(AndroidUtilities.dp(24), AndroidUtilities.dp(16), AndroidUtilities.dp(24), AndroidUtilities.dp(8)); TextView fingerprintTextView = new TextView(getContext()); fingerprintTextView.setTextColor(0xff939393); fingerprintTextView.setId(id_fingerprint_textview); fingerprintTextView.setTextAppearance(android.R.style.TextAppearance_Material_Subhead); fingerprintTextView .setText(LocaleController.getString("FingerprintInfo", R.string.FingerprintInfo)); relativeLayout.addView(fingerprintTextView); RelativeLayout.LayoutParams layoutParams = LayoutHelper .createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_START); fingerprintTextView.setLayoutParams(layoutParams); fingerprintImageView = new ImageView(getContext()); fingerprintImageView.setImageResource(R.drawable.ic_fp_40px); fingerprintImageView.setId(id_fingerprint_imageview); relativeLayout.addView(fingerprintImageView, LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, 20, 0, 0, RelativeLayout.ALIGN_PARENT_START, RelativeLayout.BELOW, id_fingerprint_textview)); fingerprintStatusTextView = new TextView(getContext()); fingerprintStatusTextView.setGravity(Gravity.CENTER_VERTICAL); fingerprintStatusTextView .setText(LocaleController.getString("FingerprintHelp", R.string.FingerprintHelp)); fingerprintStatusTextView.setTextAppearance(android.R.style.TextAppearance_Material_Body1); fingerprintStatusTextView.setTextColor(0x42000000); relativeLayout.addView(fingerprintStatusTextView); layoutParams = LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT); layoutParams.setMarginStart(AndroidUtilities.dp(16)); layoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, id_fingerprint_imageview); layoutParams.addRule(RelativeLayout.ALIGN_TOP, id_fingerprint_imageview); layoutParams.addRule(RelativeLayout.END_OF, id_fingerprint_imageview); fingerprintStatusTextView.setLayoutParams(layoutParams); AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setView(relativeLayout); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (cancellationSignal != null) { selfCancelled = true; cancellationSignal.cancel(); cancellationSignal = null; } } }); if (fingerprintDialog != null) { try { if (fingerprintDialog.isShowing()) { fingerprintDialog.dismiss(); } } catch (Exception e) { FileLog.e("tmessages", e); } } fingerprintDialog = builder.show(); cancellationSignal = new CancellationSignal(); selfCancelled = false; fingerprintManager.authenticate(null, 0, cancellationSignal, new FingerprintManagerCompat.AuthenticationCallback() { @Override public void onAuthenticationError(int errMsgId, CharSequence errString) { if (!selfCancelled) { showFingerprintError(errString); } } @Override public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) { showFingerprintError(helpString); } @Override public void onAuthenticationFailed() { showFingerprintError(LocaleController.getString("FingerprintNotRecognized", R.string.FingerprintNotRecognized)); } @Override public void onAuthenticationSucceeded( FingerprintManagerCompat.AuthenticationResult result) { try { if (fingerprintDialog.isShowing()) { fingerprintDialog.dismiss(); } } catch (Exception e) { FileLog.e("tmessages", e); } fingerprintDialog = null; processDone(true); } }, null); } } catch (Throwable e) { //ignore } } }