29 |
29 |
{
|
30 |
30 |
public static class UpdateInfo
|
31 |
31 |
{
|
32 |
|
public final String mObjectName;
|
33 |
|
public final int mMinorVersion;
|
34 |
|
|
35 |
|
public UpdateInfo(String name,int version)
|
|
32 |
public final String mObjectShortName;
|
|
33 |
public final String mObjectLongName;
|
|
34 |
public final String mDescription;
|
|
35 |
public final int mObjectMinorVersion;
|
|
36 |
public final int mExtrasMinorVersion;
|
|
37 |
public final boolean mUpdateObject;
|
|
38 |
public final boolean mUpdateExtras;
|
|
39 |
|
|
40 |
public UpdateInfo(String shortName, String longName, String description, int objectMinor, int extrasMinor, boolean updateO, boolean updateE)
|
36 |
41 |
{
|
37 |
|
mObjectName = name;
|
38 |
|
mMinorVersion= version;
|
|
42 |
mObjectShortName = shortName;
|
|
43 |
mObjectLongName = longName;
|
|
44 |
mDescription = description;
|
|
45 |
mObjectMinorVersion = objectMinor;
|
|
46 |
mExtrasMinorVersion = extrasMinor;
|
|
47 |
mUpdateObject = updateO;
|
|
48 |
mUpdateExtras = updateE;
|
39 |
49 |
}
|
40 |
50 |
}
|
41 |
51 |
|
|
52 |
private int mNumberOfUpdates;
|
42 |
53 |
private String mUrl;
|
43 |
|
private final ArrayList<UpdateInfo> mNewObjects;
|
44 |
|
private final ArrayList<UpdateInfo> mNewExtras;
|
45 |
|
private final ArrayList<UpdateInfo> mUpdObjects;
|
46 |
|
private final ArrayList<UpdateInfo> mUpdExtras;
|
|
54 |
private final ArrayList<UpdateInfo> mNew, mUpd;
|
47 |
55 |
|
48 |
56 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
49 |
57 |
|
50 |
58 |
public RubikUpdates()
|
51 |
59 |
{
|
52 |
|
mNewObjects = new ArrayList<>();
|
53 |
|
mNewExtras = new ArrayList<>();
|
54 |
|
mUpdObjects = new ArrayList<>();
|
55 |
|
mUpdExtras = new ArrayList<>();
|
|
60 |
mNew = new ArrayList<>();
|
|
61 |
mUpd = new ArrayList<>();
|
56 |
62 |
}
|
57 |
63 |
|
58 |
64 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
60 |
66 |
private String debug(ArrayList<UpdateInfo> list)
|
61 |
67 |
{
|
62 |
68 |
String ret = "";
|
63 |
|
for( UpdateInfo info : list) ret += (" "+info.mObjectName+" "+info.mMinorVersion);
|
|
69 |
|
|
70 |
for( UpdateInfo info : list)
|
|
71 |
{
|
|
72 |
ret += (info.mObjectShortName+" "+info.mObjectLongName+" "+info.mDescription+" ");
|
|
73 |
ret += (info.mObjectMinorVersion+" "+info.mExtrasMinorVersion+" "+info.mUpdateObject+" "+info.mUpdateExtras+" , ");
|
|
74 |
}
|
|
75 |
|
64 |
76 |
return ret;
|
65 |
77 |
}
|
66 |
78 |
|
... | ... | |
68 |
80 |
|
69 |
81 |
private void parseLine(String[] elements)
|
70 |
82 |
{
|
71 |
|
String objName = elements[0];
|
72 |
|
String objMinor = elements[1];
|
73 |
|
String extMinor = elements[2];
|
|
83 |
boolean added = false;
|
|
84 |
String shortName = elements[0];
|
|
85 |
String objMinor = elements[1];
|
|
86 |
String extMinor = elements[2];
|
|
87 |
String longName = elements[3];
|
|
88 |
String description = elements[4];
|
74 |
89 |
int oMinor, eMinor;
|
75 |
90 |
|
76 |
91 |
try { oMinor = Integer.parseInt(objMinor); }
|
... | ... | |
78 |
93 |
try { eMinor = Integer.parseInt(extMinor); }
|
79 |
94 |
catch (NumberFormatException ex) { eMinor = -1; }
|
80 |
95 |
|
81 |
|
int objOrdinal = RubikObjectList.getOrdinal(objName.toUpperCase());
|
82 |
|
|
83 |
|
if( oMinor>=0 )
|
|
96 |
if( oMinor>=0 && eMinor>=0 )
|
84 |
97 |
{
|
85 |
|
if( objOrdinal>=0 )
|
86 |
|
{
|
87 |
|
int localObjectMinor = RubikObjectList.getLocalObjectMinor(objOrdinal);
|
88 |
|
if( localObjectMinor>=0 && localObjectMinor<oMinor )
|
89 |
|
{
|
90 |
|
UpdateInfo info = new UpdateInfo(objName,oMinor);
|
91 |
|
mUpdObjects.add(info);
|
92 |
|
}
|
93 |
|
}
|
94 |
|
else
|
95 |
|
{
|
96 |
|
UpdateInfo info = new UpdateInfo(objName,oMinor);
|
97 |
|
mNewObjects.add(info);
|
98 |
|
}
|
99 |
|
}
|
|
98 |
int objOrdinal = RubikObjectList.getOrdinal(shortName.toUpperCase());
|
100 |
99 |
|
101 |
|
if( eMinor>=0 )
|
102 |
|
{
|
103 |
100 |
if( objOrdinal>=0 )
|
104 |
101 |
{
|
|
102 |
int localObjectMinor = RubikObjectList.getLocalObjectMinor(objOrdinal);
|
105 |
103 |
int localExtrasMinor = RubikObjectList.getLocalExtrasMinor(objOrdinal);
|
106 |
|
if( localExtrasMinor>=0 && localExtrasMinor<eMinor )
|
|
104 |
boolean updateO = localObjectMinor<oMinor;
|
|
105 |
boolean updateE = localExtrasMinor<eMinor;
|
|
106 |
|
|
107 |
if( updateO || updateE )
|
107 |
108 |
{
|
108 |
|
UpdateInfo info = new UpdateInfo(objName,eMinor);
|
109 |
|
mUpdExtras.add(info);
|
|
109 |
UpdateInfo info = new UpdateInfo(shortName,longName,description,oMinor,eMinor,updateO,updateE);
|
|
110 |
mUpd.add(info);
|
|
111 |
added = true;
|
110 |
112 |
}
|
111 |
113 |
}
|
112 |
114 |
else
|
113 |
115 |
{
|
114 |
|
UpdateInfo info = new UpdateInfo(objName,eMinor);
|
115 |
|
mNewExtras.add(info);
|
|
116 |
UpdateInfo info = new UpdateInfo(shortName,longName,description,oMinor,eMinor,true,true);
|
|
117 |
mNew.add(info);
|
|
118 |
added = true;
|
116 |
119 |
}
|
117 |
120 |
}
|
|
121 |
|
|
122 |
if( added ) mNumberOfUpdates++;
|
118 |
123 |
}
|
119 |
124 |
|
120 |
125 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
123 |
128 |
{
|
124 |
129 |
android.util.Log.e("D", updates);
|
125 |
130 |
|
126 |
|
mNewObjects.clear();
|
127 |
|
mNewExtras.clear();
|
128 |
|
mUpdObjects.clear();
|
129 |
|
mUpdExtras.clear();
|
|
131 |
mNumberOfUpdates = 0;
|
|
132 |
|
|
133 |
mNew.clear();
|
|
134 |
mUpd.clear();
|
130 |
135 |
|
131 |
136 |
String[] lines = updates.split("\n");
|
132 |
137 |
int numLines = lines.length;
|
... | ... | |
136 |
141 |
mUrl = lines[0];
|
137 |
142 |
for(int line=1; line<numLines; line++)
|
138 |
143 |
{
|
139 |
|
String[] elements = lines[line].split(" ");
|
|
144 |
String[] elements = lines[line].split(",");
|
140 |
145 |
if( elements.length>=3 ) parseLine(elements);
|
141 |
146 |
}
|
142 |
147 |
}
|
... | ... | |
146 |
151 |
|
147 |
152 |
public int getNumberOfUpdates()
|
148 |
153 |
{
|
149 |
|
int newO = mNewObjects.size();
|
150 |
|
int newE = mNewExtras.size();
|
151 |
|
int updO = mUpdObjects.size();
|
152 |
|
int updE = mUpdExtras.size();
|
153 |
|
|
154 |
|
return newO+newE+updO+updE;
|
|
154 |
return mNumberOfUpdates;
|
155 |
155 |
}
|
156 |
156 |
|
157 |
157 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
159 |
159 |
public void showDebug()
|
160 |
160 |
{
|
161 |
161 |
android.util.Log.e("D", "url: "+mUrl);
|
162 |
|
android.util.Log.e("D", "new objects: "+debug(mNewObjects));
|
163 |
|
android.util.Log.e("D", "new extras : "+debug(mNewExtras ));
|
164 |
|
android.util.Log.e("D", "upd objects: "+debug(mUpdObjects));
|
165 |
|
android.util.Log.e("D", "upd extras : "+debug(mUpdExtras ));
|
|
162 |
android.util.Log.e("D", "new objects: "+debug(mNew));
|
|
163 |
android.util.Log.e("D", "upd objects: "+debug(mUpd));
|
166 |
164 |
}
|
167 |
165 |
}
|
Progress downloading updates: dialog.