Java Code Examples for android.databinding.DataBindingUtil#setContentView()

The following examples show how to use android.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: MyDetailsActivity.java    From Studio with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestManager = Glide.with(this);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_user_details);
    setSupportActionBar(binding.toolbar);
    setHasHomeButton();
    api = App.from(this).createApi(Api.class);
    pd = new ProgressDialog(this);

    user = getIntent().getParcelableExtra(KEY_USER);
    binding.setUser(user);

    setAsCurrentUser();
    setRxClick(binding.ivPicture)
            .subscribe(new Action1<ViewClickEvent>() {
                @Override
                public void call(ViewClickEvent viewClickEvent) {
                    startActivity(new Intent(MyDetailsActivity.this, PictureActivity.class)
                            .putExtra(PictureActivity.KEY_IMAGE_URL, user.imgurl));
                }
            });

}
 
Example 2
Source File: MyAccountInfo.java    From mobikul-standalone-pos with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_my_account_info);
    setSupportActionBar(binding.toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    DataBaseController.getInstanse().getAdminData(this, new DataBaseCallBack() {
        @Override
        public void onSuccess(Object responseData, String successMsg) {
            binding.setData((Administrator) responseData);
            binding.setFirstName(((Administrator) responseData).getFirstName());
            binding.setLastName(((Administrator) responseData).getLastName());
        }

        @Override
        public void onFailure(int errorCode, String errorMsg) {
            Toast.makeText(MyAccountInfo.this, errorMsg + "", Toast.LENGTH_SHORT).show();
        }
    });
    binding.setHandler(new MyAccountInfoHandler(this));
}
 
Example 3
Source File: PublishGroupChatProfilePictureActivity.java    From Conversations with GNU General Public License v3.0 6 votes vote down vote up
@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 4
Source File: SearchActivity.java    From Villains-and-Heroes with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mBinding = DataBindingUtil.setContentView(this, R.layout.activity_search);
    setSupportActionBar(mBinding.toolbar);
    //noinspection ConstantConditions
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mBinding.search.setIconified(false);
    mBinding.search.setOnQueryTextListener(this);
    mBinding.search.setOnCloseListener(this);

    mBinding.recycler.setLayoutManager(new LinearLayoutManager(this));
    mBinding.recycler.setHasFixedSize(true);
    mBinding.recycler.setAdapter(mSearchAdapter = new CharacterAdapter(R.layout.item_list_search, this, null));

    if (savedInstanceState == null) {
        mPresenter = new SearchPresenter();
    } else {
        mPresenter = (SearchPresenter) getLastCustomNonConfigurationInstance();
    }
    mPresenter.attachView(this);
}
 
Example 5
Source File: SearchDebounceActivity.java    From AndroidMVVMSample with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SearchDebounceBinding binding = DataBindingUtil.setContentView(this,
            R.layout.activity_search_debounce);

    adapter = new SearchAdapter(this);
    RecyclerViewUtils.setLinearManagerAndAdapter(binding.recyclerView, adapter);
    binding.recyclerView.addItemDecoration(DividerItemDecoration.newVertical(this,
            R.dimen.list_divider_height, R.color.divider_color));

    //===========================@TODO
    //1,避免EditText没改变一次就请求一次.
    //2,避免频繁的请求,多个导致结果顺序错乱,最终的结果也就有问题.

    // 但是对于第二个问题,也不能彻底的解决. 比如停止输入400毫秒后,
    // 那么肯定会开始请求Search接口, 但是用户又会输入新的关键字,
    // 这个时候上个请求还没有返回, 新的请求又去请求Search接口.
    // 这个时候有可能最后的一个请求返回, 第一个请求最后返回,导致搜索结果不是想要的.
    //===========================@TODO

    subscription = RxTextView.textChangeEvents(binding.inputSearch)
            .debounce(400, TimeUnit.MILLISECONDS)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(getSearchObserver());
}
 
Example 6
Source File: SettingsActivity.java    From PainlessMusicPlayer with Apache License 2.0 6 votes vote down vote up
private void initView() {
    viewModel.suppressDayNightWarnings =
            suppressDayNightWarnings != null && suppressDayNightWarnings;

    final ActivitySettingsBinding binding = DataBindingUtil
            .setContentView(this, R.layout.activity_settings);

    binding.setModel(viewModel);
    binding.executePendingBindings();

    binding.radioGroup.setOnCheckedChangeListener((radioGroup, id) ->
            presenter.onThemeClick(id)
    );

    binding.checkboxScrobble.setOnCheckedChangeListener(
            (cb, value) -> presenter.onScrobbleEnabled(value));
}
 
