Java Code Examples for com.google.firebase.firestore.FirebaseFirestore#getInstance()

The following examples show how to use com.google.firebase.firestore.FirebaseFirestore#getInstance() . 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: EventsActivity.java    From NaviBee with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_events);

    uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
    db = FirebaseFirestore.getInstance();

    // loading
    events.add(new EventRVIndefiniteProgressBar());
    eventIdMap = new HashMap<>();

    // set up recycler view
    recyclerView = (RecyclerView)findViewById(R.id.events_recycler_view);
    viewManager = new LinearLayoutManager(this);
    viewAdapter = new EventsRVAdaptor(events);

    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(viewManager);
    recyclerView.setAdapter(viewAdapter);

    loadEvents();

}
 
Example 2
Source File: MapPresenter.java    From ridesharing-android with MIT License 6 votes vote down vote up
public MapPresenter(Context context, V view, S state) {
    mContext = context.getApplicationContext() == null ? context : context.getApplicationContext();
    mView = view;
    mState = state;
    mapPadding = mContext.getResources().getDimensionPixelSize(R.dimen.map_padding);

    Places.initialize(mContext, MainActivity.GOOGLE_API_KEY);

    mapConfig = MapUtils.getBuilder(context).build();

    hyperTrackViews = HyperTrackViews.getInstance(mContext, HyperTrackUtils.getPubKey(context));
    locationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
    db = FirebaseFirestore.getInstance();

    List<Place.Field> fields = Arrays.asList(
            Place.Field.ID, Place.Field.NAME, Place.Field.LAT_LNG,
            Place.Field.ADDRESS, Place.Field.ADDRESS_COMPONENTS
    );
    autocompleteIntentBuilder = new Autocomplete.IntentBuilder(
            AutocompleteActivityMode.OVERLAY, fields);
}
 
Example 3
Source File: ConversationManager.java    From NaviBee with GNU General Public License v3.0 5 votes vote down vote up
public static void init() {
    instance = new ConversationManager();

    instance.uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
    instance.db = FirebaseFirestore.getInstance();

    instance.listenPrivateConv();
    instance.listenGroupConv();
}
 
Example 4
Source File: PostsAdapter.java    From Hify with MIT License 5 votes vote down vote up
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    FirebaseAuth mAuth = FirebaseAuth.getInstance();
    mFirestore = FirebaseFirestore.getInstance();
    mCurrentUser = mAuth.getCurrentUser();
    View view= LayoutInflater.from(context).inflate(R.layout.item_feed_post,parent,false);
    return new ViewHolder(view);
}
 
Example 5
Source File: FirestorePagingActivity.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_firestore_paging);
    ButterKnife.bind(this);

    mFirestore = FirebaseFirestore.getInstance();
    mItemsCollection = mFirestore.collection("items");

    setUpAdapter();
}
 
Example 6
Source File: FirestoreTest.java    From firebase-android-sdk with Apache License 2.0 5 votes vote down vote up
@Test
public void setShouldTriggerListenerWithNewlySetData() throws Exception {
  FirebaseAuth auth = FirebaseAuth.getInstance();
  FirebaseFirestore firestore = FirebaseFirestore.getInstance();

  auth.signOut();
  Task<?> signInTask = auth.signInWithEmailAndPassword("[email protected]", "password");
  Tasks2.waitForSuccess(signInTask);

  DocumentReference doc = firestore.collection("restaurants").document(TestId.create());
  SnapshotListener listener = new SnapshotListener();
  ListenerRegistration registration = doc.addSnapshotListener(listener);

  try {
    HashMap<String, Object> data = new HashMap<>();
    data.put("location", "Google NYC");

    Task<?> setTask = doc.set(new HashMap<>(data));
    Task<DocumentSnapshot> snapshotTask = listener.toTask();
    Tasks2.waitForSuccess(setTask);
    Tasks2.waitForSuccess(snapshotTask);

    DocumentSnapshot result = snapshotTask.getResult();
    assertThat(result.getData()).isEqualTo(data);
  } finally {
    registration.remove();
    Tasks2.waitBestEffort(doc.delete());
  }
}
 
Example 7
Source File: EmulatorSuite.java    From snippets-android with Apache License 2.0 5 votes vote down vote up
public void emulatorSettings() {
    // [START fs_emulator_connect]
    // 10.0.2.2 is the special IP address to connect to the 'localhost' of
    // the host computer from an Android emulator.
    FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder()
            .setHost("10.0.2.2:8080")
            .setSslEnabled(false)
            .setPersistenceEnabled(false)
            .build();

    FirebaseFirestore firestore = FirebaseFirestore.getInstance();
    firestore.setFirestoreSettings(settings);
    // [END fs_emulator_connect]
}
 
