Java Code Examples for com.google.android.material.bottomsheet.BottomSheetDialog#setContentView()

The following examples show how to use com.google.android.material.bottomsheet.BottomSheetDialog#setContentView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ObservationViewActivity.java    From mage-android with Apache License 2.0 6 votes vote down vote up
private void onImportantClick() {
	ObservationImportant important = o.getImportant();
	boolean isImportant = important != null && important.isImportant();
	if (isImportant) {
		BottomSheetDialog dialog = new BottomSheetDialog(this);
		View view = getLayoutInflater().inflate(R.layout.view_important_bottom_sheet, null);
		view.findViewById(R.id.update_button).setOnClickListener(v -> {
			onUpdateImportantClick();
			dialog.dismiss();
		});
		view.findViewById(R.id.remove_button).setOnClickListener(v -> {
			onRemoveImportantClick();
			dialog.dismiss();
		});
		dialog.setContentView(view);
		dialog.show();
	} else {
		onUpdateImportantClick();
	}
}
 
Example 2
Source File: ShapeThemingDemoFragment.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateDemoView(
    LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
  View view =
      layoutInflater.inflate(
          R.layout.cat_shape_theming_container, viewGroup, false /* attachToRoot */);
  ViewGroup container = view.findViewById(R.id.container);
  layoutInflater.inflate(R.layout.cat_shape_theming_content, container, true  /* attachToRoot */);

  MaterialButton materialButton = container.findViewById(R.id.material_button);
  MaterialAlertDialogBuilder materialAlertDialogBuilder =
      new MaterialAlertDialogBuilder(getContext(), getShapeTheme())
          .setTitle(R.string.cat_shape_theming_dialog_title)
          .setMessage(R.string.cat_shape_theming_dialog_message)
          .setPositiveButton(R.string.cat_shape_theming_dialog_ok, null);
  materialButton.setOnClickListener(v -> materialAlertDialogBuilder.show());
  BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(wrappedContext);
  bottomSheetDialog.setContentView(R.layout.cat_shape_theming_bottomsheet_content);
  View bottomSheetInternal = bottomSheetDialog.findViewById(R.id.design_bottom_sheet);
  BottomSheetBehavior.from(bottomSheetInternal).setPeekHeight(300);
  MaterialButton button = container.findViewById(R.id.material_button_2);
  button.setOnClickListener(v -> bottomSheetDialog.show());

  return view;
}
 
Example 3
Source File: BaseBottomSheetDialogFragment.java    From SAI with GNU General Public License v3.0 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
    mDialog = new BottomSheetDialog(requireContext(), Theme.getInstance(requireContext()).getCurrentTheme().isDark() ? R.style.SAIBottomSheetDialog_Backup : R.style.SAIBottomSheetDialog_Backup_Light);

    View dialogView = LayoutInflater.from(requireContext()).inflate(R.layout.dialog_bottom_sheet_base, null);
    mPositiveButton = dialogView.findViewById(R.id.button_bottom_sheet_dialog_base_ok);
    mNegativeButton = dialogView.findViewById(R.id.button_bottom_sheet_dialog_base_cancel);
    mDialog.setContentView(dialogView);

    FrameLayout container = dialogView.findViewById(R.id.container_bottom_sheet_dialog_base_content);
    View contentView = onCreateContentView(LayoutInflater.from(requireContext()), container, savedInstanceState);
    if (contentView != null) {
        onContentViewCreated(contentView, savedInstanceState);
        container.addView(contentView);
    }

    return mDialog;
}
 
Example 4
Source File: MessageBoxDialog.java    From Stylish-Widget-for-Android with Apache License 2.0 6 votes vote down vote up
public BottomSheetDialog create() {
    final MessageBox messageBox = new MessageBox(context);

    messageBox.setMessage(message);

    final BottomSheetDialog dialog = new BottomSheetDialog(context);
    dialog.setContentView(messageBox);

    if (listener==null){
        listener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.hide();
            }
        };
    }
    if (text == null)
        messageBox.setCloseButton(listener);
    else
        messageBox.setActionButton(text, listener);


    return dialog;
}
 
