Skip to content

Commit

Permalink
Android: Display disc number instead of company if mulipart disc
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebola16 committed Jun 4, 2020
1 parent b3c705f commit 6d5a190
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
@@ -1,5 +1,6 @@
package org.dolphinemu.dolphinemu.adapters;

import android.content.Context;
import android.graphics.Rect;

import androidx.annotation.NonNull;
Expand All @@ -15,6 +16,7 @@
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.dialogs.GamePropertiesDialog;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.utils.PicassoUtils;
import org.dolphinemu.dolphinemu.viewholders.GameViewHolder;

Expand Down Expand Up @@ -68,11 +70,21 @@ public GameViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
@Override
public void onBindViewHolder(GameViewHolder holder, int position)
{
Context context = holder.itemView.getContext();
GameFile gameFile = mGameFiles.get(position);
PicassoUtils.loadGameCover(holder.imageScreenshot, gameFile);

holder.textGameTitle.setText(gameFile.getTitle());
holder.textCompany.setText(gameFile.getCompany());

if (GameFileCacheService.findSecondDisc(gameFile) != null)
{
holder.textGameCaption.setText(
context.getString(R.string.disc_number, GameFileCacheService.GetDiscNumber(gameFile) + 1));
}
else
{
holder.textGameCaption.setText(gameFile.getCompany());
}

holder.gameFile = gameFile;
}
Expand Down
Expand Up @@ -15,6 +15,7 @@
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.dialogs.GamePropertiesDialog;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.ui.platform.Platform;
import org.dolphinemu.dolphinemu.utils.PicassoUtils;
import org.dolphinemu.dolphinemu.viewholders.TvGameViewHolder;
Expand Down Expand Up @@ -46,13 +47,23 @@ public ViewHolder onCreateViewHolder(ViewGroup parent)
public void onBindViewHolder(ViewHolder viewHolder, Object item)
{
TvGameViewHolder holder = (TvGameViewHolder) viewHolder;
Context context = holder.cardParent.getContext();
GameFile gameFile = (GameFile) item;

holder.imageScreenshot.setImageDrawable(null);
PicassoUtils.loadGameCover(holder.imageScreenshot, gameFile);

holder.cardParent.setTitleText(gameFile.getTitle());
holder.cardParent.setContentText(gameFile.getCompany());

if (GameFileCacheService.findSecondDisc(gameFile) != null)
{
holder.cardParent.setContentText(
context.getString(R.string.disc_number, GameFileCacheService.GetDiscNumber(gameFile) + 1));
}
else
{
holder.cardParent.setContentText(gameFile.getCompany());
}

holder.gameFile = gameFile;

Expand All @@ -72,7 +83,6 @@ public void onBindViewHolder(ViewHolder viewHolder, Object item)
default:
throw new AssertionError("Not reachable.");
}
Context context = holder.cardParent.getContext();
Drawable background = ContextCompat.getDrawable(context, backgroundId);
holder.cardParent.setInfoAreaBackground(background);
holder.cardParent.setOnLongClickListener((view) ->
Expand Down
Expand Up @@ -86,6 +86,11 @@ public static GameFile findSecondDisc(GameFile game)
return matchWithoutRevision;
}

public static int GetDiscNumber(GameFile game)
{
return game.getDiscNumber();
}

public static boolean hasLoadedCache()
{
return hasLoadedCache.get();
Expand Down
Expand Up @@ -17,7 +17,7 @@ public class GameViewHolder extends RecyclerView.ViewHolder
{
public ImageView imageScreenshot;
public TextView textGameTitle;
public TextView textCompany;
public TextView textGameCaption;

public GameFile gameFile;

Expand All @@ -29,6 +29,6 @@ public GameViewHolder(View itemView)

imageScreenshot = itemView.findViewById(R.id.image_game_screen);
textGameTitle = itemView.findViewById(R.id.text_game_title);
textCompany = itemView.findViewById(R.id.text_company);
textGameCaption = itemView.findViewById(R.id.text_game_caption);
}
}
2 changes: 1 addition & 1 deletion Source/Android/app/src/main/res/layout/card_game.xml
Expand Up @@ -36,7 +36,7 @@
tools:text="The Legend of Zelda: The Wind Waker"/>

<TextView
android:id="@+id/text_company"
android:id="@+id/text_game_caption"
style="@android:style/TextAppearance.Material.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions Source/Android/app/src/main/res/values/strings.xml
Expand Up @@ -375,5 +375,6 @@
<string name="pitch">Total Pitch</string>
<string name="yaw">Total Yaw</string>
<string name="vertical_offset">Vertical Offset</string>
<string name="disc_number">Disc %1$d</string>

</resources>

0 comments on commit 6d5a190

Please sign in to comment.