Example #1
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detalle);

    viewPager = (ViewPager) findViewById(R.id.vpImagenes);
    viewPager.setPageTransformer(true, new ZoomOutPageTransformer());
  }
Example #2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_child_layout, null);
    mViewPager = (ViewPager) view.findViewById(R.id.content_pager);
    mMyPagerAdapter = new BbsPageAdapter(context, getFragmentManager());
    mFragment = mMyPagerAdapter.getItem(0);
    mViewPager.setAdapter(mMyPagerAdapter);
    mViewPager.setPageTransformer(true, new ZoomOutPageTransformer());
    mPagerSlidingTabStrip = (PagerSlidingTabStrip) view.findViewById(R.id.tabs);

    mViewPager.setOnPageChangeListener(
        new OnPageChangeListener() {

          @Override
          public void onPageSelected(int arg0) {
            mFragment = mMyPagerAdapter.getItem(arg0);
          }

          @Override
          public void onPageScrolled(int arg0, float arg1, int arg2) {}

          @Override
          public void onPageScrollStateChanged(int arg0) {}
        });
    mPagerSlidingTabStrip.setViewPager(mViewPager);
    // mPagerSlidingTabStrip.setTextColor(Color.parseColor("#fe4200"));
    mPagerSlidingTabStrip.setTextSize(26);
    mPagerSlidingTabStrip.setSelectTabTextSize(28);
    return view;
  }
  private void initView() {
    mViewPager = (ViewPager) this.findViewById(R.id.viewpager);
    mPageNum = (TextView) this.findViewById(R.id.page_num);
    mEditText = (EditText) this.findViewById(R.id.edit_text);
    mButton = (Button) this.findViewById(R.id.button);
    mButton.setOnClickListener(this);

    List<Fragment> fragments = new ArrayList<Fragment>();
    Fragment fragment1 = MyOneFragment.newInstance();
    Fragment fragment2 = MyTwoFragment.newInstance();
    Fragment fragment3 = MyThreeFragment.newInstance();
    Fragment fragment4 = MyFourFragment.newInstance();
    Fragment fragment5 = MyFiveFragment.newInstance();

    fragments.add(fragment1);
    fragments.add(fragment2);
    fragments.add(fragment3);
    fragments.add(fragment4);
    fragments.add(fragment5);

    mMyFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), fragments);
    mViewPager.setAdapter(mMyFragmentPagerAdapter);
    mViewPager.setPageTransformer(true, new FragmentTransformer()); // 设置页面变换监听,对每个页面的变化都有一个变换的监听
    mViewPager.addOnPageChangeListener(new OnMyPageChangeListener()); // 页面变化监听
    mViewPager.setOffscreenPageLimit(2); // 设置缓存页面数。当前页,左右两边(单边)最大缓存页面数。
    //        mViewPager.setOnScrollChangeListener(new
    // OnMyScrollChangeListener());//滚动状态监听,minSdkVersion:23
    //        mViewPager.getCurrentItem();//获取当前显示页索引
    //        mViewPager.getOffscreenPageLimit();//获取缓存页面数
    //        mViewPager.onSaveInstanceState();
    //        mViewPager.setPageTransformer();
    setPageNum(0); // 设置显示首页
  }