Example 5
Source File: ChatFragment.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMessageClicked(SpannableStringBuilder formattedMessage, final String userName, final String message) {
	View v = LayoutInflater.from(getContext()).inflate(R.layout.chat_message_options, null);
	final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(getContext());
	bottomSheetDialog.setContentView(v);
	final BottomSheetBehavior behavior = BottomSheetBehavior.from((View) v.getParent());
	behavior.setPeekHeight(getContext().getResources().getDisplayMetrics().heightPixels/3);

	bottomSheetDialog.setOnDismissListener(dialogInterface -> behavior.setState(BottomSheetBehavior.STATE_COLLAPSED));

	TextView mMessage = v.findViewById(R.id.text_chat_message);
	TextView mMention = v.findViewById(R.id.text_mention);
	TextView mDuplicateMessage = v.findViewById(R.id.text_duplicate_message);

	mMessage.setText(formattedMessage);
	mMention.setOnClickListener(view -> {
		insertSendText("@" + userName);
		bottomSheetDialog.dismiss();
	});
	mDuplicateMessage.setOnClickListener(view -> {
		insertSendText(message);
		bottomSheetDialog.dismiss();
	});

	bottomSheetDialog.show();
}
 
Example 6
Source File: ThreadListFragment.java    From hipda with GNU General Public License v2.0 6 votes vote down vote up
private void showThreadListSettingsDialog() {
    final LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View view = inflater.inflate(R.layout.dialog_thread_list_settings, null);

    final ValueChagerView valueChagerView = view.findViewById(R.id.value_changer);

    valueChagerView.setCurrentValue(HiSettingsHelper.getInstance().getTitleTextSizeAdj());

    final BottomSheetDialog dialog = new BottomDialog(getActivity());

    valueChagerView.setOnChangeListener(new ValueChagerView.OnChangeListener() {
        @Override
        public void onChange(int currentValue) {
            HiSettingsHelper.getInstance().setTitleTextSizeAdj(currentValue);
            if (mThreadListAdapter != null)
                mThreadListAdapter.notifyDataSetChanged();
        }
    });

    dialog.setContentView(view);
    BottomSheetBehavior mBehavior = BottomSheetBehavior.from((View) view.getParent());
    mBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
    dialog.show();
}
 
Example 7
Source File: BottomSheetDialogActivity.java    From AndroidAnimationExercise with Apache License 2.0 6 votes vote down vote up
private void showBSDialog() {
    final BottomSheetDialog dialog = new BottomSheetDialog(this);
    View view = LayoutInflater.from(this).inflate(R.layout.dialog_layout, null);
    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.bs_rv);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    SimpleStringRecyclerViewAdapter adapter = new SimpleStringRecyclerViewAdapter(this);
    adapter.setItemClickListener(new SimpleStringRecyclerViewAdapter.ItemClickListener() {
        @Override
        public void onItemClick(int pos) {
            dialog.dismiss();
            Toast.makeText(BottomSheetDialogActivity.this, "pos--->" + pos, Toast.LENGTH_LONG).show();
        }
    });
    recyclerView.setAdapter(adapter);
    dialog.setContentView(view);
    dialog.show();
}
 
