Skip to content

Commit

Permalink
Use view binding in TagListActivity
Browse files Browse the repository at this point in the history
Closes: #441
  • Loading branch information
ghusta committed Jan 17, 2025
1 parent 33d6c09 commit 925c826
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import fr.husta.android.dockersearch.databinding.ActivityTaglistBinding;
import fr.husta.android.dockersearch.databinding.DialogWarningTaglistBinding;
import fr.husta.android.dockersearch.docker.DockerRegistryClient;
import fr.husta.android.dockersearch.docker.model.RepositoryTagV2;
import fr.husta.android.dockersearch.listadapter.DockerTagListAdapter;
Expand All @@ -41,6 +43,9 @@ public class TagListActivity extends AppCompatActivity

public static final String DATA_IMG_NAME = "DATA_IMG_NAME";

private ActivityTaglistBinding binding;
private DialogWarningTaglistBinding dialogWarningTaglistBinding;

private DockerTagListAdapter dockerTagListAdapter;

private ListView listView;
Expand All @@ -60,7 +65,9 @@ protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Log.d("MAIN_DEBUG", "onCreate : " + this.getLocalClassName());
setContentView(R.layout.activity_taglist);
binding = ActivityTaglistBinding.inflate(getLayoutInflater());
dialogWarningTaglistBinding = DialogWarningTaglistBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());

Intent intent = getIntent();
imageName = intent.getStringExtra(DATA_IMG_NAME);
Expand All @@ -80,8 +87,8 @@ protected void onCreate(Bundle savedInstanceState)
progressBar.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressBar.setMessage(getString(R.string.msg_searching));

listView = findViewById(R.id.tags_listview);
fabNextPage = findViewById(R.id.fab_tags_next_page);
listView = binding.tagsListview;
fabNextPage = binding.fabTagsNextPage;
fabNextPage.setOnClickListener(view -> loadNextPage(view));

dockerTagListAdapter = new DockerTagListAdapter(TagListActivity.this, new ArrayList<>());
Expand All @@ -100,7 +107,7 @@ protected void onCreate(Bundle savedInstanceState)
.show();
});

SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.swipe_refresh_tags);
SwipeRefreshLayout swipeRefreshLayout = binding.swipeRefreshTags;
swipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary, R.color.colorSecondary);
swipeRefreshLayout.setOnRefreshListener(this);

Expand Down Expand Up @@ -208,9 +215,9 @@ public boolean onOptionsItemSelected(MenuItem item)
public void clickWarning(MenuItem item)
{
// Inflate the about message contents
View messageView = getLayoutInflater().inflate(R.layout.dialog_warning_taglist, null, false);
View messageView = dialogWarningTaglistBinding.getRoot();

TextView textView = messageView.findViewById(R.id.txt_warning_taglist);
TextView textView = dialogWarningTaglistBinding.txtWarningTaglist;
textView.setText(
"Tag list may not be up to date. \n" +
"See bug #687 ( https://github.com/docker/hub-feedback/issues/687 )");
Expand All @@ -234,7 +241,7 @@ public void loadNextPage(View view)
@Override
public void onRefresh()
{
SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.swipe_refresh_tags);
SwipeRefreshLayout swipeRefreshLayout = binding.swipeRefreshTags;
swipeRefreshLayout.setRefreshing(false);
dockerTagListAdapter.clear();
requestTagsList(imageName, 1);
Expand Down

0 comments on commit 925c826

Please sign in to comment.