Example #4
0
  @Override
  protected void initData() {
    listpath = new ArrayList<String>();
    mImageViews = new ArrayList<ImageView>();
    asyncLoadingPicture = AsyncLoadingPicture.getInstance(getApplicationContext());
    listpath.addAll(getIntent().getStringArrayListExtra("imgpath"));
    try {
      posttion = getIntent().getIntExtra("page", 0);
    } catch (Exception e) {

    }
    viewPager.setPageTransformer(true, new RotateDownPageTransformer());
    for (String imgurl : listpath) {
      ImageView imageView = new ImageView(this);
      imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
      if (imgurl.contains("http://")) asyncLoadingPicture.LoadPicture(imgurl, imageView);
      else asyncLoadingPicture.LoadPicture("file://" + imgurl, imageView);
      mImageViews.add(imageView);
      imageView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              finish();
            }
          });
    }
    viewPagerAdapter = new ImageViewPagerAdapter(mImageViews);
    viewPager.setAdapter(viewPagerAdapter);
    viewPager.setCurrentItem(posttion);
  }
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // set title
    String title = getString(R.string.nav_home_tutorial);
    getActivity().setTitle(title);

    // create view
    View view = inflater.inflate(R.layout.fragment_home_tutorial, container, false);
    ButterKnife.bind(this, view);

    final FragmentStatePagerAdapter pagerAdapter =
        new FragmentStatePagerAdapter(
            ((AppCompatActivity) getActivity()).getSupportFragmentManager()) {
          List<android.support.v4.app.Fragment> pages =
              Arrays.asList(new android.support.v4.app.Fragment[CARD_COUNT]);

          @Override
          public android.support.v4.app.Fragment getItem(int i) {
            if (pages.get(i) == null) {
              switch (i) {
                case 0:
                  pages.set(i, HTFDemoScriptureFragment.newInstance(viewPager));
                  break;
                case 1:
                  pages.set(
                      i,
                      HTFDemoPersonFragment.newInstance(
                          getString(R.string.tutorial_person_name), true));
                  break;
                case 2:
                  pages.set(i, new HTFDemoProgressFragment());
                  break;
                default:
                  pages.set(i, new BlankSupportFragment());
                  break;
              }
            }
            return pages.get(i);
          }

          @Override
          public int getCount() {
            return CARD_COUNT;
          }
        };

    viewPager.setAdapter(pagerAdapter);
    viewPager.setPageTransformer(true, new ZoomOutPageTransformer());
    viewPager.addOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int i) {
            ((HTFDemoFragment) pagerAdapter.getItem(i)).onSelected();
          }
        });
    indicator.setViewPager(viewPager);
    return view;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (vGroup == null) {
      vGroup = (ViewGroup) inflater.inflate(R.layout.fragment_media_player, null, false);
      ivBackGround = (ImageView) vGroup.findViewById(R.id.ivBackGround);
      vpAlbumArtPager = (ViewPager) vGroup.findViewById(R.id.vpAlbumArtPager);
      mSeekBar = (SeekBar) vGroup.findViewById(R.id.mSeekBar);
      lytMain = (RelativeLayout) vGroup.findViewById(R.id.lytMain);
      // ivAlbumArt = (ImageView) vGroup.findViewById(R.id.ivAlbumArt);
      tvSongName = (TextView) vGroup.findViewById(R.id.tvTitle);
      tvArtist = (TextView) vGroup.findViewById(R.id.tvArtist);
      btnForward = (ImageButton) vGroup.findViewById(R.id.btnForward);
      btnBack = (ImageButton) vGroup.findViewById(R.id.btnBack);
      setUpVisualizerAndSeekBar();
      btnForward.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              mediaPlayerListener.onNextSong(true);
              setUpViews();
              setViewPagerToCurrentIndex();
            }
          });

      loadBackGround();

      btnBack.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              mediaPlayerListener.onPreviousSong(true);
              setUpViews();
              setViewPagerToCurrentIndex();
            }
          });
      mAdapter = new PlaceSlidesFragmentAdapter(getChildFragmentManager());
      vpAlbumArtPager.setAdapter(mAdapter);

      vpAlbumArtPager.setPageMargin(-150);
      vpAlbumArtPager.offsetTopAndBottom(-50);
      vpAlbumArtPager.setPageTransformer(false, new ZoomOutPageTransformer());
      vpAlbumArtPager.setHorizontalFadingEdgeEnabled(true);
      vpAlbumArtPager.setFadingEdgeLength(100);

      vpAlbumArtPager.addOnPageChangeListener(this);

      lastPage = CloudifyController.getInstance().getSongIndex();
      vpAlbumArtPager.setCurrentItem(lastPage);
    }
    return vGroup;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_screen_slide);

    // 拿 ViewPager 并且设置 PageAdapter
    mPager = (ViewPager) findViewById(R.id.pager);
    mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
    mPager.setAdapter(mPagerAdapter);
    mPager.setPageTransformer(false, new DepthPageTransformer()); // 动画
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);
   viewPager = Views.find(this, R.id.viewpagers);
   for (int i = 1; i < 101; i++) {
     nums.add("PAGE" + i);
   }
   pagerAdapter = new SimplePagerAdapter(this, nums);
   viewPager.setAdapter(pagerAdapter);
   viewPager.setPageTransformer(false, new CubeTransformer());
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   int id = item.getItemId();
   switch (id) {
     case R.id.cube:
       viewPager.setPageTransformer(true, new CubeTransformer());
       break;
     case R.id.scale:
       viewPager.setPageTransformer(true, new ZoomOutTransformer());
       break;
     case R.id.tobigger:
       AndroidHelper.startActivity(this, ButtonToBiggerActivity.class);
       break;
     case R.id.menu_list:
       AndroidHelper.startActivity(this, MenuListActivity.class);
       break;
     case R.id.dialog_test:
       AndroidHelper.startActivity(this, DialogFragmentActivity.class);
       break;
   }
   return true;
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.acitivity_intro);

    ViewPager pager = (ViewPager) findViewById(R.id.fullscreen_pager);

    IntroPagerAdapter introPagerAdapter = new IntroPagerAdapter(getSupportFragmentManager());
    pager.setAdapter(introPagerAdapter);
    pager.setPageTransformer(true, new ColorFadingPageTransformer());
    mIndicator = (CirclePageIndicator) findViewById(R.id.indicator);
    mIndicator.setViewPager(pager);
  }
