Add progress bar when radical dictionary is updated

Julien LepillerSun Jun 26 17:07:08+0200 2022

9b3e89d

Add progress bar when radical dictionary is updated

.gitignore

77
/.idea/workspace.xml
88
/.idea/navEditor.xml
99
/.idea/assetWizardSettings.xml
10+
/.idea/misc.xml
1011
.DS_Store
1112
/build
1213
/captures

.idea/misc.xml

44
    <option name="filePathToZoomLevelMap">
55
      <map>
66
        <entry key="../../../../../../layout/custom_preview.xml" value="0.23385416666666667" />
7+
        <entry key="app/src/main/res/drawable/ic_border_bottom.xml" value="0.1535" />
78
        <entry key="app/src/main/res/drawable/ic_pitch.xml" value="0.1535" />
89
        <entry key="app/src/main/res/drawable/ic_rad.xml" value="0.1535" />
910
        <entry key="app/src/main/res/drawable/ic_reading.xml" value="0.1535" />
1011
        <entry key="app/src/main/res/layout/activity_main.xml" value="0.2078125" />
1112
        <entry key="app/src/main/res/layout/content_main.xml" value="0.2078125" />
12-
        <entry key="app/src/main/res/layout/content_radicals.xml" value="0.2078125" />
13+
        <entry key="app/src/main/res/layout/content_radicals.xml" value="0.1" />
1314
        <entry key="app/src/main/res/layout/fragment_results.xml" value="0.2078125" />
1415
        <entry key="app/src/main/res/layout/layout_result.xml" value="0.2078125" />
1516
        <entry key="app/src/main/res/xml/preferences.xml" value="0.2078125" />

app/src/main/java/eu/lepiller/nani/RadicalSelectorFragment.java

1010
import android.view.View;
1111
import android.widget.Button;
1212
import android.widget.LinearLayout;
13+
import android.widget.ProgressBar;
1314
import android.widget.TextView;
1415
import android.widget.ToggleButton;
1516

3940
4041
    private LinearLayout kanji_row1, kanji_row2;
4142
    private LinearLayout radical_table;
43+
    private ProgressBar radical_load;
4244
4345
    final List<String> selected = new ArrayList<>();
4446

6163
        kanji_row1 = getView().findViewById(R.id.kanji_row1);
6264
        kanji_row2 = getView().findViewById(R.id.kanji_row2);
6365
        radical_table = getView().findViewById(R.id.radical_table);
66+
        radical_load = getView().findViewById(R.id.radical_load);
67+
68+
        radical_load.setIndeterminate(true);
69+
        if(dictionary == null) {
70+
            radical_load.setVisibility(View.VISIBLE);
71+
            kanji_row1.setVisibility(View.GONE);
72+
            kanji_row2.setVisibility(View.GONE);
73+
            radical_table.setVisibility(View.GONE);
74+
        } else {
75+
            radical_load.setVisibility(View.GONE);
76+
            kanji_row1.setVisibility(View.VISIBLE);
77+
            kanji_row2.setVisibility(View.VISIBLE);
78+
            radical_table.setVisibility(View.VISIBLE);
79+
        }
6480
6581
        close_button.setOnClickListener((View v) -> {
6682
            Bundle result = new Bundle();

143159
144160
    public void setDictionary(RadicalDict dict) {
145161
        dictionary = dict;
162+
163+
        radical_load.setVisibility(View.VISIBLE);
164+
        kanji_row1.setVisibility(View.GONE);
165+
        kanji_row2.setVisibility(View.GONE);
166+
        radical_table.setVisibility(View.GONE);
167+
146168
        new Thread(dictionaryUpdate).start();
147169
    }
148170

201223
            box.setFlexWrap(FlexWrap.WRAP);
202224
            box.invalidate();
203225
        }
226+
227+
        radical_load.setVisibility(View.GONE);
228+
        kanji_row1.setVisibility(View.VISIBLE);
229+
        kanji_row2.setVisibility(View.VISIBLE);
230+
        radical_table.setVisibility(View.VISIBLE);
204231
    }
205232
206233
    private void updateRadicals(Set<String> available) {

app/src/main/res/layout/content_radicals.xml

44
    android:layout_height="match_parent"
55
    android:orientation="vertical">
66
7+
    <ProgressBar
8+
        android:layout_width="match_parent"
9+
        android:layout_height="wrap_content"
10+
        android:id="@+id/radical_load"
11+
        android:padding="8dp"
12+
        style="?android:attr/progressBarStyleHorizontal" />
13+
714
    <HorizontalScrollView
815
        android:layout_width="match_parent"
916
        android:layout_height="wrap_content"