List of usage examples for android.view ViewGroup setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:com.heneryh.aquanotes.ui.controllers.OutletsXFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(android.R.layout.list_content, null); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams( new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); return root;/*from w w w. j ava2s . co m*/ }
From source file:gov.wa.wsdot.android.wsdot.ui.BlogFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_list_with_swipe_refresh, null); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorScheme(17170451, // android.R.color.holo_blue_bright 17170452, // android.R.color.holo_green_light 17170456, // android.R.color.holo_orange_light 17170454); // android.R.color.holo_red_light) mEmptyView = root.findViewById(R.id.empty_list_view); return root;//from www . j av a 2 s.com }
From source file:gov.wa.wsdot.android.wsdot.ui.camera.CameraImageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup mRootView = (ViewGroup) inflater.inflate(R.layout.camera_dialog, null); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. mRootView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mSwipeRefreshLayout = mRootView.findViewById(R.id.swipe_container); mSwipeRefreshLayout.setOnRefreshListener(this); mSwipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light); mImage = mRootView.findViewById(R.id.image); viewModel = ViewModelProviders.of(this, viewModelFactory).get(CameraViewModel.class); viewModel.getResourceStatus().observe(this, resourceStatus -> { if (resourceStatus != null) { switch (resourceStatus.status) { case LOADING: mSwipeRefreshLayout.setRefreshing(true); break; case SUCCESS: mSwipeRefreshLayout.setRefreshing(false); break; case ERROR: mSwipeRefreshLayout.setRefreshing(false); Toast.makeText(this.getContext(), "connection error", Toast.LENGTH_LONG).show(); }//from w w w . j a v a2 s . c o m } }); viewModel.getCamera(mId).observe(this, camera -> { if (camera != null) { mTitle = camera.getTitle(); mUrl = camera.getUrl(); mIsStarred = camera.getIsStarred() != 0; getLoaderManager().initLoader(0, null, this); if (camera.getMilepost() != null) { ((TextView) mRootView.findViewById(R.id.milepost)) .setText(String.format("milepost %s", camera.getMilepost())); } if (!camera.getDirection().equals("null")) { String directionString; switch (camera.getDirection()) { case "N": directionString = "This camera faces north"; break; case "S": directionString = "This camera faces south"; break; case "E": directionString = "This camera faces east"; break; case "W": directionString = "This camera faces west"; break; default: directionString = "This camera could be pointing in a number of directions for operational reasons."; break; } mRootView.findViewById(R.id.direction).setVisibility(View.VISIBLE); ((TextView) mRootView.findViewById(R.id.direction)).setText(directionString); } else { mRootView.findViewById(R.id.direction).setVisibility(View.GONE); } } }); return mRootView; }
From source file:gov.wa.wsdot.android.wsdot.ui.FerriesRouteSchedulesDayDeparturesFragment.java
@SuppressWarnings("deprecation") @Override/*from w ww . j a v a 2 s . c om*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Typeface tfb = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Roboto-Bold.ttf"); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_list_with_swipe_refresh, null); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorScheme(17170451, // android.R.color.holo_blue_bright 17170452, // android.R.color.holo_green_light 17170456, // android.R.color.holo_orange_light 17170454); // android.R.color.holo_red_light) mHeaderView = inflater.inflate(R.layout.list_item_departure_times_header, null); TextView departing_title = (TextView) mHeaderView.findViewById(R.id.departing_title); departing_title.setTypeface(tfb); TextView arriving_title = (TextView) mHeaderView.findViewById(R.id.arriving_title); arriving_title.setTypeface(tfb); mEmptyView = root.findViewById(R.id.empty_list_view); return root; }
From source file:gov.wa.wsdot.android.wsdot.ui.trafficmap.socialmedia.blog.BlogFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_list_with_swipe_refresh, null); mRecyclerView = root.findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new BlogItemAdapter(null); mRecyclerView.setAdapter(mAdapter);/*from ww w . ja v a 2 s. c o m*/ // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light); mEmptyView = root.findViewById(R.id.empty_list_view); viewModel = ViewModelProviders.of(this, viewModelFactory).get(BlogViewModel.class); viewModel.getResourceStatus().observe(this, resourceStatus -> { if (resourceStatus != null) { switch (resourceStatus.status) { case LOADING: swipeRefreshLayout.setRefreshing(true); break; case SUCCESS: swipeRefreshLayout.setRefreshing(false); break; case ERROR: swipeRefreshLayout.setRefreshing(false); TextView t = (TextView) mEmptyView; t.setText(R.string.no_connection); mEmptyView.setVisibility(View.VISIBLE); Toast.makeText(getContext(), "connection error", Toast.LENGTH_SHORT).show(); } } }); viewModel.getBlogPosts().observe(this, blogItems -> { if (blogItems != null) { mEmptyView.setVisibility(View.GONE); if (!blogItems.isEmpty()) { mAdapter.setData(blogItems); } else { TextView t = (TextView) mEmptyView; t.setText("blog unavailable."); mEmptyView.setVisibility(View.VISIBLE); } } }); viewModel.refresh(); return root; }
From source file:gov.wa.wsdot.android.wsdot.ui.trafficmap.socialmedia.youtube.YouTubeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_list_with_swipe_refresh, null); mRecyclerView = root.findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new VideoItemAdapter(null); mRecyclerView.setAdapter(mAdapter);//from w w w.j a va 2s .c om // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light); mEmptyView = root.findViewById(R.id.empty_list_view); viewModel = ViewModelProviders.of(this, viewModelFactory).get(YouTubeViewModel.class); viewModel.getResourceStatus().observe(this, resourceStatus -> { if (resourceStatus != null) { switch (resourceStatus.status) { case LOADING: swipeRefreshLayout.setRefreshing(true); break; case SUCCESS: swipeRefreshLayout.setRefreshing(false); break; case ERROR: swipeRefreshLayout.setRefreshing(false); TextView t = (TextView) mEmptyView; t.setText(R.string.no_connection); mEmptyView.setVisibility(View.VISIBLE); Toast.makeText(getContext(), "connection error", Toast.LENGTH_SHORT).show(); } } }); viewModel.getYouTubePosts().observe(this, youTubeItems -> { if (youTubeItems != null) { mEmptyView.setVisibility(View.GONE); if (!youTubeItems.isEmpty()) { mAdapter.setData(youTubeItems); } else { TextView t = (TextView) mEmptyView; t.setText("posts unavailable."); mEmptyView.setVisibility(View.VISIBLE); } } }); viewModel.refresh(); return root; }
From source file:gov.wa.wsdot.android.wsdot.ui.trafficmap.news.NewsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_list_with_swipe_refresh, null); mRecyclerView = root.findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new NewsItemAdapter(null); mRecyclerView.setAdapter(mAdapter);/*from ww w .ja v a 2 s . c o m*/ mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity())); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light); mEmptyView = root.findViewById(R.id.empty_list_view); viewModel = ViewModelProviders.of(this, viewModelFactory).get(NewsViewModel.class); viewModel.getResourceStatus().observe(this, resourceStatus -> { if (resourceStatus != null) { switch (resourceStatus.status) { case LOADING: swipeRefreshLayout.setRefreshing(true); break; case SUCCESS: swipeRefreshLayout.setRefreshing(false); break; case ERROR: swipeRefreshLayout.setRefreshing(false); TextView t = (TextView) mEmptyView; t.setText(R.string.no_connection); mEmptyView.setVisibility(View.VISIBLE); Toast.makeText(getContext(), "connection error", Toast.LENGTH_SHORT).show(); } } }); viewModel.getNewsItems().observe(this, newsItemValues -> { if (newsItemValues != null) { mEmptyView.setVisibility(View.GONE); mAdapter.setData(newsItemValues); } }); viewModel.refresh(); return root; }
From source file:gov.wa.wsdot.android.wsdot.ui.camera.CameraListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Bundle args = getActivity().getIntent().getExtras(); cameraIds = args.getIntArray("cameraIds"); cameraUrls = args.getStringArray("cameraUrls"); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_with_spinner, null); mRecyclerView = (RecyclerView) root.findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new CameraGroupImageAdapter(getActivity(), null); mRecyclerView.setAdapter(mAdapter);/*from w w w .j ava2 s. com*/ mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity())); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mLoadingSpinner = root.findViewById(R.id.loading_spinner); mEmptyView = root.findViewById(R.id.empty_list_view); return root; }
From source file:gov.wa.wsdot.android.wsdot.ui.trafficmap.socialmedia.facebook.FacebookFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_list_with_swipe_refresh, null); mRecyclerView = root.findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new FacebookItemAdapter(null); mRecyclerView.setAdapter(mAdapter);/*from ww w . j a v a 2s . co m*/ mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity())); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light); mEmptyView = root.findViewById(R.id.empty_list_view); viewModel = ViewModelProviders.of(this, viewModelFactory).get(FacebookViewModel.class); viewModel.getResourceStatus().observe(this, resourceStatus -> { if (resourceStatus != null) { switch (resourceStatus.status) { case LOADING: swipeRefreshLayout.setRefreshing(true); break; case SUCCESS: swipeRefreshLayout.setRefreshing(false); break; case ERROR: swipeRefreshLayout.setRefreshing(false); TextView t = (TextView) mEmptyView; t.setText(R.string.no_connection); mEmptyView.setVisibility(View.VISIBLE); Toast.makeText(getContext(), "connection error", Toast.LENGTH_SHORT).show(); } } }); viewModel.getFacebookPosts().observe(this, facebookItems -> { if (facebookItems != null) { mEmptyView.setVisibility(View.GONE); if (!facebookItems.isEmpty()) { mAdapter.setData(facebookItems); } else { TextView t = (TextView) mEmptyView; t.setText("posts unavailable."); mEmptyView.setVisibility(View.VISIBLE); } } }); viewModel.refresh(); return root; }
From source file:gov.wa.wsdot.android.wsdot.ui.trafficmap.expresslanes.SeattleExpressLanesFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_list_with_swipe_refresh, null); mRecyclerView = root.findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new ItemAdapter(null); mRecyclerView.setAdapter(mAdapter);//from ww w .j a va 2s . c o m mRecyclerView.addItemDecoration(new DividerNoBottom(getActivity())); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); swipeRefreshLayout = root.findViewById(R.id.swipe_container); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light, R.color.holo_orange_light, R.color.holo_red_light); mEmptyView = root.findViewById(R.id.empty_list_view); routeImage.put(5, R.drawable.ic_list_i5); routeImage.put(90, R.drawable.ic_list_i90); viewModel = ViewModelProviders.of(this, viewModelFactory).get(ExpressLanesViewModel.class); viewModel.getResourceStatus().observe(this, resourceStatus -> { if (resourceStatus != null) { switch (resourceStatus.status) { case LOADING: swipeRefreshLayout.setRefreshing(true); break; case SUCCESS: swipeRefreshLayout.setRefreshing(false); break; case ERROR: swipeRefreshLayout.setRefreshing(false); TextView t = (TextView) mEmptyView; t.setText(R.string.no_connection); mEmptyView.setVisibility(View.VISIBLE); Toast.makeText(getContext(), "connection error", Toast.LENGTH_SHORT).show(); } } }); viewModel.getExpressLanesStatus().observe(this, expressLaneItems -> { if (expressLaneItems != null) { mEmptyView.setVisibility(View.GONE); mAdapter.setData(expressLaneItems); } }); viewModel.refresh(); return root; }