Example #11
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    tabLayout = (TabLayout) findViewById(R.id.tabLayout);
    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(new PagerAdapter(getFragmentManager()));
    tabLayout.addTab(tabLayout.newTab().setText(R.string.front));
    tabLayout.addTab(tabLayout.newTab().setText(R.string.back));
    if (savedInstanceState == null) {
      CountryIntentService.start(this, countryReceiver);
    }
    pager.setPageTransformer(
        true,
        new ViewPager.PageTransformer() {
          @Override
          public void transformPage(View page, float position) {
            page.setRotationY(180 * position);
          }
        });
    tabLayout.setOnTabSelectedListener(
        new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
            pager.setCurrentItem(tab.getPosition(), false);
          }

          @Override
          public void onTabUnselected(TabLayout.Tab tab) {}

          @Override
          public void onTabReselected(TabLayout.Tab tab) {}
        });
    pager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(
              int position, float positionOffset, int positionOffsetPixels) {}

          @Override
          public void onPageSelected(int position) {
            tabLayout.getTabAt(position).select();
          }

          @Override
          public void onPageScrollStateChanged(int state) {}
        });
  }
Example #12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    pm = PreferenceManager.getDefaultSharedPreferences(ActivityMisMangas.this);
    darkTheme = pm.getBoolean("dark_theme", false);
    setTheme(darkTheme ? R.style.AppTheme_miDark : R.style.AppTheme_miLight);
    super.onCreate(savedInstanceState);
    PreferenceManager.setDefaultValues(this, R.xml.fragment_preferences, false);
    setContentView(R.layout.activity_mis_mangas);

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    fragmentAddManga = new FragmentAddManga();
    fragmentMisMangas = new FragmentMisMangas();

    fragmentAddManga.setRetainInstance(true);
    fragmentMisMangas.setRetainInstance(true);
    mSectionsPagerAdapter.add(fragmentMisMangas);
    mSectionsPagerAdapter.add(fragmentAddManga);

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setPageTransformer(false, new MoreMangasPageTransformer());

    button_add = (FloatingActionButton) findViewById(R.id.button_add);
    button_add.setOnClickListener(this);

    final boolean show_dialog = pm.getBoolean("show_updates", false);
    if (!show_dialog) { // ! o no segun la version 1.36 sin !
      AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
      dlgAlert.setMessage(getString(R.string.update_message));
      dlgAlert.setTitle(R.string.app_name);
      dlgAlert.setCancelable(true);
      dlgAlert.setPositiveButton(
          android.R.string.ok,
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              pm.edit().putBoolean("show_updates", true).apply(); // false 1.36
            }
          });
      dlgAlert.setNegativeButton(
          getString(R.string.see_later),
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
              dialog.dismiss();
            }
          });
      dlgAlert.create().show();
    }
  }
  private void getOriginalXValues(Bundle savedInstanceState) {

    mOriginalXValuesMap.put(mCenterBox, mCenterBox.getX());
    mOriginalXValuesMap.put(mCamcordImage, mCamcordImage.getX());
    mOriginalXValuesMap.put(mClockImage, mClockImage.getX());
    mOriginalXValuesMap.put(mGraphImage, mGraphImage.getX());
    mOriginalXValuesMap.put(mAudioImage, mAudioImage.getX());
    mOriginalXValuesMap.put(mQuoteImage, mQuoteImage.getX());
    mOriginalXValuesMap.put(mMapImage, mMapImage.getX());
    mOriginalXValuesMap.put(mWordPressImage, mWordPressImage.getX());

    if (savedInstanceState == null) {
      mPager.setPageTransformer(true, new CustomTransformer());
    }
  }
