Beispiel #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ac_activity_content);
    ButterKnife.bind(this);
    mContentId = getIntent().getStringExtra(AcString.CONTENT_ID);

    ViewUtils.setToolbar(AcContentActivity.this, mToolbar, true);
    mCollapsingToolbarLayout.setTitle("AC" + mContentId);
    mCollapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.ExpandedTitleText);

    mAdapter = new AcContentFmAdapter(getSupportFragmentManager());
    mViewPager.setAdapter(mAdapter);
    mViewPager.setOffscreenPageLimit(2);

    mTabLayout.setTabMode(TabLayout.MODE_FIXED);
    mTabLayout.setupWithViewPager(mViewPager);

    //        View contentView = findViewById(android.R.id.content);
    //        contentView.getViewTreeObserver()
    //                .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
    //                    @Override
    //                    public void onGlobalLayout() {
    //                        if (mContentId != null) {
    //                            for (int i = 0; i < mAdapter.getCount(); i++) {
    //                                String tag = mAdapter.getFragmentTag(i);
    //                                Fragment fragment =
    // getSupportFragmentManager().findFragmentByTag(tag);
    //
    //                                if (fragment instanceof AcContentInfoFragment) {
    //                                    ((AcContentInfoFragment) fragment)
    //                                            .onAcContentResult(mContentId);
    //                                } else if (fragment instanceof AcContentReplyFragment) {
    //                                    ((AcContentReplyFragment) fragment)
    //                                            .onAcContentResult(mContentId);
    //                                }
    //                            }
    //                        }
    //                    }
    //                });

    ((AcContentInfoFragment) getAcContentFragment(FRAGMENT_TPE_CONTENT_INFO))
        .onAcContentResult(mContentId);
    ((AcContentReplyFragment) getAcContentFragment(FRAGMENT_TPE_CONTENT_REPLY))
        .onAcContentResult(mContentId);
  }
  @Override
  public void displayMovieData(MovieDetailsModel movieDetailsModel) {
    //        Setting up view with data

    String title = movieDetailsModel.getTitle();
    mcollapsingtoolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    mcollapsingtoolbar.setTitle(title);
    mcollapsingtoolbar.setExpandedTitleTextAppearance(R.style.CollapsedAppBar);
    mcollapsingtoolbar.setExpandedTitleTextAppearance(R.style.CollapsedAppBar);

    ImageView mbackdrop = (ImageView) findViewById(R.id.backdrop);
    Picasso.with(this).setLoggingEnabled(true);
    String mbackdropUrl = IMG_ENDPOINT + movieDetailsModel.getBackdropPath();
    Picasso.with(this).load(mbackdropUrl).into(mbackdrop);

    adapter.setOverViewText(movieDetailsModel.getOverview());
    movieDetailsPresenter.searchOnYoutube(title);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mr__activity_book_info);

    mToolbar = (Toolbar) findViewById(R.id.mr__abi_toolbar);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mCollapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.mr__abi_collapsing_tool_bar);
    mCollapsingToolbar.setTitle("My Toolbar Tittle");
    mCollapsingToolbar.setCollapsedTitleTextColor(Color.WHITE);
    mCollapsingToolbar.setExpandedTitleColor(Color.WHITE);
    mCollapsingToolbar.setContentScrimColor(getResources().getColor(R.color.os__primary_color));
    mCollapsingToolbar.setExpandedTitleTextAppearance(R.style.mr__ExpandedAppbarStyle);
    mCollapsingToolbar.setCollapsedTitleTextAppearance(R.style.mr__CollapsedAppbarStyle);

    initViews();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
    super.onCreate(savedInstanceState);
    Intent data = getIntent();
    earthWallpaper = (EarthWallpaper) data.getExtras().getSerializable(WALLPAPER_OBJECT);
    // setTheme(R.style.AppTheme_NoActionBar);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
      setTheme(R.style.AppTheme_NoActionBar);
    }
    setContentView(R.layout.activity_wallpaper);

    downloadDialog = new BaseDialog(this).getDownloadDialog();

    if (!downloadDir.exists()) {
      boolean created = downloadDir.mkdir();
      Log.d("WallpaperActivity", "Download directory didn't exist : creation -> " + created);
    }

    if (!Preferences.exists()) Preferences.init(this);

    downloadDir = new File(Preferences.getInstance().getWallpaperDownloadDirectory());

    rootLayout = (CoordinatorLayout) findViewById(R.id.wallpaper_coordinator_root);
    collapsingToolbarLayout =
        (CollapsingToolbarLayout) findViewById(R.id.wallpaper_collapsing_toolbar);
    // collapsingToolbarLayout.setExpandedTitleTextAppearance(android.R.style.TextAppearance_DeviceDefault_Medium);
    collapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.FullscreenTextPreview);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_details_view);
    toolbar.setTitle(earthWallpaper.getFormattedWallpaperTitle());
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // set and load the appbar image
    appBarImage = (ImageView) findViewById(R.id.wall_preview);
    Picasso.with(this).load(earthWallpaper.getWallThumbUrl()).into(appBarImage);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      appBarImage.setTransitionName(data.getExtras().getString(IMAGE_TRANSITION_NAME));
      // toolbar.setTransitionName(data.getExtras().getString(TEXT_TRANSITION_NAME));
    }

    // assigning the information to the views
    cityTextView = (TextView) findViewById(R.id.details_location_text);
    if (earthWallpaper.getWallpaperRegion() == null) {
      cityTextView.setText(R.string.details_unknown);
    } else {
      cityTextView.setText(earthWallpaper.getWallpaperRegion());
    }
    countryTextView = (TextView) findViewById(R.id.details_country_text);
    if (earthWallpaper.getWallpaperCountry() == null) {
      countryTextView.setText(R.string.details_unknown);
    } else {
      countryTextView.setText(earthWallpaper.getWallpaperCountry());
    }
    coordinatesTextView = (TextView) findViewById(R.id.details_coords_text);
    coordinatesTextView.setText(getFormattedCoordinates());

    // setting the google maps layout stuff
    googleMapsLayout = (RelativeLayout) findViewById(R.id.gmaps_nav_layout);
    googleMapsLayout.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent googleMaps =
                new Intent(Intent.ACTION_VIEW, Uri.parse(earthWallpaper.getGoogleMapsUrl()));
            startActivity(googleMaps);
          }
        });
    googleMapsHintTextView = (TextView) findViewById(R.id.details_gmaps_link_icon_text);
    googleMapsHintTextView.setText(earthWallpaper.getGoogleMapsTitle());

    final int[] c = {0};
    attributionLayout = (RelativeLayout) findViewById(R.id.details_attribution_layout);
    attributionLayout.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            c[0]++;
            if (c[0] >= 20) unlock = true;
          }
        });

    attributionTextView = (TextView) findViewById(R.id.details_attribution_text);
    if (earthWallpaper.getWallpaperAttribution() == null) {
      attributionTextView.setText(R.string.details_unknown);
    } else {
      attributionTextView.setText(earthWallpaper.getWallpaperAttribution());
    }

    shareLinkLayout = (RelativeLayout) findViewById(R.id.share_link_layout);
    shareLinkLayout.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onEarthViewShow();
          }
        });

    shareLinkTextView = (TextView) findViewById(R.id.details_share_link_text);
    shareLinkTextView.setText(earthWallpaper.getShareUrl());

    // inflating the fab menu and it's entries
    floatingActionMenu = (FloatingActionMenu) findViewById(R.id.details_fab_menu);
    floatingActionMenu.setClosedOnTouchOutside(true);

    floatingActionShare = (FloatingActionButton) findViewById(R.id.fab_item_share);
    floatingActionShare.setImageDrawable(
        new IconicsDrawable(this)
            .icon(CommunityMaterial.Icon.cmd_share_variant)
            .color(Color.WHITE)
            .sizeDp(16));
    floatingActionShare.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onEarthViewShare();
            if (floatingActionMenu.isOpened()) floatingActionMenu.close(true);
          }
        });

    floatingActionApply = (FloatingActionButton) findViewById(R.id.fab_item_apply);
    floatingActionApply.setImageDrawable(
        new IconicsDrawable(this)
            .icon(CommunityMaterial.Icon.cmd_check)
            .color(Color.WHITE)
            .sizeDp(16));
    floatingActionApply.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // Snackbar.make(rootLayout, "Applying is coming soon!", Snackbar.LENGTH_SHORT).show();
            onSetAsWallpaper();
            if (floatingActionMenu.isOpened()) floatingActionMenu.close(true);
          }
        });

    floatingActionArchive = (FloatingActionButton) findViewById(R.id.fab_item_archive);
    if (Preferences.getInstance().isFavorite(earthWallpaper)) {
      floatingActionArchive.setImageDrawable(
          new IconicsDrawable(this)
              .icon(CommunityMaterial.Icon.cmd_heart_outline)
              .color(Color.WHITE)
              .sizeDp(16));
      floatingActionArchive.setLabelText(
          getResources().getString(R.string.fab_menu_item_remove_archive));
    } else {
      floatingActionArchive.setImageDrawable(
          new IconicsDrawable(this)
              .icon(CommunityMaterial.Icon.cmd_heart)
              .color(Color.WHITE)
              .sizeDp(16));
      floatingActionArchive.setLabelText(getResources().getString(R.string.fab_menu_item_archive));
    }
    floatingActionArchive.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (floatingActionMenu.isOpened()) floatingActionMenu.close(false);

            if (Preferences.getInstance().isFavorite(earthWallpaper)) {
              Preferences.getInstance().removeFavorite(earthWallpaper);
              floatingActionArchive.setImageDrawable(
                  new IconicsDrawable(WallpaperActivityPre.this)
                      .icon(CommunityMaterial.Icon.cmd_heart)
                      .color(Color.WHITE)
                      .sizeDp(16));
              floatingActionArchive.setLabelText(
                  getResources().getString(R.string.fab_menu_item_archive));
              Snackbar.make(rootLayout, R.string.fab_snack_bar_fav_removed, Snackbar.LENGTH_SHORT)
                  .setAction(
                      R.string.fab_snack_bar_fav_action,
                      new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {}
                      })
                  .show();
            } else {
              Preferences.getInstance().addFavorite(earthWallpaper);
              floatingActionArchive.setImageDrawable(
                  new IconicsDrawable(WallpaperActivityPre.this)
                      .icon(CommunityMaterial.Icon.cmd_heart_outline)
                      .color(Color.WHITE)
                      .sizeDp(16));
              floatingActionArchive.setLabelText(
                  getResources().getString(R.string.fab_menu_item_remove_archive));
              Snackbar.make(rootLayout, R.string.fab_snack_bar_fav_added, Snackbar.LENGTH_SHORT)
                  .setAction(
                      R.string.fab_snack_bar_fav_action,
                      new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {}
                      })
                  .show();
            }
          }
        });

    floatingActionDownload = (FloatingActionButton) findViewById(R.id.fab_item_download);
    floatingActionDownload.setImageDrawable(
        new IconicsDrawable(this)
            .icon(CommunityMaterial.Icon.cmd_download)
            .color(Color.WHITE)
            .sizeDp(16));
    floatingActionDownload.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (floatingActionMenu.isOpened()) floatingActionMenu.close(true);
            if (Preferences.getInstance().canWriteExternalStorage()) {
              new DownloadWallpaperTask(
                      WallpaperActivityPre.this,
                      Preferences.getInstance().getWallpaperDownloadDir(),
                      earthWallpaper)
                  .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, unlock);
            } else {
              Preferences.getInstance()
                  .requestExternalStoragePermission(
                      WallpaperActivityPre.this, WallpaperActivityPre.this, false);
            }
          }
        });

    // EarthView.withGoogle().getEarthWallpaper(earthWallpaper.getWallpaperId(), this);
    new DownloadHighResImage(this, earthWallpaper, this)
        .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

    setTypefaces();
  }