Project

General

Profile

« Previous | Next » 

Revision 3c98dfd4

Added by Leszek Koltunski 3 days ago

progress with remembering solves.

View differences:

src/main/java/org/distorted/main/MainSolvesPopup.java
9 9

  
10 10
package org.distorted.main;
11 11

  
12
import android.content.Context;
13
import android.content.res.Resources;
14
import android.graphics.drawable.ColorDrawable;
12 15
import android.view.Gravity;
16
import android.view.LayoutInflater;
13 17
import android.view.View;
18
import android.widget.LinearLayout;
14 19
import android.widget.PopupWindow;
15 20

  
16 21
import org.distorted.objects.RubikObject;
17 22
import org.json.JSONArray;
23
import org.json.JSONException;
24
import org.json.JSONObject;
18 25

  
19 26
import java.lang.ref.WeakReference;
20 27

  
......
23 30
public class MainSolvesPopup
24 31
  {
25 32
  private final int mWidth, mHeight;
26
  private PopupWindow mPopup;
27
  private WeakReference<MainActivity> mAct;
33
  private final PopupWindow mPopup;
34
  private final WeakReference<MainActivity> mAct;
35
  private final LinearLayout mLayout;
36
  private int mMargin, mSize, mFontSize, mPadding;
28 37

  
29 38
///////////////////////////////////////////////////////////////////////////////////////////////////
30 39

  
......
35 44
    mWidth = popupWidth;
36 45
    mHeight= popupHeight;
37 46

  
47
    mMargin   = (int)(mHeight*0.01f);
48
    mSize     = (int)(mHeight*0.14f);
49
    mFontSize = (int)(mHeight*0.02f);
50
    mPadding  = (int)(mHeight*0.01f);
51

  
52
    LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
53
    final View layout = layoutInflater.inflate(R.layout.dialog_scrollable_panes, null);
54
    mPopup = new PopupWindow(act);
55
    mPopup.setContentView(layout);
56
    mPopup.setFocusable(true);
57

  
58
    Resources res = act.getResources();
59
    int l = res.getColor(act.getLightTrans());
60
    mPopup.setBackgroundDrawable(new ColorDrawable(l));
61

  
62
    mLayout= layout.findViewById(R.id.dialog_scrollable_main_layout);
63

  
64
    fillLayout(array);
65
    }
66

  
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

  
69
  private void fillLayout(JSONArray array)
70
    {
71
    int textH = (int)(mSize*0.27f);
72
    int buttH = (int)(mSize*0.35f);
73

  
74
    LinearLayout.LayoutParams pV = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, mSize );
75
    pV.setMargins(mMargin, mMargin, mMargin, 0);
76
    LinearLayout.LayoutParams pL = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, mSize );
77
    pL.setMargins(mMargin, mMargin, mMargin, mMargin);
78
    LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, textH );
79
    LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, buttH );
80

  
81
    int numSolves = array.length();
82

  
83
    try
84
      {
85
      for(int s=0; s<numSolves; s++)
86
        {
87
        JSONObject object = array.getJSONObject(s);
88
        long time = object.getLong("time");
89
        View pane = createPane(time, pL, pT, pB);
90
        mLayout.addView(pane);
91
        }
92
      }
93
    catch(JSONException jex)
94
      {
95
      android.util.Log.e("D", "fillLayout: JSON error: "+jex.getMessage());
96
      }
97

  
98
    View pane = createNewPane(pL,pT,pB);
99
    mLayout.addView(pane);
100
    }
101

  
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103

  
104
  private View createPane(long time, LinearLayout.LayoutParams pView, LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt)
105
    {
106

  
107
    }
108

  
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110

  
111
  private View createNewPane(LinearLayout.LayoutParams pView, LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt)
112
    {
113

  
38 114
    }
39 115

  
40 116
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff