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.schedulers.Schedulers;
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public class MonsterRepository {
|
||||
|
||||
private AppDatabase m_db;
|
||||
private final AppDatabase m_db;
|
||||
|
||||
public MonsterRepository(@NonNull AppDatabase db) {
|
||||
m_db = db;
|
||||
}
|
||||
|
||||
public Flowable<List<Monster>> getMonsters() {
|
||||
|
||||
return m_db.monsterDAO()
|
||||
.getAll()
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
@@ -10,14 +10,6 @@ import org.commonmark.renderer.html.HtmlNodeRendererFactory;
|
||||
import org.commonmark.renderer.html.HtmlRenderer;
|
||||
|
||||
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) {
|
||||
Parser parser = Parser.builder().build();
|
||||
Node document = parser.parse(rawCommonMark);
|
||||
@@ -35,4 +27,12 @@ public final class CommonMarkHelper {
|
||||
HtmlRenderer renderer = HtmlRenderer.builder().build();
|
||||
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> {
|
||||
|
||||
private String mName;
|
||||
private boolean mSpeaks;
|
||||
|
||||
public Language(String name, boolean speaks) {
|
||||
mName = name;
|
||||
mSpeaks = speaks;
|
||||
}
|
||||
|
||||
private String mName;
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
@@ -22,8 +23,6 @@ public class Language implements Comparator<Language>, Comparable<Language> {
|
||||
mName = value;
|
||||
}
|
||||
|
||||
private boolean mSpeaks;
|
||||
|
||||
public boolean getSpeaks() {
|
||||
return mSpeaks;
|
||||
}
|
||||
|
||||
@@ -4,13 +4,14 @@ import java.util.Comparator;
|
||||
|
||||
public class SavingThrow implements Comparator<SavingThrow>, Comparable<SavingThrow> {
|
||||
|
||||
private String mName;
|
||||
private int mOrder;
|
||||
|
||||
public SavingThrow(String name, int order) {
|
||||
mName = name;
|
||||
mOrder = order;
|
||||
}
|
||||
|
||||
private String mName;
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
@@ -19,8 +20,6 @@ public class SavingThrow implements Comparator<SavingThrow>, Comparable<SavingTh
|
||||
mName = value;
|
||||
}
|
||||
|
||||
private int mOrder;
|
||||
|
||||
public int getOrder() {
|
||||
return mOrder;
|
||||
}
|
||||
|
||||
@@ -56,9 +56,9 @@ public class EditLanguagesRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
||||
headerViewHolder.telepathy.setOnValueChangeListener(mOnTelepathyRangeChanged);
|
||||
headerViewHolder.understandsBut.setText(mUnderstandsBut);
|
||||
headerViewHolder.understandsBut.addTextChangedListener(mOnUnderstandsButChanged);
|
||||
} else if(holder instanceof ItemViewHolder) {
|
||||
ItemViewHolder itemViewHolder = (ItemViewHolder)holder;
|
||||
itemViewHolder.mItem = mValues.get(position-1);
|
||||
} else if (holder instanceof ItemViewHolder) {
|
||||
ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
|
||||
itemViewHolder.mItem = mValues.get(position - 1);
|
||||
itemViewHolder.mContentView.setText(itemViewHolder.mItem.getName());
|
||||
itemViewHolder.itemView.setOnClickListener(view -> {
|
||||
if (mOnClick != null) {
|
||||
@@ -70,7 +70,7 @@ public class EditLanguagesRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mValues.size() +1;
|
||||
return mValues.size() + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,15 +21,9 @@ import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
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 ItemCallback mOnDelete;
|
||||
private final ItemCallback mOnClick;
|
||||
private Disposable mDisposable;
|
||||
private final Flowable<List<Monster>> mItemsObservable;
|
||||
private final View.OnClickListener mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -40,6 +34,8 @@ public class MonsterListRecyclerViewAdapter extends RecyclerView.Adapter<Monster
|
||||
}
|
||||
}
|
||||
};
|
||||
private List<Monster> mValues;
|
||||
private Disposable mDisposable;
|
||||
|
||||
public MonsterListRecyclerViewAdapter(Context context,
|
||||
Flowable<List<Monster>> itemsObservable,
|
||||
@@ -79,17 +75,6 @@ public class MonsterListRecyclerViewAdapter extends RecyclerView.Adapter<Monster
|
||||
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
|
||||
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView);
|
||||
@@ -115,4 +100,19 @@ public class MonsterListRecyclerViewAdapter extends RecyclerView.Adapter<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 List<Monster> mValues;
|
||||
private Disposable mSubscriptionHandler;
|
||||
|
||||
public SearchResultsRecyclerViewAdapter(MonsterRepository repository,
|
||||
ItemCallback onClick) {
|
||||
mRepository = repository;
|
||||
|
||||
@@ -18,16 +18,11 @@ import com.majinnaibu.monstercards.R;
|
||||
|
||||
public class SwipeToDeleteCallback extends ItemTouchHelper.SimpleCallback {
|
||||
|
||||
public interface OnDeleteCallback {
|
||||
void onDelete(int position);
|
||||
}
|
||||
|
||||
private final Drawable icon;
|
||||
private final ColorDrawable background;
|
||||
private final Paint clearPaint;
|
||||
private final OnDeleteCallback mOnDelete;
|
||||
private final Context mContext;
|
||||
|
||||
public SwipeToDeleteCallback(Context context, OnDeleteCallback onDelete) {
|
||||
super(0, ItemTouchHelper.LEFT);
|
||||
mOnDelete = onDelete;
|
||||
@@ -84,4 +79,8 @@ public class SwipeToDeleteCallback extends ItemTouchHelper.SimpleCallback {
|
||||
|
||||
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
|
||||
}
|
||||
|
||||
public interface OnDeleteCallback {
|
||||
void onDelete(int position);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layoutManager="LinearLayoutManager"
|
||||
tools:context=".MonsterListFragment"
|
||||
tools:listitem="@layout/monster_list_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="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
|
||||
android:id="@+id/fab"
|
||||
@@ -26,8 +26,8 @@
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
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_constraintEnd_toEndOf="parent" />
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:srcCompat="@android:drawable/ic_input_add"
|
||||
app:tint="@android:color/white" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -24,15 +24,15 @@
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/monster_list"
|
||||
android:layout_height="0dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginLeft="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: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:listitem="@layout/monster_list_content" />
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_action_edit_monster"
|
||||
|
||||
Reference in New Issue
Block a user