本文整理汇总了Java中com.example.app.BuildConfig类的典型用法代码示例。如果您正苦于以下问题:Java BuildConfig类的具体用法?Java BuildConfig怎么用?Java BuildConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BuildConfig类属于com.example.app包,在下文中一共展示了BuildConfig类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: provideRetrofit
import com.example.app.BuildConfig; //导入依赖的package包/类
@Provides
@Singleton
Retrofit provideRetrofit(
OkHttpClient client,
@Named("apiUrl")
String endPoint,
Gson gson,
ThreadExecutor threadExecutor
) {
return new Retrofit.Builder()
.baseUrl(endPoint)
.addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJavaCallAdapterFactory.createWithScheduler(Schedulers.from(threadExecutor)))
.client(client)
.validateEagerly(BuildConfig.DEBUG)
.build();
}
示例2: onCreate
import com.example.app.BuildConfig; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// launch the app login activity when a guest user tries to favorite a Tweet
final Callback<Tweet> actionCallback = new Callback<Tweet>() {
@Override
public void success(Result<Tweet> result) {
// Intentionally blank
}
@Override
public void failure(TwitterException exception) {
if (exception instanceof TwitterAuthException) {
startActivity(TwitterCoreMainActivity.newIntent(getActivity()));
}
}
};
final UserTimeline userTimeline = new UserTimeline.Builder().screenName("twitterdev").build();
final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter.Builder(getActivity())
.setTimeline(userTimeline)
.setViewStyle(R.style.tw__TweetLightWithActionsStyle)
.setOnActionCallback(actionCallback)
.build();
moPubAdAdapter = new TwitterMoPubAdAdapter(getActivity(), adapter);
final TwitterStaticNativeAdRenderer adRenderer = new TwitterStaticNativeAdRenderer();
moPubAdAdapter.registerAdRenderer(adRenderer);
moPubAdAdapter.loadAds(BuildConfig.MOPUB_AD_UNIT_ID);
setListAdapter(moPubAdAdapter);
}
示例3: provideUserAgentHeader
import com.example.app.BuildConfig; //导入依赖的package包/类
@Provides
@Singleton
@Named("userAgent")
String provideUserAgentHeader() {
return String.format(
Locale.getDefault(),
"Android;%s;%s;%d;%s;%s;%d;",
Build.BRAND,
Build.MODEL,
Build.VERSION.SDK_INT,
BuildConfig.APPLICATION_ID,
BuildConfig.VERSION_NAME,
BuildConfig.VERSION_CODE
);
}
示例4: provideApiLogLevel
import com.example.app.BuildConfig; //导入依赖的package包/类
@Provides
@Singleton
HttpLoggingInterceptor provideApiLogLevel() {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
if (BuildConfig.DEBUG) {
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
} else {
interceptor.setLevel(HttpLoggingInterceptor.Level.NONE);
}
return interceptor;
}
示例5: create
import com.example.app.BuildConfig; //导入依赖的package包/类
/**
* Creates a String representing an error message.
*
* @param context Context needed to retrieve string resources.
* @param exception An exception used as a condition to retrieve the correct error message.
* @return {@link String} an error message.
*/
public static String create(Context context, Exception exception) {
if (BuildConfig.DEBUG) {
return exception.getMessage();
} else if (exception instanceof NetworkConnectionException) {
return context.getString(R.string.exception_message_no_connection);
} else if (exception instanceof ServerIssueException) {
return context.getString(R.string.exception_message_server_issue);
}
return context.getString(R.string.exception_message_generic);
}
示例6: provideApiUrl
import com.example.app.BuildConfig; //导入依赖的package包/类
@Provides
@Singleton
@Named("apiUrl")
String provideApiUrl() {
return BuildConfig.API_URL;
}