Example 8
Source File: StreamFragment.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 5 votes vote down vote up
private void setupProfileBottomSheet() {
    View v = LayoutInflater.from(getContext()).inflate(R.layout.stream_profile_preview, null);
    mProfileBottomSheet = new BottomSheetDialog(getContext());
    mProfileBottomSheet.setContentView(v);
    final BottomSheetBehavior behavior = getDefaultBottomSheetBehaviour(v);

    mProfileBottomSheet.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialogInterface) {
            behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
        }
    });

    TextView mNameView = mProfileBottomSheet.findViewById(R.id.twitch_name);
    TextView mFollowers = mProfileBottomSheet.findViewById(R.id.txt_followers);
    TextView mViewers = mProfileBottomSheet.findViewById(R.id.txt_viewers);
    ImageView mFollowButton = mProfileBottomSheet.findViewById(R.id.follow_unfollow_icon);
    ImageView mFullProfileButton = mProfileBottomSheet.findViewById(R.id.full_profile_icon);
    RecyclerView mPanelsRecyclerView = mProfileBottomSheet.findViewById(R.id.panel_recyclerview);

    mNameView.setText(mChannelInfo.getDisplayName());
    mFollowers.setText(mChannelInfo.getFollowers() + "");
    mViewers.setText(mChannelInfo.getViews() + "");

    mFullProfileButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mProfileBottomSheet.dismiss();

            final Intent intent = new Intent(getContext(), ChannelActivity.class);
            intent.putExtra(getContext().getResources().getString(R.string.channel_info_intent_object), mChannelInfo);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

            getContext().startActivity(intent);
        }
    });

    setupFollowButton(mFollowButton);
    setupPanels(mPanelsRecyclerView);
}
 
Example 9
Source File: BottomSheetSectionDialog.java    From FlexibleAdapter with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mBottomSheetDialog = new BottomSheetDialog(getActivity(), R.style.AppTheme_BottomSheetDialog);
    mBottomSheetDialog.setContentView(getArguments().getInt(ARG_LAYOUT));
    mBottomSheetDialog.findViewById(R.id.select_item_type).setOnClickListener(this);
    mBottomSheetDialog.findViewById(R.id.select_item_type).setOnTouchListener(new SimpleOnTouchListener(getContext()));
    mBottomSheetDialog.findViewById(R.id.select_reference_button).setOnClickListener(this);
    mBottomSheetDialog.findViewById(R.id.select_reference_button).setOnTouchListener(new SimpleOnTouchListener(getContext()));
    mBottomSheetDialog.findViewById(R.id.new_item).setOnClickListener(this);
    createPopUps();
    return mBottomSheetDialog;
}
 
Example 10
Source File: LauncherActivity.java    From HgLauncher with GNU General Public License v3.0 5 votes vote down vote up
public void showStartDialog() {
    DialogStartHintBinding binding = DialogStartHintBinding.inflate(getLayoutInflater());
    final BottomSheetDialog startDialog = new BottomSheetDialog(this);
    startDialog.setContentView(binding.getRoot());
    startDialog.setCancelable(false);
    startDialog.getBehavior().setState(BottomSheetBehavior.STATE_EXPANDED);
    Button startDismiss = binding.dismiss;
    startDismiss.setOnClickListener(new View.OnClickListener() {
        @Override public void onClick(View view) {
            startDialog.dismiss();
            PreferenceHelper.update("is_new_user", false);
        }
    });
    startDialog.show();
}
 
Example 11
Source File: BottomSheetDecorationDialog.java    From FlexibleAdapter with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mBottomSheetDialog = new BottomSheetDialog(getActivity(), R.style.AppTheme_BottomSheetDialog);
    mBottomSheetDialog.setContentView(getArguments().getInt(ARG_LAYOUT));

    setListener();
    configureEdges();
    configureDividers();

    return mBottomSheetDialog;
}
 
Example 12
Source File: BottomSheetScrollableContentDemoFragment.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateDemoView(
    LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
  View view = layoutInflater.inflate(getDemoContent(), viewGroup, false /* attachToRoot */);

  // Set up BottomSheetDialog
  BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(getContext());
  bottomSheetDialog.setContentView(R.layout.cat_bottomsheet_scrollable_content);
  View bottomSheetInternal = bottomSheetDialog.findViewById(R.id.design_bottom_sheet);
  BottomSheetBehavior.from(bottomSheetInternal).setPeekHeight(400);
  View button = view.findViewById(R.id.bottomsheet_button);
  button.setOnClickListener(v -> bottomSheetDialog.show());
  return view;
}
 