Example 7
Source File: UserListActivity.java    From Rocko-Android-Demos with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

	DataBindingUtil.setContentView(this, R.layout.user_list_activity);
}
 
Example 8
Source File: ImportBackupActivity.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
    this.mTheme = ThemeHelper.find(this);
    setTheme(this.mTheme);
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_import_backup);
    setSupportActionBar((Toolbar) binding.toolbar);
    setLoadingState(savedInstanceState != null && savedInstanceState.getBoolean("loading_state", false));
    this.backupFileAdapter = new BackupFileAdapter();
    this.binding.list.setAdapter(this.backupFileAdapter);
    this.backupFileAdapter.setOnItemClickedListener(this);
}
 
Example 9
Source File: Checkout.java    From mobikul-standalone-pos with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    checkoutBinding = DataBindingUtil.setContentView(this, R.layout.activity_checkout);
    setSupportActionBar(checkoutBinding.toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    if (getIntent().getExtras().containsKey("cartData")) {
        cartData = (CartModel) getIntent().getExtras().getSerializable("cartData");
        checkoutBinding.setData(cartData);
    }
    checkoutBinding.setVisibility(AppSharedPref.isCashEnabled(this, true));
    checkoutBinding.setHandler(new CheckoutHandler(this));
    checkoutBinding.setHasReturn(AppSharedPref.isReturnCart(this));
}
 
Example 10
Source File: ClassifiesShowActivity.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mBinding = DataBindingUtil.setContentView(this, R.layout.activity_classifies_show);
    initUrl();
    setToolBar();
    initFAB();
    initRecyclerView();
}
 
Example 11
Source File: SimpleActivityH.java    From AndroidAgeraTutorial with Apache License 2.0 5 votes vote down vote up
@Override
public void init(Bundle savedInstanceState) {

    mBinding = DataBindingUtil.setContentView(this, R.layout.activity_agera_reservoir);
    setUpRepository();
    mBinding.setObservable(mReservoir);
}
 
Example 12
Source File: ClickCountActivity.java    From AndroidMvvm with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActivityClickCountBinding binding =
            DataBindingUtil.setContentView(this, R.layout.activity_click_count);
    binding.setViewModel(clickCountViewModel);
    ButterKnife.bind(this);
}
 
Example 13
Source File: AddDeviceActivity.java    From device-database with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_add_device);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.inflateMenu(R.menu.activity_add_device);
}
 
Example 14
Source File: MainActivity.java    From priority-job-queue with MIT License 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);

    setSupportActionBar(mBinding.toolbar);

    mBinding.options.setOnCheckedChangeListener(this);
    mBinding.searchFab.setOnClickListener(this);

    mBinding.setSelectedOption(mBinding.options.getCheckedRadioButtonId());
}
 
Example 15
Source File: SearchedSessionsActivity.java    From droidkaigi2016 with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_searched_sessions);
    getComponent().inject(this);

    SearchGroup searchGroup = Parcels.unwrap(getIntent().getParcelableExtra(SearchGroup.class.getSimpleName()));

    initToolbar(searchGroup);
    AppUtil.setTaskDescription(this, searchGroup.getName(), AppUtil.getThemeColorPrimary(this));

    if(savedInstanceState == null) {
        replaceFragment(SearchedSessionsFragment.newInstance(searchGroup));
    }
}
 
Example 16
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_logcat);

    LogLine.isScrubberEnabled = PreferenceHelper.isScrubberEnabled(this);

    handleShortcuts(getIntent().getStringExtra("shortcut_action"));

    mHandler = new Handler(Looper.getMainLooper());

    binding.fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogHelper.stopRecordingLog(LogcatActivity.this);
        }
    });

    binding.list.setLayoutManager(new LinearLayoutManager(this));

    binding.list.setItemAnimator(null);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar_actionbar));
    setTitle(R.string.logcat);

    mCollapsedMode = !PreferenceHelper.getExpandedByDefaultPreference(this);

    log.d("initial collapsed mode is %s", mCollapsedMode);

    mSearchSuggestionsAdapter = new SimpleCursorAdapter(this,
            R.layout.list_item_dropdown,
            null,
            new String[]{"suggestion"},
            new int[]{android.R.id.text1},
            CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

    setUpAdapter();
    updateBackgroundColor();
    runUpdatesIfNecessaryAndShowWelcomeMessage();
}
 