Example 8
Source File: GndApplicationModule.java    From ground-android with Apache License 2.0 5 votes vote down vote up
@Provides
@Singleton
static FirebaseFirestore firebaseFirestore(FirebaseFirestoreSettings settings) {
  FirebaseFirestore firestore = FirebaseFirestore.getInstance();
  firestore.setFirestoreSettings(settings);
  FirebaseFirestore.setLoggingEnabled(Config.FIRESTORE_LOGGING_ENABLED);
  return firestore;
}
 
Example 9
Source File: MainActivity.java    From snippets-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.activity_main);

    findViewById(R.id.button_write).setOnClickListener(this);
    findViewById(R.id.button_smoketest).setOnClickListener(this);
    findViewById(R.id.button_delete_all).setOnClickListener(this);

    mFirestore = FirebaseFirestore.getInstance();

    new SolutionRateLimiting().startUpdates();
}
 
Example 10
Source File: Conversation.java    From NaviBee with GNU General Public License v3.0 5 votes vote down vote up
public Conversation(String id, Date readTimestamp, Date createTimestamp) {
    conversationId = id;
    this.readTimestamp = readTimestamp;
    this.createTimestamp = createTimestamp;
    this.uid = FirebaseAuth.getInstance().getCurrentUser().getUid();

    db = FirebaseFirestore.getInstance();
    listen();
}
 
Example 11
Source File: PostImage.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_post_image);

    imagesList=getIntent().getParcelableArrayListExtra("imagesList");

    if(imagesList.isEmpty()){
        finish();
    }

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

    int nightModeFlags=getResources().getConfiguration().uiMode& Configuration.UI_MODE_NIGHT_MASK;
    if(nightModeFlags==UI_MODE_NIGHT_NO){
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            int flags=getWindow().getDecorView().getSystemUiVisibility();
            flags|=View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
            getWindow().getDecorView().setSystemUiVisibility(flags);
        }
        toolbar.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDarkk));
    }

    try {
        getSupportActionBar().setTitle("New Image Post");
    } catch (Exception e) {
        e.printStackTrace();
    }
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    postMap = new HashMap<>();

    pager=findViewById(R.id.pager);
    indicator=findViewById(R.id.indicator);
    indicator_holder=findViewById(R.id.indicator_holder);

    indicator.setDotsClickable(true);
    adapter=new PagerPhotosAdapter(this,imagesList);
    pager.setAdapter(adapter);

    if(imagesList.size()>1){
        indicator_holder.setVisibility(View.VISIBLE);
        indicator.setViewPager(pager);
    }else{
        indicator_holder.setVisibility(GONE);
    }

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

    sharedPreferences=getSharedPreferences("uploadservice",MODE_PRIVATE);
    serviceCount=sharedPreferences.getInt("count",0);

    mEditText = findViewById(R.id.text);

    compressor=new Compressor(this)
            .setQuality(85)
            .setCompressFormat(Bitmap.CompressFormat.PNG);

    mDialog = new ProgressDialog(this);
    mStorage=FirebaseStorage.getInstance().getReference();

}
 
Example 12
Source File: AnswersActivity.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_answers);

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

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

    mFirestore=FirebaseFirestore.getInstance();
    mCurrentUser= FirebaseAuth.getInstance().getCurrentUser();
    mRecyclerView=findViewById(R.id.recyclerView);
    refreshLayout=findViewById(R.id.refreshLayout);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    if(StringUtils.isNotEmpty(getIntent().getStringExtra("question_id"))){

        Log.i(TAG,getIntent().getStringExtra("question_id"));

        mFirestore.collection("Questions")
                .document(getIntent().getStringExtra("question_id"))
                .get()
                .addOnSuccessListener(documentSnapshot -> {

                    if(documentSnapshot.exists()) {

                        author_id = documentSnapshot.getString("id");
                        author = documentSnapshot.getString("name");
                        doc_id = documentSnapshot.getId();
                        timestamp = documentSnapshot.getString("timestamp");
                        try {
                            answered_by = documentSnapshot.getString("answered_by");
                        }catch (Exception e){
                            e.printStackTrace();
                        }
                        question = documentSnapshot.getString("question");
                        setupUI();

                    }else{

                        Toasty.error(getApplicationContext(),"The question has been deleted",Toasty.LENGTH_LONG,true).show();
                        finish();

                    }
                })
                .addOnFailureListener(Throwable::printStackTrace);
    }

}
 
