Skip to content

Instantly share code, notes, and snippets.

@wispborne
wispborne / Easing.kt
Created October 6, 2022 14:44
Methods for easing.
package org.wisp.gatesawakened.jumping
/**
* Taken from <a href="https://github.com/mattdesl/cisc226game/blob/master/SpaceGame/src/space/engine/easing/Easing.java">Github</a>
*
* @author Robert Penner (functions)
* @author davedes (java port)
* @author Wisp (kotlin port)
*/
object Easing {
@wispborne
wispborne / SystemFinder.kt
Last active October 6, 2022 14:43
SystemFinder - A Starsector class to find systems using vanilla's code but without requiring a BaseHubMission.
import com.fs.starfarer.api.campaign.*
import com.fs.starfarer.api.campaign.econ.CommodityOnMarketAPI
import com.fs.starfarer.api.campaign.econ.MarketAPI
import com.fs.starfarer.api.impl.campaign.missions.cb.BaseCustomBounty
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithSearch
import com.fs.starfarer.api.impl.campaign.missions.hub.ReqMode
import org.lwjgl.util.vector.Vector2f
class SystemFinder
@JvmOverloads constructor(val mission: HubMissionWithSearch = BaseCustomBounty()) {
@wispborne
wispborne / StringUtils.java
Created May 18, 2022 06:10
Typo correction code for Starsector, based upon the CommandUtils class of LazyWizard's Console Commands.
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.FactionAPI;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class StringUtils {
import android.content.Context
import android.net.ConnectivityManager
import android.net.Network
import android.net.NetworkCapabilities
import android.net.NetworkRequest
import androidx.lifecycle.LiveData
object NetworkDetectorLiveData : LiveData<Boolean>() {
private val manager: ConnectivityManager by lazy {
ManagementApp.instance.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
@oldergod
oldergod / 01_Activity.java
Last active January 19, 2018 22:19
Managing RxState Starting point
/**
* Many things are omitted to focus on the relevant data.
*/
public class Activity extends AppCompatActivity {
Binder binder;
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
bind();
}
@vic797
vic797 / OnSwipeTouchListener.java
Last active May 28, 2018 18:45
This is a simple class for basic gestures detection on Android. The original class that I found on internet includes only the swipe gestures.
import android.content.Context;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
@SuppressWarnings("unused")
public abstract class OnSwipeTouchListener implements View.OnTouchListener {
private final GestureDetector gestureDetector;
@shymek
shymek / StringListConverter.java
Last active January 29, 2017 11:51
String List converter for requery.
import android.support.annotation.Nullable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import io.requery.Converter;
/**
* @author Jakub Szymion
import android.content.Context
import android.content.SharedPreferences
import android.preference.PreferenceManager
import java.util.*
import kotlin.reflect.KProperty
/*
* Android Shared Preferences Delegate for Kotlin
*
* Usage:
@neworld
neworld / howto.md
Last active July 10, 2024 11:24
How to make faster Android build without sacrificing new api lint check

Original solution sacrifices new api lint check.

Here my solution:

int minSdk = hasProperty('minSdk') ? minSdk.toInteger() : 16

apply plugin: 'com.android.application'

android {
 compileSdkVersion 23
@keyboardr
keyboardr / HeadlessFragment.java
Last active December 31, 2021 01:05
A file template for creating a headless Fragment. The attach() methods add the fragment to the parent if it doesn't already exist and returns the attached fragment. The methods ensure that the parent implements the parent interface. If needed, parameters may be added to the attach() methods to supply fragment arguments.
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
#parse("File Header.java")
public class ${NAME} extends Fragment {
private static final String FRAG_TAG = ${NAME}.class.getCanonicalName();