Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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
import android.util.TypedValue;
24
import android.view.View;
25
import android.widget.Button;
26
import android.widget.ImageView;
27
import android.widget.LinearLayout;
28
import android.widget.ProgressBar;
29
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
  public View createView(Activity act, RubikUpdates.UpdateInfo info, int fontSize, int padding,
46
                         LinearLayout.LayoutParams pImage, LinearLayout.LayoutParams pView,
47
                         LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt )
48
    {
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

    
56
    TextView title = view.findViewById(R.id.updates_pane_title);
57
    title.setText(info.mObjectLongName);
58
    TextView description = view.findViewById(R.id.updates_pane_description);
59
    description.setText(info.mDescription);
60

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

    
64
    image.setLayoutParams(pImage);
65
    view.setLayoutParams(pView);
66

    
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
    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

    
98
    return view;
99
    }
100
  }
(20-20/21)