Skip to content

Instantly share code, notes, and snippets.

@senamit2708
senamit2708 / gist:16906bc058adf7f65df3bb5ddda4bb1d
Created October 19, 2018 05:02
How to get sha1 value in windows
// if the sha1 value will not match with firebase, it will not get the firebase project for u ..so if u r downloading your own project
// from github and its not working from firebase side..just check that sha1 value and package name is same or not.
open android studio
on right side there is gradle, click on that
then your project name(root)
then android
then signing report
in the run tab u will see the complete details of the project.
@senamit2708
senamit2708 / FilterCategory.java
Created October 21, 2018 07:00
Inteface for sending data from adapter to the class..here i am sending data from recyclerview adapter to its fragment.
package com.example.senamit.stationaryhutpro.fragments;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.senamit.stationaryhutpro.R;
https://android.jlelse.eu/tablayout-and-viewpager-in-your-android-app-738b8840c38a
https://developer.android.com/reference/com/google/android/material/tabs/TabLayout
https://material.io/develop/android/components/tab-layout/
@senamit2708
senamit2708 / gist:dd061799a135480eeb5e6366cc1e99ec
Created April 4, 2019 19:48
how to set vector image in adapter of recycelrview from drawable
holder.imgBox.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_box_green_two));
@senamit2708
senamit2708 / gist:45ac50675a6fb0d9676a76fffb929eb5
Created April 11, 2019 21:45
scrollview with constraint layout
https://stackoverflow.com/questions/37349845/is-it-possible-to-put-a-constraintlayout-inside-a-scrollview
@senamit2708
senamit2708 / gist:19b0f4bf116df0d992fe4a58dc74e803
Created May 16, 2019 05:49
How to check a specific key is present in the documents of the collection
private void loadRecentWords() {
db.collection("TwordColl")
.orderBy("time", Query.Direction.DESCENDING)
.limit(10)
.addSnapshotListener(new EventListener<QuerySnapshot>() {
@Override
public void onEvent(@Nullable QuerySnapshot value,
@Nullable FirebaseFirestoreException e) {
if (e!= null){
Log.w(TAG, "listen failed "+e);
@senamit2708
senamit2708 / gist:e5831e82f7a3526306d2aa5cdc28d07e
Last active May 17, 2019 19:48
how to reverse array list
.addSnapshotListener(new EventListener<QuerySnapshot>() {
@Override
public void onEvent(@Nullable QuerySnapshot value,
@Nullable FirebaseFirestoreException e) {
if (e!= null){
Log.w(TAG, "listen failed "+e);
return;
}
List<MessageModel> messageList = new ArrayList<>();
for (DocumentSnapshot doc : value){
@senamit2708
senamit2708 / gist:1e2381f2df5117e31bc488c0eb56fbb6
Created June 8, 2019 02:16
Horizontal Recyclerview to scroll behavior like viewpager...one page and after sliding its showing next page
private void bindView(View view) {
recyclerView = view.findViewById(R.id.recyclerview);
mLayoutManager = new LinearLayoutManager(context);
((LinearLayoutManager) mLayoutManager).setOrientation(LinearLayoutManager.HORIZONTAL);
mAdapter = new QuizQuestionAdap(context, this);
SnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(recyclerView);
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setAdapter(mAdapter);
@senamit2708
senamit2708 / QuizQuestionFrag.java
Created June 8, 2019 15:29
How to add menu in fragment having differnet text color
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_quiz, menu);
int positionOfMenuItem = 0;
MenuItem item = menu.getItem(positionOfMenuItem);
SpannableString s = new SpannableString("Submit");
s.setSpan(new ForegroundColorSpan(Color.BLACK), 0, s.length(), 0);
item.setTitle(s);
@senamit2708
senamit2708 / SplashActivity.java
Last active June 9, 2019 10:51
Cool loading of android app
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
Intent intent = new Intent(SplashActivity.this, SchoolDiaryMainActivity.class);
startActivity(intent);
finish();