List of usage examples for android.widget RelativeLayout TRUE
int TRUE
To view the source code for android.widget RelativeLayout TRUE.
Click Source Link
From source file:org.odk.collect.android.widgets.QuestionWidget.java
/** * Default place to put the answer//from w w w . j a va 2 s . co m * (below the help text or question text if there is no help text) * If you have many elements, use this first * and use the standard addView(view, params) to place the rest */ protected void addAnswerView(View v) { if (v == null) { Timber.e("cannot add a null view as an answerView"); return; } // default place to add answer RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); if (helpTextView.getVisibility() == View.VISIBLE) { params.addRule(RelativeLayout.BELOW, helpTextView.getId()); } else { params.addRule(RelativeLayout.BELOW, questionMediaLayout.getId()); } params.setMargins(10, 0, 10, 0); addView(v, params); }
From source file:de.mrapp.android.dialog.decorator.MaterialDialogDecorator.java
/** * Creates and returns the layout params, which should be used by the dialog's root view. * * @return The layout params, which have been created, as an instance of the class {@link * RelativeLayout.LayoutParams}/*from ww w. j a v a2 s . c o m*/ */ private RelativeLayout.LayoutParams createLayoutParams() { Rect windowDimensions = new Rect(); Window window = getWindow(); assert window != null; window.getDecorView().getWindowVisibleDisplayFrame(windowDimensions); int shadowWidth = isFullscreen() ? 0 : getContext().getResources().getDimensionPixelSize(R.dimen.dialog_shadow_width); int leftInset = isFitsSystemWindowsLeft() && isFullscreen() && windowInsets != null ? windowInsets.left : 0; int topInset = isFitsSystemWindowsTop() && isFullscreen() && windowInsets != null ? windowInsets.top : 0; int rightInset = isFitsSystemWindowsRight() && isFullscreen() && windowInsets != null ? windowInsets.right : 0; int bottomInset = isFitsSystemWindowsBottom() && isFullscreen() && windowInsets != null ? windowInsets.bottom : 0; int leftMargin = getLeftMargin() - shadowWidth + leftInset; int topMargin = getTopMargin() - shadowWidth + topInset; int rightMargin = getRightMargin() - shadowWidth + rightInset; int bottomMargin = getBottomMargin() - shadowWidth + bottomInset; int width = getLayoutDimension(getWidth(), leftMargin + rightMargin, windowDimensions.right); int height = getLayoutDimension(getHeight(), topMargin + bottomMargin, windowDimensions.bottom); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(width, height); layoutParams.leftMargin = leftMargin; layoutParams.topMargin = topMargin; layoutParams.rightMargin = rightMargin; layoutParams.bottomMargin = bottomMargin; if ((getGravity() & Gravity.CENTER_HORIZONTAL) == Gravity.CENTER_HORIZONTAL) { layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); } if ((getGravity() & Gravity.CENTER_VERTICAL) == Gravity.CENTER_VERTICAL) { layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); } if ((getGravity() & Gravity.LEFT) == Gravity.LEFT) { layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); } if ((getGravity() & Gravity.TOP) == Gravity.TOP) { layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); } if ((getGravity() & Gravity.RIGHT) == Gravity.RIGHT) { layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); } if ((getGravity() & Gravity.BOTTOM) == Gravity.BOTTOM) { layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); } return layoutParams; }
From source file:com.csipsimple.ui.incall.CallActivity.java
@SuppressWarnings("deprecation") private void attachVideoPreview() { // Video stuff if (prefsWrapper.getPreferenceBooleanValue(SipConfigManager.USE_VIDEO)) { if (cameraPreview == null) { Log.d(TAG, "Create Local Renderer"); cameraPreview = ViERenderer.CreateLocalRenderer(this); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(256, 256); //lp.leftMargin = 2; //lp.topMargin= 4; lp.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); cameraPreview.setVisibility(View.GONE); mainFrame.addView(cameraPreview, lp); } else {/*from w w w .ja va 2 s . c o m*/ Log.d(TAG, "NO NEED TO Create Local Renderer"); } if (videoWakeLock == null) { videoWakeLock = powerManager.newWakeLock( PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "com.csipsimple.videoCall"); videoWakeLock.setReferenceCounted(false); } } if (videoWakeLock != null && videoWakeLock.isHeld()) { videoWakeLock.release(); } }
From source file:com.svpino.longhorn.fragments.StockListFragment.java
private void displayStockOverview(Integer position, boolean animate) { if (position != null) { setCurrentTile(position);/* w ww.ja va 2 s .c om*/ setStockOverviewState(StockOverviewState.OVERVIEW); } displayStockInViewFlipper(position); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, Extensions.dpToPixels(getResources(), STOCK_OVERVIEW_HEIGHT)); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); this.viewFlipper.setLayoutParams(layoutParams); if (animate) { Animation animation = AnimationUtils.loadAnimation(getActivity().getApplicationContext(), R.anim.slide_in_from_bottom); animation.setAnimationListener( new StockOverviewAnimationListener(this.animateStockOverviewContentCallback)); this.viewFlipper.setVisibility(View.VISIBLE); this.viewFlipper.startAnimation(animation); } else { this.viewFlipper.setVisibility(View.VISIBLE); } collapseSearchActionView(); invalidateOptionsMenu(); }
From source file:com.bluekai.sdk.BlueKai.java
private void addBlueKaiWebView(Context context) { try {/*from w w w .j a v a 2 s. c om*/ blueKaiView = new BlueKaiWebView(context, this); blueKaiView.setWebClient(); WebSettings webSettings = blueKaiView.getSettings(); webSettings.setJavaScriptEnabled(true); int height = 1, width = 1; if (devMode) { height = width = RelativeLayout.LayoutParams.MATCH_PARENT; } RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width, height); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); params.setMargins(10, 10, 10, 10); blueKaiView.setBackgroundColor(Color.LTGRAY); if (activity != null) { activity.addContentView(blueKaiView, params); } else { Logger.warn(TAG, "Activity is null. Cannot add webview"); } } catch (Exception ex) { Logger.error(TAG, "Error while adding BlueKai webview", ex); } }
From source file:com.wdullaer.materialdatetimepicker.time.TimePickerView.java
private void initView(Context context) { // View.inflate(getContext(), R.layout.mdtp_time_picker_view, this); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.mdtp_time_picker_view, this); KeyboardListener keyboardListener = new KeyboardListener(); findViewById(R.id.time_picker_view).setOnKeyListener(keyboardListener); // If an accent color has not been set manually, get it from the context if (mAccentColor == -1) { mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getContext()); }//from ww w. j a v a 2 s . 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(getContext(), mThemeDark); } Resources res = getResources(); // Context context = getContext(); 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_date_picker_text_disabled_dark_theme); mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day_dark_theme); mHourView = (TextView) findViewById(R.id.hours); mHourView.setOnKeyListener(keyboardListener); mHourSpaceView = (TextView) findViewById(R.id.hour_space); mMinuteSpaceView = (TextView) findViewById(R.id.minutes_space); mMinuteView = (TextView) findViewById(R.id.minutes); mMinuteView.setOnKeyListener(keyboardListener); mSecondSpaceView = (TextView) findViewById(R.id.seconds_space); mSecondView = (TextView) findViewById(R.id.seconds); mSecondView.setOnKeyListener(keyboardListener); mAmPmTextView = (TextView) findViewById(R.id.ampm_label); mAmPmTextView.setOnKeyListener(keyboardListener); String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0]; mPmText = amPmTexts[1]; mHapticFeedbackController = new HapticFeedbackController(getContext()); mInitialTime = roundToNearest(mInitialTime); mTimePicker = (RadialPickerLayout) findViewById(R.id.time_picker); mTimePicker.setOnValueSelectedListener(this); mTimePicker.setOnKeyListener(keyboardListener); mTimePicker.initialize(getContext(), this, mInitialTime, mIs24HourMode); mHapticFeedbackController.start(); 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) findViewById(R.id.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) findViewById(R.id.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. mAmPmHitspace = findViewById(R.id.ampm_hitspace); if (mIs24HourMode) { mAmPmTextView.setVisibility(View.GONE); } else { mAmPmTextView.setVisibility(View.VISIBLE); updateAmPmDisplay(mInitialTime.isAM() ? AM : PM); mAmPmHitspace.setOnClickListener(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); } }); } // Disable seconds picker if (!mEnableSeconds) { mSecondSpaceView.setVisibility(View.GONE); findViewById(R.id.separator_seconds).setVisibility(View.GONE); } // Center stuff depending on what's visible if (mIs24HourMode && !mEnableSeconds) { // center first separator RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT); TextView separatorView = (TextView) findViewById(R.id.separator); separatorView.setLayoutParams(paramsSeparator); } else if (mEnableSeconds) { // link separator to minutes final View separator = findViewById(R.id.separator); RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.LEFT_OF, R.id.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.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<>(); }*/ mTypedTimes = new ArrayList<>(); // Set the title (if any) TextView timePickerHeader = (TextView) findViewById(R.id.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. // mOkButton.setTextColor(mAccentColor); // mCancelButton.setTextColor(mAccentColor); timePickerHeader.setBackgroundColor(getResources().getColor(R.color.mdtp_white)); findViewById(R.id.time_display_background).setBackgroundColor(getResources().getColor(R.color.mdtp_white)); findViewById(R.id.time_display).setBackgroundColor(getResources().getColor(R.color.mdtp_white)); /*if(getDialog() == null) { view.findViewById(R.id.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); mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground); findViewById(R.id.time_picker_view).setBackgroundColor(mThemeDark ? darkBackgroundColor : backgroundColor); }
From source file:com.uzmap.pkg.uzmodules.UISearchBar.SearchBarActivity.java
@SuppressWarnings("deprecation") private void initData() { DisplayMetrics metric = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metric); mPref = getSharedPreferences("text", Context.MODE_PRIVATE); String text = mPref.getString("text", ""); if (!TextUtils.isEmpty(text)) { mEditText.setText(text);/* ww w. j a v a2 s . c om*/ mEditText.setSelection(text.length()); } mNavigationLayout.setBackgroundColor(config.navBgColor); if (TextUtils.isEmpty(config.searchBoxBgImg)) { BitmapDrawable bitmapDrawable = new BitmapDrawable(BitmapFactory.decodeResource(getResources(), UZResourcesIDFinder.getResDrawableID("mo_searchbar_bg"))); mRelativeLayout.setBackgroundDrawable(bitmapDrawable); } else { BitmapDrawable bitmapDrawable = new BitmapDrawable(generateBitmap(config.searchBoxBgImg)); mRelativeLayout.setBackgroundDrawable(bitmapDrawable); } if (config.cancel_bg_bitmap != null) { mTextView.setBackgroundDrawable(new BitmapDrawable(config.cancel_bg_bitmap)); } else { mTextView.setBackgroundColor(config.cancel_bg_color); } mTextView.setTextSize(config.cancel_size); mTextView.setTextColor(config.cancal_color); LayoutParams params = new LayoutParams(UZUtility.dipToPix(config.searchBoxWidth), UZUtility.dipToPix(config.searchBoxHeight)); params.setMargins(UZUtility.dipToPix(10), 0, 0, 0); params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); mEditText.setLayoutParams(params); WindowManager wm = this.getWindowManager(); int width = wm.getDefaultDisplay().getWidth(); double realWidth = width * 0.80; LayoutParams layoutParams = new LayoutParams((int) realWidth, UZUtility.dipToPix(config.searchBoxHeight)); layoutParams.setMargins(UZUtility.dipToPix(5), 0, 0, 0); layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); layoutParams.topMargin = UZUtility.dipToPix(8); layoutParams.bottomMargin = UZUtility.dipToPix(8); mRelativeLayout.setLayoutParams(layoutParams); double cancelRealWidth = width * 0.15; int space = (width - (int) realWidth - (int) cancelRealWidth - UZUtility.dipToPix(5)) / 2; LayoutParams cancalTxtParam = new LayoutParams((int) cancelRealWidth, UZUtility.dipToPix(config.searchBoxHeight)); cancalTxtParam.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); cancalTxtParam.addRule(RelativeLayout.CENTER_VERTICAL); cancalTxtParam.rightMargin = space; cancalTxtParam.leftMargin = space; mTextView.setLayoutParams(cancalTxtParam); mListView.setBackgroundColor(config.list_bg_color); listSize = config.list_size; mCleanTextColor = config.clear_font_color; mCleanTextSize = config.clear_font_size; recordCount = config.historyCount; /** * add clean list item */ int relativeLayoutCleanId = UZResourcesIDFinder.getResLayoutID("mo_searchbar_clean_item"); relativeLayoutClean = (LinearLayout) View.inflate(getApplicationContext(), relativeLayoutCleanId, null); int tv_cleanId = UZResourcesIDFinder.getResIdID("tv_clean"); mCleanTV = (TextView) relativeLayoutClean.findViewById(tv_cleanId); mCleanTV.setTextSize(mCleanTextSize); mCleanTV.setTextColor(mCleanTextColor); mCleanTV.setText(config.clearText); relativeLayoutClean .setBackgroundDrawable(addStateDrawable(config.clear_bg_color, config.clear_active_bg_color)); list.clear(); list.add(relativeLayoutClean); mPref = getSharedPreferences("history" + config.database, Context.MODE_PRIVATE); editor = mPref.edit(); trimHistroyList(config.historyCount); @SuppressWarnings("unchecked") Map<String, String> map = (Map<String, String>) mPref.getAll(); if (map != null) { if (map.size() != 0) { for (int i = 1; i <= map.size(); i++) { int listview_item = UZResourcesIDFinder.getResLayoutID("mo_searchbar_listview_item"); LinearLayout linearLayout = (LinearLayout) View.inflate(SearchBarActivity.this, listview_item, null); int tv_listId = UZResourcesIDFinder.getResIdID("tv_listview"); TextView tv = (TextView) linearLayout.findViewById(tv_listId); tv.setTextSize(listSize); tv.setTextColor(config.list_color); linearLayout.setBackgroundDrawable( addStateDrawable(config.list_bg_color, config.list_item_active_bg_color)); int itemBorderLineId = UZResourcesIDFinder.getResIdID("item_border_line"); linearLayout.findViewById(itemBorderLineId).setBackgroundColor(config.list_border_color); for (Entry<String, String> iterable_element : map.entrySet()) { String key = iterable_element.getKey(); if ((i + "").equals(key)) { tv.setText(iterable_element.getValue()); } } list.addFirst(linearLayout); } id = map.size(); } } adapter = new MyAdapter(); mListView.setAdapter(adapter); }
From source file:com.frostwire.android.gui.activities.MainActivity2.java
private void updateHeader(Fragment fragment) { try {//from w w w . j ava 2 s. co m RelativeLayout placeholder = (RelativeLayout) getActionBar().getCustomView(); if (placeholder != null && placeholder.getChildCount() > 0) { placeholder.removeAllViews(); } if (fragment instanceof MainFragment) { View header = ((MainFragment) fragment).getHeader(this); if (placeholder != null && header != null) { RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); placeholder.addView(header, params); } } } catch (Throwable e) { LOG.error("Error updating main header", e); } }
From source file:com.appsimobile.appsii.Appsi.java
public SidebarHotspot.SwipeListener openSidebar(HotspotItem conf, CircularArray<HotspotPageEntry> entries, int flags, boolean animate) { LockableAsyncQueryHandler.lock();//from ww w . jav a2 s. c om mSidebar.setSidebarOpening(true); if (!mLoaderManager.isStarted()) { mLoaderManager.doStart(); } boolean fullscreen = mHotspotHelper.getTopOffset() == 0; mSidebar.setInFullScreenMode(fullscreen); mNotificationLikeOpener.mRemoveAfterScrollEnd = false; mScrollAnimationListener = null; mSidebar.animate().cancel(); // users reported this may happen if (mSidebarVisible) { mPopupLayer.forceClose(); mSidebarVisible = false; } int sidebarWidth = getSidebarWidth(); mSidebarVisible = true; if (conf == null) { conf = getDefaultConfiguration(); } SwipeListener result = null; boolean openLikeNotificationBar = (flags & OPEN_FLAG_LIKE_NOTIFICATION_BAR) != 0; mSidebar.setTag(conf); boolean left = conf.mLeft; boolean forceLeft = (flags & OPEN_FLAG_LEFT) != 0; boolean forceRight = (flags & OPEN_FLAG_RIGHT) != 0; if (forceLeft) { left = true; } if (forceRight) { left = false; } mSidebar.setIsLeft(left); View v = mSidebar.findViewById(R.id.sidebar_content); RelativeLayout.LayoutParams sidebarLayoutParams = (RelativeLayout.LayoutParams) v.getLayoutParams(); sidebarLayoutParams.width = sidebarWidth; View container = mSidebar.findViewById(R.id.sidebar_container); RelativeLayout.LayoutParams slp = (RelativeLayout.LayoutParams) container.getLayoutParams(); if (left) { slp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0); slp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); sidebarLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0); sidebarLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); } else { slp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 0); slp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); sidebarLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 0); sidebarLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); } if (animate && !openLikeNotificationBar) { mNotificationLikeOpener.cancel(); if (left) { mSidebar.setTranslationX(-sidebarWidth); mSidebar.animate().setInterpolator(mInInterpolator).setDuration(400).setListener(null) .translationX(0); mSidebar.findViewById(R.id.sidebar_left_shadow).setVisibility(View.GONE); mSidebar.findViewById(R.id.sidebar_right_shadow).setVisibility(View.VISIBLE); } else { mSidebar.setTranslationX(sidebarWidth); mSidebar.animate().setDuration(400).setListener(null).setInterpolator(mInInterpolator) .translationX(0); mSidebar.findViewById(R.id.sidebar_left_shadow).setVisibility(View.VISIBLE); mSidebar.findViewById(R.id.sidebar_right_shadow).setVisibility(View.GONE); } updateDimColor(mSidebar, left); mPopupLayer.addPopupChild(mSidebar); mSidebar.updateAdapterData(conf.mDefaultPageId, entries); mScrollAnimationListener = null; } else if (openLikeNotificationBar) { result = mNotificationLikeOpener; if (left) { mSidebar.findViewById(R.id.sidebar_right_shadow).setVisibility(View.VISIBLE); mSidebar.findViewById(R.id.sidebar_left_shadow).setVisibility(View.GONE); } else { mSidebar.findViewById(R.id.sidebar_right_shadow).setVisibility(View.GONE); mSidebar.findViewById(R.id.sidebar_left_shadow).setVisibility(View.VISIBLE); } int w = mWindowManager.getDefaultDisplay().getWidth(); int h = mWindowManager.getDefaultDisplay().getHeight(); int sw = Math.min(w, h); mNotificationLikeOpener.setTargetView(mSidebar, sidebarWidth, sw, left); mSidebar.updateAdapterData(conf.mDefaultPageId, entries); mPopupLayer.addPopupChild(mSidebar); } else { mSidebar.setTranslationX(0); mPopupLayer.addPopupChild(mSidebar); } return result; }
From source file:net.e_fas.oss.tabijiman.MapsActivity.java
@Override public void onMapReady(GoogleMap googleMap) { e_print("onMapReady"); mMap = googleMap;// ww w. jav a2s. c om GoFukuiButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CameraPosition cameraPos = new CameraPosition.Builder().target(new LatLng(36.0642988, 136.220012)) .zoom(10.0f).bearing(0).build(); mMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPos)); GoFukuiButton.setVisibility(View.GONE); } }); CameraPosition cameraPos = new CameraPosition.Builder().target(new LatLng(36.0614444, 136.2229937)) .zoom(zoomLevel).bearing(0).build(); mMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPos)); // ?? mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { Toast.makeText(getApplicationContext(), marker.getTitle(), Toast.LENGTH_LONG).show(); return false; } }); mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { @Override public View getInfoWindow(Marker marker) { return null; } @Override public View getInfoContents(Marker marker) { View view = getLayoutInflater().inflate(R.layout.info_window, null); // TextView title = (TextView) view.findViewById(R.id.info_title); title.setText(marker.getTitle()); e_print("marker_Snippet >> " + marker.getSnippet()); if (marker.getSnippet() == null) { view.findViewById(R.id.info_address).setVisibility(View.GONE); } else { TextView address = (TextView) view.findViewById(R.id.info_address); address.setText(marker.getSnippet()); } return view; } }); mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { e_print("title_name >> " + marker.getTitle()); //DB()?? SQLiteDatabase dbRead = helper.getReadableDatabase(); //SQL String select_frame_sql = "SELECT * FROM frame WHERE `name` = ? AND `lat` = ? AND `lng` = ?"; String select_place_sql = "SELECT * FROM place WHERE `name` = ? AND `lat` = ? AND `lng` = ?"; //SQL? Cursor cursor = dbRead.rawQuery(select_place_sql, new String[] { marker.getTitle(), String.valueOf(marker.getPosition().latitude), String.valueOf(marker.getPosition().longitude) }); e_print("cursor_count >> " + cursor.getCount()); if (cursor.getCount() != 0) { cursor.moveToFirst(); e_print("lat >> " + marker.getPosition().latitude + " lng >> " + marker.getPosition().longitude); Intent MoreInfo = new Intent(getApplicationContext(), MoreInfo.class); MoreInfo.putExtra("id", cursor.getInt(cursor.getColumnIndex("_id"))); MoreInfo.putExtra("cat", "place"); cursor.close(); startActivity(MoreInfo); } else { cursor.close(); //SQL? Cursor cursor2 = dbRead.rawQuery(select_frame_sql, new String[] { marker.getTitle(), String.valueOf(marker.getPosition().latitude), String.valueOf(marker.getPosition().longitude) }); cursor2.moveToFirst(); /* * distance[0] = [??] * distance[1] = [???] * distance[2] = [???] */ float[] distance = getDistance(nowLocation.latitude, nowLocation.longitude, marker.getPosition().latitude, marker.getPosition().longitude); Intent MoreInfo = new Intent(getApplicationContext(), MoreInfo.class); MoreInfo.putExtra("dist", distance[0]); MoreInfo.putExtra("id", cursor2.getInt(cursor2.getColumnIndex("_id"))); MoreInfo.putExtra("cat", "frame"); cursor2.close(); startActivity(MoreInfo); } } }); mMap.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener() { @Override public boolean onMyLocationButtonClick() { Location location = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); e_print("MyLocation >> " + location); Toast.makeText(getApplicationContext(), "location >> " + location, Toast.LENGTH_SHORT).show(); return false; } }); mMap.setMyLocationEnabled(true); // MyLocationButton? UiSettings settings = mMap.getUiSettings(); settings.setMyLocationButtonEnabled(true); //?? View locationButton = ((View) super.findViewById(Integer.parseInt("1")).getParent()) .findViewById(Integer.parseInt("2")); RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) locationButton.getLayoutParams(); rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); rlp.setMargins(0, 0, 180, 180); print("mMap >> insert"); for (String provider : providers) { e_print("enable_providers >> " + provider); mLocationManager.requestLocationUpdates(provider, 3000, 0, this); } if (mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { e_print("Provider_enable >> NETWORK"); mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000, 0, this); } else if (mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { e_print("Providers_enable >> GPS"); mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 0, this); } else { e_print("All_Providers_Disable"); } }