Project

General

Profile

« Previous | Next » 

Revision ce31f774

Added by Leszek Koltunski over 1 year ago

remove all references to android.Context and android.Activity from distorted-objectlib

View differences:

src/main/java/org/distorted/bandaged/BandagedPlayLibInterface.java
9 9

  
10 10
package org.distorted.bandaged;
11 11

  
12
import android.util.DisplayMetrics;
13

  
12 14
import java.lang.ref.WeakReference;
13 15

  
14 16
import com.google.firebase.crashlytics.FirebaseCrashlytics;
......
187 189
      }
188 190
    }
189 191

  
192
///////////////////////////////////////////////////////////////////////////////////////////////////
193

  
194
  public int getScreenDensity()
195
    {
196
    DisplayMetrics dm = new DisplayMetrics();
197
    mAct.get().getWindowManager().getDefaultDisplay().getMetrics(dm);
198
    return dm.densityDpi;
199
    }
190 200
}
src/main/java/org/distorted/bandaged/BandagedPlayView.java
80 80
        {
81 81
        BandagedPlayActivity act = (BandagedPlayActivity)context;
82 82
        BandagedPlayLibInterface ref = new BandagedPlayLibInterface(act);
83
        mObjectController = new ObjectControl(act,ref);
83
        mObjectController = new ObjectControl(ref);
84 84
        mObjectController.setRotateOnCreation(true);
85 85
        mRenderer = new BandagedPlayRenderer(this);
86 86

  
src/main/java/org/distorted/config/ConfigObjectLibInterface.java
9 9

  
10 10
package org.distorted.config;
11 11

  
12
import android.util.DisplayMetrics;
13

  
12 14
import com.google.firebase.crashlytics.FirebaseCrashlytics;
13 15

  
14 16
import org.distorted.library.message.EffectMessageSender;
......
16 18
import org.distorted.objectlib.helpers.BlockController;
17 19
import org.distorted.objectlib.helpers.ObjectLibInterface;
18 20

  
21
import java.lang.ref.WeakReference;
22

  
19 23
///////////////////////////////////////////////////////////////////////////////////////////////////
20 24

  
21 25
public class ConfigObjectLibInterface implements ObjectLibInterface
22 26
{
27
  private final WeakReference<ConfigActivity> mAct;
28

  
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

  
23 31
  public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum) { }
24 32
  public void onScrambleEffectFinished() { }
25 33
  public void onBeginRotation() { }
......
127 135
      case BlockController.TYPE_THREAD    : reportThreadProblem(place,pause,resume,time); break;
128 136
      }
129 137
    }
138

  
139

  
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141

  
142
  ConfigObjectLibInterface(ConfigActivity act)
143
    {
144
    mAct = new WeakReference<>(act);
145
    }
146

  
147
///////////////////////////////////////////////////////////////////////////////////////////////////
148

  
149
  public int getScreenDensity()
150
    {
151
    DisplayMetrics dm = new DisplayMetrics();
152
    mAct.get().getWindowManager().getDefaultDisplay().getMetrics(dm);
153
    return dm.densityDpi;
154
    }
130 155
}
src/main/java/org/distorted/config/ConfigSurfaceView.java
75 75
      if(!isInEditMode())
76 76
        {
77 77
        ConfigActivity act = (ConfigActivity)context;
78
        ConfigObjectLibInterface ref = new ConfigObjectLibInterface();
79
        mObjectController = new ObjectControl(act,ref);
78
        ConfigObjectLibInterface ref = new ConfigObjectLibInterface(act);
79
        mObjectController = new ObjectControl(ref);
80 80
        mObjectController.setRotateOnCreation(true);
81 81
        mRenderer = new ConfigRenderer(this);
82 82

  
src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java
9 9

  
10 10
package org.distorted.dialogs;
11 11

  
12
import java.io.File;
13
import java.io.FileInputStream;
14
import java.io.InputStream;
12 15
import java.lang.ref.WeakReference;
13 16

  
14 17
import android.app.Activity;
......
193 196

  
194 197
        try
195 198
          {
199
          File file = new File(act.getFilesDir(), objectName);
200
          InputStream stream = new FileInputStream(file);
196 201
          JsonReader reader = new JsonReader();
197
          reader.readNumScramblesAndPrice(act,objectName);
202
          reader.readNumScramblesAndPrice(stream);
203
          stream.close();
204

  
198 205
          mInfo.mNumScrambles = reader.getNumScrambles();
199 206
          mInfo.mPrice        = reader.getPrice();
200 207
          if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Read from JSON numScrambles="+mInfo.mNumScrambles+" price="+mInfo.mPrice);
src/main/java/org/distorted/main/RubikObjectLibInterface.java
10 10
package org.distorted.main;
11 11

  
12 12
import android.os.Bundle;
13
import android.util.DisplayMetrics;
13 14

  
14 15
import androidx.annotation.NonNull;
15 16

  
......
513 514
    d.setArguments(bundle);
514 515
    d.show( act.getSupportFragmentManager(), RubikDialogNewRecord.getDialogTag() );
515 516
    }
517

  
518
///////////////////////////////////////////////////////////////////////////////////////////////////
519

  
520
  public int getScreenDensity()
521
    {
522
    DisplayMetrics dm = new DisplayMetrics();
523
    mAct.get().getWindowManager().getDefaultDisplay().getMetrics(dm);
524
    return dm.densityDpi;
525
    }
516 526
}
src/main/java/org/distorted/main/RubikSurfaceView.java
111 111
        {
112 112
        RubikActivity act = (RubikActivity)context;
113 113
        RubikObjectLibInterface ref = new RubikObjectLibInterface(act);
114
        mObjectController = new ObjectControl(act,ref);
114
        mObjectController = new ObjectControl(ref);
115 115
        mRenderer = new RubikRenderer(this);
116 116

  
117 117
        final ActivityManager activityManager= (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
src/main/java/org/distorted/purchase/PurchaseObjectLibInterface.java
9 9

  
10 10
package org.distorted.purchase;
11 11

  
12
import android.util.DisplayMetrics;
13

  
12 14
import com.google.firebase.crashlytics.FirebaseCrashlytics;
13 15

  
14 16
import org.distorted.objectlib.BuildConfig;
15 17
import org.distorted.objectlib.helpers.ObjectLibInterface;
16 18

  
19
import java.lang.ref.WeakReference;
20

  
17 21
///////////////////////////////////////////////////////////////////////////////////////////////////
18 22

  
19 23
public class PurchaseObjectLibInterface implements ObjectLibInterface
20 24
{
25
  private final WeakReference<PurchaseActivity> mAct;
26

  
27
///////////////////////////////////////////////////////////////////////////////////////////////////
28

  
29
  PurchaseObjectLibInterface(PurchaseActivity act)
30
    {
31
    mAct = new WeakReference<>(act);
32
    }
33

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

  
21 36
  public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum) { }
22 37
  public void onScrambleEffectFinished() { }
23 38
  public void onBeginRotation() { }
......
54 69
        }
55 70
      }
