@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_open_image);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    viewPager = (ViewPager) findViewById(R.id.gallery_view_pager);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                .setAction("Action", null)
                .show();
          }
        });
    usePicasso = getIntent().getBooleanExtra("usePicasso", false);
    int position = getIntent().getIntExtra("position", 0);
    Log.d("vvk", "OpenImageActivity position is " + position + " usePicasso is " + usePicasso);
    GalleryPagerAdapter pagerAdapter =
        new GalleryPagerAdapter(
            getSupportFragmentManager(),
            getApplicationContext(),
            GalleryActivity.imageFiles,
            usePicasso);
    viewPager.setAdapter(pagerAdapter);
    viewPager.setCurrentItem(position);
    viewPager.setOffscreenPageLimit(3);
    //        viewPager.setPageMargin(200);
    viewPager.setPageMarginDrawable(R.drawable.ic_doctor_default_blue);
    //
    // viewPager.setForeground(getResources().getDrawable(R.drawable.ic_doctor_default_blue,null));
    //        viewPager.set
    viewPager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {

          @Override
          public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            Log.d(
                "mytab",
                "position is "
                    + position
                    + " positionoffset "
                    + positionOffset
                    + " offsetpixels "
                    + positionOffsetPixels);
          }

          @Override
          public void onPageSelected(int position) {
            Log.d("mytab", "position is " + position);
          }

          @Override
          public void onPageScrollStateChanged(int state) {
            Log.d("mytab", "state is " + state);
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_article_detail);

    getLoaderManager().initLoader(0, null, this);

    mPagerAdapter = new MyPagerAdapter(getFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    mPager.setPageMargin(
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
    mPager.setPageMarginDrawable(new ColorDrawable(0x22000000));

    mPager.addOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {

          @Override
          public void onPageSelected(int position) {
            if (mCursor != null) {
              mCursor.moveToPosition(position);
            }
            mSelectedItemId = mCursor.getLong(ArticleLoader.Query._ID);
          }
        });

    if (savedInstanceState == null) {
      if (getIntent() != null && getIntent().getData() != null) {
        mStartId = ItemsContract.Items.getItemId(getIntent().getData());
        mSelectedItemId = mStartId;
      }
    }
  }
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.network_monitor_content);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

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

    final FragmentManager fm = getSupportFragmentManager();

    if (pager != null) {
      final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.network_monitor_pager_tabs);
      pagerTabs.addTabLabels(
          R.string.network_monitor_peer_list_title, R.string.network_monitor_block_list_title);

      final PagerAdapter pagerAdapter = new PagerAdapter(fm);

      pager.setAdapter(pagerAdapter);
      pager.setOnPageChangeListener(pagerTabs);
      pager.setPageMargin(2);
      pager.setPageMarginDrawable(R.color.bg_less_bright);

      peerListFragment = new PeerListFragment();
      blockListFragment = new BlockListFragment();
    } else {
      peerListFragment = (PeerListFragment) fm.findFragmentById(R.id.peer_list_fragment);
      blockListFragment = (BlockListFragment) fm.findFragmentById(R.id.block_list_fragment);
    }
  }
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.address_book_content);

    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    final FragmentManager fragmentManager = getFragmentManager();

    walletAddressesFragment = (WalletAddressesFragment) fragmentManager.findFragmentByTag(TAG_LEFT);
    sendingAddressesFragment =
        (SendingAddressesFragment) fragmentManager.findFragmentByTag(TAG_RIGHT);

    final FragmentTransaction removal = fragmentManager.beginTransaction();

    if (walletAddressesFragment == null) walletAddressesFragment = new WalletAddressesFragment();
    else removal.remove(walletAddressesFragment);

    if (sendingAddressesFragment == null) sendingAddressesFragment = new SendingAddressesFragment();
    else removal.remove(sendingAddressesFragment);

    if (!removal.isEmpty()) {
      removal.commit();
      fragmentManager.executePendingTransactions();
    }

    final ViewPager pager = (ViewPager) findViewById(R.id.address_book_pager);
    if (pager != null) {
      pager.setAdapter(
          new TwoFragmentAdapter(
              fragmentManager, walletAddressesFragment, sendingAddressesFragment));

      final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.address_book_pager_tabs);
      pagerTabs.addTabLabels(
          R.string.address_book_list_receiving_title, R.string.address_book_list_sending_title);

      pager.setOnPageChangeListener(pagerTabs);
      final int position = getIntent().getBooleanExtra(EXTRA_SENDING, true) ? 1 : 0;
      pager.setCurrentItem(position);
      pager.setPageMargin(2);
      pager.setPageMarginDrawable(R.color.bg_less_bright);

      pagerTabs.onPageSelected(position);
      pagerTabs.onPageScrolled(position, 0, 0);
    } else {
      fragmentManager
          .beginTransaction()
          .add(R.id.wallet_addresses_fragment, walletAddressesFragment, TAG_LEFT)
          .add(R.id.sending_addresses_fragment, sendingAddressesFragment, TAG_RIGHT)
          .commit();
    }

    updateFragments();
  }
  /** Initiate ViewPager and PagerAdapter */
  public void initPager() {
    // Initiate PagerAdapter
    PagerAdapter mPagerAdapter = new PagerAdapter(getFragmentManager());

    Bundle bundle = new Bundle();
    bundle.putString(MIME_TYPE, Audio.Playlists.CONTENT_TYPE);
    bundle.putLong(BaseColumns._ID, PLAYLIST_RECENTLY_ADDED);

    // Get tab visibility preferences
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    Set<String> defaults =
        new HashSet<String>(Arrays.asList(getResources().getStringArray(R.array.tab_titles)));
    Set<String> tabs_set = sp.getStringSet(TABS_ENABLED, defaults);
    // if its empty fill reset it to full defaults
    // stops app from crashing when no tabs are shown
    // TODO:rewrite activity to not crash when no tabs are chosen to show
    if (tabs_set.size() == 0) {
      tabs_set = defaults;
    }

    // Only show tabs that were set in preferences
    // Recently added tracks
    if (tabs_set.contains(getResources().getString(R.string.tab_recent)))
      mPagerAdapter.addFragment(new RecentlyAddedFragment(bundle));
    // Artists
    if (tabs_set.contains(getResources().getString(R.string.tab_artists)))
      mPagerAdapter.addFragment(new ArtistsFragment());
    // Albums
    if (tabs_set.contains(getResources().getString(R.string.tab_albums)))
      mPagerAdapter.addFragment(new AlbumsFragment());
    // // Tracks
    if (tabs_set.contains(getResources().getString(R.string.tab_songs)))
      mPagerAdapter.addFragment(new TracksFragment());
    // // Playlists
    if (tabs_set.contains(getResources().getString(R.string.tab_playlists)))
      mPagerAdapter.addFragment(new PlaylistsFragment());
    // // Genres
    if (tabs_set.contains(getResources().getString(R.string.tab_genres)))
      mPagerAdapter.addFragment(new GenresFragment());

    // Initiate ViewPager
    ViewPager mViewPager = (ViewPager) findViewById(R.id.viewPager);
    mViewPager.setPageMargin(getResources().getInteger(R.integer.viewpager_margin_width));
    mViewPager.setPageMarginDrawable(R.drawable.viewpager_margin);
    mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount());
    mViewPager.setAdapter(mPagerAdapter);
    // mViewPager.setCurrentItem(0);

    // Tabs
    initScrollableTabs(mViewPager);

    // Theme chooser
    ThemeUtils.initThemeChooser(this, mViewPager, "viewpager", THEME_ITEM_BACKGROUND);
    ThemeUtils.setMarginDrawable(this, mViewPager, "viewpager_margin");
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      getWindow()
          .getDecorView()
          .setSystemUiVisibility(
              View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    }
    setContentView(R.layout.activity_article_detail);

    getLoaderManager().initLoader(0, null, this);

    mPagerAdapter = new MyPagerAdapter(getFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    mPager.setPageMargin(
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
    mPager.setPageMarginDrawable(new ColorDrawable(0x22000000));

    mPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageScrollStateChanged(int state) {
            super.onPageScrollStateChanged(state);
          }

          @Override
          public void onPageSelected(int position) {
            if (mCursor != null) {
              mCursor.moveToPosition(position);
            }
            mSelectedItemId = mCursor.getLong(ArticleLoader.Query._ID);
          }
        });

    // Enable up button on toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    if (savedInstanceState == null) {
      if (getIntent() != null && getIntent().getData() != null) {
        mStartId = ItemsContract.Items.getItemId(getIntent().getData());
        mSelectedItemId = mStartId;
      }
    }
  }
