Project

General

Profile

« Previous | Next » 

Revision b3fff6fb

Added by Leszek Koltunski over 2 years ago

Remove the concept of a 'TwistyActivity' altogether.

View differences:

src/main/java/org/distorted/objectlib/main/ObjectPreRender.java
19 19

  
20 20
package org.distorted.objectlib.main;
21 21

  
22
import android.app.Activity;
22 23
import android.content.SharedPreferences;
23 24
import android.content.res.Resources;
24 25

  
25
import org.distorted.objectlib.helpers.ObjectStateActioner;
26
import org.distorted.library.main.DistortedScreen;
27
import org.distorted.objectlib.helpers.ObjectLibInterface;
26 28
import org.distorted.objectlib.effects.BaseEffect;
27 29
import org.distorted.objectlib.effects.EffectController;
28 30
import org.distorted.objectlib.effects.scramble.ScrambleEffect;
29 31
import org.distorted.objectlib.helpers.BlockController;
30 32
import org.distorted.objectlib.helpers.MovesFinished;
31
import org.distorted.objectlib.helpers.TwistyActivity;
32 33

  
33 34
import java.lang.ref.WeakReference;
34 35

  
......
36 37

  
37 38
public class ObjectPreRender implements EffectController
38 39
  {
39
  private final WeakReference<TwistyActivity> mAct;
40
  private final WeakReference<Activity> mAct;
40 41
  private final ObjectControl mController;
41 42
  private ObjectType mNextObject;
42 43
  private TwistyObject mOldObject, mNewObject;
43 44
  private SharedPreferences mPreferences;
44 45
  private MovesFinished mAddActionListener;
45 46
  private final BlockController mBlockController;
46
  private final ObjectStateActioner mActioner;
47
  private final ObjectLibInterface mInterface;
47 48
  private String mDebug;
48 49

  
49 50
  private boolean mFinishRotation, mRemoveRotation, mRemovePatternRotation, mAddRotation,
......
64 65

  
65 66
///////////////////////////////////////////////////////////////////////////////////////////////////
66 67

  
67
  public ObjectPreRender(TwistyActivity act, ObjectControl controller, ObjectStateActioner actioner)
68
  public ObjectPreRender(Activity act, ObjectControl controller, ObjectLibInterface actioner)
68 69
    {
69 70
    mAct = new WeakReference<>(act);
70
    mActioner = actioner;
71
    mInterface = actioner;
71 72
    mController = controller;
72 73

  
73 74
    mFinishRotation       = false;
......
104 105
    if( mOldObject!=null ) mOldObject.releaseResources();
105 106
    mOldObject = mNewObject;
106 107

  
107
    TwistyActivity tact = mAct.get();
108

  
108
    Activity tact = mAct.get();
109 109
    Resources res = tact.getResources();
110 110

  
111 111
    mNewObject = object.create( mController.getQuat(), moves, res, mScreenWidth);
......
126 126
    try
127 127
      {
128 128
      int index = type.ordinal();
129
      mEffectID[index] = type.startEffect(mAct.get().getScreen(),this);
129
      DistortedScreen screen = mController.getInterface().getScreen();
130
      mEffectID[index] = type.startEffect(screen,this);
130 131
      }
131 132
    catch( Exception ex )
132 133
      {
......
146 147

  
147 148
    if( solved && !mIsSolved )
148 149
      {
149
      mActioner.onSolved();
150
      mInterface.onSolved();
150 151
      unblockEverything();
151 152
      doEffectNow( BaseEffect.Type.WIN );
152 153
      }
......
573 574
        if( effectID == mEffectID[i] )
574 575
          {
575 576
          if( i!=BaseEffect.Type.WIN.ordinal() ) unblockEverything();
576
          if( i==BaseEffect.Type.SCRAMBLE.ordinal() ) mActioner.onScrambleEffectFinished(mAct.get());
577
          if( i==BaseEffect.Type.WIN.ordinal()      ) mActioner.onWinEffectFinished(mAct.get(),mDebug,mScrambleObjectNum);
577
          if( i==BaseEffect.Type.SCRAMBLE.ordinal() ) mInterface.onScrambleEffectFinished();
578
          if( i==BaseEffect.Type.WIN.ordinal()      ) mInterface.onWinEffectFinished(mDebug,mScrambleObjectNum);
578 579
          break;
579 580
          }
580 581
        }

Also available in: Unified diff