From 77ffa5059e5bfb5ebd934012f6aae080f6cdb18c Mon Sep 17 00:00:00 2001 From: Il Date: Wed, 4 Nov 2015 16:27:21 -0500 Subject: [PATCH] fixed show called before onAttached --- .travis.yml | 36 ++---- app/build.gradle | 3 +- .../library/mymodule/app/MainActivity2.java | 44 ++++++- .../res/layout/activity_main_activity2.xml | 120 +++++++++++------- app/src/main/res/values/styles.xml | 12 +- gradle.properties | 4 +- gradle/wrapper/gradle-wrapper.properties | 4 +- .../library/tooltip/ToolTipTextDrawable.java | 27 ++-- .../library/tooltip/TooltipManager.java | 2 +- .../android/library/tooltip/TooltipView.java | 61 +++++---- library/src/main/res/values/dimens.xml | 2 +- library/src/main/res/values/styles.xml | 6 +- 12 files changed, 198 insertions(+), 123 deletions(-) diff --git a/.travis.yml b/.travis.yml index 01f33bbe..8a5c40e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,8 @@ language: android +jdk: + - openjdk7 + branches: only: - master @@ -7,35 +10,18 @@ branches: notifications: email: true -before_install: - - # environment info - - ./gradlew -v - - uname -a - - # for gradle output style - - export TERM=dumb - - # just to test gradle version, against our provided one - - ./gradlew -v - - # Install required components. - # For a full list, run `android list sdk -a --extended` - - echo yes | android update sdk --filter platform-tools --no-ui --force > /dev/null - - echo yes | android update sdk --all --filter build-tools-23.0.0 --no-ui --force > /dev/null - - echo yes | android update sdk --filter android-19 --no-ui --force > /dev/null - - echo yes | android update sdk --filter extra-android-m2repository --no-ui --force > /dev/null - - # Otherwise - #- echo yes | android update sdk -t tools,platform-tools,extra-android-support,extra-android-m2repository,android-19 --force --no-ui +# Turn off caching to avoid any caching problems +cache: false +# Use the Travis Container-Based Infrastructure (see #203) +sudo: false android: components: - build-tools-23.0.0 - android-22 + - extra-google-google_play_services - extra-google-m2repository - extra-android-m2repository - - sys-img-armeabi-v7a-android-19 - extra-android-support licenses: - android-sdk-license-bcbbd656 @@ -43,6 +29,8 @@ android: # Let's try to build... -install: ./gradlew clean build +install: + - chmod +x ./gradlew; ls -l gradlew; ./gradlew wrapper -v -script: ./gradlew check +script: + - ./gradlew clean assembleDebug diff --git a/app/build.gradle b/app/build.gradle index b25b0bd6..00c76225 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -21,7 +21,8 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile project(':library') - compile 'com.android.support:appcompat-v7:22.+' + compile 'com.android.support:appcompat-v7:22.2.1' + compile 'com.android.support:design:22.2.1' debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1' releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1' diff --git a/app/src/main/java/it/sephiroth/android/library/mymodule/app/MainActivity2.java b/app/src/main/java/it/sephiroth/android/library/mymodule/app/MainActivity2.java index 8b59f5aa..6f4ca053 100644 --- a/app/src/main/java/it/sephiroth/android/library/mymodule/app/MainActivity2.java +++ b/app/src/main/java/it/sephiroth/android/library/mymodule/app/MainActivity2.java @@ -4,17 +4,20 @@ import android.graphics.Point; import android.os.Bundle; import android.os.Handler; -import android.support.v7.app.ActionBarActivity; +import android.support.design.widget.TabLayout; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; import android.util.DisplayMetrics; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.ViewGroup; import android.widget.Button; import it.sephiroth.android.library.tooltip.TooltipManager; -public class MainActivity2 extends ActionBarActivity implements View.OnClickListener, TooltipManager.onTooltipClosingCallback { +public class MainActivity2 extends AppCompatActivity implements View.OnClickListener, TooltipManager.onTooltipClosingCallback { private static final String TAG = MainActivity2.class.getSimpleName(); Button mButton1; Button mButton2; @@ -37,6 +40,43 @@ protected void onCreate(Bundle savedInstanceState) { mButton3.setOnClickListener(this); mButton4.setOnClickListener(this); mButton5.setOnClickListener(this); + + setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); + + TabLayout tablayout = (TabLayout) findViewById(R.id.tabs); + tablayout.addTab(tablayout.newTab().setText("First")); + tablayout.addTab(tablayout.newTab().setText("Second")); + + test(); + } + + private void test() { + TabLayout tablayout = (TabLayout) findViewById(R.id.tabs); + final ViewGroup root = (ViewGroup) tablayout.getChildAt(0); + final View tab = root.getChildAt(1); + + // if (tab.getWidth() <= 1) { + // + // tab.getViewTreeObserver().addOnGlobalLayoutListener( + // new ViewTreeObserver.OnGlobalLayoutListener() { + // @Override + // public void onGlobalLayout() { + // test(); + // tab.getViewTreeObserver().removeOnGlobalLayoutListener(this); + // } + // }); + // return; + // } + + TooltipManager.getInstance().create(this, 111222) + .anchor(tab, TooltipManager.Gravity.BOTTOM) + .actionBarSize(Utils.getActionBarSize(getBaseContext())) + .closePolicy(TooltipManager.ClosePolicy.TouchOutside, 0) + .text(R.string.hello_world) + .toggleArrow(true) + .maxWidth(400) + .withStyleId(R.style.ToolTipLayoutDefaultStyle_TextColor1) + .show(); } @Override diff --git a/app/src/main/res/layout/activity_main_activity2.xml b/app/src/main/res/layout/activity_main_activity2.xml index 14e0d55f..94e15297 100644 --- a/app/src/main/res/layout/activity_main_activity2.xml +++ b/app/src/main/res/layout/activity_main_activity2.xml @@ -1,44 +1,78 @@ - -