Project

General

Profile

« Previous | Next » 

Revision d5fb0e7e

Added by Leszek Koltunski about 4 years ago

Improve the 'Scores' dialog: run less on the UI thread which makes this more responsive.

View differences:

src/main/java/org/distorted/dialog/RubikDialogScoresPagerAdapter.java
25 25
import android.support.v4.view.ViewPager;
26 26
import android.view.View;
27 27
import android.view.ViewGroup;
28
import android.widget.LinearLayout;
28 29

  
29 30
import org.distorted.network.RubikScoresDownloader;
30 31
import org.distorted.object.RubikObject;
......
92 93
      final String[] n = name[section];
93 94
      final String[] t = time[section];
94 95

  
96
      final LinearLayout layout = view.createSection(mAct, sec, c, n, t);
97

  
95 98
      mAct.runOnUiThread(new Runnable()
96 99
        {
97 100
        @Override
98 101
        public void run()
99 102
          {
100
          view.addSection(mAct, sec, c, n, t);
103
          view.addSection(layout);
101 104
          }
102 105
        });
103 106

  
src/main/java/org/distorted/dialog/RubikDialogScoresView.java
82 82

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

  
85
  void addSection(FragmentActivity act, int scramble, final int[] country, final String[] name, final String[] time)
85
  void addSection(LinearLayout section)
86
    {
87
    mLayout.addView(section);
88
    }
89

  
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91

  
92
  LinearLayout createSection(FragmentActivity act, int scramble, final int[] country, final String[] name, final String[] time)
86 93
    {
87 94
    LinearLayout level = (LinearLayout)inflate(act, R.layout.dialog_scores_scramble_title, null);
88 95
    TextView text = level.findViewById(R.id.scoresScrambleTitle);
......
106 113
        }
107 114
      }
108 115

  
109
    mLayout.addView(level);
116
    return level;
110 117
    }
111 118
  }

Also available in: Unified diff