Example 13
Source File: MainActivity.java    From quickstart-android with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mBinding = ActivityMainBinding.inflate(getLayoutInflater());
    setContentView(mBinding.getRoot());

    setSupportActionBar(mBinding.toolbar);

    mBinding.filterBar.setOnClickListener(this);
    mBinding.buttonClearFilter.setOnClickListener(this);

    // View model
    mViewModel = new ViewModelProvider(this).get(MainActivityViewModel.class);

    // Enable Firestore logging
    FirebaseFirestore.setLoggingEnabled(true);

    // Firestore
    mFirestore = FirebaseFirestore.getInstance();

    // Get ${LIMIT} restaurants
    mQuery = mFirestore.collection("restaurants")
            .orderBy("avgRating", Query.Direction.DESCENDING)
            .limit(LIMIT);

    // RecyclerView
    mAdapter = new RestaurantAdapter(mQuery, this) {
        @Override
        protected void onDataChanged() {
            // Show/hide content if the query returns empty.
            if (getItemCount() == 0) {
                mBinding.recyclerRestaurants.setVisibility(View.GONE);
                mBinding.viewEmpty.setVisibility(View.VISIBLE);
            } else {
                mBinding.recyclerRestaurants.setVisibility(View.VISIBLE);
                mBinding.viewEmpty.setVisibility(View.GONE);
            }
        }

        @Override
        protected void onError(FirebaseFirestoreException e) {
            // Show a snackbar on errors
            Snackbar.make(mBinding.getRoot(),
                    "Error: check logs for info.", Snackbar.LENGTH_LONG).show();
        }
    };

    mBinding.recyclerRestaurants.setLayoutManager(new LinearLayoutManager(this));
    mBinding.recyclerRestaurants.setAdapter(mAdapter);

    // Filter Dialog
    mFilterDialog = new FilterDialogFragment();
}
 
Example 14
Source File: AddFriends.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);

    firestore = FirebaseFirestore.getInstance();
    mAuth = FirebaseAuth.getInstance();

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

    ItemTouchHelper.SimpleCallback itemTouchHelperCallback = new RecyclerViewTouchHelper(0, ItemTouchHelper.LEFT, new RecyclerViewTouchHelper.RecyclerItemTouchHelperListener() {
        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction, int position) {
            if (viewHolder instanceof AddFriendAdapter.ViewHolder) {
                // get the removed item name to display it in snack bar
                String name = usersList.get(viewHolder.getAdapterPosition()).getName();

                // backup of removed item for undo purpose
                final Friends deletedItem = usersList.get(viewHolder.getAdapterPosition());
                final int deletedIndex = viewHolder.getAdapterPosition();

                Snackbar snackbar = Snackbar
                        .make(view.findViewById(R.id.layout), "Friend request sent to " + name, Snackbar.LENGTH_LONG);

                // remove the item from recycler view
                usersAdapter.removeItem(viewHolder.getAdapterPosition(), snackbar, deletedIndex, deletedItem);

            }
        }
    });

    usersList = new ArrayList<>();
    usersAdapter = new AddFriendAdapter(usersList, view.getContext(), view.findViewById(R.id.layout));

    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(new LinearLayoutManager(view.getContext()));
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.addItemDecoration(new DividerItemDecoration(view.getContext(), DividerItemDecoration.VERTICAL));
    new ItemTouchHelper(itemTouchHelperCallback).attachToRecyclerView(mRecyclerView);
    mRecyclerView.setAdapter(usersAdapter);

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

    getAllUsers();

}
 
Example 15
Source File: FirebaseModule.java    From triviums with MIT License 4 votes vote down vote up
@Singleton
@Provides
FirebaseFirestore providesFirestore() {
    FirebaseFirestore.setLoggingEnabled(true);
    return FirebaseFirestore.getInstance();
}
 
