Project

General

Profile

Download (3.47 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / objects / MainEntryList.java @ ceca1387

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.objects;
21

    
22
import org.distorted.main.R;
23

    
24
import java.util.ArrayList;
25

    
26
///////////////////////////////////////////////////////////////////////////////////////////////////
27

    
28
public class MainEntryList
29
{
30
  private final ArrayList<MainEntry> mList;
31
  private static MainEntryList mThis;
32

    
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34

    
35
  private MainEntryList()
36
    {
37
    mList = new ArrayList<>();
38

    
39
    int numObjects = RubikObjectList.getNumObjects();
40

    
41
    for(int i=0; i<numObjects; i++)
42
      {
43
      RubikObject object = RubikObjectList.getObject(i);
44

    
45
      if( object!=null )
46
        {
47
        MainEntry entry = new MainEntry(object);
48
        mList.add(entry);
49

    
50
        String name = object.getLowerName();
51

    
52
        if( name!=null && name.equals("ban4_3") )
53
          {
54
          MainEntry creator = new MainEntry(MainEntry.TYPE_CREATOR, R.drawable.plus);
55
          mList.add(creator);
56
          }
57
        }
58
      }
59
    }
60

    
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62

    
63
  public static MainEntryList getInstance()
64
    {
65
    if( mThis==null ) mThis = new MainEntryList();
66
    return mThis;
67
    }
68

    
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70

    
71
  public void addEntry(MainEntry entry)
72
    {
73
    mList.add(entry);
74
    }
75

    
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77

    
78
  public int getNumOfEntries()
79
    {
80
    return mList.size();
81
    }
82

    
83
///////////////////////////////////////////////////////////////////////////////////////////////////
84

    
85
  public MainEntry getEntry(int index)
86
    {
87
    return mList.get(index);
88
    }
89
}
(2-2/4)