Example 13
Source File: LauncherActivity.java    From HgLauncher with GNU General Public License v3.0 5 votes vote down vote up
public void showStartDialog() {
    DialogStartHintBinding binding = DialogStartHintBinding.inflate(getLayoutInflater());
    final BottomSheetDialog startDialog = new BottomSheetDialog(this);
    startDialog.setContentView(binding.getRoot());
    startDialog.setCancelable(false);
    startDialog.getBehavior().setState(BottomSheetBehavior.STATE_EXPANDED);
    Button startDismiss = binding.dismiss;
    startDismiss.setOnClickListener(new View.OnClickListener() {
        @Override public void onClick(View view) {
            startDialog.dismiss();
            PreferenceHelper.update("is_new_user", false);
        }
    });
    startDialog.show();
}
 
Example 14
Source File: EditObservationFragment.java    From ground-android with Apache License 2.0 5 votes vote down vote up
private void onShowPhotoSelectorDialog(Field field) {
  EditObservationBottomSheetBinding addPhotoBottomSheetBinding =
      EditObservationBottomSheetBinding.inflate(getLayoutInflater());
  addPhotoBottomSheetBinding.setViewModel(viewModel);
  addPhotoBottomSheetBinding.setField(field);

  BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(getContext());
  bottomSheetDialog.setContentView(addPhotoBottomSheetBinding.getRoot());
  bottomSheetDialog.setCancelable(true);
  bottomSheetDialog.show();

  AddPhotoDialogAdapter.ItemClickListener listener =
      type -> {
        bottomSheetDialog.dismiss();
        switch (type) {
          case PHOTO_SOURCE_CAMERA:
            viewModel.showPhotoCapture(field);
            break;
          case PHOTO_SOURCE_STORAGE:
            viewModel.showPhotoSelector(field);
            break;
          default:
            throw new IllegalArgumentException("Unknown type: " + type);
        }
      };

  RecyclerView recyclerView = addPhotoBottomSheetBinding.recyclerView;
  recyclerView.setHasFixedSize(true);
  recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
  recyclerView.setAdapter(new AddPhotoDialogAdapter(listener));
}
 
Example 15
Source File: FriendProfile.java    From Hify with MIT License 5 votes vote down vote up
@Override
public void onViewCreated(View view,@Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    Bundle bundle = this.getArguments();
    if (bundle != null) {
        id = bundle.getString("id");
    }else{
        Toasty.error(rootView.getContext(), "Error retrieving information.", Toasty.LENGTH_SHORT,true).show();
        getActivity().finish();
    }

    refreshLayout=rootView.findViewById(R.id.refreshLayout);
    statsheetView = ((AppCompatActivity)getActivity()).getLayoutInflater().inflate(R.layout.stat_bottom_sheet_dialog, null);
    mmBottomSheetDialog = new BottomSheetDialog(rootView.getContext());
    mmBottomSheetDialog.setContentView(statsheetView);
    mmBottomSheetDialog.setCanceledOnTouchOutside(true);

    postList=new ArrayList<>();
    mAdapter=new PostsAdapter(postList, rootView.getContext(),getActivity(),mmBottomSheetDialog,statsheetView,false);

    mRecyclerView=rootView.findViewById(R.id.recyclerView);

    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(new LinearLayoutManager(rootView.getContext(), VERTICAL, false));
    mRecyclerView.addItemDecoration(new DividerItemDecoration(view.getContext(),DividerItemDecoration.VERTICAL));
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setAdapter(mAdapter);

    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            postList.clear();
            mAdapter.notifyDataSetChanged();
            getPosts(id);
        }
    });

    getPosts(id);

}
 