Example #14
0
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    strip.setDrawFullUnderline(false);
    strip.setTabIndicatorColor(Color.DKGRAY);
    strip.setBackgroundColor(Color.GRAY);
    strip.setNonPrimaryAlpha(0.5f);
    strip.setTextSpacing(15);
    strip.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);

    // Note: 此处使用ViewPager,只能使用getChildFragmentManager(),否则弹栈将出现问题
    // http://stackoverflow.com/questions/7338823/viewpager-recursive-entry-to-executependingtransactions
    viewPager.setAdapter(new HomePagerAdapter(getChildFragmentManager()));
    viewPager.setOnPageChangeListener(new HomePageChangeListener());
    viewPager.setPageTransformer(false, new HomePageTransformer());
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_screen_slide);

    // Instantiate a ViewPager and a PagerAdapter.
    mPager = (ViewPager) findViewById(R.id.pager);
    mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
    mPager.setAdapter(mPagerAdapter);
    // mPager.setPageTransformer(true, new ZoomOutPageTransformer());
    mPager.setPageTransformer(true, new DepthPageTransformer());
    mPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            invalidateOptionsMenu();
          }
        });
  }
  /** Setup the viewpager for current and past trip lists */
  private void setupViewPager() {
    FragmentManager fm = getSupportFragmentManager();

    final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);

    if (viewPager != null) {
      int tabPosition =
          PreferencesUtils.getInt(
              mActivity, R.string.feed_list_selected_key, PreferencesUtils.Tab.FEED_LIST_UPCOMING);

      FeedPagerAdapter adapter = new FeedPagerAdapter(fm);
      viewPager.setAdapter(adapter);
      viewPager.setPageTransformer(true, new ZoomOutSlideTransformer());
      viewPager.setCurrentItem(tabPosition, true);

      TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
      tabLayout.setupWithViewPager(viewPager);
      tabLayout.setSmoothScrollingEnabled(true);
      tabLayout.setOnTabSelectedListener(
          new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
              PreferencesUtils.setInt(
                  mActivity, R.string.feed_list_selected_key, tab.getPosition());
              viewPager.setCurrentItem(tab.getPosition(), true);
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {}

            @Override
            public void onTabReselected(TabLayout.Tab tab) {
              PreferencesUtils.setInt(
                  mActivity, R.string.feed_list_selected_key, tab.getPosition());
            }
          });
      TabLayout.Tab tab = tabLayout.getTabAt(tabPosition);
      if (tab != null) {
        tab.select();
      }
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ins = this; // Necessary for the Connection receiver to work
    setContentView(R.layout.activity_main);

    getWindow()
        .getDecorView()
        .setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_blue_gradient));
    mPagerTitleStrip = (PagerTitleStrip) findViewById(R.id.pager_title_strip);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mPagerAdapter = new SectionsPagerAdapter(this, getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mPagerAdapter);
    mViewPager.addOnPageChangeListener(this);
    mViewPager.setOffscreenPageLimit(2);
    mViewPager.setPageTransformer(true, new ZoomOutPageTransformer());
    mViewPager.setCurrentItem(1);

    // Initialize the GoogleAPIClient
    mGoogleApiClient =
        new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();

    // Create the LocationRequest object
    mLocationRequest =
        LocationRequest.create()
            .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
            .setInterval(LOCATION_REQUEST_MAX_INTERVAL * 1000) // 10 seconds, in milliseconds
            .setFastestInterval(
                LOCATION_REQUEST_FASTEST_INTERVAL * 1000); // 10 seconds, in milliseconds

    Log.i(TAG, "Main Activity On Create method is done.");
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   initData();
   setContentView(R.layout.activity_viewpager_transform);
   viewpager = (ViewPager) findViewById(R.id.viewpager);
   viewpager.setPageMargin(-200);
   viewpager.setOffscreenPageLimit(3);
   viewpager.setPageTransformer(true, new ZoomOutPageTransformer());
   mAdapter = new MyPagerAdapter();
   viewpager.setAdapter(mAdapter);
   findViewById(R.id.reduce)
       .setOnClickListener(
           new View.OnClickListener() {
             @Override
             public void onClick(View v) {
               mViews.remove(2);
               mAdapter.notifyDataSetChanged();
             }
           });
 }
