This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Game { | |
private String answer; | |
private String hits; | |
private String misses; | |
public static final int MAX_MISSES = 7; | |
public Game(String answer) { | |
this.answer = answer; | |
hits = ""; | |
misses = ""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
Gson gson = new Gson(); | |
String file; | |
JsonObject jsonObject; | |
// used in the map example only | |
Type type = new TypeToken<Map<String, String>>(){}.getType(); | |
FileReader json = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.keinix.interactivestory; | |
import android.app.Activity; | |
import android.app.Application; | |
import android.content.pm.ActivityInfo; | |
import android.os.Bundle; | |
public class InteractiveStoryApplication extends Application { | |
@Override | |
public void onCreate() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean networkIsAvailable() { | |
ConnectivityManager manager = (ConnectivityManager) | |
getSystemService(Context.CONNECTIVITY_SERVICE); | |
NetworkInfo networkInfo = manager.getActiveNetworkInfo(); | |
boolean isAvailable = false; | |
if (networkInfo != null && networkInfo.isConnected()) { | |
isAvailable = true; | |
} | |
return isAvailable; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void sortSubReddits(List<SubReddit> subreddits) { | |
Collections.sort(subreddits, (sub1, sub2) -> | |
String.CASE_INSENSITIVE_ORDER.compare(sub1.getDisplayName(), sub2.getDisplayName())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (dX > 0) { // Swiping to the right | |
background.setBounds(itemView.getLeft(), itemView.getTop(), | |
itemView.getLeft() + ((int) dX) + backgroundCornerOffset, | |
itemView.getBottom()); | |
} else if (dX < 0) { // Swiping to the left | |
background.setBounds(itemView.getRight() + ((int) dX) - backgroundCornerOffset, | |
itemView.getTop(), itemView.getRight(), itemView.getBottom()); | |
} else { // view is unSwiped | |
background.setBounds(0, 0, 0, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int iconMargin = (itemView.getHeight() - icon.getIntrinsicHeight()) / 2; | |
int iconTop = itemView.getTop() + (itemView.getHeight() - icon.getIntrinsicHeight()) / 2; | |
int iconBottom = iconTop + icon.getIntrinsicHeight(); | |
if (dX > 0) { // Swiping to the right | |
int iconLeft = itemView.getLeft() + iconMargin + icon.getIntrinsicWidth(); | |
int iconRight = itemView.getLeft() + iconMargin; | |
icon.setBounds(iconLeft, iconTop, iconRight, iconBottom); | |
background.setBounds(itemView.getLeft(), itemView.getTop(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.keinix.protoflow.util; | |
import android.graphics.Canvas; | |
import android.graphics.Color; | |
import android.graphics.drawable.ColorDrawable; | |
import android.graphics.drawable.Drawable; | |
import android.support.v4.content.ContextCompat; | |
import android.support.v7.widget.RecyclerView; | |
import android.support.v7.widget.helper.ItemTouchHelper; | |
import android.view.View; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Book implements Literature { | |
// variables and methods | |
@Override | |
public int getType() { | |
return Literature.TYPE_BOOK; | |
} | |
} | |
public class Magazine implements Literature{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LiteratureAdapter extends RecyclerView.Adapter { | |
... | |
class BookViewHolder extends RecyclerView.ViewHolder { | |
public BookViewHolder(View itemView) { | |
super(itemView); | |
// get reference to views | |
// itemView.findViewById... |
OlderNewer