Project

General

Profile

« Previous | Next » 

Revision 2c9ab085

Added by Leszek Koltunski over 2 years ago

Downloading updates: dialog progress.

View differences:

src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java
25 25
import android.widget.Button;
26 26
import android.widget.ImageView;
27 27
import android.widget.LinearLayout;
28
import android.widget.ProgressBar;
28 29
import android.widget.TextView;
29 30

  
30 31
import org.distorted.main.R;
31 32
import org.distorted.network.RubikUpdates;
32
import org.distorted.objectlib.json.JsonWriter;
33 33

  
34 34
///////////////////////////////////////////////////////////////////////////////////////////////////
35 35

  
36 36
public class RubikDialogUpdateView
37 37
  {
38
  private View mView;
39

  
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41

  
42 38
  public RubikDialogUpdateView()
43 39
    {
44 40

  
......
46 42

  
47 43
///////////////////////////////////////////////////////////////////////////////////////////////////
48 44

  
49
  public View createView(Activity act, RubikUpdates.UpdateInfo info, int fontSize, int padding, boolean isNew,
45
  public View createView(Activity act, RubikUpdates.UpdateInfo info, int fontSize, int padding,
50 46
                         LinearLayout.LayoutParams pImage, LinearLayout.LayoutParams pView,
51 47
                         LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt )
52 48
    {
53
    int layoutID = R.layout.dialog_updates_pane;
54
    mView = act.getLayoutInflater().inflate(layoutID, null);
49
    boolean isCompleted = info.mPercent>=100;
50
    int layoutID = isCompleted
51
                   ? R.layout.dialog_updates_completed
52
                   : R.layout.dialog_updates_started;
55 53

  
56
    Button button = mView.findViewById(R.id.updates_pane_button);
57

  
58
    button.setOnClickListener( new View.OnClickListener()
59
      {
60
      @Override
61
      public void onClick(View v)
62
        {
63
        android.util.Log.e("D", "INSTALL pressed");
64
        }
65
      });
54
    View view = act.getLayoutInflater().inflate(layoutID, null);
66 55

  
67
    TextView title = mView.findViewById(R.id.updates_pane_title);
56
    TextView title = view.findViewById(R.id.updates_pane_title);
68 57
    title.setText(info.mObjectLongName);
69
    TextView description = mView.findViewById(R.id.updates_pane_description);
58
    TextView description = view.findViewById(R.id.updates_pane_description);
70 59
    description.setText(info.mDescription);
71 60

  
72
    ImageView image = mView.findViewById(R.id.updates_pane_image);
61
    ImageView image = view.findViewById(R.id.updates_pane_image);
73 62
    image.setBackgroundResource(R.drawable.unknown_icon);
74 63

  
75 64
    image.setLayoutParams(pImage);
76
    mView.setLayoutParams(pView);
65
    view.setLayoutParams(pView);
77 66

  
78 67
    title.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
79 68
    description.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
80
    button.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
81 69

  
82 70
    title.setLayoutParams(pText);
83 71
    description.setLayoutParams(pText);
84
    button.setLayoutParams(pButt);
85 72

  
86
    mView.setPadding(padding,padding,padding,padding);
73
    view.setPadding(padding,padding,padding,padding);
74

  
75
    if( isCompleted )
76
      {
77
      Button button = view.findViewById(R.id.updates_pane_button);
78

  
79
      button.setOnClickListener( new View.OnClickListener()
80
        {
81
        @Override
82
        public void onClick(View v)
83
          {
84
          android.util.Log.e("D", "INSTALL pressed");
85
          }
86
        });
87

  
88
      button.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
89
      button.setLayoutParams(pButt);
90
      }
91
    else
92
      {
93
      ProgressBar bar = view.findViewById(R.id.updates_pane_bar);
94
      bar.setLayoutParams(pButt);
95
      bar.setProgress(info.mPercent);
96
      }
87 97

  
88
    return mView;
98
    return view;
89 99
    }
90 100
  }

Also available in: Unified diff