-
-
Save arthtilva/ddd2e18b33a92fba16f2ff6cd2f08bfb to your computer and use it in GitHub Desktop.
Frequently Used Methods and codes
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
/***************************************************************************************/ | |
/****************************** Full Screen Theme **************************************/ | |
/***************************************************************************************/ | |
<style name="AppThemeFullScreen" parent="Theme.AppCompat.Light.NoActionBar"> | |
<item name="windowActionBar">false</item> | |
<item name="windowNoTitle">true</item> | |
<item name="android:windowFullscreen">true</item> | |
<item name="android:windowContentOverlay">@null</item> | |
</style> | |
/***************************************************************************************/ | |
/*********************************** White Color Status Bar ****************************/ | |
/***************************************************************************************/ | |
Add in main theme v-23 | |
<item name="android:windowDrawsSystemBarBackgrounds">true</item> | |
<item name="android:statusBarColor">@android:color/transparent</item> | |
<item name="android:windowLightStatusBar">true</item> | |
/***************************************************************************************/ | |
/********************* Fragment Transactions / Change Fragment *************************/ | |
/***************************************************************************************/ | |
fun changeFragment(fragment: Fragment, title: String?, args: Bundle?, add: Boolean) { | |
val ft: FragmentTransaction | |
ft = if (add) { | |
supportFragmentManager.beginTransaction().addToBackStack(title) | |
} else supportFragmentManager.beginTransaction() | |
if (args != null) fragment.setArguments(args) | |
ft.replace(R.id.content, fragment).commit() | |
tvTitle.text = title | |
} | |
/******************************************************************************/ | |
/******************Change Navigation drawer icon color*************************/ | |
/******************************************************************************/ | |
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle"> | |
<item name="color">@android:color/white</item> | |
</style> | |
//Add it in main theme | |
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item> | |
/******************************************************************************/ | |
/******************************Logout Dialog***********************************/ | |
/******************************************************************************/ | |
new AlertDialog.Builder(activity).setTitle("Confirm").setMessage("Are you sure you want to logout?") | |
.setPositiveButton("Yes", new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
// TODO Auto-generated method stub | |
storeUserData.clearData(activity); | |
startActivity(new Intent(activity, LoginActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK)); | |
} | |
}) | |
.setNegativeButton("No", new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
// TODO Auto-generated method stub | |
} | |
}).show(); | |
/******************************************************************************/ | |
/******************************printHashKey for facebook***********************/ | |
/******************************************************************************/ | |
public void printHashKey(Context pContext) { | |
try { | |
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES); | |
for (Signature signature : info.signatures) { | |
MessageDigest md = MessageDigest.getInstance("SHA"); | |
md.update(signature.toByteArray()); | |
String hashKey = new String(Base64.encode(md.digest(), 0)); | |
Log.i("aaa", "printHashKey() Hash Key: " + hashKey); | |
} | |
} catch (NoSuchAlgorithmException e) { | |
Log.e("", "printHashKey()", e); | |
} catch (Exception e) { | |
Log.e("", "printHashKey()", e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment