Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7519b7bc authored by Michael Bestas's avatar Michael Bestas
Browse files

DeskClock: Convert resource switch statements to if-else

Change-Id: I89df5b93719ac87cbc4cd9b9ceee45c72d941c4d
parent f64c5fc1
Loading
Loading
Loading
Loading
+22 −27
Original line number Diff line number Diff line
@@ -341,12 +341,11 @@ public final class ClockFragment extends DeskClockFragment {
        @Override
        public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            final View view = mInflater.inflate(viewType, parent, false);
            switch (viewType) {
                case WORLD_CLOCK:
            if (viewType == WORLD_CLOCK) {
                return new CityViewHolder(view);
                case MAIN_CLOCK:
            } else if (viewType == MAIN_CLOCK) {
                return new MainClockViewHolder(view);
                default:
            } else {
                throw new IllegalArgumentException("View type not recognized");
            }
        }
@@ -354,25 +353,21 @@ public final class ClockFragment extends DeskClockFragment {
        @Override
        public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
            final int viewType = getItemViewType(position);
            switch (viewType) {
                case WORLD_CLOCK:
            if (viewType == WORLD_CLOCK) {
                // Retrieve the city to bind.
                final City city;
                // If showing home clock, put it at the top
                if (mShowHomeClock && position == (mIsPortrait ? 1 : 0)) {
                    city = getHomeCity();
                } else {
                        final int positionAdjuster = (mIsPortrait ? 1 : 0)
                                + (mShowHomeClock ? 1 : 0);
                    final int positionAdjuster = (mIsPortrait ? 1 : 0) + (mShowHomeClock ? 1 : 0);
                    city = getCities().get(position - positionAdjuster);
                }
                ((CityViewHolder) holder).bind(mContext, city);
                    break;
                case MAIN_CLOCK:
            } else if (viewType == MAIN_CLOCK) {
                ((MainClockViewHolder) holder).bind(mContext, mDateFormat,
                        mDateFormatForAccessibility);
                    break;
                default:
            } else {
                throw new IllegalArgumentException("Unexpected view type: " + viewType);
            }
        }