Example #19
0
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    numberLayout.setVisibility(View.GONE);
    shareButton.setVisibility(View.INVISIBLE);
    applyWallpaperButton.setVisibility(View.INVISIBLE);
    playButton.setVisibility(View.INVISIBLE);
    saveButton.setVisibility(View.INVISIBLE);
    toolbarLayout.setVisibility(View.GONE);

    animationBatchExecutor =
        new AnimationBatchExecutor(
            getActivity(),
            R.anim.action_show,
            R.anim.action_hidden,
            70,
            shareButton,
            applyWallpaperButton,
            playButton,
            saveButton);
    viewPagerPlayer = new ViewPagerPlayer(viewPager);
    new PageNumberSetter(currentItemTextView, viewPager);
    viewPager.setPageTransformer(true, new DepthPageTransformer());

    shareButton.setOnClickListener(this);
    applyWallpaperButton.setOnClickListener(this);
    playButton.setOnClickListener(this);
    saveButton.setOnClickListener(this);

    if (uris != null) {
      viewPager.setAdapter(new ImageFragmentAdapter(getChildFragmentManager(), uris));
      viewPager.setCurrentItem(position);
      currentItemTextView.setText(position + 1 + "");
      countTextView.setText(uris.size() + "");
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    EventBus.getDefault().registerSticky(this);
    setContentView(R.layout.activity_media_player);

    Intent intent = getIntent();
    NUM_PAGES = intent.getIntExtra(NUM_PAGES_KEY, 0);
    int clickedPage = intent.getIntExtra(CLICKED_PAGE, 0);

    pager = (ViewPager) findViewById(R.id.pager);
    pagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
    pager.setAdapter(pagerAdapter);
    pager.setPageTransformer(true, new ZoomOutPageTransformer());
    pager.setCurrentItem(clickedPage);

    mpcf =
        (MediaPlayerControlsFragment)
            getSupportFragmentManager().findFragmentById(R.id.fragment_media_controls);
    playClickedTrack(clickedPage);

    pager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(
              final int position, final float positionOffset, final int positionOffsetPixels) {}

          @Override
          public void onPageSelected(final int position) {
            mpcf.switchTrack(position); // for touch slides
          }

          @Override
          public void onPageScrollStateChanged(final int state) {}
        });
  }
  public void initializePager() {
    viewPager = (ViewPager) findViewById(R.id.myviewpager);
    myPagerAdapter = new MyPagerAdapter();
    viewPager.setAdapter(myPagerAdapter);
    viewPager.setPageTransformer(true, new ZoomOutPageTransformer());

    viewPager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {

          @Override
          public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            readMessage(infotext[position], "page" + position);
          }

          @Override
          public void onPageSelected(int position) {
            readMessage(infotext[position], "page" + position);
            invalidateOptionsMenu();
          }

          @Override
          public void onPageScrollStateChanged(int state) {}
        });
  }