Example 17
Source File: MainActivity.java    From Animated-Vector-Drawables with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  DataBindingUtil.setContentView(this, R.layout.activity_main);
}
 
Example 18
Source File: XActivity.java    From XDroid-Databinding with MIT License 4 votes vote down vote up
public void bindUI(@LayoutRes int layoutResID) {
    binding = DataBindingUtil.setContentView(context, layoutResID);
}
 
Example 19
Source File: MainActivity.java    From data-binding-sample with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);

    final TitleAdapter adapter = new TitleAdapter(this);
    adapter.add(new Title("Simple Binding", new Action0() {
        @Override
        public void call() {
            startActivity(SimpleBindingActivity.createIntent(MainActivity.this));
        }
    }));
    adapter.add(new Title("Auto Update", new Action0() {
        @Override
        public void call() {
            startActivity(AutoUpdateBindingActivity.createIntent(MainActivity.this));
        }
    }));
    adapter.add(new Title("View With IDs", new Action0() {
        @Override
        public void call() {
            startActivity(ViewsWithIDsActivity.createIntent(MainActivity.this));
        }
    }));
    adapter.add(new Title("MVVM Pattern", new Action0() {
        @Override
        public void call() {
            startActivity(MVVMActivity.createIntent(MainActivity.this));
        }
    }));
    adapter.add(new Title("Avoiding NullPointerException", new Action0() {
        @Override
        public void call() {
            startActivity(AvoidingNullPointerExceptionActivity.createIntent(MainActivity.this));
        }
    }));

    adapter.add(new Title("Include Data Binding Layout", new Action0() {
        @Override
        public void call() {
            startActivity(IncludeDataBindingLayoutActivity.createIntent(MainActivity.this));
        }
    }));
    adapter.add(new Title("Include Data Binding Layout (fix bug on rc1)", new Action0() {
        @Override
        public void call() {
            startActivity(IncludeLayoutActivity.createIntent(MainActivity.this));
        }
    }));

    adapter.add(new Title("Expression Language", new Action0() {
        @Override
        public void call() {
            startActivity(ExpressionLanguageActivity.createIntent(MainActivity.this));
        }
    }));
    adapter.add(new Title("Binding Adapter", new Action0() {
        @Override
        public void call() {
            startActivity(BindingAdapterActivity.createIntent(MainActivity.this));
        }
    }));

    //ListView landscape portrait

    binding.listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent,
                View view, int position, long id) {
            adapter.getItem(position).action.call();
        }
    });
    binding.listView.setAdapter(adapter);
}
 
Example 20
Source File: ShareLocationActivity.java    From Conversations with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	this.binding = DataBindingUtil.setContentView(this,R.layout.activity_share_location);
	setSupportActionBar((Toolbar) binding.toolbar);
	configureActionBar(getSupportActionBar());
	setupMapView(binding.map, LocationProvider.getGeoPoint(this));

	this.binding.cancelButton.setOnClickListener(view -> {
		setResult(RESULT_CANCELED);
		finish();
	});

	this.snackBar = Snackbar.make(this.binding.snackbarCoordinator, R.string.location_disabled, Snackbar.LENGTH_INDEFINITE);
	this.snackBar.setAction(R.string.enable, view -> {
		if (isLocationEnabledAndAllowed()) {
			updateUi();
		} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !hasLocationPermissions()) {
			requestPermissions(REQUEST_CODE_SNACKBAR_PRESSED);
		} else if (!isLocationEnabled()) {
			startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
		}
	});
	ThemeHelper.fix(this.snackBar);

	this.binding.shareButton.setOnClickListener(view -> {
		final Intent result = new Intent();

		if (marker_fixed_to_loc && myLoc != null) {
			result.putExtra("latitude", myLoc.getLatitude());
			result.putExtra("longitude", myLoc.getLongitude());
			result.putExtra("altitude", myLoc.getAltitude());
			result.putExtra("accuracy", (int) myLoc.getAccuracy());
		} else {
			final IGeoPoint markerPoint = this.binding.map.getMapCenter();
			result.putExtra("latitude", markerPoint.getLatitude());
			result.putExtra("longitude", markerPoint.getLongitude());
		}

		setResult(RESULT_OK, result);
		finish();
	});

	this.marker_fixed_to_loc = isLocationEnabledAndAllowed();

	this.binding.fab.setOnClickListener(view -> {
		if (!marker_fixed_to_loc) {
			if (!isLocationEnabled()) {
				startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
			} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
				requestPermissions(REQUEST_CODE_FAB_PRESSED);
			}
		}
		toggleFixedLocation();
	});
}