Project

General

Profile

« Previous | Next » 

Revision 7480fbab

Added by Leszek Koltunski over 1 year ago

Progress with marking objects as free.

View differences:

src/main/java/org/distorted/purchase/PurchaseScreenPane.java
10 10
package org.distorted.purchase;
11 11

  
12 12
import android.util.TypedValue;
13
import android.view.View;
14
import android.widget.Button;
13 15
import android.widget.ImageView;
14 16
import android.widget.LinearLayout;
15 17
import android.widget.TextView;
......
38 40
  public  static final float PADDING_RATIO = 0.025f;
39 41
  private static final float TEXT_RATIO    = 0.050f;
40 42

  
43
  private RubikObject mObject;
44

  
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46
// TODO
47

  
48
  private boolean buyOne(String shortName)
49
    {
50
    return true;
51
    }
52

  
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54
// TODO
55

  
56
  private boolean buyAll()
57
    {
58
    return true;
59
    }
60

  
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62

  
63
  private void oneButtonClicked()
64
    {
65
    if( mObject!=null )
66
      {
67
      String shortName = mObject.getUpperName();
68

  
69
      if( !RubikObjectList.objectAlreadyBought(shortName) && buyOne(shortName) )
70
        {
71
        android.util.Log.e("D", "buying "+shortName);
72

  
73
        RubikObjectList.buyObject(shortName);
74
        }
75
      }
76
    }
77

  
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79

  
80
  private void allButtonClicked()
81
    {
82
    if( !RubikObjectList.allAlreadyBought() && buyAll() )
83
      {
84
      RubikObjectList.buyAll();
85
      }
86
    }
87

  
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

  
90
  private void setUpButtons(LinearLayout one, LinearLayout all)
91
    {
92
    Button butO = one.findViewById(R.id.purchaseButtonOne);
93
    Button butA = all.findViewById(R.id.purchaseButtonAll);
94

  
95
    butO.setOnClickListener( new View.OnClickListener()
96
      {
97
      @Override
98
      public void onClick(View v)
99
        {
100
        oneButtonClicked();
101
        }
102
      });
103

  
104
    butA.setOnClickListener( new View.OnClickListener()
105
      {
106
      @Override
107
      public void onClick(View v)
108
        {
109
        allButtonClicked();
110
        }
111
      });
112
    }
113

  
41 114
///////////////////////////////////////////////////////////////////////////////////////////////////
42 115

  
43 116
  void updatePane(PurchaseActivity act, int objectOrdinal)
44 117
    {
45
    RubikObject object = RubikObjectList.getObject(objectOrdinal);
118
    mObject = RubikObjectList.getObject(objectOrdinal);
46 119

  
47
    if( object!=null )
120
    if( mObject!=null )
48 121
      {
49
      InputStream stream = object.getObjectStream(act);
122
      InputStream stream = mObject.getObjectStream(act);
50 123
      JsonReader reader = JsonReader.getInstance();
51 124
      String author, name;
52 125
      int year, difficulty;
......
128 201
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
129 202
    text = allLayout.findViewById(R.id.purchaseTextAll);
130 203
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
204

  
205
    setUpButtons(oneLayout,allLayout);
131 206
    }
132 207
}

Also available in: Unified diff