Example #22
0
 public void setCustomTransformer(@Nullable ViewPager.PageTransformer transformer) {
   pager.setPageTransformer(true, transformer);
 }
Example #23
0
 /** 覆盖该方法,不设置PageTransformer,以成员变量的形式保存PageTransformer */
 @Override
 public void setPageTransformer(
     boolean reverseDrawingOrder, ViewPager.PageTransformer transformer) {
   super.setPageTransformer(reverseDrawingOrder, null);
   mPageTransformer = transformer;
 }
Example #24
0
 /**
  * 设置切换效果
  *
  * @param b
  * @param rotateTransformer
  */
 public void setPageTransformer(boolean b, PageTransformer rotateTransformer) {
   // TODO Auto-generated method stub
   mViewPager.setPageTransformer(b, rotateTransformer);
 }
Example #25
0
  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    findUI();

    setSupportActionBar(toolbar);
    getSupportActionBar().setElevation(0);
    ActionBarDrawerToggle drawerToggle =
        new ActionBarDrawerToggle(
            this,
            drawerLayout,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawerLayout.setDrawerListener(drawerToggle);
    drawerToggle.syncState();

    navigationView.setNavigationItemSelectedListener(this);

    // Initialise
    drawerLayout.setViewPager(navigationView, R.id.pager_material);
    scroll.setColorSchemeResources(R.color.colorPrimary);
    scroll.setOnRefreshListener(this);

    pagerMaterial.setAdapter(new MaterialPageAdapter(this));
    pagerMaterial.setPageTransformer(true, new MaterialTransformer());
    pagerCity.setAdapter(new CityPageAdapter(this));

    pagerMaterial.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            pagerCity.onTouchEvent(event);
            return false;
          }
        });
    pagerCity.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            pagerMaterial.onTouchEvent(event);
            return false;
          }
        });

    pagerCity.setOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(
              int position, float positionOffset, int positionOffsetPixels) {}

          @Override
          public void onPageSelected(int position) {
            WeatherController.getInstance()
                .setCurrentCity(WeatherController.getInstance().getCities().get(position));
            try {
              ((ForecastFragment) getFragmentManager().findFragmentByTag(FRAGMENT_TAG)).update();
            } catch (ClassCastException ignored) {

            }
          }

          @Override
          public void onPageScrollStateChanged(int state) {}
        });
    Log.d(TAG, "Updating forecast for current city");
    pagerCity.setCurrentItem(WeatherController.getInstance().getIDCurrentCity());
    pagerMaterial.setCurrentItem(WeatherController.getInstance().getIDCurrentCity());

    b_cities.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            startActivityForResult(new Intent(ForecastActivity.this, CitiesActivity.class), 1);
            drawerLayout.closeDrawer(GravityCompat.START);
          }
        });

    if (savedInstanceState == null) onNavigationItemSelected(navigationView.getMenu().getItem(0));
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main1);

    facebookKeyHashs();

    sharedPref.setTourtag(this, "1");

    try {
      m = usageAccessGranted(this);
      if (m == true) {

      } else {
        Intent usageAccessIntent = new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS);
        usageAccessIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(usageAccessIntent);
      }
    } catch (NoClassDefFoundError e) {
      e.printStackTrace();
    } catch (IllegalArgumentException e) {
      e.printStackTrace();
    }

    // Toast.makeText(getApplicationContext(),""+m,Toast.LENGTH_LONG).show();

    pager = (ViewPager) findViewById(R.id.viewPager);

    myPagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
    pager.setAdapter(myPagerAdapter);
    // pager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));
    pager.setCurrentItem(0);
    pager.setOnPageChangeListener(this);
    setUiPageViewController();

    pager.setPageTransformer(
        false,
        new ViewPager.PageTransformer() {
          @Override
          public void transformPage(View page, float position) {
            // do transformation here
            if (position == 0) {

              FirstFragment.newInstance("FirstFragment, Instance 1");
              // Toast.makeText(getApplicationContext(),"Hello",Toast.LENGTH_LONG).show();
            }
            if (position == 1) {
              SecondFragment.newInstance("SecondFragment, Instance 1", 1);
              // Toast.makeText(getApplicationContext(),"Hello1",Toast.LENGTH_LONG).show();
            }
            if (position == 2) {
              ThirdFragment.newInstance("ThirdFragment, Instance 1");
              // Toast.makeText(getApplicationContext(),"Hello2",Toast.LENGTH_LONG).show();
            }
            if (position == 3) {
              FourFragment.newInstance("FourFragment, Default");
              // Toast.makeText(getApplicationContext(),"Hello3",Toast.LENGTH_LONG).show();
            }
          }
        });
  }