Example 16
Source File: Home.java    From Hify with MIT License 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {

    mFirestore = FirebaseFirestore.getInstance();
    mAuth = FirebaseAuth.getInstance();
    currentUser = mAuth.getCurrentUser();

    refreshLayout=view.findViewById(R.id.refreshLayout);

    statsheetView = ((AppCompatActivity)getActivity()).getLayoutInflater().inflate(R.layout.stat_bottom_sheet_dialog, null);
    mmBottomSheetDialog = new BottomSheetDialog(view.getContext());
    mmBottomSheetDialog.setContentView(statsheetView);
    mmBottomSheetDialog.setCanceledOnTouchOutside(true);
    mPostsRecyclerView = view.findViewById(R.id.posts_recyclerview);

    mPostsList = new ArrayList<>();

    mAdapter_v19 = new PostsAdapter(mPostsList, view.getContext(), getActivity(), mmBottomSheetDialog, statsheetView, false);
    mPostsRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mPostsRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    mPostsRecyclerView.setHasFixedSize(true);
    mPostsRecyclerView.addItemDecoration(new DividerItemDecoration(view.getContext(),DividerItemDecoration.VERTICAL));
    mPostsRecyclerView.setAdapter(mAdapter_v19);

    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {

            mPostsList.clear();
            mAdapter_v19.notifyDataSetChanged();
            getAllPosts();

        }
    });

    getAllPosts();
}
 
Example 17
Source File: StreamFragment.java    From Twire with GNU General Public License v3.0 5 votes vote down vote up
private void setupProfileBottomSheet() {
    View v = LayoutInflater.from(getContext()).inflate(R.layout.stream_profile_preview, null);
    mProfileBottomSheet = new BottomSheetDialog(getContext());
    mProfileBottomSheet.setContentView(v);
    final BottomSheetBehavior behavior = getDefaultBottomSheetBehaviour(v);

    mProfileBottomSheet.setOnDismissListener(dialogInterface -> behavior.setState(BottomSheetBehavior.STATE_COLLAPSED));

    TextView mNameView = mProfileBottomSheet.findViewById(R.id.twitch_name);
    TextView mFollowers = mProfileBottomSheet.findViewById(R.id.txt_followers);
    TextView mViewers = mProfileBottomSheet.findViewById(R.id.txt_viewers);
    ImageView mFollowButton = mProfileBottomSheet.findViewById(R.id.follow_unfollow_icon);
    ImageView mFullProfileButton = mProfileBottomSheet.findViewById(R.id.full_profile_icon);
    RecyclerView mPanelsRecyclerView = mProfileBottomSheet.findViewById(R.id.panel_recyclerview);

    mNameView.setText(mChannelInfo.getDisplayName());
    mFollowers.setText(mChannelInfo.getFollowers() + "");
    mViewers.setText(mChannelInfo.getViews() + "");

    mFullProfileButton.setOnClickListener(view -> {
        mProfileBottomSheet.dismiss();

        final Intent intent = new Intent(getContext(), ChannelActivity.class);
        intent.putExtra(getContext().getResources().getString(R.string.channel_info_intent_object), mChannelInfo);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        getContext().startActivity(intent);
    });

    setupFollowButton(mFollowButton);
    setupPanels(mPanelsRecyclerView);
}
 
Example 18
Source File: SinglePostView.java    From Hify with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    ViewPump.init(ViewPump.builder()
            .addInterceptor(new CalligraphyInterceptor(
                    new CalligraphyConfig.Builder()
                            .setDefaultFontPath("fonts/bold.ttf")
                            .setFontAttrId(R.attr.fontPath)
                            .build()))
            .build());

    setContentView(R.layout.activity_single_post_view);

    String post_id=getIntent().getStringExtra("post_id");

    Toolbar toolbar=findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle("Post");

    getSupportActionBar().setTitle("Post");
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    if(!TextUtils.isEmpty(post_id)){

        boolean forComment=getIntent().getBooleanExtra("forComment",false);

        pbar=findViewById(R.id.pbar);
        mFirestore=FirebaseFirestore.getInstance();

        statsheetView = getLayoutInflater().inflate(R.layout.stat_bottom_sheet_dialog, null);
        mmBottomSheetDialog = new BottomSheetDialog(this);
        mmBottomSheetDialog.setContentView(statsheetView);
        mmBottomSheetDialog.setCanceledOnTouchOutside(true);

        mPostsList = new ArrayList<>();

        if(forComment)
            mAdapter = new PostsAdapter(mPostsList, this,this,mmBottomSheetDialog,statsheetView,true);
        else
            mAdapter = new PostsAdapter(mPostsList, this,this,mmBottomSheetDialog,statsheetView,false);


        RecyclerView mRecyclerView=findViewById(R.id.recyclerView);
        mRecyclerView.setItemAnimator(new DefaultItemAnimator());
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.setHasFixedSize(true);
        mRecyclerView.setAdapter(mAdapter);

        pbar.setVisibility(View.VISIBLE);
        getPosts(post_id);



    }else{
        finish();
    }

}
 