56 71
    }
72

  
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74

  
75
  public int getScreenDensity()
76
    {
77
    DisplayMetrics dm = new DisplayMetrics();
78
    mAct.get().getWindowManager().getDefaultDisplay().getMetrics(dm);
79
    return dm.densityDpi;
80
    }
57 81
}
src/main/java/org/distorted/purchase/PurchaseSurfaceView.java
72 72
      if(!isInEditMode())
73 73
        {
74 74
        PurchaseActivity act = (PurchaseActivity)context;
75
        PurchaseObjectLibInterface ref = new PurchaseObjectLibInterface();
76
        mObjectController = new ObjectControl(act,ref);
75
        PurchaseObjectLibInterface ref = new PurchaseObjectLibInterface(act);
76
        mObjectController = new ObjectControl(ref);
77 77
        mObjectController.setRotateOnCreation(true);
78 78
        mRenderer = new PurchaseRenderer(this);
79 79

  
src/main/java/org/distorted/tutorials/TutorialObjectLibInterface.java
9 9

  
10 10
package org.distorted.tutorials;
11 11

  
12
import android.util.DisplayMetrics;
13

  
12 14
import com.google.firebase.crashlytics.FirebaseCrashlytics;
13 15

  
14 16
import org.distorted.library.message.EffectMessageSender;
......
22 24

  
23 25
public class TutorialObjectLibInterface implements ObjectLibInterface
24 26
{
25
   WeakReference<TutorialActivity> mAct;
27
  private final WeakReference<TutorialActivity> mAct;
26 28

  
27 29
///////////////////////////////////////////////////////////////////////////////////////////////////
28 30

  
......
31 33
    mAct = new WeakReference<>(act);
32 34
    }
33 35

  
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

  
34 38
  public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum) { }
35 39
  public void onScrambleEffectFinished() { }
36 40
  public void onBeginRotation() { }
......
139 143

  
140 144
///////////////////////////////////////////////////////////////////////////////////////////////////
141 145

  
142
   public void onFinishRotation(int axis, int row, int angle)
146
  public void onFinishRotation(int axis, int row, int angle)
143 147
     {
144 148
     TutorialActivity act = mAct.get();
145 149
     TutorialScreen state = act.getState();
......
148 152

  
149 153
///////////////////////////////////////////////////////////////////////////////////////////////////
150 154

  
151
   public void failedToDrag()
155
  public void failedToDrag()
152 156
     {
153 157
     TutorialActivity act = mAct.get();
154 158
     TutorialScreen state = act.getState();
155 159
     state.reddenLock(act);
156 160
     }
161

  
162
///////////////////////////////////////////////////////////////////////////////////////////////////
163

  
164
  public int getScreenDensity()
165
    {
166
    DisplayMetrics dm = new DisplayMetrics();
167
    mAct.get().getWindowManager().getDefaultDisplay().getMetrics(dm);
168
    return dm.densityDpi;
169
    }
157 170
}
src/main/java/org/distorted/tutorials/TutorialSurfaceView.java
85 85
        {
86 86
        TutorialActivity act = (TutorialActivity)context;
87 87
        TutorialObjectLibInterface ref = new TutorialObjectLibInterface(act);
88
        mObjectController = new ObjectControl(act,ref);
88
        mObjectController = new ObjectControl(ref);
89 89
        mRenderer = new TutorialRenderer(this);
90 90

  
91 91
        final ActivityManager activityManager= (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);

Also available in: Unified diff