Project

General

Profile

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

magiccube / src / main / java / org / distorted / info / InfoActivity.java @ a5972f92

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 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.info;
11

    
12
import java.io.InputStream;
13

    
14
import android.os.Bundle;
15

    
16
import org.distorted.helpers.BaseActivity;
17
import org.distorted.library.main.DistortedLibrary;
18
import org.distorted.objectlib.main.InitAssets;
19
import org.distorted.objectlib.main.ObjectControl;
20
import org.distorted.main.R;
21
import org.distorted.dialogs.RubikDialogError;
22
import org.distorted.objectlib.main.TwistyObject;
23
import org.distorted.objects.RubikObject;
24
import org.distorted.objects.RubikObjectList;
25

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

    
28
public class InfoActivity extends BaseActivity
29
{
30
    private static final int ACTIVITY_NUMBER = 1;
31
    private InfoScreen mScreen;
32
    private int mObjectOrdinal;
33

    
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

    
36
    @Override
37
    protected void onCreate(Bundle savedState)
38
      {
39
      super.onCreate(savedState);
40
      DistortedLibrary.onCreate(ACTIVITY_NUMBER);
41
      setContentView(R.layout.info);
42

    
43
      Bundle b = getIntent().getExtras();
44
      if(b != null) mObjectOrdinal = b.getInt("obj");
45

    
46
      computeScreenDimensions();
47
      hideNavigationBar();
48
      cutoutHack();
49
      computeLowerBarHeight(RATIO_BAR);
50
      }
51

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53
    
54
    @Override
55
    protected void onPause() 
56
      {
57
      super.onPause();
58
      InfoSurfaceView view = findViewById(R.id.infoSurfaceView);
59
      view.onPause();
60
      DistortedLibrary.onPause(ACTIVITY_NUMBER);
61
      }
62

    
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64
    
65
    @Override
66
    protected void onResume() 
67
      {
68
      super.onResume();
69
      DistortedLibrary.onResume(ACTIVITY_NUMBER);
70
      InfoSurfaceView view = findViewById(R.id.infoSurfaceView);
71
      view.onResume();
72

    
73
      if( mScreen==null ) mScreen = new InfoScreen();
74
      mScreen.onAttachedToWindow(this,mObjectOrdinal);
75

    
76
      if( mObjectOrdinal>=0 && mObjectOrdinal< RubikObjectList.getNumObjects() )
77
        {
78
        RubikObject object = RubikObjectList.getObject(mObjectOrdinal);
79
        changeIfDifferent(object,mObjectOrdinal,view.getObjectControl());
80
        }
81
      }
82

    
83
///////////////////////////////////////////////////////////////////////////////////////////////////
84
    
85
    @Override
86
    protected void onDestroy() 
87
      {
88
      super.onDestroy();
89
      DistortedLibrary.onDestroy(ACTIVITY_NUMBER);
90
      }
91

    
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93

    
94
    void OpenGLError()
95
      {
96
      RubikDialogError errDiag = new RubikDialogError();
97
      errDiag.show(getSupportFragmentManager(), null);
98
      }
99

    
100
///////////////////////////////////////////////////////////////////////////////////////////////////
101

    
102
    private void changeIfDifferent(RubikObject object,int ordinal,ObjectControl control)
103
      {
104
      if( object!=null )
105
        {
106
        int iconMode           = TwistyObject.MODE_NORM;
107
        InputStream jsonStream = object.getObjectStream(this);
108
        InputStream meshStream = object.getMeshStream(this);
109
        String name            = object.getUpperName();
110
        InitAssets asset       = new InitAssets(jsonStream,meshStream,null);
111
        control.changeIfDifferent(ordinal,name,iconMode,asset);
112
        }
113
      }
114

    
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116
// PUBLIC API
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118

    
119
    public ObjectControl getControl()
120
      {
121
      InfoSurfaceView view = findViewById(R.id.infoSurfaceView);
122
      return view.getObjectControl();
123
      }
124
}
(1-1/6)