Project

General

Profile

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

magiccube / src / main / java / org / distorted / purchase / PurchaseScreen.java @ 9dfb553f

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.purchase;
11

    
12
import android.view.View;
13
import android.widget.LinearLayout;
14

    
15
import org.distorted.helpers.TransparentImageButton;
16
import org.distorted.main.R;
17
import org.distorted.main.RubikActivity;
18
import org.distorted.objectlib.main.ObjectControl;
19

    
20
///////////////////////////////////////////////////////////////////////////////////////////////////
21

    
22
public class PurchaseScreen
23
{
24
  private TransparentImageButton mBackButton;
25
  private boolean mBlocked;
26

    
27
///////////////////////////////////////////////////////////////////////////////////////////////////
28

    
29
  void blockUI()
30
    {
31
    mBlocked = true;
32
    }
33

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

    
36
  private void setupBackButton(final PurchaseActivity act)
37
    {
38
    int icon = RubikActivity.getDrawable(R.drawable.ui_small_smallback,R.drawable.ui_medium_smallback, R.drawable.ui_big_smallback, R.drawable.ui_huge_smallback);
39
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
40
    mBackButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
41

    
42
    mBackButton.setOnClickListener( new View.OnClickListener()
43
      {
44
      @Override
45
      public void onClick(View v)
46
        {
47
        if( !mBlocked )
48
          {
49
          ObjectControl control = act.getControl();
50
          if( control!=null ) control.unblockEverything();
51
          act.finish();
52
          }
53
        }
54
      });
55
    }
56

    
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58

    
59
  void onAttachedToWindow(final PurchaseActivity act, final int ordinal)
60
    {
61
    mBlocked = false;
62
    int width = act.getScreenWidthInPixels();
63

    
64
    LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
65
    LinearLayout.LayoutParams paramsM = new LinearLayout.LayoutParams(width/2, LinearLayout.LayoutParams.MATCH_PARENT);
66
    LinearLayout.LayoutParams paramsR = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
67

    
68
    LinearLayout layoutLeft = new LinearLayout(act);
69
    layoutLeft.setLayoutParams(paramsL);
70
    LinearLayout layoutMid  = new LinearLayout(act);
71
    layoutMid.setLayoutParams(paramsM);
72
    LinearLayout layoutRight= new LinearLayout(act);
73
    layoutRight.setLayoutParams(paramsR);
74

    
75
    setupBackButton(act);
76

    
77
    layoutRight.addView(mBackButton);
78

    
79
    LinearLayout layout = act.findViewById(R.id.lowerBar);
80
    layout.removeAllViews();
81
    layout.addView(layoutLeft);
82
    layout.addView(layoutMid);
83
    layout.addView(layoutRight);
84

    
85
    PurchaseScreenPane pane = new PurchaseScreenPane(act);
86
    pane.updatePane(act,ordinal);
87
    }
88
}
(4-4/6)