Project

General

Profile

Download (4.18 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / dialogs / RubikDialogUpdateView.java @ 2c9ab085

1 9c39179e Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20
package org.distorted.dialogs;
21
22
import android.app.Activity;
23 c651024f Leszek Koltunski
import android.util.TypedValue;
24 9c39179e Leszek Koltunski
import android.view.View;
25
import android.widget.Button;
26 7bee6064 Leszek Koltunski
import android.widget.ImageView;
27 c651024f Leszek Koltunski
import android.widget.LinearLayout;
28 2c9ab085 Leszek Koltunski
import android.widget.ProgressBar;
29 9c39179e Leszek Koltunski
import android.widget.TextView;
30
31
import org.distorted.main.R;
32
import org.distorted.network.RubikUpdates;
33
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35
36
public class RubikDialogUpdateView
37
  {
38
  public RubikDialogUpdateView()
39
    {
40
41
    }
42
43
///////////////////////////////////////////////////////////////////////////////////////////////////
44
45 2c9ab085 Leszek Koltunski
  public View createView(Activity act, RubikUpdates.UpdateInfo info, int fontSize, int padding,
46 c651024f Leszek Koltunski
                         LinearLayout.LayoutParams pImage, LinearLayout.LayoutParams pView,
47
                         LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt )
48 9c39179e Leszek Koltunski
    {
49 2c9ab085 Leszek Koltunski
    boolean isCompleted = info.mPercent>=100;
50
    int layoutID = isCompleted
51
                   ? R.layout.dialog_updates_completed
52
                   : R.layout.dialog_updates_started;
53 9c39179e Leszek Koltunski
54 2c9ab085 Leszek Koltunski
    View view = act.getLayoutInflater().inflate(layoutID, null);
55 9c39179e Leszek Koltunski
56 2c9ab085 Leszek Koltunski
    TextView title = view.findViewById(R.id.updates_pane_title);
57 9c39179e Leszek Koltunski
    title.setText(info.mObjectLongName);
58 2c9ab085 Leszek Koltunski
    TextView description = view.findViewById(R.id.updates_pane_description);
59 9c39179e Leszek Koltunski
    description.setText(info.mDescription);
60
61 2c9ab085 Leszek Koltunski
    ImageView image = view.findViewById(R.id.updates_pane_image);
62 7bee6064 Leszek Koltunski
    image.setBackgroundResource(R.drawable.unknown_icon);
63
64 c651024f Leszek Koltunski
    image.setLayoutParams(pImage);
65 2c9ab085 Leszek Koltunski
    view.setLayoutParams(pView);
66 c651024f Leszek Koltunski
67
    title.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
68
    description.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
69
70
    title.setLayoutParams(pText);
71
    description.setLayoutParams(pText);
72
73 2c9ab085 Leszek Koltunski
    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
      }
97 99b8a069 Leszek Koltunski
98 2c9ab085 Leszek Koltunski
    return view;
99 9c39179e Leszek Koltunski
    }
100
  }