Example #27
0
 public void setFadeAnimation() {
   pager.setPageTransformer(true, new FadePageTransformer());
 }
Example #28
0
 public void setDepthAnimation() {
   pager.setPageTransformer(
       true, new ViewPageTransformer(ViewPageTransformer.TransformType.DEPTH));
 }
  public MaterialCalendarView(Context context, AttributeSet attrs) {
    super(context, attrs);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      // If we're on good Android versions, turn off clipping for cool effects
      setClipToPadding(false);
      setClipChildren(false);
    } else {
      // Old Android does not like _not_ clipping view pagers, we need to clip
      setClipChildren(true);
      setClipToPadding(true);
    }

    buttonPast = new DirectionButton(getContext());
    title = new TextView(getContext());
    buttonFuture = new DirectionButton(getContext());
    pager = new ViewPager(getContext());

    setupChildren();

    title.setOnClickListener(onClickListener);
    buttonPast.setOnClickListener(onClickListener);
    buttonFuture.setOnClickListener(onClickListener);

    titleChanger = new TitleChanger(title);
    titleChanger.setTitleFormatter(DEFAULT_TITLE_FORMATTER);
    adapter = new MonthPagerAdapter();
    adapter.setTitleFormatter(DEFAULT_TITLE_FORMATTER);
    pager.setAdapter(adapter);
    pager.setOnPageChangeListener(pageChangeListener);
    pager.setPageTransformer(
        false,
        new ViewPager.PageTransformer() {
          @Override
          public void transformPage(View page, float position) {
            position = (float) Math.sqrt(1 - Math.abs(position));
            page.setAlpha(position);
          }
        });

    adapter.setCallbacks(monthViewCallbacks);

    TypedArray a =
        context.getTheme().obtainStyledAttributes(attrs, R.styleable.MaterialCalendarView, 0, 0);
    try {

      int tileSize = a.getDimensionPixelSize(R.styleable.MaterialCalendarView_mcv_tileSize, -1);
      if (tileSize > 0) {
        setTileSize(tileSize);
      }

      setArrowColor(a.getColor(R.styleable.MaterialCalendarView_mcv_arrowColor, Color.BLACK));
      Drawable leftMask = a.getDrawable(R.styleable.MaterialCalendarView_mcv_leftArrowMask);
      if (leftMask == null) {
        leftMask = getResources().getDrawable(R.drawable.mcv_action_previous);
      }
      setLeftArrowMask(leftMask);
      Drawable rightMask = a.getDrawable(R.styleable.MaterialCalendarView_mcv_rightArrowMask);
      if (rightMask == null) {
        rightMask = getResources().getDrawable(R.drawable.mcv_action_next);
      }
      setRightArrowMask(rightMask);

      setSelectionColor(
          a.getColor(
              R.styleable.MaterialCalendarView_mcv_selectionColor, getThemeAccentColor(context)));

      CharSequence[] array = a.getTextArray(R.styleable.MaterialCalendarView_mcv_weekDayLabels);
      if (array != null) {
        setWeekDayFormatter(new ArrayWeekDayFormatter(array));
      }

      array = a.getTextArray(R.styleable.MaterialCalendarView_mcv_monthLabels);
      if (array != null) {
        setTitleFormatter(new MonthArrayTitleFormatter(array));
      }

      setHeaderTextAppearance(
          a.getResourceId(
              R.styleable.MaterialCalendarView_mcv_headerTextAppearance,
              R.style.TextAppearance_MaterialCalendarWidget_Header));
      setWeekDayTextAppearance(
          a.getResourceId(
              R.styleable.MaterialCalendarView_mcv_weekDayTextAppearance,
              R.style.TextAppearance_MaterialCalendarWidget_WeekDay));
      setDateTextAppearance(
          a.getResourceId(
              R.styleable.MaterialCalendarView_mcv_dateTextAppearance,
              R.style.TextAppearance_MaterialCalendarWidget_Date));
      setShowOtherDates(a.getBoolean(R.styleable.MaterialCalendarView_mcv_showOtherDates, false));

      int firstDayOfWeek = a.getInt(R.styleable.MaterialCalendarView_mcv_firstDayOfWeek, -1);
      if (firstDayOfWeek < 0) {
        firstDayOfWeek = CalendarUtils.getInstance().getFirstDayOfWeek();
      }
      setFirstDayOfWeek(firstDayOfWeek);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      a.recycle();
    }

    currentMonth = CalendarDay.today();
    setCurrentDate(currentMonth);

    if (isInEditMode()) {
      removeView(pager);
      MonthView monthView = new MonthView(context, currentMonth, getFirstDayOfWeek());
      monthView.setSelectionColor(getSelectionColor());
      monthView.setDateTextAppearance(adapter.getDateTextAppearance());
      monthView.setWeekDayTextAppearance(adapter.getWeekDayTextAppearance());
      monthView.setShowOtherDates(getShowOtherDates());
      addView(monthView, new LayoutParams(MonthView.DEFAULT_MONTH_TILE_HEIGHT));
    }
  }
