Skip to content

Commit

Permalink
Revert "Kotlin conversion"
Browse files Browse the repository at this point in the history
This reverts commit ef06794.
  • Loading branch information
hannesa2 committed May 6, 2024
1 parent 55aa5bf commit dd7d9a6
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 88 deletions.
114 changes: 114 additions & 0 deletions library/src/main/java/com/panoramagl/ios/NSTimer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* PanoramaGL library
* Version 0.2 beta
* Copyright (c) 2010 Javier Baez <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.panoramagl.ios;

import android.os.SystemClock;

import java.util.Date;

import timber.log.Timber;

public class NSTimer extends Object {
/**
* member variables
*/

private boolean mIsRunning;

private final long mInterval;
private Runnable mTarget;
private Object[] mUserInfo;
private final boolean mRepeats;

private Thread mThread;
private long mLastTime, mTime;

/**
* init methods
*/

public NSTimer(Date date, float interval, Runnable target, Object[] userInfo, boolean repeats) {
super();
mIsRunning = true;
mInterval = (long) (interval * 1000.0f);
mTarget = target;
mUserInfo = userInfo;
mRepeats = repeats;
mLastTime = date.getTime();
mThread = new Thread(new java.lang.Runnable() {
@Override
public void run() {
while (mIsRunning) {
mTime = SystemClock.uptimeMillis();
if (mTime - mLastTime >= mInterval) {
try {
mTarget.run(NSTimer.this, mUserInfo);
} catch (Throwable e) {
Timber.e(e);
}
if (!mRepeats)
invalidate();
}
mLastTime = mTime;
try {
Thread.sleep(mInterval);
} catch (Throwable ignored) {
}
}
}
});
mThread.start();
}

public static NSTimer scheduledTimerWithTimeInterval(float interval, Runnable target, Object[] userInfo, boolean repeats) {
return new NSTimer(new Date(SystemClock.uptimeMillis()), interval, target, userInfo, repeats);
}

public void invalidate() {
mIsRunning = false;
mThread = null;
mTarget = null;
mUserInfo = null;
}

public boolean isValid() {
return mIsRunning;
}

/**
* dealloc methods
*/

@Override
protected void finalize() throws Throwable {
try {
this.invalidate();
} catch (Throwable ignored) {
}
super.finalize();
}

/**
* sub-interfaces declaration
*/

public interface Runnable {
void run(NSTimer target, Object[] userInfo);
}
}
87 changes: 0 additions & 87 deletions library/src/main/java/com/panoramagl/ios/NSTimer.kt

This file was deleted.

25 changes: 24 additions & 1 deletion library/src/main/java/com/panoramagl/ios/structs/CGPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@
import com.panoramagl.structs.PLIStruct;

public class CGPoint implements PLIStruct<CGPoint> {
/**
* member variables
*/

public float x, y;

/**
* init methods
*/

public CGPoint() {
this(0.0f, 0.0f);
}
Expand All @@ -50,6 +57,10 @@ public static CGPoint CGPointMake(float x, float y) {
return new CGPoint(x, y);
}

/**
* reset methods
*/

@Override
public boolean isResetted() {
return (x == 0.0f && y == 0.0f);
Expand All @@ -61,6 +72,10 @@ public CGPoint reset() {
return this;
}

/**
* set methods
*/

@Override
public CGPoint setValues(CGPoint point) {
x = point.x;
Expand All @@ -74,14 +89,22 @@ public CGPoint setValues(float x, float y) {
return this;
}

/**
* clone methods
*/

@Override
public CGPoint clone() {
return new CGPoint(x, y);
}

/**
* native methods
*/

@Override
public boolean equals(Object o) {
if (o instanceof CGPoint) {
if (o != null && o instanceof CGPoint) {
if (this == o)
return true;
CGPoint point = (CGPoint) o;
Expand Down

0 comments on commit dd7d9a6

Please sign in to comment.