Migrated CategoryDetailsActivity , MainActivity to View Binding (#5595)

* Butterknife to ViewBinding
* code fix to pass all tests
This commit is contained in:
Shashank Kumar 2024-03-20 05:51:51 +05:30 committed by GitHub
parent 23492ab11f
commit 8df0055a5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 116 additions and 116 deletions

View file

@ -1,69 +1,69 @@
package fr.free.nrw.commons.settings;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import androidx.appcompat.app.AppCompatDelegate;
import fr.free.nrw.commons.databinding.ActivitySettingsBinding;
import fr.free.nrw.commons.theme.BaseActivity;
/**
* allows the user to change the settings
*/
public class SettingsActivity extends BaseActivity {
private ActivitySettingsBinding binding;
private AppCompatDelegate settingsDelegate;
/**
* to be called when the activity starts
* @param savedInstanceState the previously saved state
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivitySettingsBinding.inflate(getLayoutInflater());
final View view = binding.getRoot();
setContentView(view);
setSupportActionBar(binding.toolbarBinding.toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
// Get an action bar
/**
* takes care of actions taken after the creation has happened
* @param savedInstanceState the saved state
*/
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
if (settingsDelegate == null) {
settingsDelegate = AppCompatDelegate.create(this, null);
}
settingsDelegate.onPostCreate(savedInstanceState);
}
@Override
public boolean onSupportNavigateUp() {
onBackPressed();
return true;
}
/**
* Handle action-bar clicks
* @param item the selected item
* @return true on success, false on failure
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
package fr.free.nrw.commons.settings;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import androidx.appcompat.app.AppCompatDelegate;
import fr.free.nrw.commons.databinding.ActivitySettingsBinding;
import fr.free.nrw.commons.theme.BaseActivity;
/**
* allows the user to change the settings
*/
public class SettingsActivity extends BaseActivity {
private ActivitySettingsBinding binding;
private AppCompatDelegate settingsDelegate;
/**
* to be called when the activity starts
* @param savedInstanceState the previously saved state
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivitySettingsBinding.inflate(getLayoutInflater());
final View view = binding.getRoot();
setContentView(view);
setSupportActionBar(binding.toolbarBinding.toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
// Get an action bar
/**
* takes care of actions taken after the creation has happened
* @param savedInstanceState the saved state
*/
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
if (settingsDelegate == null) {
settingsDelegate = AppCompatDelegate.create(this, null);
}
settingsDelegate.onPostCreate(savedInstanceState);
}
@Override
public boolean onSupportNavigateUp() {
onBackPressed();
return true;
}
/**
* Handle action-bar clicks
* @param item the selected item
* @return true on success, false on failure
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}