coding-blocks / DigitalOceanApp

Admin Console for Digital Ocean
GNU General Public License v3.0
56 stars 75 forks source link

Fix: DropletCreateActivity crash - Fedora Atomic unhandled #103

Closed firefinchdev closed 6 years ago

firefinchdev commented 6 years ago

Fixes #102

codecov[bot] commented 6 years ago

Codecov Report

Merging #103 into master will decrease coverage by 0.05%. The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master    #103      +/-   ##
===========================================
- Coverage     26.65%   26.6%   -0.06%     
  Complexity       33      33              
===========================================
  Files            83      83              
  Lines          1883    1887       +4     
  Branches         93      93              
===========================================
  Hits            502     502              
- Misses         1343    1347       +4     
  Partials         38      38
Impacted Files Coverage Δ Complexity Δ
...in/tosc/digitaloceanapp/adapters/ImageAdapter.java 46.83% <0%> (-2.5%) 0 <0> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 039bb50...85744d8. Read the comment docs.

firefinchdev commented 6 years ago

screenshot_20180725-011652

4lch4 commented 6 years ago

In order to fix the CodeClimate issue, I'd recommend we do something like so:

public void selectImage(int position, ViewHolder holder) {
    String distro = imageList.get(position).getDistribution();
    int selectorImage = 0;

    if (distro.contains("CoreOS")) selectorImage = R.drawable.coreos_selected;
    else if (distro.contains("FreeBSD")) selectorImage = R.drawable.freebsd_selected;
    else if (distro.contains("Fedora")) selectorImage = R.drawable.fedora_selected;
    else if (distro.contains("Debian")) selectorImage = R.drawable.debian_selected;
    else if (distro.contains("CentOS")) selectorImage = R.drawable.centos_selected;
    else if (distro.contains("Ubuntu")) selectorImage = R.drawable.ubuntu_selected;

    holder.imageImage.setBackground(ContextCompat.getDrawable(context, selectorImage));
    Log.i("OnClick", imageList.get(position).getDistribution());
    holder.imageImage.setTag(true);
}

This way we can check for multiple variations of Fedora or Ubuntu w/out adding a bunch of case statements.