mapbox-android-demo icon indicating copy to clipboard operation
mapbox-android-demo copied to clipboard

Refactor MainActivity adapter setup

Open tobrun opened this issue 8 years ago • 1 comments

We currently have a MainActivity#listItems method that generates all the required adapter items. Currently everything is hard coded in one method block. We should look into generating code for this instead.

tobrun avatar Apr 26 '17 08:04 tobrun

@tobrun , how do you envision improving this? MainActivity for reference

Anything else besides breaking things up into separate methods (seen below)? Or would that be enough/fine?

private void buildPlugins() {
    exampleItemModel.add(new ExampleItemModel(
      R.string.activity_plugins_traffic_plugin_title,
      R.string.activity_plugins_traffic_plugin_description,
      new Intent(MainActivity.this, TrafficPluginActivity.class),
      R.string.activity_plugins_traffic_plugin_url
    ));
    exampleItemModel.add(new ExampleItemModel(
      R.string.activity_plugins_building_plugin_title,
      R.string.activity_plugins_building_plugin_description,
      new Intent(MainActivity.this, BuildingPluginActivity.class),
      R.string.activity_plugins_building_plugin_url, true
    ));
    exampleItemModel.add(new ExampleItemModel(
      R.string.activity_plugins_location_plugin_title,
      R.string.activity_plugins_location_plugin_description,
      new Intent(MainActivity.this, LocationPluginActivity.class),
      R.string.activity_plugins_location_plugin_url, true
    ));
  }

and then in the switch/case statement 👇

case R.id.nav_plugins:
        buildPlugins();
        currentCategory = R.id.nav_plugins;
        break;

Do the same for all of the nav drawer example sections.

langsmith avatar Sep 21 '17 21:09 langsmith