Example 16
Source File: Friends.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);

    firestore = FirebaseFirestore.getInstance();
    mAuth = FirebaseAuth.getInstance();

    mRecyclerView =  getView().findViewById(R.id.recyclerView);
    refreshLayout=getView().findViewById(R.id.refreshLayout);

    usersList = new ArrayList<>();
    usersAdapter = new ViewFriendAdapter(usersList, view.getContext());

    ItemTouchHelper.SimpleCallback itemTouchHelperCallback = new RecyclerViewTouchHelper(0, ItemTouchHelper.LEFT, new RecyclerViewTouchHelper.RecyclerItemTouchHelperListener() {
        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction, int position) {
            if (viewHolder instanceof ViewFriendAdapter.ViewHolder) {

                usersAdapter.removeItem(viewHolder.getAdapterPosition());

            }
        }
    });

    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(new LinearLayoutManager(view.getContext()));
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.addItemDecoration(new DividerItemDecoration(view.getContext(), DividerItemDecoration.VERTICAL));
    new ItemTouchHelper(itemTouchHelperCallback).attachToRecyclerView(mRecyclerView);
    mRecyclerView.setAdapter(usersAdapter);

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

    startListening();

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

    context = getView().getContext();
    mCurrentUser = FirebaseAuth.getInstance().getCurrentUser();
    adapter = new QuestionAdapter(allQuestionsModelList);

    if (mCurrentUser != null) {

        mFirestore = FirebaseFirestore.getInstance();

        if(getArguments()!=null){
            userId=getArguments().getString("user_id");
        }else{
            userId=mCurrentUser.getUid();
        }

        et0=getView().findViewById(R.id.all);
        et1=getView().findViewById(R.id.accountancy);
        et2=getView().findViewById(R.id.astronomy);
        et3=getView().findViewById(R.id.biology);
        et4=getView().findViewById(R.id.business_maths);
        et5=getView().findViewById(R.id.computer_science);
        et6=getView().findViewById(R.id.commerce);
        et7=getView().findViewById(R.id.chemistry);
        et8=getView().findViewById(R.id.economics);
        et9=getView().findViewById(R.id.geography);
        et10=getView().findViewById(R.id.history);
        et11=getView().findViewById(R.id.physics);
        et12=getView().findViewById(R.id.p_science);
        et13=getView().findViewById(R.id.maths);

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

        recyclerView = getView().findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(context));
        recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
        recyclerView.setItemAnimator(new DefaultItemAnimator());

        allQuestionsModelList.clear();
        recyclerView.setAdapter(adapter);

        refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                allQuestionsModelList.clear();
                adapter.notifyDataSetChanged();
                getQuestions();
            }
        });

        setUpOnClick();
        getQuestions();

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

    context = getView().getContext();
    mCurrentUser = FirebaseAuth.getInstance().getCurrentUser();
    adapter = new QuestionAdapter(allQuestionsModelList);

    if (mCurrentUser != null) {

        mFirestore = FirebaseFirestore.getInstance();

        if(getArguments()!=null){
            userId=getArguments().getString("user_id");
        }else{
            userId=mCurrentUser.getUid();
        }

        refreshLayout=getView().findViewById(R.id.refreshLayout);
        et0=getView().findViewById(R.id.all);
        et1=getView().findViewById(R.id.accountancy);
        et2=getView().findViewById(R.id.astronomy);
        et3=getView().findViewById(R.id.biology);
        et4=getView().findViewById(R.id.business_maths);
        et5=getView().findViewById(R.id.computer_science);
        et6=getView().findViewById(R.id.commerce);
        et7=getView().findViewById(R.id.chemistry);
        et8=getView().findViewById(R.id.economics);
        et9=getView().findViewById(R.id.geography);
        et10=getView().findViewById(R.id.history);
        et11=getView().findViewById(R.id.physics);
        et12=getView().findViewById(R.id.p_science);
        et13=getView().findViewById(R.id.maths);

        recyclerView = getView().findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(context));
        recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
        recyclerView.setItemAnimator(new DefaultItemAnimator());

        allQuestionsModelList.clear();
        recyclerView.setAdapter(adapter);

        refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                allQuestionsModelList.clear();
                adapter.notifyDataSetChanged();
                getQuestions();
            }
        });

        setUpOnClick();
        getQuestions();

    }
}
 
Example 19
Source File: EventEditActivity.java    From NaviBee with GNU General Public License v3.0 4 votes vote down vote up
public void uploadAll() {

        String name = nameView.getText().toString();

        String holder = FirebaseAuth.getInstance().getCurrentUser().getUid();

        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, dateMap.get("year"));
        calendar.set(Calendar.MONTH, dateMap.get("month"));
        calendar.set(Calendar.DAY_OF_MONTH, dateMap.get("day"));
        calendar.set(Calendar.HOUR_OF_DAY, dateMap.get("hour"));
        calendar.set(Calendar.MINUTE, dateMap.get("minute"));
        Date eventDate = calendar.getTime();

        Map<String, Boolean> users = new HashMap<>();
        users.put(holder, true);

        EventsActivity.EventItem newEvent = new EventsActivity.EventItem(name, holder,
                eventDate, users, picsStoragePath, getPlaceDisplayName(eventLocation),
                eventLocation.getLatLng().longitude, eventLocation.getLatLng().latitude, privateSwitch.isChecked());

        FirebaseFirestore db = FirebaseFirestore.getInstance();
        db.collection("events").add(newEvent).addOnCompleteListener( task -> {
                    if (task.isSuccessful()) {
                        String eid = task.getResult().getId();
                        if(selectedUsers != null && !selectedUsers.isEmpty()){

                            Map<String, String> data = new HashMap<>();
                            data.put("eid", eid);
                            data.put("name", name);

                            Gson gson = new Gson();
                            String payload = gson.toJson(data);

                            for(String user: selectedUsers.keySet()) {
                                ConversationManager.getInstance()
                                    .getPrivateConversation(user).sendMessage("event", payload);
                            }
                        }
                        finish();

                    } else {
                        badInternetConnection();
                    }
                });

    }
 
Example 20
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();
    }

}