/** * Inflates the video view layout, replacing the {@link ViewStub} with the correct backing * implementation. * * @param context The context to use for inflating the correct video view * @param attrs The attributes for retrieving custom backing implementations. */ protected void inflateVideoView(@NonNull Context context, @Nullable AttributeSet attrs) { View.inflate(context, R.layout.exomedia_video_view_layout, this); ViewStub videoViewStub = (ViewStub) findViewById(R.id.video_view_api_impl_stub); videoViewStub.setLayoutResource(getVideoViewApiImplementation(context, attrs)); videoViewStub.inflate(); }
protected void setupSimpleActionBar(String txtTitle) { stubNavigation.setLayoutResource(R.layout.nav_simple); layoutActionbar = (ViewGroup) stubNavigation.inflate(); findViewById(R.id.btnBack).setOnClickListener(this); txtTitleBar = (TextView) findViewById(R.id.txtTitleBar); txtTitleBar.setText(txtTitle); }
public void setEmptyViewId(int id) { if (id == 0) return; emptyViewId = id; emptyContentContainer = (ViewStub) findViewById(R.id.rrv_empty_content_container); emptyContentContainer.setLayoutResource(emptyViewId); emptyContentContainer.inflate(); }
private void setDownloadedFilmsData() { this.mGridView.setAdapter(new FilmAdapter(getActivity(), sDOWNLOADED_FILMS)); this.mSectionLabel.setText(getString(R.string.label_section_discover)); if (sDOWNLOADED_FILMS.isEmpty()) { ConnectivityManager cm = (ConnectivityManager) getActivity().getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting(); if (!isConnected) { viewStub.setLayoutResource(R.layout.no_connection_layout); mGridView.setEmptyView(viewStub); } else { viewStub.setLayoutResource(R.layout.list_empty_layout); mGridView.setEmptyView(viewStub); /* Starting Download Service */ DownloadResultReceiver mReceiver = new DownloadResultReceiver(new Handler()); mReceiver.setReceiver(this); Intent intent = new Intent(Intent.ACTION_SYNC, null, this.getActivity(), FilmDownloadService.class); /* Send optional extras to Download IntentService */ intent.putExtra(FilmDownloadService.RECEIVER_KEY, mReceiver); this.getActivity().startService(intent); } } else { setSecondFragmentContent(sDOWNLOADED_FILMS.get(0)); } }
private void initEmptyView(int loaded) { if (loaded == 0) { emptyViewStub.setVisibility(View.VISIBLE); } else { emptyViewStub.setVisibility(View.GONE); } }
public void showImageGridView() { // 显示转发的布局 mForwardLayout.setVisibility(View.VISIBLE); if (mImageGvViewStub.getVisibility() == View.GONE) { mImageGvViewStub.setVisibility(View.VISIBLE); // gridview布局umeng_comm_images_gc.xml int imageGvResId = ResFinder.getId("umeng_comm_msg_gridview"); mImageGv = (WrapperGridView) this.findViewById(imageGvResId); mImageGv.hasScrollBar = true; } mImageGv.setBackgroundColor(Color.TRANSPARENT); mImageGv.setVisibility(View.VISIBLE); // adapter FeedImageAdapter gridviewAdapter = new FeedImageAdapter(mContext); gridviewAdapter.addDatasOnly(mFeedItem.getImages()); // 设置图片 mImageGv.setAdapter(gridviewAdapter); // 计算列数 mImageGv.updateColumns(3); // 图片GridView mImageGv.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int pos, long id) { mPresenter.jumpToImageBrowser(mFeedItem.getImages(), pos); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { if (getIntent().hasExtra(ARG_PARENT_CATEGORY_STYLE)) { int styleResId = getIntent().getIntExtra(ARG_PARENT_CATEGORY_STYLE, -1); if (styleResId > 0) { setTheme(styleResId); } } super.onCreate(savedInstanceState); mParentCategoryId = getIntent().getLongExtra(ARG_PARENT_CATEGORY_ID, 0); if (mParentCategoryId == 0) { Intent categoryIntent = new Intent(this, CategoriesActivity.class); startActivity(categoryIntent); } setContentView(R.layout.app_bar); ViewStub mainContent = (ViewStub) findViewById(R.id.main_content); mainContent.setLayoutResource(R.layout.content_fragment); mainContent.inflate(); mAppBarLayout = (AppBarLayout) findViewById(R.id.app_bar); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); } getSupportLoaderManager().initLoader(0, null, this); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Intent newCategoryIntent = new Intent(SubcategoriesActivity.this, ManageCategoryActivity.class); newCategoryIntent.putExtra( ManageCategoryActivity.ARG_PARENT_CATEGORY_ID, mParentCategoryId); startActivity(newCategoryIntent); } }); fab.setVisibility(View.VISIBLE); if (savedInstanceState == null) { CategoriesFragment fragment = CategoriesFragment.newInstance(mParentCategoryId); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.add(R.id.fragment, fragment); transaction.commit(); } }
private void inflateAutoLoginBar() { if (mAutoLogin != null) { return; } ViewStub stub = (ViewStub) findViewById(R.id.autologin_stub); mAutoLogin = (AutologinBar) stub.inflate(); mAutoLogin.setTitleBar(this); }
private void inflateSnapshotBar() { if (mSnapshotBar != null) { return; } ViewStub stub = (ViewStub) findViewById(R.id.snapshotbar_stub); mSnapshotBar = (SnapshotBar) stub.inflate(); mSnapshotBar.setTitleBar(this); }
@Override protected void onFinishInflate() { super.onFinishInflate(); // mScrollView = findViewById(R.id.scroll_view); // mStackScroller = findViewById(R.id.notification_stack_scroller); mKeyguardStatusBar = findViewById(R.id.keyguard_header); ViewStub userSwitcher = (ViewStub) findViewById(R.id.keyguard_user_switcher); userSwitcher.setOnInflateListener(this); mUserSwitcher = userSwitcher; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); super.onCreateDrawer(); ViewStub stub = (ViewStub) findViewById(R.id.layout_stub); stub.setLayoutResource(R.layout.content_stamp); View inflated = stub.inflate(); /* your logic here */ }
private void inflateImageView() { ViewStub viewStub = (ViewStub) mView.findViewById(R.id.media_listitem_details_stub); if (viewStub != null) { if (mIsLocal) viewStub.setLayoutResource(R.layout.media_grid_image_local); else viewStub.setLayoutResource(R.layout.media_grid_image_network); viewStub.inflate(); } mImageView = (ImageView) mView.findViewById(R.id.media_listitem_details_image); // add a background color so something appears while image is downloaded mImageView.setImageDrawable(new ColorDrawable(getResources().getColor(R.color.grey_light))); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_feed, container, false); ButterKnife.inject(this, v); if (AppSharePreferences.getFollowFlag(getActivity())) { listLayout = mListViewStub.inflate(); initListView(listLayout); } else { settingLayout = mSetting.inflate(); initSettingView(settingLayout); } return v; }
private void showBanner() { if (m_bannerViewStub == null) { m_bannerViewStub = (ViewStub) findViewById(R.id.viewstub_banner); View v = m_bannerViewStub.inflate(); m_closeButton = (ImageButton) v.findViewById(R.id.imagebutton_close); m_closeButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View arg0) { m_bannerViewStub.setVisibility(View.GONE); } }); } m_bannerViewStub.setVisibility(View.VISIBLE); }
private void updateUiFromCursor(Cursor c) { if ((c == null || c.getCount() == 0) && mEmptyView == null) { // Set empty page view. We delay this so that the empty view won't flash. final ViewStub emptyViewStub = (ViewStub) getView().findViewById(R.id.home_empty_view_stub); mEmptyView = emptyViewStub.inflate(); final ImageView emptyIcon = (ImageView) mEmptyView.findViewById(R.id.home_empty_image); emptyIcon.setImageResource(R.drawable.icon_bookmarks_empty); final TextView emptyText = (TextView) mEmptyView.findViewById(R.id.home_empty_text); emptyText.setText(R.string.home_bookmarks_empty); mList.setEmptyView(mEmptyView); } }
@SuppressWarnings("deprecation") private void inflateTitleBar(ViewGroup view) { ViewStub stub = (ViewStub) view.findViewById(R.id.com_facebook_picker_title_bar_stub); if (stub != null) { View titleBar = stub.inflate(); final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); layoutParams.addRule(RelativeLayout.BELOW, R.id.com_facebook_picker_title_bar); listView.setLayoutParams(layoutParams); if (titleBarBackground != null) { titleBar.setBackgroundDrawable(titleBarBackground); } doneButton = (Button) view.findViewById(R.id.com_facebook_picker_done_button); if (doneButton != null) { doneButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { logAppEvents(true); appEventsLogged = true; if (onDoneButtonClickedListener != null) { onDoneButtonClickedListener.onDoneButtonClicked(PickerFragment.this); } } }); if (getDoneButtonText() != null) { doneButton.setText(getDoneButtonText()); } if (doneButtonBackground != null) { doneButton.setBackgroundDrawable(doneButtonBackground); } } titleTextView = (TextView) view.findViewById(R.id.com_facebook_picker_title); if (titleTextView != null) { if (getTitleText() != null) { titleTextView.setText(getTitleText()); } } } }
@Override public void setSecondary( boolean show, String name, boolean nameIsNumber, String label, Drawable photo, boolean isConference, boolean isGeneric) { if (show) { if (isConference) { name = getConferenceString(isGeneric); photo = getConferencePhoto(isGeneric); nameIsNumber = false; } showAndInitializeSecondaryCallInfo(); mSecondaryCallName.setText(name); int nameDirection = View.TEXT_DIRECTION_INHERIT; if (nameIsNumber) { nameDirection = View.TEXT_DIRECTION_LTR; } mSecondaryCallName.setTextDirection(nameDirection); setDrawableToImageView(mSecondaryPhoto, photo); } else { mSecondaryCallInfo.setVisibility(View.GONE); } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); mContext = getActivity(); filter = false; mainActivity = (MainActivity) getActivity(); mainListView = (LinearLayout) inflater.inflate(R.layout.fragment_main_list, container, false); stub = (ViewStub) mainListView.findViewById(android.R.id.empty); stub.setLayoutResource(R.layout.task_empty_stub); header = (TextView) mainListView.findViewById(R.id.header); header.setText(R.string.tasks); setHasOptionsMenu(true); taskListAdapter = new TaskListAdapter(mContext, null, "Mine"); taskListAdapter.setAutoload(false); setListAdapter(taskListAdapter); taskListAdapter.addOnQueryLoadListener(this); taskListAdapter.loadObjects(); return mainListView; }
private void setSavedFilmsData() { this.mGridView.setAdapter(new FilmAdapter(getActivity(), sSAVED_FILMS)); this.mSectionLabel.setText(getString(R.string.label_section_favorites)); if (sSAVED_FILMS.isEmpty()) { viewStub.setLayoutResource(R.layout.list_empty_layout); mGridView.setEmptyView(viewStub); } }
@Override protected void onFinishInflate() { super.onFinishInflate(); mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic); mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded); ViewStub gutsStub = (ViewStub) findViewById(R.id.notification_guts_stub); gutsStub.setOnInflateListener( new ViewStub.OnInflateListener() { @Override public void onInflate(ViewStub stub, View inflated) { mGuts = (NotificationGuts) inflated; mGuts.setClipTopAmount(getClipTopAmount()); mGuts.setActualHeight(getActualHeight()); } }); mVetoButton = findViewById(R.id.veto); }
private boolean attach() { final View attachView = mParentView == null ? mContext.findViewById(mAttachId) : mParentView.findViewById(mAttachId); if (attachView instanceof RecyclerView) { mRecyclerView = (RecyclerView) attachView; } else if (attachView instanceof ViewStub) { ViewStub stub = (ViewStub) attachView; stub.setLayoutResource(R.layout.weekdays_recycler_view); stub.setInflatedId(mAttachId); mRecyclerView = (RecyclerView) stub.inflate(); } else { throw new IllegalStateException( "Weeekdays Buttons was unable to attach to your Layout, required [ViewStub],[recycleView] or ['parent' View] doesn't exist."); } if (mRecyclerView != null) { getDrawableProvider(); if (mTextDrawableType == WeekdaysDrawableProvider.MW_MULTIPLE_LETTERS && mNumberOfLetters < 2) mNumberOfLetters = 2; int position = 0; for (Map.Entry<Integer, String> map : getDays().entrySet()) { String day = map.getValue(); int calendarDayId = map.getKey(); if (!TextUtils.isEmpty(day)) { WeekdaysDataItem item = itemFromType(position, calendarDayId, day, getSelectedDays().get(calendarDayId)); if (getWeekdaysCount() == position) getWeekdaysItems().add(item); else getWeekdaysItems().set(position, item); position++; } } initRecyclerView(mContext); return true; } return false; }
@Override public ActionMode startActionMode(ActionMode.Callback callback) { if (DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback); if (mActionMode != null) { mActionMode.finish(); } final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback); ActionMode mode = null; // Emulate Activity's onWindowStartingActionMode: initActionBar(); if (aActionBar != null) { mode = aActionBar.startActionMode(wrappedCallback); } if (mode != null) { mActionMode = mode; } else { if (mActionModeView == null) { ViewStub stub = (ViewStub) mDecor.findViewById(R.id.abs__action_mode_bar_stub); if (stub != null) { mActionModeView = (ActionBarContextView) stub.inflate(); } } if (mActionModeView != null) { mActionModeView.killMode(); mode = new StandaloneActionMode(mActivity, mActionModeView, wrappedCallback, true); if (callback.onCreateActionMode(mode, mode.getMenu())) { mode.invalidate(); mActionModeView.initForMode(mode); mActionModeView.setVisibility(View.VISIBLE); mActionMode = mode; mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); } else { mActionMode = null; } } } if (mActionMode != null && mActivity instanceof OnActionModeStartedListener) { ((OnActionModeStartedListener) mActivity).onActionModeStarted(mActionMode); } return mActionMode; }
public void showComboView(ComboViews startWith, Bundle extras) { if (mComboView == null) { ViewStub stub = (ViewStub) mActivity.getWindow().getDecorView().findViewById(R.id.combo_view_stub); mComboView = (ComboView) stub.inflate(); mComboView.setVisibility(View.GONE); mComboView.setupViews(mActivity); } mNavBar.setVisibility(View.GONE); if (mActionBar != null) mActionBar.hide(); Bundle b = new Bundle(); b.putString(ComboViewActivity.EXTRA_INITIAL_VIEW, startWith.name()); b.putBundle(ComboViewActivity.EXTRA_COMBO_ARGS, extras); Tab t = getActiveTab(); if (t != null) { b.putString(ComboViewActivity.EXTRA_CURRENT_URL, t.getUrl()); } mComboView.showViews(mActivity, b); }
private void inflateTwoPane(ViewStub stub) { stub.setLayoutResource(R.layout.preference_list_content); stub.inflate(); mGroupList = (ListView) mRoot.findViewById(android.R.id.list); mPrefsContainer = (ViewGroup) mRoot.findViewById(R.id.prefs_frame); mFragmentBreadCrumbs = (FragmentBreadCrumbs) mRoot.findViewById(android.R.id.title); mFragmentBreadCrumbs.setMaxVisible(1); mFragmentBreadCrumbs.setActivity(getActivity()); mPrefsContainer.setVisibility(View.VISIBLE); mGroupList.setAdapter(new HistoryGroupWrapper(mAdapter)); mGroupList.setOnItemClickListener(mGroupItemClickListener); mGroupList.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); mChildWrapper = new HistoryChildWrapper(mAdapter); mChildList = new ListView(getActivity()); mChildList.setAdapter(mChildWrapper); mChildList.setOnItemClickListener(mChildItemClickListener); registerForContextMenu(mChildList); ViewGroup prefs = (ViewGroup) mRoot.findViewById(R.id.prefs); prefs.addView(mChildList); }
private void updateUiFromCursor(Cursor c) { if (c != null && c.getCount() > 0) { return; } // Cursor is empty, so set the empty view if it hasn't been set already. if (mEmptyView == null) { // Set empty panel view. We delay this so that the empty view won't flash. final ViewStub emptyViewStub = (ViewStub) getView().findViewById(R.id.home_empty_view_stub); mEmptyView = emptyViewStub.inflate(); final ImageView emptyIcon = (ImageView) mEmptyView.findViewById(R.id.home_empty_image); emptyIcon.setImageResource(R.drawable.icon_most_recent_empty); final TextView emptyText = (TextView) mEmptyView.findViewById(R.id.home_empty_text); emptyText.setText(R.string.home_most_recent_empty); mList.setEmptyView(mEmptyView); } }
@Override public void doShowloading() { if (view_loading == null) { view_loading = stub_loading.inflate(); } else { view_loading.setVisibility(View.VISIBLE); } if (view_noData != null) { view_noData.setVisibility(View.GONE); } }
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ViewGroup view = (ViewGroup) getView(); if (showSearchBox) { ViewStub stub = (ViewStub) view.findViewById(R.id.com_facebook_placepickerfragment_search_box_stub); if (stub != null) { searchBox = (EditText) stub.inflate(); // Put the list under the search box RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); layoutParams.addRule(RelativeLayout.BELOW, R.id.search_box); ListView listView = (ListView) view.findViewById(R.id.com_facebook_picker_list_view); listView.setLayoutParams(layoutParams); // If we need to, put the search box under the title bar. if (view.findViewById(R.id.com_facebook_picker_title_bar) != null) { layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); layoutParams.addRule(RelativeLayout.BELOW, R.id.com_facebook_picker_title_bar); searchBox.setLayoutParams(layoutParams); } searchBox.addTextChangedListener(new SearchTextWatcher()); if (!TextUtils.isEmpty(searchText)) { searchBox.setText(searchText); } } } }
public void onEventMainThread(SubscriptionAddActivity.FollowFlagEvent event) { if (event.flag) { if (mSetting != null) mSetting.setVisibility(View.GONE); if (listLayout == null) { listLayout = mListViewStub.inflate(); initListView(listLayout); } else { listLayout.setVisibility(View.VISIBLE); data.clear(); adapter.notifyDataSetChanged(); mEmptyView.show(true); mEmptyView.onLoading(); request(Urls.SERVER_PATH + "/user/feeds", 0); } } else { stopRefreshNews(); if (mListViewStub != null) mListViewStub.setVisibility(View.GONE); if (settingLayout == null) { settingLayout = mSetting.inflate(); initSettingView(settingLayout); } else settingLayout.setVisibility(View.VISIBLE); } }
private void bindData() { TippyTipperApplication appState = ((TippyTipperApplication) this.getApplication()); TextView lbl_split_amount = (TextView) findViewById(R.id.lbl_split_amount); TextView lbl_split_tip = (TextView) findViewById(R.id.lbl_split_tip); TextView lbl_split_adjustment = (TextView) findViewById(R.id.lbl_split_adjustment); TextView lbl_split_total = (TextView) findViewById(R.id.lbl_split_total); TextView lbl_NumberOfPeople = (TextView) findViewById(R.id.lbl_NumberOfPeople); View inflated_splitTax = findViewById(R.id.inflated_splitTax); float excludeTaxRate = Settings.getExcludeTaxRate(getBaseContext()); if (excludeTaxRate != 0) { ViewStub stub_splitTax = (ViewStub) findViewById(R.id.stub_splitTax); if (stub_splitTax != null) stub_splitTax.setVisibility(View.VISIBLE); else if (inflated_splitTax != null) inflated_splitTax.setVisibility(View.VISIBLE); TextView lbl_split_tax = (TextView) findViewById(R.id.lbl_split_tax); lbl_split_tax.setText(appState.service.getSplitTaxAmount()); } else { if (inflated_splitTax != null) inflated_splitTax.setVisibility(View.GONE); } lbl_split_amount.setText(appState.service.getSplitBillAmount()); lbl_split_tip.setText(appState.service.getSplitTipAmount()); lbl_split_adjustment.setText(appState.service.getSplitAdjustment()); lbl_split_total.setText(appState.service.getSplitTotalAmount()); lbl_NumberOfPeople.setText(Integer.toString(appState.service.getNumberOfPeople())); Map<String, String> params = new HashMap<String, String>(); params.put("Number of People", String.valueOf(appState.service.getNumberOfPeople())); params.put("Split Bill Amount", appState.service.getSplitBillAmount()); params.put("Split Tax Amount", appState.service.getSplitTaxAmount()); params.put("Split Tip Amount", appState.service.getSplitTipAmount()); params.put("Split Adjustment Amount", appState.service.getSplitAdjustment()); params.put("Split Total Amount", appState.service.getSplitTotalAmount()); FlurryAgent.onEvent("Split Bill Bind Data", params); }
private View getHeaderView(int mode) { View header = null; switch (mode) { case QuickContact.MODE_SMALL: header = mWindow.findViewById(R.id.header_small); break; case QuickContact.MODE_MEDIUM: header = mWindow.findViewById(R.id.header_medium); break; case QuickContact.MODE_LARGE: header = mWindow.findViewById(R.id.header_large); break; } if (header instanceof ViewStub) { // Inflate actual header if we picked a stub final ViewStub stub = (ViewStub) header; header = stub.inflate(); } else if (header != null) { header.setVisibility(View.VISIBLE); } return header; }