Project

General

Profile

« Previous | Next » 

Revision b92ad5cd

Added by Leszek Koltunski almost 3 years ago

Download Update icons - progress.

View differences:

src/main/java/org/distorted/network/RubikNetwork.java
664 664
    {
665 665
    try
666 666
      {
667
      android.util.Log.e("D", "downloading "+url);
668

  
667 669
      java.net.URL connectURL = new URL(url);
668 670
      HttpURLConnection conn = (HttpURLConnection) connectURL.openConnection();
669 671
      conn.setDoInput(true);
......
688 690

  
689 691
    for(int c=0; c<numC; c++)
690 692
      {
691
      Bitmap icon = mUpdates.getCompletedIcon(c);
693
      int iconPresent = mUpdates.getCompletedIconPresent(c);
692 694

  
693
      if( icon==null )
694
        {
695
        String url = mUpdates.getCompletedURL(c);
696
        icon = downloadIcon(url);
697
        }
698
      if( icon!=null )
695
      if( iconPresent!=0 )
699 696
        {
700
        mUpdates.setCompletedIcon(c,icon);
701
        mUpdatee.iconDownloaded(c,icon);
697
        Bitmap icon = mUpdates.getCompletedIcon(c);
698

  
699
        if( icon==null )
700
          {
701
          String url = mUpdates.getCompletedURL(c);
702
          icon = downloadIcon(url);
703
          }
704
        if( icon!=null )
705
          {
706
          mUpdates.setCompletedIcon(c,icon);
707
          mUpdatee.iconDownloaded(c,icon);
708
          }
702 709
        }
703 710
      }
704 711

  
705 712
    for(int s=0; s<numS; s++)
706 713
      {
707
      Bitmap icon = mUpdates.getStartedIcon(s);
714
      int iconPresent = mUpdates.getStartedIconPresent(s);
708 715

  
709
      if( icon==null )
716
      if( iconPresent!=0 )
710 717
        {
711
        String url = mUpdates.getStartedURL(s);
712
        icon = downloadIcon(url);
713
        }
714
      if( icon!=null )
715
        {
716
        mUpdates.setStartedIcon(s,icon);
717
        mUpdatee.iconDownloaded(numC+s,icon);
718
        Bitmap icon = mUpdates.getStartedIcon(s);
719

  
720
        if( icon==null )
721
          {
722
          String url = mUpdates.getStartedURL(s);
723
          icon = downloadIcon(url);
724
          }
725
        if( icon!=null )
726
          {
727
          mUpdates.setStartedIcon(s,icon);
728
          mUpdatee.iconDownloaded(numC+s,icon);
729
          }
718 730
        }
719 731
      }
720 732
    }
src/main/java/org/distorted/network/RubikUpdates.java
35 35
    public final int mObjectMinorVersion;
36 36
    public final int mExtrasMinorVersion;
37 37
    public final int mPercent;
38
    public final int mIconPresent;
38 39
    public final boolean mUpdateObject;
39 40
    public final boolean mUpdateExtras;
40 41
    public Bitmap mIcon;
41 42

  
42 43
    public UpdateInfo(String shortName, String longName, String description, int objectMinor,
43
                      int extrasMinor, int percent, boolean updateO, boolean updateE)
44
                      int extrasMinor, int percent, int iconPresent, boolean updateO, boolean updateE)
44 45
      {
45 46
      mObjectShortName    = shortName;
46 47
      mObjectLongName     = longName;
......
48 49
      mObjectMinorVersion = objectMinor;
49 50
      mExtrasMinorVersion = extrasMinor;
50 51
      mPercent            = percent;
52
      mIconPresent        = iconPresent;
51 53
      mUpdateObject       = updateO;
52 54
      mUpdateExtras       = updateE;
53 55

  
......
89 91
    String objMinor    = elements[1].trim();
90 92
    String extMinor    = elements[2].trim();
91 93
    String percent     = elements[3].trim();
92
    String longName    = elements[4];
93
    String description = elements[5];
94
    int oMinor, eMinor, oPercent;
94
    String iconPresent = elements[4].trim();
95
    String longName    = elements[5];
96
    String description = elements[6];
97
    int oMinor, eMinor, oPercent, oIcon;
95 98

  
96 99
    try { oMinor = Integer.parseInt(objMinor); }
97 100
    catch (NumberFormatException ex) { oMinor = -1; }
......
99 102
    catch (NumberFormatException ex) { eMinor = -1; }
100 103
    try { oPercent = Integer.parseInt(percent); }
101 104
    catch (NumberFormatException ex) { oPercent = -1; }
105
    try { oIcon = Integer.parseInt(iconPresent); }
106
    catch (NumberFormatException ex) { oIcon = 0; }
102 107

  
103 108
    if( oMinor>=0 && eMinor>=0 && oPercent>=0 )
104 109
      {
......
114 119
        }
115 120
      if( updateO || updateE )
116 121
        {
117
        UpdateInfo info = new UpdateInfo(shortName,longName,description,oMinor,eMinor,oPercent,updateO,updateE);
122
        UpdateInfo info = new UpdateInfo(shortName,longName,description,oMinor,eMinor,oPercent,oIcon,updateO,updateE);
118 123
        if(oPercent>=100) mCompleted.add(info);
119 124
        else              mStarted.add(info);
120 125
        }
......
141 146
      for(int line=1; line<numLines; line++)
142 147
        {
143 148
        String[] elements = lines[line].split(",");
144
        if( elements.length>=6 ) parseLine(elements);
149
        if( elements.length>=7 ) parseLine(elements);
145 150
        }
146 151
      }
147 152
    }
......
202 207
    return mStarted.get(ordinal).mIcon;
203 208
    }
204 209

  
210
///////////////////////////////////////////////////////////////////////////////////////////////////
211

  
212
  public int getCompletedIconPresent(int ordinal)
213
    {
214
    return mCompleted.get(ordinal).mIconPresent;
215
    }
216

  
217
///////////////////////////////////////////////////////////////////////////////////////////////////
218

  
219
  public int getStartedIconPresent(int ordinal)
220
    {
221
    return mStarted.get(ordinal).mIconPresent;
222
    }
223

  
205 224
///////////////////////////////////////////////////////////////////////////////////////////////////
206 225

  
207 226
  public String getCompletedURL(int ordinal)

Also available in: Unified diff