Project

General

Profile

« Previous | Next » 

Revision 9fde123a

Added by Leszek Koltunski almost 3 years ago

Downloading updates: dialog progress.

View differences:

src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java
31 31
import org.distorted.main.R;
32 32
import org.distorted.network.RubikUpdates;
33 33

  
34
import static android.view.View.GONE;
35

  
34 36
///////////////////////////////////////////////////////////////////////////////////////////////////
35 37

  
36 38
public class RubikDialogUpdateView
......
46 48
                         LinearLayout.LayoutParams pImage, LinearLayout.LayoutParams pView,
47 49
                         LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt )
48 50
    {
49
    boolean isCompleted = info.mPercent>=100;
50
    int layoutID = isCompleted
51
                   ? R.layout.dialog_updates_completed
52
                   : R.layout.dialog_updates_started;
53

  
54
    View view = act.getLayoutInflater().inflate(layoutID, null);
55

  
51
    View view = act.getLayoutInflater().inflate(R.layout.dialog_updates_pane, null);
56 52
    TextView title = view.findViewById(R.id.updates_pane_title);
57 53
    title.setText(info.mObjectLongName);
58 54
    TextView description = view.findViewById(R.id.updates_pane_description);
......
72 68

  
73 69
    view.setPadding(padding,padding,padding,padding);
74 70

  
75
    if( isCompleted )
76
      {
77
      Button button = view.findViewById(R.id.updates_pane_button);
71
    ProgressBar bar = view.findViewById(R.id.updates_pane_bar);
72
    Button button   = view.findViewById(R.id.updates_pane_button);
78 73

  
74
    if( info.mPercent>=100 )
75
      {
76
      bar.setVisibility(GONE);
79 77
      button.setOnClickListener( new View.OnClickListener()
80 78
        {
81 79
        @Override
......
90 88
      }
91 89
    else
92 90
      {
93
      ProgressBar bar = view.findViewById(R.id.updates_pane_bar);
91
      button.setVisibility(GONE);
94 92
      bar.setLayoutParams(pButt);
95 93
      bar.setProgress(info.mPercent);
96 94
      }
src/main/res/layout/dialog_updates_completed.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout
3
	xmlns:android="http://schemas.android.com/apk/res/android"
4
	android:layout_width="match_parent"
5
	android:layout_height="wrap_content"
6
	android:background="@color/medium_grey"
7
	android:padding="8dp"
8
	android:orientation="horizontal">
9

  
10
   	<ImageView
11
   	    android:id="@+id/updates_pane_image"
12
   	    android:scaleType="fitCenter"
13
   		android:layout_width="wrap_content"
14
   		android:layout_height="wrap_content"/>
15

  
16
   	<LinearLayout
17
   		android:layout_width="match_parent"
18
 		android:layout_height="match_parent"
19
 		android:orientation="vertical"
20
 		android:layout_marginStart="8dp">
21

  
22
		<TextView
23
    		android:id="@+id/updates_pane_title"
24
    		android:gravity="top|start"
25
    		android:layout_width="match_parent"
26
    		android:layout_height="wrap_content"
27
    		android:singleLine="true"
28
            android:textStyle="bold"/>
29

  
30
        <TextView
31
    		android:id="@+id/updates_pane_description"
32
    		android:gravity="top|start"
33
    		android:layout_width="match_parent"
34
    		android:layout_height="wrap_content"
35
    		android:singleLine="true"/>
36

  
37
    	<Button
38
             android:id="@+id/updates_pane_button"
39
             android:layout_width="match_parent"
40
             android:layout_height="wrap_content"
41
             android:backgroundTint="@color/black"
42
             android:minHeight="0dp"
43
             android:minWidth="0dp"
44
             android:insetTop="0dp"
45
             android:insetBottom="0dp"
46
             android:text="@string/install"/>
47

  
48
 	</LinearLayout>
49
</LinearLayout>
src/main/res/layout/dialog_updates_pane.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout
3
	xmlns:android="http://schemas.android.com/apk/res/android"
4
	android:layout_width="match_parent"
5
	android:layout_height="wrap_content"
6
	android:background="@color/medium_grey"
7
	android:padding="8dp"
8
	android:orientation="horizontal">
9

  
10
   	<ImageView
11
   	    android:id="@+id/updates_pane_image"
12
   	    android:scaleType="fitCenter"
13
   		android:layout_width="wrap_content"
14
   		android:layout_height="wrap_content"/>
15

  
16
   	<LinearLayout
17
   		android:layout_width="match_parent"
18
 		android:layout_height="match_parent"
19
 		android:orientation="vertical"
20
 		android:layout_marginStart="8dp">
21

  
22
		<TextView
23
    		android:id="@+id/updates_pane_title"
24
    		android:gravity="top|start"
25
    		android:layout_width="match_parent"
26
    		android:layout_height="wrap_content"
27
    		android:singleLine="true"
28
    		android:textStyle="bold"/>
29

  
30
        <TextView
31
    		android:id="@+id/updates_pane_description"
32
    		android:gravity="top|start"
33
    		android:layout_width="wrap_content"
34
    		android:layout_height="wrap_content"
35
    		android:singleLine="true"/>
36

  
37
    	<Button
38
             android:id="@+id/updates_pane_button"
39
             android:layout_width="match_parent"
40
             android:layout_height="wrap_content"
41
             android:backgroundTint="@color/black"
42
             android:minHeight="0dp"
43
             android:minWidth="0dp"
44
             android:insetTop="0dp"
45
             android:insetBottom="0dp"
46
             android:text="@string/install"/>
47

  
48
    	<ProgressBar
49
             android:id="@+id/updates_pane_bar"
50
             android:layout_width="match_parent"
51
             android:layout_height="wrap_content"
52
             style="@android:style/Widget.ProgressBar.Horizontal"
53
             android:progressDrawable="@drawable/black_progress"
54
             android:max="100"/>
55

  
56
 	</LinearLayout>
57
</LinearLayout>
src/main/res/layout/dialog_updates_started.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout
3
	xmlns:android="http://schemas.android.com/apk/res/android"
4
	android:layout_width="match_parent"
5
	android:layout_height="wrap_content"
6
	android:background="@color/medium_grey"
7
	android:padding="8dp"
8
	android:orientation="horizontal">
9

  
10
   	<ImageView
11
   	    android:id="@+id/updates_pane_image"
12
   	    android:scaleType="fitCenter"
13
   		android:layout_width="wrap_content"
14
   		android:layout_height="wrap_content"/>
15

  
16
   	<LinearLayout
17
   		android:layout_width="match_parent"
18
 		android:layout_height="match_parent"
19
 		android:orientation="vertical"
20
 		android:layout_marginStart="8dp">
21

  
22
		<TextView
23
    		android:id="@+id/updates_pane_title"
24
    		android:gravity="top|start"
25
    		android:layout_width="match_parent"
26
    		android:layout_height="wrap_content"
27
    		android:singleLine="true"
28
    		android:textStyle="bold"/>
29

  
30
        <TextView
31
    		android:id="@+id/updates_pane_description"
32
    		android:gravity="top|start"
33
    		android:layout_width="wrap_content"
34
    		android:layout_height="wrap_content"
35
    		android:singleLine="true"/>
36

  
37
    	<ProgressBar
38
             android:id="@+id/updates_pane_bar"
39
             android:layout_width="match_parent"
40
             android:layout_height="wrap_content"
41
             style="@android:style/Widget.ProgressBar.Horizontal"
42
             android:progressDrawable="@drawable/black_progress"
43
             android:max="100"/>
44

  
45
 	</LinearLayout>
46
</LinearLayout>

Also available in: Unified diff