This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<FrameLayout | |
android:id="@+id/speaker_avatar_container" | |
android:layout_width="40dp" | |
android:layout_height="40dp" | |
android:layout_gravity="center_vertical"> | |
<TextView | |
android:id="@+id/placeholder" | |
android:layout_width="40dp" | |
android:layout_height="40dp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void firstTimeAskingPermission(Context context, String permission, boolean isFirstTime){ | |
SharedPreferences sharedPreference = context.getSharedPreferences(PREFS_FILE_NAME, MODE_PRIVATE; | |
sharedPreference.edit().putBoolean(permission, isFirstTime).apply(); | |
} | |
public static boolean isFirstTimeAskingPermission(Context context, String permission){ | |
return context.getSharedPreferences(PREFS_FILE_NAME, MODE_PRIVATE).getBoolean(permission, true); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This class is FragmentPagerAdapter where all the fragments are in an array and you can access to them later. | |
* @property mFragments the list of fragments, | |
* @property NUMBER_OF_FRAGMENTS the total number of fragments that will be created. Change the value of this param accordingly. | |
*/ | |
class MyFragmentPagerAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm) { | |
companion object { | |
private val NUMBER_OF_FRAGMENTS = 2 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sriyank.spannablestring | |
import android.graphics.Color | |
import android.graphics.Typeface | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import android.text.Spannable | |
import android.text.SpannableString | |
import android.text.SpannableStringBuilder | |
import android.text.TextPaint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LoginManager.getInstance().logOut(); | |
LoginManager.getInstance().logInWithReadPermissions(WelcomeActivity.this, Arrays.asList("public_profile", "email")); | |
public void loginToFacebook() { | |
callbackManager = CallbackManager.Factory.create(); | |
LoginManager.getInstance().registerCallback(callbackManager, | |
new FacebookCallback<LoginResult>() { | |
@Override | |
public void onSuccess(LoginResult loginResult) { | |
GraphRequest request = GraphRequest.newMeRequest( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Networking is one of the most important parts of Android applications. At the early stage, we wrote our own HTTP classes to handle networking. As time passed development got easier making us dependent on libraries. We use many libraries to get the work done faster but most of us do not analyse its limitations and drawbacks. Before using any library we need to analyse three things What, Why and How. One popular library which we use for Networking is Retrofit. In this post, let’s analyse these things and understand how the request gets processed inside Retrofit. | |
What? | |
Retrofit is a type-safe HTTP client for Android and Java. | |
Why? | |
Using Retrofit made networking easier in Android apps. As it has many features like, | |
Easy to connect to web-services by translating the API into Java or Kotlin. | |
Easy to add Headers and request types. | |
Easily Customisable, you can customise it and add say any convertors like Gson, JackSon, Moshi, Prtobuf, XML etc. You can also customise it to add different interceptors and cache. | |
It prov |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sriyank.mdccomponents | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import android.view.View | |
import android.widget.Toast | |
import kotlinx.android.synthetic.main.activity_main.* | |
class MainActivity : AppCompatActivity() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sriyank.mdccomponents | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import android.view.View | |
import android.widget.Toast | |
import kotlinx.android.synthetic.main.activity_main.* | |
class MainActivity : AppCompatActivity() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class VolleyErrorHelper { | |
/** | |
* Returns appropriate message which is to be displayed to the user | |
* against the specified error object. | |
* | |
* @param error | |
* @param context | |
* @return | |
*/ | |
public static String getMessage(Object error, Context context) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sriyank.mdccomponents | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import android.widget.Toast | |
import androidx.core.widget.NestedScrollView | |
import kotlinx.android.synthetic.main.activity_main.* | |
class MainActivity : AppCompatActivity() { |