Revision 806329e3
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java | ||
---|---|---|
34 | 34 |
import org.distorted.main.R; |
35 | 35 |
import org.distorted.external.RubikNetwork; |
36 | 36 |
import org.distorted.external.RubikUpdates; |
37 |
import org.distorted.objects.RubikObjectList; |
|
38 |
|
|
39 |
import java.io.IOException; |
|
40 |
import java.lang.ref.WeakReference; |
|
37 | 41 |
|
38 | 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
39 | 43 |
|
... | ... | |
45 | 49 |
private Button mButton; |
46 | 50 |
private TextView mDescription; |
47 | 51 |
|
52 |
private WeakReference<Activity> mAct; |
|
53 |
|
|
48 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
49 | 55 |
|
50 | 56 |
public View createView(Activity act, RubikUpdates.UpdateInfo info, int fontSize, int padding, |
51 | 57 |
LinearLayout.LayoutParams pView, LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt ) |
52 | 58 |
{ |
59 |
mAct = new WeakReference<>(act); |
|
53 | 60 |
mInfo = info; |
54 | 61 |
final RubikNetwork.Downloadee downloadee = this; |
55 | 62 |
View view = act.getLayoutInflater().inflate(R.layout.dialog_updates_pane, null); |
... | ... | |
134 | 141 |
mDescription.setText(R.string.installing); |
135 | 142 |
|
136 | 143 |
RubikFiles files = RubikFiles.getInstance(); |
137 |
boolean oSuccess=true, eSuccess=true; |
|
144 |
boolean iSuccess=true,oSuccess=true, eSuccess=true; |
|
145 |
|
|
146 |
if( mInfo.mIcon!=null ) |
|
147 |
{ |
|
148 |
String name = mInfo.mObjectShortName + ".png"; |
|
149 |
Activity act = mAct.get(); |
|
150 |
iSuccess = files.saveFile(act,mInfo.mIcon, name); |
|
151 |
} |
|
138 | 152 |
|
139 | 153 |
if( mInfo.mObjectStream!=null ) |
140 | 154 |
{ |
141 | 155 |
String name = mInfo.mObjectShortName + "_object.json"; |
142 |
oSuccess = files.saveFile(mInfo.mObjectStream, name); |
|
156 |
Activity act = mAct.get(); |
|
157 |
oSuccess = files.saveFile(act,mInfo.mObjectStream, name); |
|
143 | 158 |
} |
144 | 159 |
|
145 | 160 |
if( mInfo.mExtrasStream!=null ) |
146 | 161 |
{ |
147 | 162 |
String name = mInfo.mObjectShortName + "_extras.json"; |
148 |
eSuccess = files.saveFile(mInfo.mExtrasStream, name); |
|
163 |
Activity act = mAct.get(); |
|
164 |
eSuccess = files.saveFile(act,mInfo.mExtrasStream, name); |
|
149 | 165 |
} |
150 | 166 |
|
151 |
if( oSuccess ) |
|
167 |
if( iSuccess && oSuccess )
|
|
152 | 168 |
{ |
153 | 169 |
mBar.setProgress(75); |
154 | 170 |
mDescription.setText(R.string.configuring); |
171 |
RubikObjectList.addDownloadedObject(mInfo.mObjectShortName,iSuccess,oSuccess,eSuccess); |
|
172 |
mBar.setProgress(100); |
|
173 |
mDescription.setText(R.string.success); |
|
174 |
|
|
175 |
RubikNetwork network = RubikNetwork.getInstance(); |
|
176 |
network.updateDone(mInfo.mObjectShortName); |
|
155 | 177 |
} |
156 | 178 |
else |
157 | 179 |
{ |
Also available in: Unified diff
Support for saving the downloaded JSONs in local data storage.