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 boolean isConnectedToInternet(Context context) { | |
| if (isConnectingToInternet(context)) { | |
| return isNetworkAvailable(); | |
| } | |
| return false; | |
| } | |
| public static boolean isConnectingToInternet(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
| public void collapse(final View v) { | |
| final int initialHeight = v.getMeasuredHeight(); | |
| Animation a = new Animation() { | |
| @Override | |
| protected void applyTransformation(float interpolatedTime, | |
| Transformation t) { | |
| if (interpolatedTime == 1) { | |
| v.setVisibility(View.GONE); | |
| } else { |
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
| @Override | |
| public boolean onPrepareOptionsMenu(Menu menu) { | |
| // getMenuInflater().inflate(R.menu.text_menu, menu); | |
| getMenuInflater().inflate(R.menu.actionview_menu, menu); | |
| // menu.getItem(0).setVisible(false); | |
| this.menu = menu; | |
| MenuItem shareItem = menu.findItem(R.id.action_share); | |
| ShareActionProvider actionProvider = (ShareActionProvider) MenuItemCompat |
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 int getActionBarHeight() { | |
| int actionBarHeight = 0; | |
| TypedValue tv = new TypedValue(); | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { | |
| if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, | |
| true)) | |
| actionBarHeight = TypedValue.complexToDimensionPixelSize( | |
| tv.data, getResources().getDisplayMetrics()); | |
| } else { | |
| actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, |
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 float convertPixelsToDp(float px){ | |
| DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics(); | |
| float dp = px / (metrics.densityDpi / 160f); | |
| return Math.round(dp); | |
| } | |
| public static float convertDpToPixel(float dp){ | |
| DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics(); | |
| float px = dp * (metrics.densityDpi / 160f); | |
| return Math.round(px); |
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 int getStatusBarHeight(){ | |
| int result=0;\ | |
| int resourceId= getResources().getIdentifier("status_bar_height","dimen","android"); | |
| if(resourceId >0) | |
| result = getResources().getDimensionPixelSize(resourceId); | |
| return result; | |
| } |
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
| WindowManager windowManager =(WindowManager)getSystemService(Context.WindowService); | |
| DisplayMetrics displayMetrics = new DisplayMetrics(); | |
| windowManager.getDefaultDisplay().getMetrics(displayMetrics); | |
| int screenWidth = displayMetrics.widthPixels; | |
| int screenHeight = displayMetrics.heightPixels; |
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
| Intent intent = new Intent(Intent.ACTION_SEND); | |
| intent.setData(Uri.parse("mailto:")); | |
| intent.setType("message/rfc822"); | |
| intent.putExtra(Intent.EXTRA_EMAIL, new String[] { email }); | |
| intent.putExtra(Intent.EXTRA_SUBJECT, Constants.SHARE_MSG); | |
| intent.putExtra(Intent.EXTRA_TEXT, Constants.INVITE_MSG); | |
| intent.putExtra(Constants.EXIT_ON_SENT, true); | |
| startActivity(Intent.createChooser(intent, | |
| getString(R.string.invite_via))); |
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
| float a = 221, b = 77, c = 17, d = 88, e = 22, f = 44; | |
| float total = a + b + c + d + e + f; | |
| int sum = (int) Math.round(100.0 / total * a) | |
| + (int) Math.round(100.0 / total * b) | |
| + (int) Math.round(100.0 / total * c) | |
| + (int) Math.round(100.0 / total * d) | |
| + (int) Math.round(100.0 / total * e) | |
| + (int) Math.round(100.0 / total * f); | |
| System.out.println(Math.round(100.0 / total * a)); | |
| System.out.println(Math.round(100.0 / total * b)); |
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
| import java.lang.ref.WeakReference; | |
| import java.lang.reflect.Field; | |
| import android.app.Activity; | |
| import android.content.Context; | |
| import android.content.Intent; | |
| import android.net.Uri; | |
| import android.util.AttributeSet; | |
| import android.webkit.WebView; | |
| import android.webkit.WebViewClient; |