@Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    View view = inflater.inflate(R.layout.soft_tags_wall_view, container, false);
    ButterKnife.bind(this, view);

    ((AppCompatActivity) mActivity).setSupportActionBar(mToolbar);
    ((AppCompatActivity) mActivity).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ((AppCompatActivity) mActivity)
        .getSupportActionBar()
        .setHomeAsUpIndicator(R.drawable.back_arrow);
    mToolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // hack to get click working
            mActivity.onBackPressed();
          }
        });
    // tag name
    String tag = getArguments().getString(K.KEY_TAG.name());
    mToolbar.setTitle(tag);

    // recyclers
    mLayoutManager = new LinearLayoutManager(mActivity);
    setupRecyclerView();

    return view;
  }
  /**
   * Set a {@link Toolbar} to act as the {@link android.support.v7.app.ActionBar}ActionBar for this
   * Activity window. You must take care of hiding the old {@link Toolbar} if necessary.
   *
   * @param toolbar Toolbar to set as the Activity's action bar
   */
  @Override
  public void setSupportActionBar(@Nullable Toolbar toolbar) {
    if (toolbar != null) {
      if (toolbar != mDefaultToolbar && mDefaultToolbar.getVisibility() != View.GONE) {
        mDefaultToolbar.setVisibility(View.GONE);
      }

      super.setSupportActionBar(toolbar);

      mDrawerToggle =
          new ActionBarDrawerToggle(
              this,
              mDrawer,
              toolbar,
              R.string.md_content_description_drawer_open,
              R.string.md_content_description_drawer_close) {
            public void onDrawerClosed(View view) {
              invalidateOptionsMenu();
            }

            public void onDrawerOpened(View drawerView) {
              invalidateOptionsMenu();
            }
          };
      mDrawerToggle.syncState();
      mDrawer.setDrawerListener(mDrawerToggle);
    }
  }
  // ****************************************************************
  // * Constructors
  // ****************************************************************
  public GroupCreateActivityViewHolder(
      Context context, IFragmentController fragmentController, View view) {
    super(context, fragmentController, view);
    try {
      AppCompatActivity activity = (AppCompatActivity) context;

      Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
      activity.setSupportActionBar(toolbar);
      final ActionBar actionBar = activity.getSupportActionBar();
      actionBar.setHomeAsUpIndicator(R.drawable.ic_back);
      actionBar.setDisplayHomeAsUpEnabled(true);
      actionBar.setDisplayShowTitleEnabled(false);
      fragmentManager = activity.getSupportFragmentManager();
      groupCreateFragment =
          (GroupCreateFragment) fragmentManager.findFragmentById(R.id.groupCreateFragment);
      groupCreateChoosePrivacyFragment =
          (GroupCreateChoosePrivacyFragment)
              fragmentManager.findFragmentById(R.id.groupCreateChoosePrivacyFragment);
      groupCreateChooseIconFragment =
          (GroupCreateChooseIconFragment)
              fragmentManager.findFragmentById(R.id.groupCreateChooseIconFragment);
      progressBar = (RelativeLayout) view.findViewById(R.id.progressBar);

      title = (TextView) view.findViewById(R.id.toolbarTitle);
      initialize(context);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Beispiel #4
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_articles, container, false);

    mRecyclerView = (RecyclerView) view.findViewById(R.id.articles);
    mLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.addItemDecoration(new VerticalSpaceItemDecoration(15));
    adapter = new RecyclerArticleAdapter(getActivity(), articleList);
    mRecyclerView.setAdapter(adapter);

    Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    AppCompatActivity activity = ((AppCompatActivity) getActivity());
    activity.setSupportActionBar(toolbar);

    toolbar.setNavigationIcon(R.drawable.ic_menu);
    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            listener.showNavDrawer();
          }
        });

    return view;
  }
Beispiel #5
0
 public static void initActionBar(AppCompatActivity activity, Toolbar toolbar) {
   if (toolbar != null && activity != null) {
     toolbar.setNavigationIcon(R.drawable.ic_back);
     activity.setSupportActionBar(toolbar);
     if (activity.getActionBar() != null) {
       activity.getActionBar().setDisplayShowHomeEnabled(true);
       activity.getActionBar().setHomeButtonEnabled(true);
     }
   }
 }
