TablePlugin another create factory method
This commit is contained in:
parent
705dec0571
commit
82fe43a921
@ -23,8 +23,8 @@ abstract class AppBarItem {
|
||||
final TextView subtitle;
|
||||
|
||||
Renderer(@NonNull View view, @NonNull View.OnClickListener themeChangeClicked) {
|
||||
this.title = Views.findView(view, R.id.app_bar_title);
|
||||
this.subtitle = Views.findView(view, R.id.app_bar_subtitle);
|
||||
this.title = view.findViewById(R.id.app_bar_title);
|
||||
this.subtitle = view.findViewById(R.id.app_bar_subtitle);
|
||||
view.findViewById(R.id.app_bar_theme_changer)
|
||||
.setOnClickListener(themeChangeClicked);
|
||||
}
|
||||
|
@ -28,9 +28,6 @@ public class MainActivity extends Activity {
|
||||
|
||||
@Inject
|
||||
UriProcessor uriProcessor;
|
||||
//
|
||||
// @Inject
|
||||
// GifProcessor gifProcessor;
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
@ -42,9 +39,6 @@ public class MainActivity extends Activity {
|
||||
|
||||
themes.apply(this);
|
||||
|
||||
// how can we obtain MarkwonConfiguration after theme was applied?
|
||||
// as we inject `themes` we won't be able to inject configuration, as it requires theme set
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
// we process additionally github urls, as if url has in path `blob`, we won't receive
|
||||
@ -60,7 +54,7 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
});
|
||||
|
||||
final TextView textView = Views.findView(this, R.id.text);
|
||||
final TextView textView = findViewById(R.id.text);
|
||||
final View progress = findViewById(R.id.progress);
|
||||
|
||||
appBarRenderer.render(appBarState());
|
||||
|
@ -8,7 +8,6 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.Spanned;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
package ru.noties.markwon;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.support.annotation.IntDef;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.View;
|
||||
@ -13,16 +11,6 @@ public abstract class Views {
|
||||
@interface NotVisible {
|
||||
}
|
||||
|
||||
public static <V extends View> V findView(@NonNull View view, @IdRes int id) {
|
||||
//noinspection unchecked
|
||||
return (V) view.findViewById(id);
|
||||
}
|
||||
|
||||
public static <V extends View> V findView(@NonNull Activity activity, @IdRes int id) {
|
||||
//noinspection unchecked
|
||||
return (V) activity.findViewById(id);
|
||||
}
|
||||
|
||||
public static void setVisible(@NonNull View view, boolean visible) {
|
||||
setVisible(view, visible, View.GONE);
|
||||
}
|
||||
|
@ -23,6 +23,10 @@ import ru.noties.markwon.SpannableBuilder;
|
||||
|
||||
public class TablePlugin extends AbstractMarkwonPlugin {
|
||||
|
||||
public interface ThemeConfigure {
|
||||
void configureTheme(@NonNull TableTheme.Builder builder);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static TablePlugin create(@NonNull Context context) {
|
||||
return new TablePlugin(TableTheme.create(context));
|
||||
@ -33,6 +37,13 @@ public class TablePlugin extends AbstractMarkwonPlugin {
|
||||
return new TablePlugin(tableTheme);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static TablePlugin create(@NonNull ThemeConfigure themeConfigure) {
|
||||
final TableTheme.Builder builder = new TableTheme.Builder();
|
||||
themeConfigure.configureTheme(builder);
|
||||
return new TablePlugin(builder.build());
|
||||
}
|
||||
|
||||
private final TableVisitor visitor;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
|
@ -181,6 +181,8 @@ public abstract class MarkwonAdapter extends RecyclerView.Adapter<MarkwonAdapter
|
||||
|
||||
public abstract void setParsedMarkdown(@NonNull Markwon markwon, @NonNull List<Node> nodes);
|
||||
|
||||
public abstract int getNodeViewType(@NonNull Class<? extends Node> node);
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public static class Holder extends RecyclerView.ViewHolder {
|
||||
|
||||
|
@ -111,7 +111,7 @@ class MarkwonAdapterImpl extends MarkwonAdapter {
|
||||
return entry.id(node);
|
||||
}
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@Override
|
||||
public int getNodeViewType(@NonNull Class<? extends Node> node) {
|
||||
// if has registered -> then return it, else 0
|
||||
final int hash = node.hashCode();
|
||||
|
Loading…
x
Reference in New Issue
Block a user