Project

General

Profile

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

magiccube / src / main / java / org / distorted / purchase / PurchaseScreen.java @ 71cda061

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

    
26
///////////////////////////////////////////////////////////////////////////////////////////////////
27

    
28
  private void setupBackButton(final PurchaseActivity act)
29
    {
30
    int icon = RubikActivity.getDrawable(R.drawable.ui_small_smallback,R.drawable.ui_medium_smallback, R.drawable.ui_big_smallback, R.drawable.ui_huge_smallback);
31
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
32
    mBackButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
33

    
34
    mBackButton.setOnClickListener( new View.OnClickListener()
35
      {
36
      @Override
37
      public void onClick(View v)
38
        {
39
        ObjectControl control = act.getControl();
40
        if( control!=null ) control.unblockEverything();
41
        act.finish();
42
        }
43
      });
44
    }
45

    
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47

    
48
  void onAttachedToWindow(final PurchaseActivity act, final int ordinal)
49
    {
50
    int width = act.getScreenWidthInPixels();
51

    
52
    LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
53
    LinearLayout.LayoutParams paramsM = new LinearLayout.LayoutParams(width/2, LinearLayout.LayoutParams.MATCH_PARENT);
54
    LinearLayout.LayoutParams paramsR = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
55

    
56
    LinearLayout layoutLeft = new LinearLayout(act);
57
    layoutLeft.setLayoutParams(paramsL);
58
    LinearLayout layoutMid  = new LinearLayout(act);
59
    layoutMid.setLayoutParams(paramsM);
60
    LinearLayout layoutRight= new LinearLayout(act);
61
    layoutRight.setLayoutParams(paramsR);
62

    
63
    setupBackButton(act);
64

    
65
    layoutRight.addView(mBackButton);
66

    
67
    LinearLayout layout = act.findViewById(R.id.lowerBar);
68
    layout.removeAllViews();
69
    layout.addView(layoutLeft);
70
    layout.addView(layoutMid);
71
    layout.addView(layoutRight);
72

    
73
    PurchaseScreenPane pane = new PurchaseScreenPane(act);
74
    pane.updatePane(act,ordinal);
75
    }
76
}
(4-4/6)