// Path: app/src/main/java/com/steevsapps/idledaddy/listeners/GamePickedListener.java
// public interface GamePickedListener {
//     void onGamePicked(Game game);
//     void onGamesPicked(List<Game> games);
//     void onGameRemoved(Game game);
//     void onGameLongPressed(Game game);
// }
// 
// Path: app/src/main/java/com/steevsapps/idledaddy/steam/model/Game.java
// public class Game implements Comparable<Game>, Parcelable {
//     private final static String IMG_URL = "http://media.steampowered.com/steamcommunity/public/images/apps/%d/%s.jpg";
// 
//     @SerializedName("appid")
//     public int appId;
//     @SerializedName("name")
//     public String name;
//     @SerializedName("img_logo_url")
//     public String iconUrl;
//     @SerializedName("playtime_forever")
//     public float hoursPlayed;
//     @SerializedName("drops_remaining")
//     public int dropsRemaining;
// 
//     public Game(int appId, String name, float hoursPlayed, int dropsRemaining) {
//         this.appId = appId;
//         this.name = name;
//         this.iconUrl = "http://cdn.akamai.steamstatic.com/steam/apps/" + appId + "/header_292x136.jpg";
//         this.hoursPlayed = hoursPlayed;
//         this.dropsRemaining = dropsRemaining;
//     }
// 
//     private Game(Parcel parcel) {
//         appId = parcel.readInt();
//         name = parcel.readString();
//         iconUrl = parcel.readString();
//         hoursPlayed = parcel.readFloat();
//         dropsRemaining = parcel.readInt();
//     }
// 
//     @Override
//     public int compareTo(@NonNull Game game) {
//         if (hoursPlayed == game.hoursPlayed) {
//             return 0;
//         }
//         return hoursPlayed < game.hoursPlayed ? -1 : 1;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (obj == this) {
//             return true;
//         }
//         if (obj == null) {
//             return false;
//         }
//         if (obj.getClass() != getClass()) {
//             return false;
//         }
//         final Game otherGame = (Game) obj;
//         return otherGame.appId == appId;
//     }
// 
//     @Override
//     public int hashCode() {
//         // Start with a non-zero constant. Prime is preferred
//         int result = 17;
//         // Include a hash for each field
//         result = 31 * result + appId;
//         return result;
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel parcel, int i) {
//         parcel.writeInt(appId);
//         parcel.writeString(name);
//         parcel.writeString(iconUrl);
//         parcel.writeFloat(hoursPlayed);
//         parcel.writeInt(dropsRemaining);
//     }
// 
//     public final static Parcelable.Creator<Game> CREATOR = new Parcelable.Creator<Game>() {
//         @Override
//         public Game createFromParcel(Parcel parcel) {
//             return new Game(parcel);
//         }
// 
//         @Override
//         public Game[] newArray(int i) {
//             return new Game[i];
//         }
//     };
// }


import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import com.steevsapps.idledaddy.R;
import com.steevsapps.idledaddy.listeners.GamePickedListener;
import com.steevsapps.idledaddy.steam.model.Game;
        // Apply the adapter to the spinner
        spinner.setAdapter(adapter);

        return new AlertDialog.Builder(getActivity())
                .setTitle(R.string.idle_custom_app)
                .setView(view)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        switch (spinner.getSelectedItemPosition()) {
                            case TYPE_APPID:
                                idleHiddenApp();
                                break;
                            case TYPE_CUSTOM:
                                idleNonSteamApp();
                                break;
                        }
                    }
                })
                .setNegativeButton(android.R.string.cancel, null)
                .create();
    }

    private void idleHiddenApp() {
        final String text = customApp.getText().toString().trim();
        if (text.isEmpty()) {
            return;
        }
        try {
            final int appId = Integer.parseInt(text);
// Path: app/src/main/java/com/steevsapps/idledaddy/listeners/GamePickedListener.java
// public interface GamePickedListener {
//     void onGamePicked(Game game);
//     void onGamesPicked(List<Game> games);
//     void onGameRemoved(Game game);
//     void onGameLongPressed(Game game);
// }
// 
// Path: app/src/main/java/com/steevsapps/idledaddy/steam/model/Game.java
// public class Game implements Comparable<Game>, Parcelable {
//     private final static String IMG_URL = "http://media.steampowered.com/steamcommunity/public/images/apps/%d/%s.jpg";
// 
//     @SerializedName("appid")
//     public int appId;
//     @SerializedName("name")
//     public String name;
//     @SerializedName("img_logo_url")
//     public String iconUrl;
//     @SerializedName("playtime_forever")
//     public float hoursPlayed;
//     @SerializedName("drops_remaining")
//     public int dropsRemaining;
// 
//     public Game(int appId, String name, float hoursPlayed, int dropsRemaining) {
//         this.appId = appId;
//         this.name = name;
//         this.iconUrl = "http://cdn.akamai.steamstatic.com/steam/apps/" + appId + "/header_292x136.jpg";
//         this.hoursPlayed = hoursPlayed;
//         this.dropsRemaining = dropsRemaining;
//     }
// 
//     private Game(Parcel parcel) {
//         appId = parcel.readInt();
//         name = parcel.readString();
//         iconUrl = parcel.readString();
//         hoursPlayed = parcel.readFloat();
//         dropsRemaining = parcel.readInt();
//     }
// 
//     @Override
//     public int compareTo(@NonNull Game game) {
//         if (hoursPlayed == game.hoursPlayed) {
//             return 0;
//         }
//         return hoursPlayed < game.hoursPlayed ? -1 : 1;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (obj == this) {
//             return true;
//         }
//         if (obj == null) {
//             return false;
//         }
//         if (obj.getClass() != getClass()) {
//             return false;
//         }
//         final Game otherGame = (Game) obj;
//         return otherGame.appId == appId;
//     }
// 
//     @Override
//     public int hashCode() {
//         // Start with a non-zero constant. Prime is preferred
//         int result = 17;
//         // Include a hash for each field
//         result = 31 * result + appId;
//         return result;
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel parcel, int i) {
//         parcel.writeInt(appId);
//         parcel.writeString(name);
//         parcel.writeString(iconUrl);
//         parcel.writeFloat(hoursPlayed);
//         parcel.writeInt(dropsRemaining);
//     }
// 
//     public final static Parcelable.Creator<Game> CREATOR = new Parcelable.Creator<Game>() {
//         @Override
//         public Game createFromParcel(Parcel parcel) {
//             return new Game(parcel);
//         }
// 
//         @Override
//         public Game[] newArray(int i) {
//             return new Game[i];
//         }
//     };
// }


// Path: app/src/main/java/com/steevsapps/idledaddy/dialogs/CustomAppDialog.java
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import com.steevsapps.idledaddy.R;
import com.steevsapps.idledaddy.listeners.GamePickedListener;
import com.steevsapps.idledaddy.steam.model.Game;

        // Apply the adapter to the spinner
        spinner.setAdapter(adapter);

        return new AlertDialog.Builder(getActivity())
                .setTitle(R.string.idle_custom_app)
                .setView(view)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        switch (spinner.getSelectedItemPosition()) {
                            case TYPE_APPID:
                                idleHiddenApp();
                                break;
                            case TYPE_CUSTOM:
                                idleNonSteamApp();
                                break;
                        }
                    }
                })
                .setNegativeButton(android.R.string.cancel, null)
                .create();
    }

    private void idleHiddenApp() {
        final String text = customApp.getText().toString().trim();
        if (text.isEmpty()) {
            return;
        }
        try {
            final int appId = Integer.parseInt(text);
            final Game game = new Game(appId, getString(R.string.playing_unknown_app, appId), 0, 0);