Example 19
Source File: ProfileFragment.java    From Hify with MIT License 4 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    postList=new ArrayList<>();

    statsheetView = ((AppCompatActivity)getActivity()).getLayoutInflater().inflate(R.layout.stat_bottom_sheet_dialog, null);
    mmBottomSheetDialog = new BottomSheetDialog(rootView.getContext());
    mmBottomSheetDialog.setContentView(statsheetView);
    mmBottomSheetDialog.setCanceledOnTouchOutside(true);
    refreshLayout=rootView.findViewById(R.id.refreshLayout);

    title=rootView.findViewById(R.id.default_title);
    text=rootView.findViewById(R.id.default_text);
    image=rootView.findViewById(R.id.imageview);

    image.setImageDrawable(getResources().getDrawable(R.drawable.ic_bookmark_black_24dp));
    title.setText("No saved posts found");
    text.setText("All your saved posts appear here");

    mRecyclerView=rootView.findViewById(R.id.recyclerView);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(new LinearLayoutManager(rootView.getContext(), VERTICAL, false));
    mRecyclerView.setHasFixedSize(true);

    mAdapter_v19 = new PostsAdapter(postList, rootView.getContext(), getActivity(), mmBottomSheetDialog, statsheetView, false);
    mRecyclerView.addItemDecoration(new DividerItemDecoration(rootView.getContext(),DividerItemDecoration.VERTICAL));
    mRecyclerView.setAdapter(mAdapter_v19);

    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {

            postList.clear();
            mAdapter_v19.notifyDataSetChanged();
            getPosts();

        }
    });

    getPosts();

}
 
Example 20
Source File: ProfileFragment.java    From Hify with MIT License 4 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    statsheetView = ((AppCompatActivity)getActivity()).getLayoutInflater().inflate(R.layout.stat_bottom_sheet_dialog, null);
    mmBottomSheetDialog = new BottomSheetDialog(rootView.getContext());
    mmBottomSheetDialog.setContentView(statsheetView);
    mmBottomSheetDialog.setCanceledOnTouchOutside(true);

    refreshLayout=rootView.findViewById(R.id.refreshLayout);

    postList=new ArrayList<>();

    mRecyclerView=rootView.findViewById(R.id.recyclerView);

    title=rootView.findViewById(R.id.default_title);
    text=rootView.findViewById(R.id.default_text);
    image=rootView.findViewById(R.id.imageview);

    image.setImageDrawable(getResources().getDrawable(R.drawable.ic_photo_camera_black_24dp));
    title.setText("No posts found");
    text.setText("Add some posts to see them here");

    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(new LinearLayoutManager(rootView.getContext(), VERTICAL, false));
    mRecyclerView.setHasFixedSize(true);

    mAdapter_v19 = new PostsAdapter(postList, rootView.getContext(), getActivity(), mmBottomSheetDialog, statsheetView, false);
    mRecyclerView.addItemDecoration(new DividerItemDecoration(rootView.getContext(),DividerItemDecoration.VERTICAL));
    mRecyclerView.setAdapter(mAdapter_v19);

    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            postList.clear();
            mAdapter_v19.notifyDataSetChanged();
            getPosts();
        }
    });
    getPosts();

}