Example #7
0
  /**
   * Sets up the local pager widget. Should be called from onCreate() after both the cursor and
   * adapter are created.
   */
  protected void setupPager() {
    syncFragment = (SyncUpdateFragment) fragmentManager.findFragmentByTag(SyncUpdateFragment.TAG);
    if (syncFragment == null) {
      syncFragment = new SyncUpdateFragment();
      fragmentManager.beginTransaction().add(syncFragment, SyncUpdateFragment.TAG).commit();
    }

    pager = (ViewPager) findViewById(R.id.reading_pager);
    pager.setPageMargin(UIUtils.convertDPsToPixels(getApplicationContext(), 1));
    pager.setPageMarginDrawable(R.drawable.divider_light);
    pager.setOnPageChangeListener(this);

    pager.setAdapter(readingAdapter);
    pager.setCurrentItem(passedPosition);
    this.enableOverlays();
  }
 protected void onCreate(Bundle bundle) {
   super.onCreate(bundle);
   requestWindowFeature(1);
   ViewPager viewpager;
   Resources resources;
   try {
     v = getIntent().getBooleanExtra("extra.has_anim", false);
   } catch (Exception exception) {
   }
   setContentView(h());
   i();
   viewpager = r;
   resources = getResources();
   com.dianxinos.dxbs.R.dimen _tmp = ly.d;
   viewpager.setPageMargin(resources.getDimensionPixelSize(0x7f080109));
   r.setPageMarginDrawable(0x106000d);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    try {
      //  mHasAnimation = getIntent().getBooleanExtra(SingleActivity.EXTRA_HAS_ANIM, false);
    } catch (Exception e) {
      // ignore
    }

    setContentView(getMainViewResId());
    initViews();

    mPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.page_margin_width));
    mPager.setPageMarginDrawable(R.color.page_viewer_margin_color);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_article_detail);

    getLoaderManager().initLoader(0, null, this);

    mPagerAdapter = new MyPagerAdapter(getFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    mPager.setPageMargin(
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
    mPager.setPageMarginDrawable(new ColorDrawable(0x22000000));

    mPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageScrollStateChanged(int state) {
            super.onPageScrollStateChanged(state);
            mUpButton
                .animate()
                .alpha((state == ViewPager.SCROLL_STATE_IDLE) ? 1f : 0f)
                .setDuration(300);
          }

          @Override
          public void onPageSelected(int position) {
            if (mCursor != null) {
              mCursor.moveToPosition(position);
            }
            mSelectedItemId = mCursor.getLong(ArticleLoader.Query._ID);
            updateUpButtonPosition();
          }
        });

    mUpButtonContainer = findViewById(R.id.up_container);

    mUpButton = findViewById(R.id.action_up);
    mUpButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            onSupportNavigateUp();
          }
        });

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      mUpButtonContainer.setOnApplyWindowInsetsListener(
          new View.OnApplyWindowInsetsListener() {
            @Override
            public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
              view.onApplyWindowInsets(windowInsets);
              mTopInset = windowInsets.getSystemWindowInsetTop();
              mUpButtonContainer.setTranslationY(mTopInset);
              updateUpButtonPosition();
              return windowInsets;
            }
          });
    }

    if (savedInstanceState == null) {
      if (getIntent() != null && getIntent().getData() != null) {
        mStartId = ItemsContract.Items.getItemId(getIntent().getData());
        mSelectedItemId = mStartId;
      }
    }
  }
    @Override
    public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View view = inflater.inflate(layout, null);
      if (this.layout == R.layout.fragment_add_clips) {
        // Set up the clip ViewPager with the clip adapter.
        mClipViewPager = (ViewPager) view.findViewById(R.id.viewPager);
        mClipViewPager.setPageMargin(-75);
        mClipViewPager.setPageMarginDrawable(R.drawable.ic_action_forward_gray);
        mClipViewPager.setOffscreenPageLimit(5);

      } else if (this.layout == R.layout.fragment_order_clips) {
        mDGV = (DraggableGridView) view.findViewById(R.id.DraggableGridView01);

        ImageView iv = new ImageView(getActivity());
        iv.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.cliptype_close));
        mDGV.addView(iv);

        iv = new ImageView(getActivity());
        iv.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.cliptype_detail));
        mDGV.addView(iv);

        iv = new ImageView(getActivity());
        iv.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.cliptype_long));
        mDGV.addView(iv);

        iv = new ImageView(getActivity());
        iv.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.cliptype_medium));
        mDGV.addView(iv);

        iv = new ImageView(getActivity());
        iv.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.cliptype_wide));
        mDGV.addView(iv);

        mDGV.setOnRearrangeListener(
            new OnRearrangeListener() {

              @Override
              public void onRearrange(int arg0, int arg1) {
                // TODO Auto-generated method stub
                Log.d(TAG, "grid rearranged");
              }
            });

        mDGV.setOnItemClickListener(
            new OnItemClickListener() {

              @Override
              public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                Log.d(TAG, "item clicked");
              }
            });
      } else if (this.layout == R.layout.fragment_story_publish) {

        Button btn = (Button) view.findViewById(R.id.btnPublish);
        btn.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {

                handlePublish();
              }
            });
      }
      return view;
    }