Skip to content

Instantly share code, notes, and snippets.

@Michenux
Last active January 2, 2016 10:19
Show Gist options
  • Save Michenux/8288768 to your computer and use it in GitHub Desktop.
Save Michenux/8288768 to your computer and use it in GitHub Desktop.
package org.michenux.drodrolib.accounts;
import android.text.TextUtils;
public class AccountUtils {
public static String buildAccountType(String flavor, String accountName, boolean debug) {
StringBuilder authority = new StringBuilder();
if ( !TextUtils.isEmpty(flavor)) {
authority.append(flavor);
authority.append('.');
}
authority.append(accountName);
if (debug) {
authority.append(".debug");
}
return authority.toString();
}
}
package org.michenux.drodrolib.content;
import android.text.TextUtils;
public class ContentProviderUtils {
public static String buildAuthority( String packageName, String flavor, String name) {
StringBuilder authority = new StringBuilder(packageName);
if ( !TextUtils.isEmpty(flavor)) {
authority.append('.');
authority.append(flavor);
}
authority.append('.');
authority.append(name);
return authority.toString();
}
}
private static final String AUTHORITY = ContentProviderUtils.buildAuthority(
BuildConfig.PACKAGE_NAME, BuildConfig.FLAVOR, "friends");
public static final String ACCOUNT_TYPE = AccountUtils.buildAccountType(
BuildConfig.FLAVOR, "michenux.net", BuildConfig.DEBUG);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment