Project

General

Profile

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

magiccube / src / main / java / org / distorted / purchase / PurchaseScreen.java @ 083d854d

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
19
///////////////////////////////////////////////////////////////////////////////////////////////////
20
21
public class PurchaseScreen
22
{
23 7c9910e5 Leszek Koltunski
  private TransparentImageButton mBackButton;
24 7654a99d Leszek Koltunski
  private boolean mBlocked;
25
26
///////////////////////////////////////////////////////////////////////////////////////////////////
27
28
  void blockUI()
29
    {
30
    mBlocked = true;
31
    }
32 c7238c67 Leszek Koltunski
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34
35
  private void setupBackButton(final PurchaseActivity act)
36
    {
37
    int icon = RubikActivity.getDrawable(R.drawable.ui_small_smallback,R.drawable.ui_medium_smallback, R.drawable.ui_big_smallback, R.drawable.ui_huge_smallback);
38
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
39
    mBackButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
40
41
    mBackButton.setOnClickListener( new View.OnClickListener()
42
      {
43
      @Override
44
      public void onClick(View v)
45
        {
46 aa622165 Leszek Koltunski
        if( !mBlocked ) act.finish();
47 c7238c67 Leszek Koltunski
        }
48
      });
49
    }
50
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52
53 7c9910e5 Leszek Koltunski
  void onAttachedToWindow(final PurchaseActivity act, final int ordinal)
54 c7238c67 Leszek Koltunski
    {
55 7654a99d Leszek Koltunski
    mBlocked = false;
56 c7238c67 Leszek Koltunski
    int width = act.getScreenWidthInPixels();
57
58
    LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
59
    LinearLayout.LayoutParams paramsM = new LinearLayout.LayoutParams(width/2, LinearLayout.LayoutParams.MATCH_PARENT);
60
    LinearLayout.LayoutParams paramsR = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
61
62
    LinearLayout layoutLeft = new LinearLayout(act);
63
    layoutLeft.setLayoutParams(paramsL);
64
    LinearLayout layoutMid  = new LinearLayout(act);
65
    layoutMid.setLayoutParams(paramsM);
66
    LinearLayout layoutRight= new LinearLayout(act);
67
    layoutRight.setLayoutParams(paramsR);
68
69
    setupBackButton(act);
70
71
    layoutRight.addView(mBackButton);
72
73
    LinearLayout layout = act.findViewById(R.id.lowerBar);
74
    layout.removeAllViews();
75
    layout.addView(layoutLeft);
76
    layout.addView(layoutMid);
77
    layout.addView(layoutRight);
78
79 71cda061 Leszek Koltunski
    PurchaseScreenPane pane = new PurchaseScreenPane(act);
80 7c9910e5 Leszek Koltunski
    pane.updatePane(act,ordinal);
81 c7238c67 Leszek Koltunski
    }
82
}