Java Code Examples for androidx.databinding.DataBindingUtil#setContentView()
The following examples show how to use
androidx.databinding.DataBindingUtil#setContentView() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LibraryActivity.java From Jockey with Apache License 2.0 | 6 votes |
@Override protected void onCreateLayout(@Nullable Bundle savedInstanceState) { super.onCreateLayout(savedInstanceState); ViewGroup contentViewContainer = findViewById(android.R.id.content); View root = contentViewContainer.getChildAt(0); contentViewContainer.removeAllViews(); mBinding = DataBindingUtil.setContentView(this, R.layout.activity_library); ViewGroup contentContainer = findViewById(R.id.library_content_container); contentContainer.addView(root); mBinding.libraryDrawerNavigationView.setNavigationItemSelectedListener(item -> { mBinding.libraryDrawerLayout.closeDrawers(); onNavigationItemSelected(item.getItemId()); return true; }); }
Example 2
Source File: MediaBrowserActivity.java From Pix-Art-Messenger with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { this.mSavedInstanceAccount = savedInstanceState.getString("account"); this.mSavedInstanceJid = savedInstanceState.getString("jid"); } this.binding = DataBindingUtil.setContentView(this, R.layout.activity_media_browser); setSupportActionBar((Toolbar) binding.toolbar); configureActionBar(getSupportActionBar()); mMediaAdapter = new MediaAdapter(this, R.dimen.media_size); this.binding.media.setAdapter(mMediaAdapter); GridManager.setupLayoutManager(this, this.binding.media, R.dimen.browser_media_size); this.binding.noMedia.setVisibility(View.GONE); this.binding.progressbar.setVisibility(View.VISIBLE); this.OnlyImagesVideos = getPreferences().getBoolean("show_videos_images_only", this.getResources().getBoolean(R.bool.show_videos_images_only)); }
Example 3
Source File: MainActivity.java From changelog with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ---------------------------------------- // OPTIONAL GLOBAL SETUP // should be done ONCE only, preferable in a custom application class! // ---------------------------------------- // register a custom tag ChangelogSetup.get().registerTag(new MyCustomXMLTag()); // --------- // Views... // --------- mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main); disableEnableControls(false, mBinding.cvCustomFilter); mBinding.rgCustomFilter.setOnCheckedChangeListener((group, checkedId) -> { disableEnableControls(checkedId != R.id.rbAll, mBinding.cvCustomFilter); }); mBinding.btShowChangelog.setOnClickListener(view -> { showChangelog(); }); }
Example 4
Source File: PublishGroupChatProfilePictureActivity.java From Pix-Art-Messenger with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_publish_profile_picture); setSupportActionBar((Toolbar) this.binding.toolbar); configureActionBar(getSupportActionBar()); this.binding.cancelButton.setOnClickListener((v) -> this.finish()); this.binding.secondaryHint.setVisibility(View.GONE); this.binding.accountImage.setOnClickListener((v) -> PublishProfilePictureActivity.chooseAvatar(this)); Intent intent = getIntent(); String uuid = intent == null ? null : intent.getStringExtra("uuid"); if (uuid != null) { pendingConversationUuid.push(uuid); } this.binding.publishButton.setEnabled(uri != null); this.binding.publishButton.setOnClickListener(this::publish); }
Example 5
Source File: AllgroTestActivity.java From ans-android-sdk with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDataBinding = DataBindingUtil.setContentView(this, R.layout.activity_test_allgro); mDataBinding.viewPager.setAdapter(adapter);//viewPager设置上适配器 mDataBinding.viewPager.addOnPageChangeListener(this);//给ViewPager设置滑动监听,目的是为了显示Fragment mDataBinding.btn1.setSelected(true);//首次进入默认选中第一个 //下方btn设置监听,点击时切换页面 mDataBinding.btn0.setOnClickListener(this); mDataBinding.btn1.setOnClickListener(this); mDataBinding.btn2.setOnClickListener(this); mDataBinding.btn3.setOnClickListener(this); mDataBinding.setPageInfo(this); }
Example 6
Source File: LoginActivity.java From shinny-futures-android with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mBinding = DataBindingUtil.setContentView(this, R.layout.activity_login); initData(); initEvent(); checkResponsibility(); checkPermissions(); initBrokerAccount(); registerBroaderCast(); }
Example 7
Source File: MoodleAssignmentsActivity.java From ETSMobile-Android2 with Apache License 2.0 | 5 votes |
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = DataBindingUtil.setContentView(this, R.layout.activity_moodle_assignments); binding.setLoading(true); setUpTitleBar(); assignmentsElv = findViewById(R.id.assignments_elv); loadingView = findViewById(R.id.loading_view); openAssignmentFab = findViewById(R.id.open_assignment_fab); ProgressBar progressBar = findViewById(R.id.progress_bar); progressBar.getIndeterminateDrawable().setColorFilter(ContextCompat.getColor(this, R.color.ets_red), android.graphics.PorterDuff.Mode.SRC_IN); subscribeUIList(); subscribeUISelectedAssignment(); setUpBottomSheet(); if (savedInstanceState != null && savedInstanceState.getBoolean(SHOW_BS_KEY)) { MoodleAssignment selectedAssignment = moodleViewModel.getSelectedAssignment().getValue(); if (selectedAssignment != null) { displaySelectedAssignment(selectedAssignment); openAssignmentFab.show(); } } }
Example 8
Source File: DetailActivity.java From android-popular-movies-app with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDetailBinding = DataBindingUtil.setContentView(this, R.layout.activity_detail); // Get the movie data from the MainActivity. The movie data includes the movie id, original title, // title, poster path, overview, vote average, release date, and backdrop path. Intent intent = getIntent(); if (intent != null) { if (intent.hasExtra(EXTRA_MOVIE)) { Bundle b = intent.getBundleExtra(EXTRA_MOVIE); mMovie = b.getParcelable(EXTRA_MOVIE); } } // Get the MovieDatabase instance mDb = MovieDatabase.getInstance(getApplicationContext()); // Check if the movie is in the favorites collection or not mIsInFavorites = isInFavoritesCollection(); // Setup the UI setupUI(); if (savedInstanceState != null) { mDetailBinding.pbDetailLoadingIndicator.setVisibility(View.GONE); String resultRuntime = savedInstanceState.getString(RESULTS_RUNTIME); String resultReleaseYear = savedInstanceState.getString(RESULTS_RELEASE_YEAR); String resultGenre = savedInstanceState.getString(RESULTS_GENRE); mDetailBinding.tvRuntime.setText(resultRuntime); mDetailBinding.tvReleaseYear.setText(resultReleaseYear); mDetailBinding.tvGenre.setText(resultGenre); } }
Example 9
Source File: ProgramStageSelectionActivity.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { programId = getIntent().getStringExtra("PROGRAM_UID"); enrollmentId = getIntent().getStringExtra("ENROLLMENT_UID"); String eventCreationType = getIntent().getStringExtra(EVENT_CREATION_TYPE); ((App) getApplicationContext()).userComponent().plus(new ProgramStageSelectionModule(this, programId, enrollmentId, eventCreationType)).inject(this); super.onCreate(savedInstanceState); binding = DataBindingUtil.setContentView(this, R.layout.activity_program_stage_selection); binding.setPresenter(presenter); adapter = new ProgramStageSelectionAdapter(presenter); binding.recyclerView.setAdapter(adapter); }
Example 10
Source File: SecondActivity.java From Snake with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); dataBinding = DataBindingUtil.setContentView(this, R.layout.activity_second); dataBinding.setOnNavigateUpListener(() -> finish()); dataBinding.setLifecycleOwner(this); dataBinding.setTitle(SecondActivity.class.getSimpleName()); }
Example 11
Source File: BaseActivity.java From Pixiv-Shaft with MIT License | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mLayoutID = initLayout(); mContext = this; mActivity = this; Intent intent = getIntent(); if (intent != null) { Bundle bundle = intent.getExtras(); if (bundle != null) { initBundle(bundle); } } if (hideStatusBar()) { getWindow().setStatusBarColor(Color.TRANSPARENT); getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); } baseBind = DataBindingUtil.setContentView(mActivity, mLayoutID); BarUtils.setNavBarColor(mActivity, getResources().getColor(R.color.trans)); initView(); initData(); }
Example 12
Source File: VideoTrimmerActivity.java From Android-Video-Trimmer with Apache License 2.0 | 5 votes |
@Override public void initUI() { mBinding = DataBindingUtil.setContentView(this, R.layout.activity_video_trim); Bundle bd = getIntent().getExtras(); String path = ""; if (bd != null) path = bd.getString(VIDEO_PATH_KEY); if (mBinding.trimmerView != null) { mBinding.trimmerView.setOnTrimVideoListener(this); mBinding.trimmerView.initVideoByURI(Uri.parse(path)); } }
Example 13
Source File: FirstActivity.java From Snake with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); dataBinding = DataBindingUtil.setContentView(this, R.layout.activity_first); dataBinding.setLifecycleOwner(this); dataBinding.setVm(viewModel); dataBinding.setOnNavigateUpListener(() -> { finish(); }); dataBinding.setTitle(FirstActivity.class.getSimpleName()); setupDragToCloseStatus(); setupNavigation(); }
Example 14
Source File: ReservedValueActivity.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((App) getApplicationContext()).userComponent().plus(new ReservedValueModule(this)).inject(this); reservedBinding = DataBindingUtil.setContentView(this, R.layout.activity_reserved_value); reservedBinding.setVariable(BR.presenter, presenter); adapter = new ReservedValueAdapter(presenter); }
Example 15
Source File: ViewModelHelper.java From AndroidViewModel with Apache License 2.0 | 5 votes |
public void performBinding(@NonNull final IView bindingView) { // skip if already create if (mBinding != null) { return; } // get ViewModelBinding config final ViewModelBindingConfig viewModelConfig = bindingView.getViewModelBindingConfig(); // if fragment not providing ViewModelBindingConfig, do not perform binding operations if (viewModelConfig == null) { return; } // perform Data Binding initialization final ViewDataBinding viewDataBinding; if (bindingView instanceof Activity) { viewDataBinding = DataBindingUtil.setContentView(((Activity) bindingView), viewModelConfig.getLayoutResource()); } else if (bindingView instanceof Fragment) { viewDataBinding = DataBindingUtil.inflate(LayoutInflater.from(viewModelConfig.getContext()), viewModelConfig.getLayoutResource(), null, false); } else { throw new IllegalArgumentException("View must be an instance of Activity or Fragment (support-v4)."); } // bind all together if (!viewDataBinding.setVariable(viewModelConfig.getViewModelVariableName(), getViewModel())) { throw new IllegalArgumentException("Binding variable wasn't set successfully. Probably viewModelVariableName of your " + "ViewModelBindingConfig of " + bindingView.getClass().getSimpleName() + " doesn't match any variable in " + viewDataBinding.getClass().getSimpleName()); } mBinding = viewDataBinding; }
Example 16
Source File: MainActivity.java From earth with GNU General Public License v3.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= 19) { SystemUiVisibilityUtil.addFlags(getWindow().getDecorView(), View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); } binding = DataBindingUtil.setContentView(this, R.layout.main_activity); setTitle(null); setSupportActionBar(binding.toolbar.toolbar); binding.setVm(vm); binding.setAccelerated(BuildConfig.USE_OXO_SERVER); binding.settingsPanel.editMode.setOnClickListener(v -> animateInEditMode()); binding.scaling.apply.setOnClickListener(v -> animateOutEditMode()); binding.scaling.apply.setOnLongClickListener(v -> restoreScalingDefault()); binding.action.done.setOnClickListener(v -> saveAndHideSettings()); binding.action.done.setOnLongClickListener(v -> openAdvancedSettings()); binding.earth.scalingLayout.setOnClickListener(v -> { if (!isSettingsShown()) { toggleImmersiveMode(); } }); pref = PreferenceManager.getDefaultSharedPreferences(this); loadSettings(); loadEarth(); final ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); if (NetworkStateUtil.shouldConsiderSavingData(cm)) { Toast.makeText(this, R.string.data_saver_considered, Toast.LENGTH_SHORT).show(); } }
Example 17
Source File: MainActivity.java From android-popular-movies-app with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mMainBinding = DataBindingUtil.setContentView(this, R.layout.activity_main); // Set the LayoutManager to the RecyclerView and create MoviePagedListAdapter and FavoriteAdapter initAdapter(); // Check if savedInstance is null not to recreate a dialog when rotating if (savedInstanceState == null) { // Show a dialog when there is no internet connection showNetworkDialog(isOnline()); } // Get the sort criteria currently set in Preferences mSortCriteria = MoviePreferences.getPreferredSortCriteria(this); // Get the ViewModel from the factory setupViewModel(mSortCriteria); // Update the UI depending on the sort order updateUI(mSortCriteria); // Register MainActivity as an OnPreferenceChangedListener to receive a callback when a // SharedPreference has changed. Please note that we must unregister MainActivity as an // OnSharedPreferenceChanged listener in onDestroy to avoid any memory leaks. PreferenceManager.getDefaultSharedPreferences(this) .registerOnSharedPreferenceChangeListener(this); // Set the color scheme of the SwipeRefreshLayout and setup OnRefreshListener setSwipeRefreshLayout(); // Set column spacing to make each column have the same spacing setColumnSpacing(); if (savedInstanceState != null) { // Get the scroll position mSavedLayoutState = savedInstanceState.getParcelable(LAYOUT_MANAGER_STATE); // Restore the scroll position mMainBinding.rvMovie.getLayoutManager().onRestoreInstanceState(mSavedLayoutState); } // Initialize the Mobile Ads SDK and enable test ads setupTestAds(); }
Example 18
Source File: VideoSelectActivity.java From Android-Video-Trimmer with Apache License 2.0 | 4 votes |
@SuppressLint("CheckResult") @Override public void initUI() { mVideoLoadManager = new VideoLoadManager(); mVideoLoadManager.setLoader(new VideoCursorLoader()); mBinding = DataBindingUtil.setContentView(this, R.layout.activity_video_select); mCameraSurfaceViewLy = findViewById(R.id.layout_surface_view); mBinding.mBtnBack.setOnClickListener(this); RxPermissions rxPermissions = new RxPermissions(this); rxPermissions.request(Manifest.permission.READ_EXTERNAL_STORAGE).subscribe(granted -> { if (granted) { // Always true pre-M mVideoLoadManager.load(this, new SimpleCallback() { @Override public void success(Object obj) { if (mVideoSelectAdapter == null) { mVideoSelectAdapter = new VideoSelectAdapter(VideoSelectActivity.this, (Cursor) obj); } else { mVideoSelectAdapter.swapCursor((Cursor) obj); } if (mBinding.videoGridview.getAdapter() == null) { mBinding.videoGridview.setAdapter(mVideoSelectAdapter); } mVideoSelectAdapter.notifyDataSetChanged(); } }); } else { finish(); } }); if (rxPermissions.isGranted(Manifest.permission.CAMERA)) { initCameraPreview(); } else { mBinding.cameraPreviewLy.setVisibility(View.GONE); mBinding.openCameraPermissionLy.setVisibility(View.VISIBLE); mBinding.mOpenCameraPermission.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { rxPermissions.request(Manifest.permission.CAMERA).subscribe(granted -> { if (granted) { initCameraPreview(); } }); } }); } }
Example 19
Source File: LttrsActivity.java From lttrs-android with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = DataBindingUtil.setContentView(this, R.layout.activity_lttrs); final ViewModelProvider viewModelProvider = new ViewModelProvider( this, getDefaultViewModelProviderFactory() ); lttrsViewModel = viewModelProvider.get(LttrsViewModel.class); lttrsViewModel.getHasAccounts().observe(this, this::onHasAccountsChanged); setSupportActionBar(binding.toolbar); final NavController navController = Navigation.findNavController( this, R.id.nav_host_fragment ); binding.drawerLayout.addDrawerListener(this); labelListAdapter.setOnMailboxOverviewItemSelectedListener((label, currentlySelected) -> { binding.drawerLayout.closeDrawer(GravityCompat.START); if (currentlySelected) { return; } final boolean navigateToInbox = label.getRole() == Role.INBOX; if (navigateToInbox) { navController.navigate(LttrsNavigationDirections.actionToInbox()); } else if (label instanceof MailboxOverviewItem) { final MailboxOverviewItem mailbox = (MailboxOverviewItem) label; navController.navigate(LttrsNavigationDirections.actionToMailbox(mailbox.id)); } else if (label instanceof KeywordLabel) { final KeywordLabel keyword = (KeywordLabel) label; navController.navigate(LttrsNavigationDirections.actionToKeyword(keyword)); } else { throw new IllegalStateException(String.format("%s is an unsupported label", label.getClass())); } if (mSearchItem != null) { mSearchItem.collapseActionView(); } //currently unused should remain here in case we bring scrollable toolbar back binding.appBarLayout.setExpanded(true, false); }); binding.mailboxList.setAdapter(labelListAdapter); lttrsViewModel.getNavigatableLabels().observe(this, labelListAdapter::submitList); }
Example 20
Source File: ChangePasswordActivity.java From armadillo with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = DataBindingUtil.setContentView(this, R.layout.activity_change_password); getSupportActionBar().setTitle("Change Password"); }