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.sam016.vsflatomation.service.ble; | |
import java.util.HashMap; | |
import java.util.UUID; | |
public class AllGattCharacteristics { | |
private static HashMap<String, String> attributes = new HashMap(); | |
static { | |
attributes.put("00002a00-0000-1000-8000-00805f9b34fb", "Device Name"); |
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 { | |
private List<Literature> mLiteratureList; | |
@NonNull | |
@Override | |
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | |
View itemView; | |
switch (viewType) { | |
case Literature.TYPE_BOOK: |
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
@Override | |
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | |
switch (getItemViewType(position)) { | |
case Literature.TYPE_BOOK: | |
((BookViewHolder) holder).bindView(position); | |
break; | |
case Literature.TYPE_MAGAZINE: | |
((MagazineViewHolder) holder).bindView(position); | |
break; | |
case Literature.TYPE_NEWSPAPER: |
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
@NonNull | |
@Override | |
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | |
View itemView; | |
switch (viewType) { | |
case Literature.TYPE_BOOK: | |
itemView = LayoutInflater.from(parent.getContext()) | |
.inflate(R.layout.your_layout, parent, false); | |
return new BookViewHolder(itemView); | |
case Literature.TYPE_MAGAZINE: |
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... |
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
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
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
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
public void sortSubReddits(List<SubReddit> subreddits) { | |
Collections.sort(subreddits, (sub1, sub2) -> | |
String.CASE_INSENSITIVE_ORDER.compare(sub1.getDisplayName(), sub2.getDisplayName())); | |
} |
NewerOlder