Auto formatted all files.
This commit is contained in:
@@ -13,16 +13,16 @@ import io.reactivex.rxjava3.core.Completable;
|
|||||||
import io.reactivex.rxjava3.core.Flowable;
|
import io.reactivex.rxjava3.core.Flowable;
|
||||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
|
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
public class MonsterRepository {
|
public class MonsterRepository {
|
||||||
|
|
||||||
private AppDatabase m_db;
|
private final AppDatabase m_db;
|
||||||
|
|
||||||
public MonsterRepository(@NonNull AppDatabase db) {
|
public MonsterRepository(@NonNull AppDatabase db) {
|
||||||
m_db = db;
|
m_db = db;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Flowable<List<Monster>> getMonsters() {
|
public Flowable<List<Monster>> getMonsters() {
|
||||||
|
|
||||||
return m_db.monsterDAO()
|
return m_db.monsterDAO()
|
||||||
.getAll()
|
.getAll()
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
|
|||||||
@@ -10,14 +10,6 @@ import org.commonmark.renderer.html.HtmlNodeRendererFactory;
|
|||||||
import org.commonmark.renderer.html.HtmlRenderer;
|
import org.commonmark.renderer.html.HtmlRenderer;
|
||||||
|
|
||||||
public final class CommonMarkHelper {
|
public final class CommonMarkHelper {
|
||||||
private static final class MyNodeRendererFactory implements HtmlNodeRendererFactory {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NodeRenderer create(HtmlNodeRendererContext context) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toHtml(String rawCommonMark) {
|
public static String toHtml(String rawCommonMark) {
|
||||||
Parser parser = Parser.builder().build();
|
Parser parser = Parser.builder().build();
|
||||||
Node document = parser.parse(rawCommonMark);
|
Node document = parser.parse(rawCommonMark);
|
||||||
@@ -35,4 +27,12 @@ public final class CommonMarkHelper {
|
|||||||
HtmlRenderer renderer = HtmlRenderer.builder().build();
|
HtmlRenderer renderer = HtmlRenderer.builder().build();
|
||||||
return renderer.render(document);
|
return renderer.render(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final class MyNodeRendererFactory implements HtmlNodeRendererFactory {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NodeRenderer create(HtmlNodeRendererContext context) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ import java.util.Objects;
|
|||||||
|
|
||||||
public class Language implements Comparator<Language>, Comparable<Language> {
|
public class Language implements Comparator<Language>, Comparable<Language> {
|
||||||
|
|
||||||
|
private String mName;
|
||||||
|
private boolean mSpeaks;
|
||||||
|
|
||||||
public Language(String name, boolean speaks) {
|
public Language(String name, boolean speaks) {
|
||||||
mName = name;
|
mName = name;
|
||||||
mSpeaks = speaks;
|
mSpeaks = speaks;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String mName;
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
@@ -22,8 +23,6 @@ public class Language implements Comparator<Language>, Comparable<Language> {
|
|||||||
mName = value;
|
mName = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean mSpeaks;
|
|
||||||
|
|
||||||
public boolean getSpeaks() {
|
public boolean getSpeaks() {
|
||||||
return mSpeaks;
|
return mSpeaks;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,14 @@ import java.util.Comparator;
|
|||||||
|
|
||||||
public class SavingThrow implements Comparator<SavingThrow>, Comparable<SavingThrow> {
|
public class SavingThrow implements Comparator<SavingThrow>, Comparable<SavingThrow> {
|
||||||
|
|
||||||
|
private String mName;
|
||||||
|
private int mOrder;
|
||||||
|
|
||||||
public SavingThrow(String name, int order) {
|
public SavingThrow(String name, int order) {
|
||||||
mName = name;
|
mName = name;
|
||||||
mOrder = order;
|
mOrder = order;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String mName;
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
@@ -19,8 +20,6 @@ public class SavingThrow implements Comparator<SavingThrow>, Comparable<SavingTh
|
|||||||
mName = value;
|
mName = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int mOrder;
|
|
||||||
|
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
return mOrder;
|
return mOrder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,9 +56,9 @@ public class EditLanguagesRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
headerViewHolder.telepathy.setOnValueChangeListener(mOnTelepathyRangeChanged);
|
headerViewHolder.telepathy.setOnValueChangeListener(mOnTelepathyRangeChanged);
|
||||||
headerViewHolder.understandsBut.setText(mUnderstandsBut);
|
headerViewHolder.understandsBut.setText(mUnderstandsBut);
|
||||||
headerViewHolder.understandsBut.addTextChangedListener(mOnUnderstandsButChanged);
|
headerViewHolder.understandsBut.addTextChangedListener(mOnUnderstandsButChanged);
|
||||||
} else if(holder instanceof ItemViewHolder) {
|
} else if (holder instanceof ItemViewHolder) {
|
||||||
ItemViewHolder itemViewHolder = (ItemViewHolder)holder;
|
ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
|
||||||
itemViewHolder.mItem = mValues.get(position-1);
|
itemViewHolder.mItem = mValues.get(position - 1);
|
||||||
itemViewHolder.mContentView.setText(itemViewHolder.mItem.getName());
|
itemViewHolder.mContentView.setText(itemViewHolder.mItem.getName());
|
||||||
itemViewHolder.itemView.setOnClickListener(view -> {
|
itemViewHolder.itemView.setOnClickListener(view -> {
|
||||||
if (mOnClick != null) {
|
if (mOnClick != null) {
|
||||||
@@ -70,7 +70,7 @@ public class EditLanguagesRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return mValues.size() +1;
|
return mValues.size() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -111,4 +111,4 @@ public class EditLanguagesRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
return super.toString() + " '" + mContentView.getText() + "'";
|
return super.toString() + " '" + mContentView.getText() + "'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,15 +21,9 @@ import io.reactivex.rxjava3.disposables.Disposable;
|
|||||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
|
|
||||||
public class MonsterListRecyclerViewAdapter extends RecyclerView.Adapter<MonsterListRecyclerViewAdapter.ViewHolder> {
|
public class MonsterListRecyclerViewAdapter extends RecyclerView.Adapter<MonsterListRecyclerViewAdapter.ViewHolder> {
|
||||||
public interface ItemCallback {
|
|
||||||
void onItemCallback(Monster monster);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Monster> mValues;
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final ItemCallback mOnDelete;
|
private final ItemCallback mOnDelete;
|
||||||
private final ItemCallback mOnClick;
|
private final ItemCallback mOnClick;
|
||||||
private Disposable mDisposable;
|
|
||||||
private final Flowable<List<Monster>> mItemsObservable;
|
private final Flowable<List<Monster>> mItemsObservable;
|
||||||
private final View.OnClickListener mOnClickListener = new View.OnClickListener() {
|
private final View.OnClickListener mOnClickListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -40,6 +34,8 @@ public class MonsterListRecyclerViewAdapter extends RecyclerView.Adapter<Monster
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private List<Monster> mValues;
|
||||||
|
private Disposable mDisposable;
|
||||||
|
|
||||||
public MonsterListRecyclerViewAdapter(Context context,
|
public MonsterListRecyclerViewAdapter(Context context,
|
||||||
Flowable<List<Monster>> itemsObservable,
|
Flowable<List<Monster>> itemsObservable,
|
||||||
@@ -79,17 +75,6 @@ public class MonsterListRecyclerViewAdapter extends RecyclerView.Adapter<Monster
|
|||||||
return mContext;
|
return mContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
|
||||||
final TextView mIdView;
|
|
||||||
final TextView mContentView;
|
|
||||||
|
|
||||||
ViewHolder(View view) {
|
|
||||||
super(view);
|
|
||||||
mIdView = view.findViewById(R.id.id_text);
|
|
||||||
mContentView = view.findViewById(R.id.content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||||
super.onAttachedToRecyclerView(recyclerView);
|
super.onAttachedToRecyclerView(recyclerView);
|
||||||
@@ -115,4 +100,19 @@ public class MonsterListRecyclerViewAdapter extends RecyclerView.Adapter<Monster
|
|||||||
mOnDelete.onItemCallback(monster);
|
mOnDelete.onItemCallback(monster);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface ItemCallback {
|
||||||
|
void onItemCallback(Monster monster);
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
final TextView mIdView;
|
||||||
|
final TextView mContentView;
|
||||||
|
|
||||||
|
ViewHolder(View view) {
|
||||||
|
super(view);
|
||||||
|
mIdView = view.findViewById(R.id.id_text);
|
||||||
|
mContentView = view.findViewById(R.id.content);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public class SearchResultsRecyclerViewAdapter extends RecyclerView.Adapter<Searc
|
|||||||
private String mSearchText;
|
private String mSearchText;
|
||||||
private List<Monster> mValues;
|
private List<Monster> mValues;
|
||||||
private Disposable mSubscriptionHandler;
|
private Disposable mSubscriptionHandler;
|
||||||
|
|
||||||
public SearchResultsRecyclerViewAdapter(MonsterRepository repository,
|
public SearchResultsRecyclerViewAdapter(MonsterRepository repository,
|
||||||
ItemCallback onClick) {
|
ItemCallback onClick) {
|
||||||
mRepository = repository;
|
mRepository = repository;
|
||||||
|
|||||||
@@ -18,16 +18,11 @@ import com.majinnaibu.monstercards.R;
|
|||||||
|
|
||||||
public class SwipeToDeleteCallback extends ItemTouchHelper.SimpleCallback {
|
public class SwipeToDeleteCallback extends ItemTouchHelper.SimpleCallback {
|
||||||
|
|
||||||
public interface OnDeleteCallback {
|
|
||||||
void onDelete(int position);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Drawable icon;
|
private final Drawable icon;
|
||||||
private final ColorDrawable background;
|
private final ColorDrawable background;
|
||||||
private final Paint clearPaint;
|
private final Paint clearPaint;
|
||||||
private final OnDeleteCallback mOnDelete;
|
private final OnDeleteCallback mOnDelete;
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
|
|
||||||
public SwipeToDeleteCallback(Context context, OnDeleteCallback onDelete) {
|
public SwipeToDeleteCallback(Context context, OnDeleteCallback onDelete) {
|
||||||
super(0, ItemTouchHelper.LEFT);
|
super(0, ItemTouchHelper.LEFT);
|
||||||
mOnDelete = onDelete;
|
mOnDelete = onDelete;
|
||||||
@@ -84,4 +79,8 @@ public class SwipeToDeleteCallback extends ItemTouchHelper.SimpleCallback {
|
|||||||
|
|
||||||
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
|
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface OnDeleteCallback {
|
||||||
|
void onDelete(int position);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import android.util.Log;
|
|||||||
|
|
||||||
public class Logger {
|
public class Logger {
|
||||||
public static final String LOG_TAG = "MonsterCards";
|
public static final String LOG_TAG = "MonsterCards";
|
||||||
|
|
||||||
public static void logUnimplementedMethod() {
|
public static void logUnimplementedMethod() {
|
||||||
Exception ex = new Exception();
|
Exception ex = new Exception();
|
||||||
StackTraceElement[] stackTrace = ex.getStackTrace();
|
StackTraceElement[] stackTrace = ex.getStackTrace();
|
||||||
|
|||||||
@@ -12,12 +12,12 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layoutManager="LinearLayoutManager"
|
app:layoutManager="LinearLayoutManager"
|
||||||
tools:context=".MonsterListFragment"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
tools:listitem="@layout/monster_list_content"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent" />
|
tools:context=".MonsterListFragment"
|
||||||
|
tools:listitem="@layout/monster_list_content" />
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
android:id="@+id/fab"
|
android:id="@+id/fab"
|
||||||
@@ -26,8 +26,8 @@
|
|||||||
android:layout_gravity="bottom|end"
|
android:layout_gravity="bottom|end"
|
||||||
android:layout_margin="@dimen/fab_margin"
|
android:layout_margin="@dimen/fab_margin"
|
||||||
android:contentDescription="@string/action_add_monster"
|
android:contentDescription="@string/action_add_monster"
|
||||||
app:srcCompat="@android:drawable/ic_input_add"
|
|
||||||
app:tint="@android:color/white"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent" />
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
app:srcCompat="@android:drawable/ic_input_add"
|
||||||
|
app:tint="@android:color/white" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|||||||
@@ -24,17 +24,17 @@
|
|||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/monster_list"
|
android:id="@+id/monster_list"
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_marginLeft="16dp"
|
||||||
android:layout_marginRight="16dp"
|
android:layout_marginRight="16dp"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/search_query"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layoutManager="LinearLayoutManager"
|
app:layoutManager="LinearLayoutManager"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/search_query"
|
||||||
tools:context=".SearchResultsFragment"
|
tools:context=".SearchResultsFragment"
|
||||||
tools:listitem="@layout/monster_list_content" />
|
tools:listitem="@layout/monster_list_content" />
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_action_edit_monster"
|
android:id="@+id/menu_action_edit_monster"
|
||||||
android:icon="@drawable/ic_edit_24"
|
android:icon="@drawable/ic_edit_24"
|
||||||
android:title="@string/action_edit"
|
android:title="@string/action_edit"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="always" />
|
||||||
</menu>
|
</menu>
|
||||||
|
|||||||
Reference in New Issue
Block a user