This file contains 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
protected String replaceImageResolution(String images) { | |
int sqIndex = images.indexOf("sq"); | |
String f; | |
if (sqIndex != -1){ | |
String prefix = images.substring(0,sqIndex + 3); | |
String suffix = images.substring(sqIndex + 3); | |
char c; | |
int startTrim = 0; | |
for(int i=0; i< suffix.length();i++){ | |
c = suffix.charAt(i); |
This file contains 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
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://someurl.com")); | |
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
//Give chrome browser a priority , if exist, otherwise, returns other browser package | |
final String browserPackage = ActivityUtils.getBrowserPackage(intent, this); | |
if (!browserPackage.isEmpty()) { | |
intent.setPackage(browserPackage); | |
} | |
try { | |
startActivity(intent); | |
} catch (ActivityNotFoundException ex) { |
This file contains 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
{ | |
"IAB1": "Arts & Entertainment", | |
"IAB1-1": "Books & Literature", | |
"IAB1-2": "Celebrity Fan/Gossip", | |
"IAB1-3": "Fine Art", | |
"IAB1-4": "Humor", | |
"IAB1-5": "Movies", | |
"IAB1-6": "Music", | |
"IAB1-7": "Television", | |
"IAB2": "Automotive", |
This file contains 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
private void initWebView() { | |
mWebView.setWebViewClient(new WebViewClientImpl()); | |
mWebView.setWebChromeClient(new WebChromeClient()); | |
mWebView.getSettings().setUseWideViewPort(true); | |
mWebView.getSettings().setLoadWithOverviewMode(true); | |
mWebView.getSettings().setSupportZoom(true); | |
mWebView.getSettings().setBuiltInZoomControls(true); | |
mWebView.loadUrl(mUrl); | |
} |
This file contains 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
IAB25("Non-Standard Content",CategoryTier.T1), | |
IAB25_3("Pornography", CategoryTier.T2), | |
IAB25_2("Extreme Graphic and Explicit Violence",CategoryTier.T2), | |
IAB25_1("Unmoderated UGC",CategoryTier.T2), | |
IAB25_7("Incentivized",CategoryTier.T2), | |
IAB25_6("Under Construction",CategoryTier.T2), | |
IAB25_5("Hate Content",CategoryTier.T2), | |
IAB25_4("Profane Content",CategoryTier.T2), | |
IAB13("Personal Finance",CategoryTier.T1), | |
IAB13_9("Options",CategoryTier.T2), |
This file contains 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 String getBrowserPackage(Intent intent, Context context){ | |
PackageManager pm = context.getPackageManager(); | |
List<ResolveInfo> appsList = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); | |
String tmpPkg = "", pkg=""; | |
for (ResolveInfo app : appsList){ | |
tmpPkg = app.activityInfo.packageName.toLowerCase(); | |
if ("com.android.chrome".equals(tmpPkg)){ | |
return tmpPkg; | |
} | |
if (tmpPkg.contains("browse") || tmpPkg.contains("chrome") || tmpPkg.contains("com.UCMobile.intl") || tmpPkg.contains("org.mozilla.firefox") || tmpPkg.contains("com.opera.mini.native")){ |
This file contains 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
private void animateClosing() { | |
AnimatorSet animator = new AnimatorSet(); | |
ObjectAnimator translation = ObjectAnimator.ofFloat(mSideTabs, "translationX", 0, sideTabsWidth); | |
ObjectAnimator fadeOut = ObjectAnimator.ofFloat(mSideTabs, "alpha", 1f, 0f); | |
animator.playTogether(translation, fadeOut); | |
animator.setDuration(300); | |
animator.addListener(new Animator.AnimatorListener() { | |
@Override | |
public void onAnimationStart(Animator animation) { | |
isAnimated = true; |
This file contains 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
/** | |
* Get ISO 3166-1 alpha-2 country code for this device (or null if not available) | |
* @param context Context reference to get the TelephonyManager instance from | |
* @return country code or null | |
*/ | |
public String getUserCountry(Context context) { | |
try { | |
final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); | |
final String simCountry = tm.getSimCountryIso(); | |
if (simCountry != null && simCountry.length() == 2) { // SIM country code is available |
This file contains 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
//callback for user id: | |
//Either takes the user's advertiserId or creates a unique ID, if | |
AsyncTask<Void, Void, String> task = new AsyncTask<Void, Void, String>() { | |
@Override | |
protected String doInBackground(Void... params) { | |
try { | |
AdvertisingIdClient.Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(YourApplicationClass.this); | |
if (!adInfo.isLimitAdTrackingEnabled()) {//if user hasn't opt-out | |
return adInfo.getId(); | |
}else{ |
This file contains 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 String getVideoUrl(View view, String clickUrl) { | |
int height = 300, width = 600; | |
String appName =""; | |
String gpUrl=""; | |
try { | |
appName = URLEncoder.encode(view.getContext().getString(R.string.app_name), "UTF-8"); | |
gpUrl = URLEncoder.encode( "http://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID, "UTF-8"); | |
} catch (UnsupportedEncodingException e) { | |
e.printStackTrace(); |
OlderNewer