Project

General

Profile

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

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

1 c7238c67 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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 7c9910e5 Leszek Koltunski
  private TransparentImageButton mBackButton;
25 7654a99d Leszek Koltunski
  private boolean mBlocked;
26
27
///////////////////////////////////////////////////////////////////////////////////////////////////
28
29
  void blockUI()
30
    {
31
    mBlocked = true;
32
    }
33 c7238c67 Leszek Koltunski
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 7654a99d Leszek Koltunski
        if( !mBlocked )
48
          {
49
          ObjectControl control = act.getControl();
50
          if( control!=null ) control.unblockEverything();
51
          act.finish();
52
          }
53 c7238c67 Leszek Koltunski
        }
54
      });
55
    }
56
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58
59 7c9910e5 Leszek Koltunski
  void onAttachedToWindow(final PurchaseActivity act, final int ordinal)
60 c7238c67 Leszek Koltunski
    {
61 7654a99d Leszek Koltunski
    mBlocked = false;
62 c7238c67 Leszek Koltunski
    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 71cda061 Leszek Koltunski
    PurchaseScreenPane pane = new PurchaseScreenPane(act);
86 7c9910e5 Leszek Koltunski
    pane.updatePane(act,ordinal);
87 c7238c67 Leszek Koltunski
    }
88
}