Skip to content

Instantly share code, notes, and snippets.

View babedev's full-sized avatar

Christopher Ng babedev

  • BabeDev
  • Bangkok, Thailand
View GitHub Profile
TapTargetView.showFor(this, // `this` is an Activity
TapTarget.forView(findViewById(R.id.target), "This is a target", "We have the best targets, believe me")
// All options below are optional
.outerCircleColor(R.color.red) // Specify a color for the outer circle
.targetCircleColor(R.color.white) // Specify a color for the target circle
.titleTextSize(20) // Specify the size (in sp) of the title text
.titleTextColor(R.color.white) // Specify the color of the title text
.descriptionTextSize(10) // Specify the size (in sp) of the description text
.descriptionTextColor(R.color.red) // Specify the color of the description text
.textColor(R.color.blue) // Specify a color for both the title and description text
new TapTargetSequence(this)
.targets(
TapTarget.forView(findViewById(R.id.never), "Gonna"),
TapTarget.forView(findViewById(R.id.give), "You", "Up")
.dimColor(android.R.color.never)
.outerCircleColor(R.color.gonna)
.targetCircleColor(R.color.let)
.textColor(android.R.color.you),
TapTarget.forBounds(rickTarget, "Down", ":^)")
.cancelable(false)
ViewTreeObserver viewTreeObserver = lvRoot.getViewTreeObserver();
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
listView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
View view = listView.getChildAt(1).findViewById(R.id.icon);
TapTargetView.showFor(TutorialActivity.this, TapTarget.forView(view
, "New Feature", "Click me!!!")
private void generateView() throws IOException {
TypeSpec mvpView = TypeSpec.interfaceBuilder(featureName + "View")
.build();
JavaFile javaFile = JavaFile.builder(packageName + "." + featureName.toLowerCase(), mvpView)
.build();
File file = new File("app/src/main/java");
javaFile.writeTo(file);
}
private void generateView() throws IOException {
TypeSpec mvpView = TypeSpec.interfaceBuilder(featureName + "View")
.build();
JavaFile javaFile = JavaFile.builder(packageName + "." + featureName.toLowerCase(), mvpView)
.build();
File file = new File("app/src/main/java");
javaFile.writeTo(file);
}
private void generatePresenter() throws IOException {
MethodSpec attachView = MethodSpec.methodBuilder("attachView")
.addJavadoc(CodeBlock.of("Attach View"))
.addParameter(getViewType(), "view")
.addStatement("mView = view")
.build();
TypeSpec mvpPresenter = TypeSpec.classBuilder(featureName + "Presenter")
.addMethod(attachView)
.addField(getViewType(), "mView", Modifier.PRIVATE)
package com.babedev.javapoetcodelab.sample;
interface SampleView {
}
ClassName.bestGuess(packageName + "." + featureName.toLowerCase() + "." + featureName + "View");
package com.babedev.javapoetcodelab.sample;
class SamplePresenter {
private SampleView mView;
/**
* Attach View
*/
void attachView(SampleView view) {
private void generateActivity() throws IOException {
MethodSpec onCreate = MethodSpec.methodBuilder("onCreate")
.addAnnotation(Override.class)
.addModifiers(Modifier.PUBLIC)
.returns(void.class)
.addParameter(Bundle.class, "savedInstanceState")
.addComment("TODO setContentView()")
.addStatement("mPresenter = new $T()", getPresenterType())
.addStatement("mPresenter.attachView(this)")
.build();