Example #30
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // Test

    super.onCreate(savedInstanceState);
    Window window = getWindow();
    window.setFlags(
        WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
        WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

    setContentView(R.layout.activity_tutorial);

    skip = Button.class.cast(findViewById(R.id.skip));
    skip.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            endTutorial();
          }
        });

    next = ImageButton.class.cast(findViewById(R.id.next));
    next.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            pager.setCurrentItem(pager.getCurrentItem() + 1, true);
          }
        });

    done = Button.class.cast(findViewById(R.id.done));
    done.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            endTutorial();
          }
        });

    pager = (ViewPager) findViewById(R.id.pager);
    pagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
    pager.setAdapter(pagerAdapter);
    pager.setPageTransformer(true, new CrossfadePageTransformer());
    pager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            if (position == NUM_PAGES - 2 && positionOffset > 0) {
              if (isOpaque) {
                pager.setBackgroundColor(Color.TRANSPARENT);
                isOpaque = false;
              }
            } else {
              if (!isOpaque) {
                pager.setBackgroundColor(getResources().getColor(R.color.primary_material_light));
                isOpaque = true;
              }
            }
          }

          @Override
          public void onPageSelected(int position) {
            setIndicator(position);
            if (position == NUM_PAGES - 2) {
              skip.setVisibility(View.GONE);
              next.setVisibility(View.GONE);
              done.setVisibility(View.VISIBLE);
            } else if (position < NUM_PAGES - 2) {
              skip.setVisibility(View.VISIBLE);
              next.setVisibility(View.VISIBLE);
              done.setVisibility(View.GONE);
            } else if (position == NUM_PAGES - 1) {
              endTutorial();
            }
          }

          @Override
          public void onPageScrollStateChanged(int state) {}
        });

    buildCircles();
  }