List of usage examples for android.view ViewGroup findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:com.heneryh.aquanotes.ui.CtlrStatusFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { /**/*from w w w . java2 s .co m*/ * The ctlr_status fragment is a left/right scroll button a title and a workspace below it for content */ ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_ctlr_status, null); mLeftIndicator = root.findViewById(R.id.indicator_left); mWorkspaceTitleView = (TextView) root.findViewById(R.id.controller_title); mRightIndicator = root.findViewById(R.id.indicator_right); mWorkspace = (Workspace) root.findViewById(R.id.workspace); // Need at least one for the process to continue setupCtlr(new Ctlr(), -1, "Empty1"); // setupCtlr(new Ctlr(), -2,"Empty2"); /** * Add click listeners for the scroll buttons. */ mLeftIndicator.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View view, MotionEvent motionEvent) { if ((motionEvent.getAction() & MotionEventUtils.ACTION_MASK) == MotionEvent.ACTION_DOWN) { mWorkspace.scrollLeft(); return true; } return false; } }); mLeftIndicator.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { mWorkspace.scrollLeft(); } }); mRightIndicator.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View view, MotionEvent motionEvent) { if ((motionEvent.getAction() & MotionEventUtils.ACTION_MASK) == MotionEvent.ACTION_DOWN) { mWorkspace.scrollRight(); return true; } return false; } }); mRightIndicator.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { mWorkspace.scrollRight(); } }); setHasOptionsMenu(true); /** * Set the scroll listener for the workspace */ mWorkspace.setOnScrollListener(new Workspace.OnScrollListener() { public void onScroll(float screenFraction) { updateWorkspaceHeader(Math.round(screenFraction)); } }, true); return root; }
From source file:com.tasomaniac.openwith.resolver.ResolverActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { final Intent intent = makeMyIntent(); setTheme(R.style.BottomSheet_Light); super.onCreate(savedInstanceState); mPm = getPackageManager();//from ww w .j av a 2s . c o m mRequestedUri = intent.getData(); boolean isCallerPackagePreferred = false; final String callerPackage = getCallerPackage(); ResolveInfo lastChosen = null; final Cursor query = getContentResolver().query(withHost(intent.getData().getHost()), null, null, null, null); if (query != null && query.moveToFirst()) { final boolean isPreferred = query.getInt(query.getColumnIndex(PREFERRED)) == 1; final boolean isLastChosen = query.getInt(query.getColumnIndex(LAST_CHOSEN)) == 1; if (isPreferred || isLastChosen) { final String componentString = query.getString(query.getColumnIndex(COMPONENT)); final Intent lastChosenIntent = new Intent(); final ComponentName lastChosenComponent = ComponentName.unflattenFromString(componentString); lastChosenIntent.setComponent(lastChosenComponent); ResolveInfo ri = mPm.resolveActivity(lastChosenIntent, PackageManager.MATCH_DEFAULT_ONLY); if (isPreferred && ri != null) { isCallerPackagePreferred = ri.activityInfo.packageName.equals(callerPackage); if (!isCallerPackagePreferred) { intent.setComponent(lastChosenComponent); startActivity(intent); finish(); return; } } lastChosen = ri; } query.close(); } mPackageMonitor.register(this, getMainLooper(), false); mRegistered = true; final ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE); mIconDpi = am.getLauncherLargeIconDensity(); mAdapter = new ResolveListAdapter(this, getHistory(), intent, callerPackage, lastChosen, true); mAdapter.setPriorityItems(intent.getStringArrayExtra(EXTRA_PRIORITY_PACKAGES)); mAlwaysUseOption = true; final int layoutId; final boolean useHeader; if (mAdapter.hasFilteredItem()) { layoutId = R.layout.resolver_list_with_default; mAlwaysUseOption = false; useHeader = true; } else { useHeader = false; layoutId = R.layout.resolver_list; } //If the caller is already the preferred, don't change it. if (isCallerPackagePreferred) { mAlwaysUseOption = false; } int count = mAdapter.mList.size(); if (count > 1) { setContentView(layoutId); mListView = (RecyclerView) findViewById(R.id.resolver_list); mListView.setAdapter(mAdapter); mAdapter.setOnItemClickedListener(this); mAdapter.setOnItemLongClickedListener(this); if (mAlwaysUseOption) { mAdapter.setSelectable(true); } if (useHeader) { mAdapter.setHeader(new ResolveListAdapter.Header()); } } else if (count == 1) { startActivity(mAdapter.intentForPosition(0, false)); mPackageMonitor.unregister(); mRegistered = false; finish(); return; } else { setContentView(R.layout.resolver_list); final TextView empty = (TextView) findViewById(R.id.empty); empty.setVisibility(View.VISIBLE); mListView = (RecyclerView) findViewById(R.id.resolver_list); mListView.setVisibility(View.GONE); } mListView.setLayoutManager(new LinearLayoutManager(this)); // Prevent the Resolver window from becoming the top fullscreen window and thus from taking // control of the system bars. getWindow().clearFlags(FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR); final ResolverDrawerLayout rdl = (ResolverDrawerLayout) findViewById(R.id.contentPanel); if (rdl != null) { rdl.setOnDismissedListener(new ResolverDrawerLayout.OnDismissedListener() { @Override public void onDismissed() { finish(); } }); } CharSequence title = getTitleForAction(); if (!TextUtils.isEmpty(title)) { final TextView titleView = (TextView) findViewById(R.id.title); if (titleView != null) { titleView.setText(title); } setTitle(title); } final ImageView iconView = (ImageView) findViewById(R.id.icon); final DisplayResolveInfo iconInfo = mAdapter.getFilteredItem(); if (iconView != null && iconInfo != null) { new LoadIconIntoViewTask(iconView).execute(iconInfo); } if (mAlwaysUseOption || mAdapter.hasFilteredItem()) { final ViewGroup buttonLayout = (ViewGroup) findViewById(R.id.button_bar); if (buttonLayout != null) { buttonLayout.setVisibility(View.VISIBLE); mAlwaysButton = (Button) buttonLayout.findViewById(R.id.button_always); mOnceButton = (Button) buttonLayout.findViewById(R.id.button_once); } else { mAlwaysUseOption = false; } } if (mAdapter.hasFilteredItem()) { mAlwaysButton.setEnabled(true); mOnceButton.setEnabled(true); } }
From source file:com.boko.vimusic.ui.fragments.phone.MusicBrowserPhoneFragment.java
/** * {@inheritDoc}//w ww. j a v a 2s.c o m */ @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { // The View for the fragment's UI final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_music_browser_phone, container, false); // Initialize the adapter mPagerAdapter = new PagerAdapter(getActivity()); final MusicFragments[] mFragments = MusicFragments.values(); for (final MusicFragments mFragment : mFragments) { mPagerAdapter.add(mFragment.getFragmentClass(), null); } // Initialize the ViewPager mViewPager = (ViewPager) rootView.findViewById(R.id.fragment_home_phone_pager); // Attch the adapter mViewPager.setAdapter(mPagerAdapter); // Offscreen pager loading limit mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount() - 1); // Start on the last page the user was on mViewPager.setCurrentItem(mPreferences.getStartPage()); // Initialze the TPI final TitlePageIndicator pageIndicator = (TitlePageIndicator) rootView .findViewById(R.id.fragment_home_phone_pager_titles); // Attach the ViewPager pageIndicator.setViewPager(mViewPager); // Scroll to the current artist, album, or song pageIndicator.setOnCenterItemClickListener(this); return rootView; }
From source file:com.greatspeeches.slides.ScreenSlidePageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout containing a title and body text. ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.description_layout, container, false); final android.support.v4.app.FragmentManager fragmentManager = myContext.getSupportFragmentManager(); fragmentManager.addOnBackStackChangedListener(new OnBackStackChangedListener() { @Override/*from www. j a v a2 s .c om*/ public void onBackStackChanged() { if (fragmentManager.getBackStackEntryCount() == 0) { closeYVplayer(); } } }); scroll = (StickyScrollView) rootView.findViewById(R.id.topScroll); scroll.setTouchListener(touchHandler); fragmentsLayout = (FrameLayout) rootView.findViewById(R.id.video_container); // Set the title view to show the page number. infoData = ((TextView) rootView.findViewById(R.id.person_info)); infoData.setMaxLines(Integer.MAX_VALUE); infoData.setMovementMethod(new ScrollingMovementMethod()); infoData.setText("\t\t\t" + mPersonObj.getInfo()); personImg = (ImageView) rootView.findViewById(R.id.person_image); personImg.setBackgroundResource(GreateSpeechesUtil.getResId(mPersonObj.getImageId(), R.drawable.class)); cVideoView = (CustomVideoView) rootView.findViewById(R.id.surface_video); closeImg = (ImageView) rootView.findViewById(R.id.closeBtn); videoRel = (RelativeLayout) rootView.findViewById(R.id.forVideo); videoRel.setOnTouchListener(customTouchListener); fragmentsLayout.setOnTouchListener(customTouchListener); if (null != mPersonObj.getdDate() && mPersonObj.getdDate().length() == 0) { RelativeLayout dRel = (RelativeLayout) rootView.findViewById(R.id.dDateRel); dRel.setVisibility(View.GONE); } TextView bDateTxt = (TextView) rootView.findViewById(R.id.bDate); bDateTxt.setText("" + mPersonObj.getbDate()); TextView bachievementTxt = (TextView) rootView.findViewById(R.id.C_info); bachievementTxt.setText("" + mPersonObj.getAchievement()); // TextView pNameTxt = (TextView)rootView.findViewById(R.id.acTitleTxt); // pNameTxt.setText(""+getResources().getString(R.string.achievement, mPersonObj.getName())); TextView dDateTxt = (TextView) rootView.findViewById(R.id.dDate); dDateTxt.setText("" + mPersonObj.getdDate()); closeImg.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub closeVplayer(); } }); return rootView; }
From source file:com.cw.litenote.note.Note_adapter.java
@SuppressLint("SetJavaScriptEnabled") @Override/*from www .jav a 2 s . c o m*/ public Object instantiateItem(ViewGroup container, final int position) { System.out.println("Note_adapter / instantiateItem / position = " + position); // Inflate the layout containing // 1. picture group: image,video, thumb nail, control buttons // 2. text group: title, body, time View pagerView = inflater.inflate(R.layout.note_view_adapter, container, false); int style = Note.getStyle(); pagerView.setBackgroundColor(ColorSet.mBG_ColorArray[style]); // Picture group ViewGroup pictureGroup = (ViewGroup) pagerView.findViewById(R.id.pictureContent); String tagPictureStr = "current" + position + "pictureView"; pictureGroup.setTag(tagPictureStr); // image view TouchImageView imageView = ((TouchImageView) pagerView.findViewById(R.id.image_view)); String tagImageStr = "current" + position + "imageView"; imageView.setTag(tagImageStr); // video view VideoViewCustom videoView = ((VideoViewCustom) pagerView.findViewById(R.id.video_view)); String tagVideoStr = "current" + position + "videoView"; videoView.setTag(tagVideoStr); ProgressBar spinner = (ProgressBar) pagerView.findViewById(R.id.loading); // link web view CustomWebView linkWebView = ((CustomWebView) pagerView.findViewById(R.id.link_web_view)); String tagStr = "current" + position + "linkWebView"; linkWebView.setTag(tagStr); // line view View line_view = pagerView.findViewById(R.id.line_view); // text group ViewGroup textGroup = (ViewGroup) pagerView.findViewById(R.id.textGroup); // Set tag for text web view CustomWebView textWebView = ((CustomWebView) textGroup.findViewById(R.id.textBody)); // set accessibility textGroup.setContentDescription(act.getResources().getString(R.string.note_text)); textWebView.getRootView().setContentDescription(act.getResources().getString(R.string.note_text)); tagStr = "current" + position + "textWebView"; textWebView.setTag(tagStr); // set text web view setWebView(textWebView, spinner, CustomWebView.TEXT_VIEW); String linkUri = db_page.getNoteLinkUri(position, true); String strTitle = db_page.getNoteTitle(position, true); String strBody = db_page.getNoteBody(position, true); // View mode // picture only if (Note.isPictureMode()) { System.out.println("Note_adapter / _instantiateItem / isPictureMode "); pictureGroup.setVisibility(View.VISIBLE); showPictureView(position, imageView, videoView, linkWebView, spinner); line_view.setVisibility(View.GONE); textGroup.setVisibility(View.GONE); } // text only else if (Note.isTextMode()) { System.out.println("Note_adapter / _instantiateItem / isTextMode "); pictureGroup.setVisibility(View.GONE); line_view.setVisibility(View.VISIBLE); textGroup.setVisibility(View.VISIBLE); if (Util.isYouTubeLink(linkUri) || !Util.isEmptyString(strTitle) || !Util.isEmptyString(strBody) || linkUri.startsWith("http")) { showTextWebView(position, textWebView); } } // picture and text else if (Note.isViewAllMode()) { System.out.println("Note_adapter / _instantiateItem / isViewAllMode "); // picture pictureGroup.setVisibility(View.VISIBLE); showPictureView(position, imageView, videoView, linkWebView, spinner); line_view.setVisibility(View.VISIBLE); textGroup.setVisibility(View.VISIBLE); // text if (!Util.isEmptyString(strTitle) || !Util.isEmptyString(strBody) || Util.isYouTubeLink(linkUri) || linkUri.startsWith("http")) { showTextWebView(position, textWebView); } else { textGroup.setVisibility(View.GONE); } } // footer of note view TextView footerText = (TextView) pagerView.findViewById(R.id.note_view_footer); if (!Note.isPictureMode()) { footerText.setVisibility(View.VISIBLE); footerText.setText(String.valueOf(position + 1) + "/" + pager.getAdapter().getCount()); footerText.setTextColor(ColorSet.mText_ColorArray[Note.mStyle]); footerText.setBackgroundColor(ColorSet.mBG_ColorArray[Note.mStyle]); } else footerText.setVisibility(View.GONE); container.addView(pagerView, 0); return pagerView; }
From source file:com.willowtreeapps.spurceexampleapp.fragments.ControlsFragment.java
@Nullable @Override//from w w w . j a v a2 s .c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, @Nullable Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.controls_fragment, container, false); parent = (GridLayout) ((SpruceActivity) getActivity()).parent; children = ((SpruceActivity) getActivity()).children; sortDropDown = ((SpruceActivity) getActivity()).sortDropDown; linearRadioGroup = (RadioGroup) rootView.findViewById(R.id.directional_radio_group); corneredRadioGroup = (RadioGroup) rootView.findViewById(R.id.cornered_radio_group); positionalRadioGroup = (RadioGroupGridLayout) rootView.findViewById(R.id.positional_radio_group); RadioGroup verticalWeightedRadioGroup = (RadioGroup) rootView .findViewById(R.id.vertical_weighted_radio_group); RadioGroup horizontalWeightedRadioGroup = (RadioGroup) rootView .findViewById(R.id.horizontal_weighted_radio_group); verticalWeightLayout = (LinearLayout) rootView.findViewById(R.id.vertical_weight); horizontalWeightLayout = (LinearLayout) rootView.findViewById(R.id.horizontal_weight); linearReversed = (CheckBox) rootView.findViewById(R.id.linear_reversed); seekBar = (SeekBar) rootView.findViewById(R.id.animation_seek); animationEndText = (TextView) rootView.findViewById(R.id.animation_end); seekBarTitle = (TextView) rootView.findViewById(R.id.seek_bar_title); codeSample = (EditText) rootView.findViewById(R.id.code_sample); animators = new Animator[] { DefaultAnimations.shrinkAnimator(parent, /*duration=*/800), DefaultAnimations.fadeInAnimator(parent, /*duration=*/800) }; View.OnClickListener click = new View.OnClickListener() { @Override public void onClick(View v) { resetChildViewsAndStartSort(); } }; container.setOnClickListener(click); parent.setOnClickListener(click); sortDropDown.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case CORNERED_SORT: case INLINE_SORT: linearRadioGroup.setVisibility(View.GONE); linearReversed.setVisibility(View.VISIBLE); positionalRadioGroup.setVisibility(View.GONE); verticalWeightLayout.setVisibility(View.GONE); horizontalWeightLayout.setVisibility(View.GONE); corneredRadioGroup.setVisibility(View.VISIBLE); break; case LINEAR_SORT: linearRadioGroup.setVisibility(View.VISIBLE); linearReversed.setVisibility(View.VISIBLE); positionalRadioGroup.setVisibility(View.GONE); verticalWeightLayout.setVisibility(View.GONE); horizontalWeightLayout.setVisibility(View.GONE); corneredRadioGroup.setVisibility(View.GONE); break; case CONTINUOUS_SORT: case RADIAL_SORT: positionalRadioGroup.setVisibility(View.VISIBLE); verticalWeightLayout.setVisibility(View.GONE); horizontalWeightLayout.setVisibility(View.GONE); linearReversed.setVisibility(View.VISIBLE); linearRadioGroup.setVisibility(View.GONE); corneredRadioGroup.setVisibility(View.GONE); break; case CONTINUOUS_WEIGHTED_SORT: positionalRadioGroup.setVisibility(View.VISIBLE); verticalWeightLayout.setVisibility(View.VISIBLE); horizontalWeightLayout.setVisibility(View.VISIBLE); linearReversed.setVisibility(View.VISIBLE); linearRadioGroup.setVisibility(View.GONE); corneredRadioGroup.setVisibility(View.GONE); break; default: linearReversed.setVisibility(View.GONE); positionalRadioGroup.setVisibility(View.GONE); verticalWeightLayout.setVisibility(View.GONE); horizontalWeightLayout.setVisibility(View.GONE); linearRadioGroup.setVisibility(View.GONE); corneredRadioGroup.setVisibility(View.GONE); break; } resetChildViewsAndStartSort(); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); // set default vertical weight verticalWeight = ContinuousWeightedSort.MEDIUM_WEIGHT; verticalWeightedRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) { switch (checkedId) { case R.id.vertical_light: verticalWeight = ContinuousWeightedSort.LIGHT_WEIGHT; break; case R.id.vertical_medium: verticalWeight = ContinuousWeightedSort.MEDIUM_WEIGHT; break; case R.id.vertical_heavy: verticalWeight = ContinuousWeightedSort.HEAVY_WEIGHT; break; } resetChildViewsAndStartSort(); } }); // set default horizontal weight horizontalWeight = ContinuousWeightedSort.MEDIUM_WEIGHT; horizontalWeightedRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) { switch (checkedId) { case R.id.horizontal_light: horizontalWeight = ContinuousWeightedSort.LIGHT_WEIGHT; break; case R.id.horizontal_medium: horizontalWeight = ContinuousWeightedSort.MEDIUM_WEIGHT; break; case R.id.horizontal_heavy: horizontalWeight = ContinuousWeightedSort.HEAVY_WEIGHT; break; } resetChildViewsAndStartSort(); } }); // set default direction direction = LinearSort.Direction.BOTTOM_TO_TOP; linearRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) { switch (checkedId) { case R.id.bottom_to_top: direction = LinearSort.Direction.BOTTOM_TO_TOP; break; case R.id.top_to_bottom: direction = LinearSort.Direction.TOP_TO_BOTTOM; break; case R.id.left_to_right: direction = LinearSort.Direction.LEFT_TO_RIGHT; break; case R.id.right_to_left: direction = LinearSort.Direction.RIGHT_TO_LEFT; break; } resetChildViewsAndStartSort(); } }); // set default corner corner = CorneredSort.Corner.TOP_LEFT; corneredRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) { switch (checkedId) { case R.id.top_left: corner = CorneredSort.Corner.TOP_LEFT; break; case R.id.top_right: corner = CorneredSort.Corner.TOP_RIGHT; break; case R.id.bottom_left: corner = CorneredSort.Corner.BOTTOM_LEFT; break; case R.id.bottom_right: corner = CorneredSort.Corner.BOTTOM_RIGHT; break; } resetChildViewsAndStartSort(); } }); linearReversed.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { resetChildViewsAndStartSort(); } }); seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { resetChildViewsAndStartSort(); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); positionalRadioGroup.setGroupChildChangedListener(this); resetChildViewsAndStartSort(); return rootView; }
From source file:com.todoroo.astrid.adapter.TaskAdapter.java
/** Creates a new view for use in the list view */ @Override// ww w . j a va2 s . co m public View newView(Context context, Cursor cursor, ViewGroup parent) { ViewGroup view = (ViewGroup) inflater.inflate(R.layout.task_adapter_row_simple, parent, false); // create view holder ViewHolder viewHolder = new ViewHolder(); viewHolder.task = new Task(); viewHolder.rowBody = (ViewGroup) view.findViewById(R.id.rowBody); viewHolder.nameView = (TextView) view.findViewById(R.id.title); viewHolder.completeBox = (CheckableImageView) view.findViewById(R.id.completeBox); viewHolder.dueDate = (TextView) view.findViewById(R.id.due_date); viewHolder.tagBlock = (TextView) view.findViewById(R.id.tag_block); viewHolder.taskActionContainer = view.findViewById(R.id.taskActionContainer); viewHolder.taskActionIcon = (ImageView) view.findViewById(R.id.taskActionIcon); boolean showFullTaskTitle = preferences.getBoolean(R.string.p_fullTaskTitle, false); if (showFullTaskTitle) { viewHolder.nameView.setMaxLines(Integer.MAX_VALUE); viewHolder.nameView.setSingleLine(false); viewHolder.nameView.setEllipsize(null); } view.setTag(viewHolder); for (int i = 0; i < view.getChildCount(); i++) { view.getChildAt(i).setTag(viewHolder); } // add UI component listeners addListeners(view); return view; }
From source file:ca.taglab.PictureFrame.ScreenSlidePageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout containing a title and body text. final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_screen_slide_page, container, false);/*w ww.ja v a 2 s . c o m*/ Bitmap picture = BitmapFactory.decodeFile(mImgPath); rootView.setBackground(new BitmapDrawable(getResources(), picture)); mConfirmation = (ImageView) rootView.findViewById(R.id.confirm); ((TextView) rootView.findViewById(R.id.name)).setText(mName); rootView.findViewById(R.id.control).getBackground().setAlpha(200); optionsOpen = false; mMsgHistory = rootView.findViewById(R.id.msg); mMsgHistory.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), MessagesActivity.class); intent.putExtra("user_name", mName); intent.putExtra("user_id", mId); intent.putExtra("owner_id", mOwnerId); startActivity(intent); hideOptions(); } }); mPhoto = rootView.findViewById(R.id.photo); mPhoto.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { String filename = String.valueOf(System.currentTimeMillis()) + ".jpg"; ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, filename); mCapturedImageURI = getActivity().getContentResolver() .insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI); startActivityForResult(intent, CAPTURE_PICTURE); hideOptions(); } catch (Exception e) { Log.e(TAG, "Camera intent failed"); } } }); mVideo = rootView.findViewById(R.id.video); mVideo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { String filename = String.valueOf(System.currentTimeMillis()) + ".3gp"; ContentValues values = new ContentValues(); values.put(MediaStore.Video.Media.TITLE, filename); mCapturedVideoURI = getActivity().getContentResolver() .insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, values); Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedVideoURI); startActivityForResult(intent, CAPTURE_VIDEO); hideOptions(); } catch (Exception e) { Log.e(TAG, "Video intent failed"); } } }); mAudio = rootView.findViewById(R.id.audio); mAudio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { Intent intent = new Intent(getActivity(), AudioRecorderActivity.class); startActivityForResult(intent, CAPTURE_AUDIO); hideOptions(); } catch (Exception e) { Log.e(TAG, "Audio intent failed"); } } }); mWave = rootView.findViewById(R.id.wave); mWave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { new SendEmailAsyncTask(getActivity(), mEmail, "PictureFrame: I'm thinking of you", "Wave sent via PictureFrame", null).execute(); //Toast.makeText(getActivity(), "Wave sent to: " + mEmail, Toast.LENGTH_SHORT).show(); hideOptions(); messageSent(v); } catch (Exception e) { Log.e("SendEmailAsyncTask", e.getMessage(), e); //Toast.makeText(getActivity(), "Wave to " + mEmail + " failed", Toast.LENGTH_SHORT).show(); } } }); mCancel = rootView.findViewById(R.id.close); mPhoto.getBackground().setAlpha(200); mVideo.getBackground().setAlpha(200); mAudio.getBackground().setAlpha(200); mWave.getBackground().setAlpha(200); mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime); mLongAnimationDuration = getResources().getInteger(android.R.integer.config_longAnimTime); rootView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!optionsOpen) showOptions(); } }); mCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (optionsOpen) hideOptions(); } }); Cursor unread = getActivity().getContentResolver().query(UserContentProvider.MESSAGE_CONTENT_URI, MessageTable.PROJECTION, MessageTable.COL_TO_ID + "=? AND " + MessageTable.COL_FROM_ID + "=? AND " + MessageTable.COL_READ + "=?", new String[] { Long.toString(mOwnerId), Long.toString(mId), Long.toString(0) }, null); if (unread != null && unread.moveToFirst()) { rootView.findViewById(R.id.notification).setVisibility(View.VISIBLE); rootView.findViewById(R.id.notification).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), MessagesActivity.class); intent.putExtra("user_name", mName); intent.putExtra("user_id", mId); intent.putExtra("owner_id", mOwnerId); startActivity(intent); v.setVisibility(View.INVISIBLE); } }); } if (unread != null) { unread.close(); } return rootView; }
From source file:com.cw.litenote.note.NoteUi.java
void hide_picViewUI(String pictureStr) { String tagStr = "current" + pager.getCurrentItem() + "pictureView"; ViewGroup pictureGroup = (ViewGroup) pager.findViewWithTag(tagStr); System.out.println("NoteUi / _hide_picViewUI / tagStr = " + tagStr); if ((pictureGroup != null)) { // image view TextView picView_title = (TextView) (pictureGroup.findViewById(R.id.image_title)); TextView picView_footer = (TextView) (pictureGroup.findViewById(R.id.image_footer)); Button picView_back_button = (Button) (pictureGroup.findViewById(R.id.image_view_back)); Button picView_viewMode_button = (Button) (pictureGroup.findViewById(R.id.image_view_mode)); Button picView_previous_button = (Button) (pictureGroup.findViewById(R.id.image_view_previous)); Button picView_next_button = (Button) (pictureGroup.findViewById(R.id.image_view_next)); picView_title.setVisibility(View.GONE); picView_footer.setVisibility(View.GONE); picView_back_button.setVisibility(View.GONE); // view mode button visibility affects pop up menu ON/OFF picView_viewMode_button.setVisibility(View.GONE); if (Note.isPictureMode() && UtilImage.hasImageExtension(pictureStr, act)) { if (picView_previous_button != null) { picView_previous_button.setVisibility(View.GONE); picView_next_button.setVisibility(View.GONE); }/* w w w .j av a 2 s . c o m*/ } // video view Button videoPlayButton = (Button) (pictureGroup.findViewById(R.id.video_view_play_video)); TextView videoView_currPosition = (TextView) (pictureGroup.findViewById(R.id.video_current_pos)); SeekBar videoView_seekBar = (SeekBar) (pictureGroup.findViewById(R.id.video_seek_bar)); TextView videoView_fileLength = (TextView) (pictureGroup.findViewById(R.id.video_file_length)); // since the play button is designed at the picture center, should be gone when playing if (UtilVideo.getVideoState() == UtilVideo.VIDEO_AT_PLAY) { videoPlayButton.setVisibility(View.GONE); } if ((!UtilVideo.hasMediaControlWidget) && UtilVideo.hasVideoExtension(pictureStr, act)) { picView_previous_button.setVisibility(View.GONE); picView_next_button.setVisibility(View.GONE); } videoView_currPosition.setVisibility(View.GONE); videoView_seekBar.setVisibility(View.GONE); videoView_fileLength.setVisibility(View.GONE); } cancel_UI_callbacks(); }
From source file:com.android.mail.browse.ConversationItemViewCoordinates.java
private ConversationItemViewCoordinates(final Context context, final Config config, final CoordinatesCache cache) { Utils.traceBeginSection("CIV coordinates constructor"); final Resources res = context.getResources(); final int layoutId = R.layout.conversation_item_view; ViewGroup view = (ViewGroup) cache.getView(layoutId); if (view == null) { view = (ViewGroup) LayoutInflater.from(context).inflate(layoutId, null); cache.put(layoutId, view);//from w ww . ja v a 2 s . c om } // Show/hide optional views before measure/layout call final TextView folders = (TextView) view.findViewById(R.id.folders); folders.setVisibility(config.areFoldersVisible() ? View.VISIBLE : View.GONE); View contactImagesView = view.findViewById(R.id.contact_image); switch (config.getGadgetMode()) { case GADGET_CONTACT_PHOTO: contactImagesView.setVisibility(View.VISIBLE); break; case GADGET_CHECKBOX: contactImagesView.setVisibility(View.GONE); contactImagesView = null; break; default: contactImagesView.setVisibility(View.GONE); contactImagesView = null; break; } final View replyState = view.findViewById(R.id.reply_state); replyState.setVisibility(config.isReplyStateVisible() ? View.VISIBLE : View.GONE); final View personalIndicator = view.findViewById(R.id.personal_indicator); personalIndicator.setVisibility(config.isPersonalIndicatorVisible() ? View.VISIBLE : View.GONE); setFramePadding(context, view, config.useFullPadding()); // Layout the appropriate view. ViewCompat.setLayoutDirection(view, config.getLayoutDirection()); final int widthSpec = MeasureSpec.makeMeasureSpec(config.getWidth(), MeasureSpec.EXACTLY); final int heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); view.measure(widthSpec, heightSpec); view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); // Once the view is measured, let's calculate the dynamic width variables. folderLayoutWidth = (int) (view.getWidth() * res.getInteger(R.integer.folder_max_width_proportion) / 100.0); folderCellWidth = (int) (view.getWidth() * res.getInteger(R.integer.folder_cell_max_width_proportion) / 100.0); // Utils.dumpViewTree((ViewGroup) view); // Records coordinates. // Contact images view if (contactImagesView != null) { contactImagesWidth = contactImagesView.getWidth(); contactImagesHeight = contactImagesView.getHeight(); contactImagesX = getX(contactImagesView); contactImagesY = getY(contactImagesView); } else { contactImagesX = contactImagesY = contactImagesWidth = contactImagesHeight = 0; } final boolean isRtl = ViewUtils.isViewRtl(view); final View star = view.findViewById(R.id.star); final int starPadding = res.getDimensionPixelSize(R.dimen.conv_list_star_padding_start); starX = getX(star) + (isRtl ? 0 : starPadding); starY = getY(star); starWidth = star.getWidth(); final TextView senders = (TextView) view.findViewById(R.id.senders); final int sendersTopAdjust = getLatinTopAdjustment(senders); sendersX = getX(senders); sendersY = getY(senders) + sendersTopAdjust; sendersWidth = senders.getWidth(); sendersHeight = senders.getHeight(); sendersLineCount = SINGLE_LINE; sendersFontSize = senders.getTextSize(); final TextView subject = (TextView) view.findViewById(R.id.subject); final int subjectTopAdjust = getLatinTopAdjustment(subject); subjectX = getX(subject); subjectY = getY(subject) + subjectTopAdjust; subjectWidth = subject.getWidth(); subjectHeight = subject.getHeight(); subjectFontSize = subject.getTextSize(); final TextView snippet = (TextView) view.findViewById(R.id.snippet); final int snippetTopAdjust = getLatinTopAdjustment(snippet); snippetX = getX(snippet); snippetY = getY(snippet) + snippetTopAdjust; maxSnippetWidth = snippet.getWidth(); snippetHeight = snippet.getHeight(); snippetFontSize = snippet.getTextSize(); if (config.areFoldersVisible()) { foldersLeft = getX(folders); foldersRight = foldersLeft + folders.getWidth(); foldersY = getY(folders); foldersTypeface = folders.getTypeface(); foldersFontSize = folders.getTextSize(); } else { foldersLeft = 0; foldersRight = 0; foldersY = 0; foldersTypeface = null; foldersFontSize = 0; } final View colorBlock = view.findViewById(R.id.color_block); if (config.isColorBlockVisible() && colorBlock != null) { colorBlockX = getX(colorBlock); colorBlockY = getY(colorBlock); colorBlockWidth = colorBlock.getWidth(); colorBlockHeight = colorBlock.getHeight(); } else { colorBlockX = colorBlockY = colorBlockWidth = colorBlockHeight = 0; } if (config.isReplyStateVisible()) { replyStateX = getX(replyState); replyStateY = getY(replyState); } else { replyStateX = replyStateY = 0; } if (config.isPersonalIndicatorVisible()) { personalIndicatorX = getX(personalIndicator); personalIndicatorY = getY(personalIndicator); } else { personalIndicatorX = personalIndicatorY = 0; } final View infoIcon = view.findViewById(R.id.info_icon); infoIconX = getX(infoIcon); infoIconXRight = infoIconX + infoIcon.getWidth(); infoIconY = getY(infoIcon); final TextView date = (TextView) view.findViewById(R.id.date); dateX = getX(date); dateXRight = dateX + date.getWidth(); dateY = getY(date); datePaddingStart = ViewUtils.getPaddingStart(date); dateFontSize = date.getTextSize(); dateYBaseline = dateY + getLatinTopAdjustment(date) + date.getBaseline(); final View paperclip = view.findViewById(R.id.paperclip); paperclipY = getY(paperclip); paperclipPaddingStart = ViewUtils.getPaddingStart(paperclip); height = view.getHeight() + sendersTopAdjust; Utils.traceEndSection(); }