Skip to content

Instantly share code, notes, and snippets.

View jayrambhia's full-sized avatar

Jay Rambhia jayrambhia

View GitHub Profile
@jayrambhia
jayrambhia / Android TopSheetDialog Implementation by Taskito.md
Last active December 16, 2023 12:36
Android Top Sheet Implementation
<style name="TopSheet_DialogAnimation">
  <item name="android:windowEnterAnimation">@anim/slide_out_from_top</item>
  <item name="android:windowExitAnimation">@anim/slide_back_to_top</item>
</style>

slide_out_from_top

@jayrambhia
jayrambhia / BattleshipActivity.kt
Last active April 21, 2023 14:11
Battleship game in Kotlin
class BattleshipActivity: AppCompatActivity() {
private lateinit var gridAdpater: UiCellAdapter
private lateinit var myBoard: Board
private lateinit var otherBoard: Board
private val width: Int = 10
override fun onCreate(savedInstanceState: Bundle?) {
@jayrambhia
jayrambhia / appstore1.kt
Last active May 9, 2019 06:30
Redux implementation in Kotlin
data class AppState(val searchState: SearchState = SearchState())
class AppStore: Store<AppState>(
initialState = AppState(),
reducers = listOf(::reduceSearchState)) {
companion object {
val instance by lazy {
AppStore()
}
@jayrambhia
jayrambhia / ColorDetector.java
Last active June 22, 2021 19:00
ColorDetector - Lint detector
public class ColorDetector extends ResourceXmlDetector {
private static final String ID = "CustomColors";
private static final String DESCRIPTION = "Custom colors used";
private static final String EXPLANATION = "Use pre-defined (allowed) colors only";
private static final Category CATEGORY = Category.CORRECTNESS;
private static final int PRIORITY = 6;
private static final Severity SEVERITY = Severity.ERROR;
public static final Issue ISSUE = Issue.create(
@LayoutSpec(events = { LikeChangeEvent.class })
public class FullScreenComponentSpec {
... other stuff
@OnEvent(ClickEvent.class)
static void onLikeButtonClicked(ComponentContext c, @State boolean isLiked, @Prop GifItem gif, @Prop Component gifComponent) {
FullScreenComponent.updateLikeButtonAsync(c, !isLiked);
FullScreenComponent.dispatchLikeChangeEvent(FullScreenComponent.getLikeChangeEventHandler(c), !isLiked, gif.getId());
@jayrambhia
jayrambhia / EventHandler.java
Last active April 28, 2017 11:28
Events with Litho
final EventDispatcher likeEventDispatcher = new EventDispatcher() {
@Override
public Object dispatchOnEvent(EventHandler eventHandler, Object eventState) {
// Do stuff here
return null;
}
};
HasEventDispatcher hasEventDispatcher = new HasEventDispatcher() {
@Override
@jayrambhia
jayrambhia / FullScreenComponentSpec.java
Last active April 26, 2017 13:24
Component Navigation with Litho
@LayoutSpec
public class FullScreenComponentSpec {
@OnCreateInitialState
static void createInitialState(ComponentContext c, StateValue<Boolean> isLiked, @Prop boolean initLiked) {
isLiked.set(initLiked);
}
@OnCreateLayout
static ComponentLayout onCreateLayout(ComponentContext context, @Prop RequestManager glide, @Prop GifItem gif, @State boolean isLiked) {
@jayrambhia
jayrambhia / GifItem.java
Last active April 24, 2017 23:10
Android Litho State
public class GifItem {
private final String id;
private final String image;
private final boolean isLiked;
public GifItem(JsonObject json, boolean isLiked) {
this.id = json.get("id").getAsString();
JsonObject image = json.get("images").getAsJsonObject().get("original").getAsJsonObject();
this.image = image.get("url").getAsString();
@jayrambhia
jayrambhia / GifItem.java
Last active June 24, 2017 12:09
GIF search engine with Litho and Giphy for Android
public class GifItem {
private final String id;
private final String image;
public GifItem(JsonObject json) {
this.id = json.get("id").getAsString();
JsonObject image = json.get("images").getAsJsonObject().get("original").getAsJsonObject();
this.image = image.get("url").getAsString();
}
@jayrambhia
jayrambhia / lenx_privacy_policy.txt
Created February 13, 2017 09:25
Lenx Privacy Policy
Privacy Policy
Fenchtose built Lenx app as a commercial app. This SERVICE is provided by Fenchtose is intended for use as is.
This page is used to inform website visitors regarding my policies with the collection, use, and
disclosure of Personal Information if anyone decided to use my Service.
If you choose to use my Service, then you agree to the collection and use of information in
relation with this policy. The Personal Information that I collect are used for providing and
improving the Service. I will not use or share your information with anyone except as described
in this Privacy Policy.