List of usage examples for android.view ViewGroup findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:mp.teardrop.LibraryPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { final int type = mTabOrder[position]; ViewGroup containingLayout = mContainingLayouts[type]; if (containingLayout == null) { LibraryActivity activity = mActivity; LayoutInflater inflater = activity.getLayoutInflater(); LibraryAdapter adapter;//from w w w . ja va2 s .c o m containingLayout = (RelativeLayout) inflater.inflate(R.layout.listview, null); switch (type) { case MediaUtils.TYPE_FILE: adapter = mFilesAdapter = new FileSystemAdapter(activity, null); break; case MediaUtils.TYPE_UNIFIED: adapter = mUnifiedAdapter = new UnifiedAdapter(activity, null); break; case MediaUtils.TYPE_DROPBOX: adapter = mDropboxAdapter = new DropboxAdapter(activity, null); //if linked with Dropbox, query the root //TODO: maybe use a field in activity or somewhere to save linked state instead of checking prefs here SharedPreferences prefs = activity.getSharedPreferences(LibraryActivity.ACCOUNT_PREFS_NAME, 0); String key = prefs.getString(LibraryActivity.ACCESS_KEY_NAME, null); String secret = prefs.getString(LibraryActivity.ACCESS_SECRET_NAME, null); /* if we're linked with Dropbox, show the loading message and retrieve the root folder's contents */ if (!(key == null || secret == null || key.length() == 0 || secret.length() == 0)) { View screen = containingLayout.findViewById(R.id.list_view_loading_screen); screen.setOnClickListener(new View.OnClickListener() { //will stick for the entire session @Override public void onClick(View v) { } }); screen.setVisibility(View.VISIBLE); activity.requeryDropbox(null); } break; default: throw new IllegalArgumentException("Invalid media type: " + type); } mLimiterScroller = (HorizontalScrollView) containingLayout.findViewById(R.id.new_limiter_scroller); ListView view = (ListView) containingLayout.findViewById(R.id.actual_list_view); view.setOnCreateContextMenuListener(this); view.setOnItemClickListener(this); view.setTag(type); view.setAdapter(adapter); adapter.setFilter(mFilter); mAdapters[type] = adapter; mContainingLayouts[type] = containingLayout; mRequeryNeeded[type] = true; } requeryIfNeeded(type); container.addView(containingLayout); return containingLayout; }
From source file:com.androzic.MapActivity.java
private final void updateMapButtons() { ViewGroup container = (ViewGroup) findViewById(R.id.button_container); for (String action : panelActions) { int id = getResources().getIdentifier(action, "id", getPackageName()); ImageButton aib = (ImageButton) container.findViewById(id); if (aib != null) { if (activeActions.contains(action)) { aib.setVisibility(View.VISIBLE); switch (id) { case R.id.follow: aib.setImageDrawable(getResources() .getDrawable(map.isFollowing() ? R.drawable.cursor_drag_arrow : R.drawable.target)); break; case R.id.locate: boolean isLocating = locationService != null && locationService.isLocating(); aib.setImageDrawable(getResources() .getDrawable(isLocating ? R.drawable.pin_map_no : R.drawable.pin_map)); break; case R.id.tracking: boolean isTracking = locationService != null && locationService.isTracking(); aib.setImageDrawable(getResources() .getDrawable(isTracking ? R.drawable.doc_delete : R.drawable.doc_edit)); break; }//from www . j a va 2 s. c o m } else { aib.setVisibility(View.GONE); } } } }
From source file:android.support.transition.Visibility.java
/** * The default implementation of this method does nothing. Subclasses * should override if they need to create an Animator when targets disappear. * The method should only be called by the Visibility class; it is * not intended to be called from external classes. * * @param sceneRoot The root of the transition hierarchy * @param startValues The target values in the start scene * @param startVisibility The target visibility in the start scene * @param endValues The target values in the end scene * @param endVisibility The target visibility in the end scene * @return An Animator to be started at the appropriate time in the * overall transition for this scene change. A null value means no animation * should be run./*from w ww . j a v a2s . c o m*/ */ @SuppressWarnings("UnusedParameters") public Animator onDisappear(ViewGroup sceneRoot, TransitionValues startValues, int startVisibility, TransitionValues endValues, int endVisibility) { if ((mMode & MODE_OUT) != MODE_OUT) { return null; } View startView = (startValues != null) ? startValues.view : null; View endView = (endValues != null) ? endValues.view : null; View overlayView = null; View viewToKeep = null; if (endView == null || endView.getParent() == null) { if (endView != null) { // endView was removed from its parent - add it to the overlay overlayView = endView; } else if (startView != null) { // endView does not exist. Use startView only under certain // conditions, because placing a view in an overlay necessitates // it being removed from its current parent if (startView.getParent() == null) { // no parent - safe to use overlayView = startView; } else if (startView.getParent() instanceof View) { View startParent = (View) startView.getParent(); TransitionValues startParentValues = getTransitionValues(startParent, true); TransitionValues endParentValues = getMatchedTransitionValues(startParent, true); VisibilityInfo parentVisibilityInfo = getVisibilityChangeInfo(startParentValues, endParentValues); if (!parentVisibilityInfo.mVisibilityChange) { overlayView = TransitionUtils.copyViewImage(sceneRoot, startView, startParent); } else if (startParent.getParent() == null) { int id = startParent.getId(); if (id != View.NO_ID && sceneRoot.findViewById(id) != null && mCanRemoveViews) { // no parent, but its parent is unparented but the parent // hierarchy has been replaced by a new hierarchy with the same id // and it is safe to un-parent startView overlayView = startView; } } } } } else { // visibility change if (endVisibility == View.INVISIBLE) { viewToKeep = endView; } else { // Becoming GONE if (startView == endView) { viewToKeep = endView; } else { overlayView = startView; } } } final int finalVisibility = endVisibility; if (overlayView != null && startValues != null) { // TODO: Need to do this for general case of adding to overlay int[] screenLoc = (int[]) startValues.values.get(PROPNAME_SCREEN_LOCATION); int screenX = screenLoc[0]; int screenY = screenLoc[1]; int[] loc = new int[2]; sceneRoot.getLocationOnScreen(loc); overlayView.offsetLeftAndRight((screenX - loc[0]) - overlayView.getLeft()); overlayView.offsetTopAndBottom((screenY - loc[1]) - overlayView.getTop()); final ViewGroupOverlayImpl overlay = ViewGroupUtils.getOverlay(sceneRoot); overlay.add(overlayView); Animator animator = onDisappear(sceneRoot, overlayView, startValues, endValues); if (animator == null) { overlay.remove(overlayView); } else { final View finalOverlayView = overlayView; animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { overlay.remove(finalOverlayView); } }); } return animator; } if (viewToKeep != null) { int originalVisibility = viewToKeep.getVisibility(); ViewUtils.setTransitionVisibility(viewToKeep, View.VISIBLE); Animator animator = onDisappear(sceneRoot, viewToKeep, startValues, endValues); if (animator != null) { DisappearListener disappearListener = new DisappearListener(viewToKeep, finalVisibility, true); animator.addListener(disappearListener); AnimatorUtils.addPauseListener(animator, disappearListener); addListener(disappearListener); } else { ViewUtils.setTransitionVisibility(viewToKeep, originalVisibility); } return animator; } return null; }
From source file:com.dmsl.anyplace.UnifiedNavigationActivity.java
private void handlePoisOnMap(Collection<PoisModel> collection) { visiblePois.clearAll();//from w w w . j av a2 s.c o m String currentFloor = userData.getSelectedFloorNumber(); // Display part of Description Text Only // Make an approximation of available space based on map size final int fragmentWidth = (int) (findViewById(R.id.map).getWidth() * 2); ViewGroup infoWindow = (ViewGroup) getLayoutInflater().inflate(R.layout.info_window, null); TextView infoSnippet = (TextView) infoWindow.findViewById(R.id.snippet); TextPaint paint = infoSnippet.getPaint(); for (PoisModel pm : collection) { if (pm.floor_number.equalsIgnoreCase(currentFloor)) { String snippet = AndroidUtils.fillTextBox(paint, fragmentWidth, pm.description); Marker m = mMap.addMarker(new MarkerOptions() .position(new LatLng(Double.parseDouble(pm.lat), Double.parseDouble(pm.lng))).title(pm.name) .snippet(snippet).icon(BitmapDescriptorFactory.fromResource(R.drawable.pin8))); visiblePois.addMarkerAndPoi(m, pm); } } }
From source file:com.android.tv.settings.dialog.old.BaseDialogFragment.java
public void performEntryTransition(final Activity activity, final ViewGroup contentView, int iconResourceId, Uri iconResourceUri, final ImageView icon, final TextView title, final TextView description, final TextView breadcrumb) { // Pull out the root layout of the dialog and set the background drawable, to be // faded in during the transition. final ViewGroup twoPane = (ViewGroup) contentView.getChildAt(0); twoPane.setVisibility(View.INVISIBLE); // If the appropriate data is embedded in the intent and there is an icon specified // in the content fragment, we animate the icon from its initial position to the final // position. Otherwise, we perform a simpler transition in which the ActionFragment // slides in and the ContentFragment text fields slide in. mIntroAnimationInProgress = true;/*from w w w. j av a 2 s .c o m*/ List<TransitionImage> images = TransitionImage.readMultipleFromIntent(activity, activity.getIntent()); TransitionImageAnimation ltransitionAnimation = null; final Uri iconUri; final int color; if (images != null && images.size() > 0) { if (iconResourceId != 0) { iconUri = Uri.parse(UriUtils.getAndroidResourceUri(activity, iconResourceId)); } else if (iconResourceUri != null) { iconUri = iconResourceUri; } else { iconUri = null; } TransitionImage src = images.get(0); color = src.getBackground(); if (iconUri != null) { ltransitionAnimation = new TransitionImageAnimation(contentView); ltransitionAnimation.addTransitionSource(src); ltransitionAnimation.transitionDurationMs(ANIMATE_IN_DURATION).transitionStartDelayMs(0) .interpolator(new DecelerateInterpolator(1f)); } } else { iconUri = null; color = 0; } final TransitionImageAnimation transitionAnimation = ltransitionAnimation; // Fade out the old activity, and hard cut the new activity. activity.overridePendingTransition(R.anim.hard_cut_in, R.anim.fade_out); int bgColor = mFragment.getResources().getColor(R.color.dialog_activity_background); mBgDrawable.setColor(bgColor); mBgDrawable.setAlpha(0); twoPane.setBackground(mBgDrawable); // If we're animating the icon, we create a new ImageView in which to place the embedded // bitmap. We place it in the root layout to match its location in the previous activity. mShadowLayer = (FrameLayoutWithShadows) twoPane.findViewById(R.id.shadow_layout); if (transitionAnimation != null) { transitionAnimation.listener(new TransitionImageAnimation.Listener() { @Override public void onRemovedView(TransitionImage src, TransitionImage dst) { if (icon != null) { //want to make sure that users still see at least the source image // if the dst image is too large to finish downloading before the // animation is done. Check if the icon is not visible. This mean // BaseContentFragement have not finish downloading the image yet. if (icon.getVisibility() != View.VISIBLE) { icon.setImageDrawable(src.getBitmap()); int intrinsicWidth = icon.getDrawable().getIntrinsicWidth(); LayoutParams lp = icon.getLayoutParams(); lp.height = lp.width * icon.getDrawable().getIntrinsicHeight() / intrinsicWidth; icon.setVisibility(View.VISIBLE); } icon.setAlpha(1f); } if (mShadowLayer != null) { mShadowLayer.setShadowsAlpha(1f); } onIntroAnimationFinished(); } }); icon.setAlpha(0f); if (mShadowLayer != null) { mShadowLayer.setShadowsAlpha(0f); } } // We need to defer the remainder of the animation preparation until the first // layout has occurred, as we don't yet know the final location of the icon. twoPane.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { twoPane.getViewTreeObserver().removeOnGlobalLayoutListener(this); // if we buildLayer() at this time, the texture is actually not created // delay a little so we can make sure all hardware layer is created before // animation, in that way we can avoid the jittering of start animation twoPane.postOnAnimationDelayed(mEntryAnimationRunnable, ANIMATE_DELAY); } final Runnable mEntryAnimationRunnable = new Runnable() { @Override public void run() { if (!mFragment.isAdded()) { // We have been detached before this could run, so just bail return; } twoPane.setVisibility(View.VISIBLE); final int secondaryDelay = SLIDE_IN_DISTANCE; // Fade in the activity background protection ObjectAnimator oa = ObjectAnimator.ofInt(mBgDrawable, "alpha", 255); oa.setDuration(ANIMATE_IN_DURATION); oa.setStartDelay(secondaryDelay); oa.setInterpolator(new DecelerateInterpolator(1.0f)); oa.start(); View actionFragmentView = activity.findViewById(mActionAreaId); boolean isRtl = ViewCompat.getLayoutDirection(contentView) == ViewCompat.LAYOUT_DIRECTION_RTL; int startDist = isRtl ? SLIDE_IN_DISTANCE : -SLIDE_IN_DISTANCE; int endDist = isRtl ? -actionFragmentView.getMeasuredWidth() : actionFragmentView.getMeasuredWidth(); // Fade in and slide in the ContentFragment TextViews from the start. prepareAndAnimateView(title, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), false); prepareAndAnimateView(breadcrumb, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), false); prepareAndAnimateView(description, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), false); // Fade in and slide in the ActionFragment from the end. prepareAndAnimateView(actionFragmentView, 0, endDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), false); if (icon != null && transitionAnimation != null) { // now we get the icon view in place, update the transition target TransitionImage target = new TransitionImage(); target.setUri(iconUri); target.createFromImageView(icon); if (icon.getBackground() instanceof ColorDrawable) { ColorDrawable d = (ColorDrawable) icon.getBackground(); target.setBackground(d.getColor()); } transitionAnimation.addTransitionTarget(target); transitionAnimation.startTransition(); } else if (icon != null) { prepareAndAnimateView(icon, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), true /* is the icon */); if (mShadowLayer != null) { mShadowLayer.setShadowsAlpha(0f); } } } }; }); }
From source file:android.transitions.everywhere.Transition.java
/** * Recursive method that captures values for the given view and the * hierarchy underneath it.// www . j a v a 2 s .c o m * @param sceneRoot The root of the view hierarchy being captured * @param start true if this capture is happening before the scene change, * false otherwise */ void captureValues(ViewGroup sceneRoot, boolean start) { clearValues(start); if ((mTargetIds.size() > 0 || mTargets.size() > 0) && (mTargetNames == null || mTargetNames.isEmpty()) && (mTargetTypes == null || mTargetTypes.isEmpty())) { for (int i = 0; i < mTargetIds.size(); ++i) { int id = mTargetIds.get(i); View view = sceneRoot.findViewById(id); if (view != null) { TransitionValues values = new TransitionValues(); values.view = view; if (start) { captureStartValues(values); } else { captureEndValues(values); } values.targetedTransitions.add(this); capturePropagationValues(values); if (start) { addViewValues(mStartValues, view, values); } else { addViewValues(mEndValues, view, values); } } } for (int i = 0; i < mTargets.size(); ++i) { View view = mTargets.get(i); TransitionValues values = new TransitionValues(); values.view = view; if (start) { captureStartValues(values); } else { captureEndValues(values); } values.targetedTransitions.add(this); capturePropagationValues(values); if (start) { addViewValues(mStartValues, view, values); } else { addViewValues(mEndValues, view, values); } } } else { captureHierarchy(sceneRoot, start); } if (!start && mNameOverrides != null) { int numOverrides = mNameOverrides.size(); ArrayList<View> overriddenViews = new ArrayList<View>(numOverrides); for (int i = 0; i < numOverrides; i++) { String fromName = mNameOverrides.keyAt(i); overriddenViews.add(mStartValues.nameValues.remove(fromName)); } for (int i = 0; i < numOverrides; i++) { View view = overriddenViews.get(i); if (view != null) { String toName = mNameOverrides.valueAt(i); mStartValues.nameValues.put(toName, view); } } } }
From source file:cc.flydev.launcher.Page.java
protected void onAttachedToWindow() { super.onAttachedToWindow(); // Hook up the page indicator ViewGroup parent = (ViewGroup) getParent(); if (mPageIndicator == null && mPageIndicatorViewId > -1) { mPageIndicator = (PageIndicator) parent.findViewById(mPageIndicatorViewId); mPageIndicator.removeAllMarkers(mAllowPagedViewAnimations); ArrayList<PageIndicator.PageMarkerResources> markers = new ArrayList<PageIndicator.PageMarkerResources>(); for (int i = 0; i < getChildCount(); ++i) { markers.add(getPageIndicatorMarker(i)); }/*from w w w. j a v a 2 s. c o m*/ mPageIndicator.addMarkers(markers, mAllowPagedViewAnimations); OnClickListener listener = getPageIndicatorClickListener(); if (listener != null) { mPageIndicator.setOnClickListener(listener); } mPageIndicator.setContentDescription(getPageIndicatorDescription()); } }
From source file:com.dmsl.anyplace.UnifiedNavigationActivity.java
/** * Sets up the map if it is possible to do so (i.e., the Google Play services APK is correctly installed) and the map has not already been instantiated.. This will ensure that we only ever call * {@link #setUpMap()} once when {@link #mMap} is not null. * <p>// w w w . j a v a2 s. c o m * If it isn't installed {@link SupportMapFragment} (and {@link com.google.android.gms.maps.MapView MapView}) will show a prompt for the user to install/update the Google Play services APK on * their device. * <p> * A user can return to this FragmentActivity after following the prompt and correctly installing/updating/enabling the Google Play services. Since the FragmentActivity may not have been * completely destroyed during this process (it is likely that it would only be stopped or paused), {@link #onCreate(Bundle)} may not be called again so we should call this method in * {@link #onResume()} to guarantee that it will be called. */ private void setUpMapIfNeeded() { // Do a null check to confirm that we have not already instantiated the // map. if (mMap != null) { return; } // Try to obtain the map from the SupportMapFragment. mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); mClusterManager = new ClusterManager<BuildingModel>(this, mMap); // Check if we were successful in obtaining the map. if (mMap != null) { // http://stackoverflow.com/questions/14123243/google-maps-android-api-v2-interactive-infowindow-like-in-original-android-go final MapWrapperLayout mapWrapperLayout = (MapWrapperLayout) findViewById(R.id.map_relative_layout); // MapWrapperLayout initialization // 39 - default marker height // 20 - offset between the default InfoWindow bottom edge and // it's content bottom edge mapWrapperLayout.init(mMap, getPixelsFromDp(this, 39 + 20)); final ViewGroup infoWindow; final TextView infoTitle; final TextView infoSnippet; final Button infoButton1; final OnInfoWindowElemTouchListener infoButtonListener1; Button infoButton2; final OnInfoWindowElemTouchListener infoButtonListener2; // We want to reuse the info window for all the markers, // so let's create only one class member instance infoWindow = (ViewGroup) getLayoutInflater().inflate(R.layout.info_window, null); infoTitle = (TextView) infoWindow.findViewById(R.id.title); infoSnippet = (TextView) infoWindow.findViewById(R.id.snippet); infoButton1 = (Button) infoWindow.findViewById(R.id.button1); infoButton2 = (Button) infoWindow.findViewById(R.id.button2); // Setting custom OnTouchListener which deals with the pressed // state // so it shows up infoButtonListener1 = new OnInfoWindowElemTouchListener(infoButton1, getResources().getDrawable(R.drawable.button_unsel), getResources().getDrawable(R.drawable.button_sel)) { @Override protected void onClickConfirmed(View v, Marker marker) { PoisModel poi = visiblePois.getPoisModelFromMarker(marker); if (poi != null) { // start the navigation using the clicked marker as // destination startNavigationTask(poi.puid); } } }; infoButton1.setOnTouchListener(infoButtonListener1); // Setting custom OnTouchListener which deals with the pressed // state // so it shows up infoButtonListener2 = new OnInfoWindowElemTouchListener(infoButton2, getResources().getDrawable(R.drawable.button_unsel), getResources().getDrawable(R.drawable.button_sel)) { @Override protected void onClickConfirmed(View v, Marker marker) { PoisModel poi = visiblePois.getPoisModelFromMarker(marker); if (poi != null) { if (poi.description.equals("") || poi.description.equals("-")) { // start the navigation using the clicked marker // as destination popup_msg("No description available.", poi.name); } else { popup_msg(poi.description, poi.name); } } } }; infoButton2.setOnTouchListener(infoButtonListener2); mMap.setInfoWindowAdapter(new InfoWindowAdapter() { @Override public View getInfoWindow(Marker marker) { return null; } @Override public View getInfoContents(Marker marker) { // Setting up the infoWindow with current's marker info infoTitle.setText(marker.getTitle()); infoSnippet.setText(marker.getSnippet()); infoButtonListener1.setMarker(marker); infoButtonListener2.setMarker(marker); // We must call this to set the current marker and // infoWindow references // to the MapWrapperLayout mapWrapperLayout.setMarkerWithInfoWindow(marker, infoWindow); return infoWindow; } }); setUpMap(); } }
From source file:jp.co.rediscovery.firstflight.BaseAutoPilotFragment.java
@Override protected View internalCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState, final int layout_id) { Bundle args = savedInstanceState;//w ww.j a va 2 s .c o m if (args == null) { args = getArguments(); } mPrefName = args.getString(KEY_PREF_NAME_AUTOPILOT, mPrefName); mMode = args.getInt(KEY_AUTOPILOT_MODE, mMode); mPref = getActivity().getSharedPreferences(mPrefName, 0); // ??? mCameraAutoWhiteBlance = getInt(mPref, KEY_CAMERA_WHITE_BLANCE, DEFAULT_CAMERA_WHITE_BLANCE); mCameraExposure = mPref.getFloat(KEY_CAMERA_EXPOSURE, DEFAULT_CAMERA_EXPOSURE); mCameraSaturation = mPref.getFloat(KEY_CAMERA_SATURATION, DEFAULT_CAMERA_SATURATION); mCameraPan = getInt(mPref, KEY_CAMERA_PAN, DEFAULT_CAMERA_PAN); mCameraTilt = getInt(mPref, KEY_CAMERA_TILT, DEFAULT_CAMERA_TILT); // mExposure = mPref.getFloat(KEY_EXPOSURE, DEFAULT_EXPOSURE); mSaturation = mPref.getFloat(KEY_SATURATION, DEFAULT_SATURATION); mBrightness = mPref.getFloat(KEY_BRIGHTNESS, DEFAULT_BRIGHTNESS); mBinarizeThreshold = mPref.getFloat(KEY_BINARIZE_THRESHOLD, DEFAULT_BINARIZE_THRESHOLD); // mExtractH = mPref.getFloat(KEY_EXTRACT_H, DEFAULT_EXTRACT_H); mExtractRangeH = mPref.getFloat(KEY_EXTRACT_RANGE_H, DEFAULT_EXTRACT_RANGE_H); mExtractS = mPref.getFloat(KEY_EXTRACT_S, DEFAULT_EXTRACT_S); mExtractRangeS = mPref.getFloat(KEY_EXTRACT_RANGE_S, DEFAULT_EXTRACT_RANGE_S); mExtractV = mPref.getFloat(KEY_EXTRACT_V, DEFAULT_EXTRACT_V); mExtractRangeV = mPref.getFloat(KEY_EXTRACT_RANGE_V, DEFAULT_EXTRACT_RANGE_V); // mEnableGLESExtraction = mPref.getBoolean(KEY_ENABLE_EXTRACTION, DEFAULT_ENABLE_EXTRACTION); // mAreaLimitMin = mPref.getFloat(KEY_AREA_LIMIT_MIN, DEFAULT_AREA_LIMIT_MIN); mAspectLimitMin = mPref.getFloat(KEY_ASPECT_LIMIT_MIN, DEFAULT_ASPECT_LIMIT_MIN); mAreaErrLimit1 = mPref.getFloat(KEY_AREA_ERR_LIMIT1, DEFAULT_AREA_ERR_LIMIT1); mAreaErrLimit2 = mPref.getFloat(KEY_AREA_ERR_LIMIT2, DEFAULT_AREA_ERR_LIMIT2); // mTraceAttitudeYaw = mPref.getFloat(KEY_TRACE_ATTITUDE_YAW, DEFAULT_TRACE_ATTITUDE_YAW); mTraceSpeed = mPref.getFloat(KEY_TRACE_SPEED, DEFAULT_TRACE_SPEED); mTraceAltitudeEnabled = mPref.getBoolean(KEY_TRACE_ALTITUDE_ENABLED, DEFAULT_TRACE_ALTITUDE_ENABLED); mTraceAltitude = Math.min(mPref.getFloat(KEY_TRACE_ALTITUDE, DEFAULT_TRACE_ALTITUDE), mFlightController.getMaxAltitude().current()); mTraceDirectionalReverseBias = mPref.getFloat(KEY_TRACE_DIR_REVERSE_BIAS, DEFAULT_TRACE_DIR_REVERSE_BIAS); mTraceMovingAveTap = mPref.getInt(KEY_TRACE_MOVING_AVE_TAP, DEFAULT_TRACE_MOVING_AVE_TAP); mTraceDecayRate = mPref.getFloat(KEY_TRACE_DECAY_RATE, DEFAULT_TRACE_DECAY_RATE); mTraceSensitivity = mPref.getFloat(KEY_TRACE_SENSITIVITY, DEFAULT_TRACE_SENSITIVITY); // View??? mActionViews.clear(); final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_pilot_auto, container, false); final ViewGroup controllerFrame = (ViewGroup) rootView.findViewById(R.id.controller_frame); controllerFrame.setOnClickListener(mOnClickListener); // ? mTopPanel = rootView.findViewById(R.id.top_panel); mTopPanel.setOnClickListener(mOnClickListener); mTopPanel.setOnLongClickListener(mOnLongClickListener); mActionViews.add(mTopPanel); // mFlatTrimBtn = (ImageButton) rootView.findViewById(R.id.flat_trim_btn); mFlatTrimBtn.setOnClickListener(mOnClickListener); mFlatTrimBtn.setOnLongClickListener(mOnLongClickListener); mActionViews.add(mFlatTrimBtn); // mConfigShowBtn = (ImageButton) rootView.findViewById(R.id.config_show_btn); mConfigShowBtn.setOnClickListener(mOnClickListener); // mBatteryLabel = (TextView) rootView.findViewById(R.id.batteryLabel); mAlertMessage = (TextView) rootView.findViewById(R.id.alert_message); mAlertMessage.setVisibility(View.INVISIBLE); // ? // ?? // mBottomPanel = rootView.findViewById(R.id.bottom_panel); mEmergencyBtn = (ImageButton) rootView.findViewById(R.id.emergency_btn); mEmergencyBtn.setOnClickListener(mOnClickListener); // ? mTakeOnOffBtn = (ImageButton) rootView.findViewById(R.id.take_onoff_btn); mTakeOnOffBtn.setOnClickListener(mOnClickListener); mTakeOnOffBtn.setOnLongClickListener(mOnLongClickListener); mActionViews.add(mTakeOnOffBtn); // ?? mRightSidePanel = rootView.findViewById(R.id.right_side_panel); mActionViews.add(mRightSidePanel); // mCopilotBtn = (ImageButton) rootView.findViewById(R.id.copilot_btn); mCopilotBtn.setOnClickListener(mOnClickListener); mCopilotBtn.setVisibility(mController instanceof ISkyController ? View.VISIBLE : View.GONE); // ? mStillCaptureBtn = (ImageButton) rootView.findViewById(R.id.still_capture_btn); mStillCaptureBtn.setOnClickListener(mOnClickListener); // mVideoRecordingBtn = (ImageButton) rootView.findViewById(R.id.video_capture_btn); mVideoRecordingBtn.setOnClickListener(mOnClickListener); // mTraceButton = (ImageButton) rootView.findViewById(R.id.trace_btn); mTraceButton.setOnClickListener(mOnClickListener); mTraceButton.setOnLongClickListener(mOnLongClickListener); if (mController instanceof ICameraController) { ((ICameraController) mController).setCameraControllerListener(null); ((ICameraController) mController).sendCameraOrientation(0, 0); } mVideoView = (VideoView) rootView.findViewById(R.id.drone_view); mVideoView.setOnClickListener(mOnClickListener); mDetectView = (SurfaceView) rootView.findViewById(R.id.detect_view); mDetectView.setVisibility(View.VISIBLE); //-------------------------------------------------------------------------------- final ConfigPagerAdapter adapter = new ConfigPagerAdapter(inflater); final ViewPager pager = (ViewPager) rootView.findViewById(R.id.pager); pager.setAdapter(adapter); // mTraceTv1 = (TextView) rootView.findViewById(R.id.trace1_tv); mTraceTv2 = (TextView) rootView.findViewById(R.id.trace2_tv); mTraceTv3 = (TextView) rootView.findViewById(R.id.trace3_tv); // mCpuLoadTv = (TextView) rootView.findViewById(R.id.cpu_load_textview); // mFpsSrcTv = (TextView) rootView.findViewById(R.id.fps_src_textview); mFpsSrcTv.setText(null); mFpsResultTv = (TextView) rootView.findViewById(R.id.fps_result_textview); mFpsResultTv.setText(null); return rootView; }
From source file:com.cairoconfessions.MainActivity.java
public void addItem(View view) { // Instantiate a new "row" view. final ViewGroup mFilter = (ViewGroup) findViewById(R.id.filter_cat); final ViewGroup mFilterLoc = (ViewGroup) findViewById(R.id.filter_loc); final ViewGroup mFilterMain = (ViewGroup) findViewById(R.id.filter_main); final ViewGroup newView = (ViewGroup) LayoutInflater.from(this).inflate(R.layout.list_item_example, null); final ViewGroup newViewLoc = (ViewGroup) LayoutInflater.from(this).inflate(R.layout.list_item_example, null);/*from w ww. j av a 2 s . com*/ final ViewGroup newViewMain = (ViewGroup) LayoutInflater.from(this).inflate(R.layout.list_item_example, null); ArrayList<View> presentView = new ArrayList<View>(); mFilter.findViewsWithText(presentView, ((TextView) view).getText(), 1); if (presentView.size() == 0) { final String filterName = ((TextView) view).getText().toString(); switch (((LinearLayout) view.getParent()).getId()) { case R.id.cat_filter_list: Categories.add(filterName); break; case R.id.locations: Cities.add(filterName); break; } if (filterName.equals("Love")) { newView.getChildAt(0).setBackgroundResource(R.color.love); newViewLoc.getChildAt(0).setBackgroundResource(R.color.love); newViewMain.getChildAt(0).setBackgroundResource(R.color.love); } if (filterName.equals("Pain")) { newView.getChildAt(0).setBackgroundResource(R.color.pain); newViewLoc.getChildAt(0).setBackgroundResource(R.color.pain); newViewMain.getChildAt(0).setBackgroundResource(R.color.pain); } if (filterName.equals("Guilt")) { newView.getChildAt(0).setBackgroundResource(R.color.guilt); newViewLoc.getChildAt(0).setBackgroundResource(R.color.guilt); newViewMain.getChildAt(0).setBackgroundResource(R.color.guilt); } if (filterName.equals("Fantasy")) { newView.getChildAt(0).setBackgroundResource(R.color.fantasy); newViewLoc.getChildAt(0).setBackgroundResource(R.color.fantasy); newViewMain.getChildAt(0).setBackgroundResource(R.color.fantasy); } if (filterName.equals("Dream")) { newView.getChildAt(0).setBackgroundResource(R.color.dream); newViewLoc.getChildAt(0).setBackgroundResource(R.color.dream); newViewMain.getChildAt(0).setBackgroundResource(R.color.dream); } ((TextView) newView.findViewById(android.R.id.text1)).setText(filterName); ((TextView) newViewLoc.findViewById(android.R.id.text1)).setText(filterName); ((TextView) newViewMain.findViewById(android.R.id.text1)).setText(filterName); // Set a click listener for the "X" button in the row that will // remove the row. newView.findViewById(R.id.delete_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mFilter.removeView(newView); mFilterLoc.removeView(newViewLoc); mFilterMain.removeView(newViewMain); if (mFilter.getChildCount() == 0) { findViewById(R.id.content_loc).setVisibility(View.GONE); findViewById(R.id.content_cat).setVisibility(View.GONE); findViewById(R.id.content_main).setVisibility(View.GONE); } if (Categories.contains(filterName)) while (Categories.remove(filterName)) ; if (Cities.contains(filterName)) while (Cities.remove(filterName)) ; updateFilters(); } }); newViewLoc.findViewById(R.id.delete_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mFilterLoc.removeView(newViewLoc); mFilter.removeView(newView); mFilterMain.removeView(newViewMain); if (mFilterLoc.getChildCount() == 0) { findViewById(R.id.content_loc).setVisibility(View.GONE); findViewById(R.id.content_cat).setVisibility(View.GONE); findViewById(R.id.content_main).setVisibility(View.GONE); } if (Categories.contains(filterName)) while (Categories.remove(filterName)) ; if (Cities.contains(filterName)) while (Cities.remove(filterName)) ; updateFilters(); } }); newViewMain.findViewById(R.id.delete_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mFilterLoc.removeView(newViewLoc); mFilter.removeView(newView); mFilterMain.removeView(newViewMain); if (mFilterMain.getChildCount() == 0) { findViewById(R.id.content_loc).setVisibility(View.GONE); findViewById(R.id.content_cat).setVisibility(View.GONE); findViewById(R.id.content_main).setVisibility(View.GONE); } if (Categories.contains(filterName)) while (Categories.remove(filterName)) ; if (Cities.contains(filterName)) while (Cities.remove(filterName)) ; updateFilters(); } }); // Because mFilter has android:animateLayoutChanges set to true, // adding this view is automatically animated. // mFilterCat.addView(newViewCat); mFilter.addView(newView, 0); mFilterLoc.addView(newViewLoc, 0); mFilterMain.addView(newViewMain, 0); findViewById(R.id.content_loc).setVisibility(View.VISIBLE); findViewById(R.id.content_cat).setVisibility(View.VISIBLE); findViewById(R.id.content_main).setVisibility(View.VISIBLE); updateFilters(); Toast.makeText(this, filterName + " filter added!", Toast.LENGTH_LONG).show(); } else Toast.makeText(this, "Already added!", Toast.LENGTH_LONG).show(); }