Beispiel #6
0
 public static void initBaseToolBar(
     final AppCompatActivity activity, Toolbar mToolbar, String title) {
   activity.setSupportActionBar(mToolbar);
   mToolbar.setTitle(title);
   mToolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
   mToolbar.setNavigationOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           activity.finish();
         }
       });
 }
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mToolbar = (Toolbar) view.findViewById(R.id.toolbar);

    if (mToolbar != null) {

      AppCompatActivity activity = ((AppCompatActivity) getActivity());
      activity.setSupportActionBar(mToolbar);
      activity.getSupportActionBar().setHomeButtonEnabled(true);
      activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
  }
 private void initViewToolbar(View rootView) {
   mToolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
   AppCompatActivity activity = ((AppCompatActivity) getActivity());
   if (activity != null) {
     activity.setSupportActionBar(mToolbar);
     ActionBar actionBar = activity.getSupportActionBar();
     if (actionBar != null) {
       actionBar.setDisplayHomeAsUpEnabled(true);
       actionBar.setDisplayShowHomeEnabled(true);
       actionBar.setHomeAsUpIndicator(R.drawable.ic_back);
       actionBar.setTitle(R.string.title_add_new_condition);
     }
   }
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_home, container, false);
    slidingUpPanelLayout = (SlidingUpPanelLayout) view.findViewById(R.id.sliding_layout);
    toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    AppCompatActivity compatActivity = (AppCompatActivity) getActivity();
    compatActivity.setSupportActionBar(toolbar);
    buttonShow = (Button) view.findViewById(R.id.btn_show);
    buttonHide = (Button) view.findViewById(R.id.btn_hide);
    buttonShow.setOnClickListener(this);
    buttonHide.setOnClickListener(this);

    return view;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mRootView = inflater.inflate(R.layout.fragment_article_detail, container, false);
    mPhotoView = (ImageView) mRootView.findViewById(R.id.photo);

    Toolbar toolbar = (Toolbar) mRootView.findViewById(R.id.toolbar);
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(toolbar);
    activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    bindViews();

    return mRootView;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    view = inflater.inflate(R.layout.fragment_view_photo, container, false);
    ButterKnife.bind(this, view);
    activity.setSupportActionBar(toolbarViewPicture);
    activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    toolbarViewPicture.setNavigationOnClickListener(
        view -> {
          FragmentManager fm = getActivity().getSupportFragmentManager();
          fm.popBackStack();
        });

    return view;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRootView = inflater.inflate(R.layout.fragment_article_detail, container, false);

    setHasOptionsMenu(true);

    Toolbar toolbar = (Toolbar) mRootView.findViewById(R.id.toolbar);
    AppCompatActivity activity = ((AppCompatActivity) getActivity());
    activity.setSupportActionBar(toolbar);
    ActionBar actionBar = activity.getSupportActionBar();
    if (actionBar != null) {
      actionBar.setDisplayHomeAsUpEnabled(true);
      actionBar.setDisplayShowHomeEnabled(true);

    } else {
      Log.e(TAG, "Missing actionbar!");
    }

    mPhotoView = (ImageView) mRootView.findViewById(R.id.ivPhoto);

    mRootView
        .findViewById(R.id.share_fab)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                startActivity(
                    Intent.createChooser(
                        ShareCompat.IntentBuilder.from(getActivity())
                            .setType("text/plain")
                            .setText("Some sample text")
                            .getIntent(),
                        getString(R.string.action_share)));
              }
            });

    bindViews();
    return mRootView;
  }
 private void prepareActionBarWithToolbar() {
   mActivity.setSupportActionBar(mToolbar);
 }
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ActivitiesFragmentBinding binding =
        DataBindingUtil.inflate(inflater, R.layout.activities_fragment, container, false);
    binding.setCategory(category);

    Toolbar toolbar = binding.toolbar;
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(toolbar);
    assert activity.getSupportActionBar() != null;
    final ActionBar ab = activity.getSupportActionBar();
    ab.setDisplayShowTitleEnabled(false);
    ab.setDisplayHomeAsUpEnabled(false);

    Spinner spinner = binding.spinner;
    spinner.setAdapter(
        new ArrayAdapter<>(
            ab.getThemedContext(), android.R.layout.simple_spinner_item, localizedCategory));
    spinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (currentCategory != position) {
              currentCategory = position;
              category.set(localizedCategory[currentCategory]);
              activities.clear();
              list.getAdapter().notifyDataSetChanged();
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });

    slider = binding.slider;
    slider.setCustomIndicator(binding.customIndicator);
    slider.setDuration(3500);
    slider.setPresetTransformer(SliderLayout.Transformer.Fade);
    api.getActivities("recommendations", 0, 5)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(
            new Action1<List<Activity>>() {
              @Override
              public void call(List<Activity> activities) {
                slider.stopAutoCycle();
                slider.removeAllSliders();
                for (Activity activity : activities) {
                  ActivitySliderView view = new ActivitySliderView(getContext(), activity);
                  view.bundle(new Bundle());
                  view.getBundle().putLong("id", activity.getId());
                  view.setOnSliderClickListener(sliderClickListener);
                  slider.addSlider(view);
                }
                slider.startAutoCycle();
              }
            },
            new Action1<Throwable>() {
              @Override
              public void call(Throwable throwable) {
                Timber.e("failed to fetch recommended activities", throwable);
                throwable.printStackTrace();
              }
            });

    list = binding.list;
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
    list.setLayoutManager(linearLayoutManager);
    list.addItemDecoration(new MarginDownDecoration(getContext()));
    list.setAdapter(new ActivitiesAdapter(activities));
    list.addOnScrollListener(
        new EndlessRecyclerOnScrollListener(linearLayoutManager) {
          @Override
          public void onLoadMore(int currentPage) {
            loadPage(currentPage);
          }
        });

    // loadPage(0);

    return binding.getRoot();
  }