从Android O(API 26)版本引入的通知渠道.我从以下链接中了解到它:
问题:
如果我有多个通知数,那么在应用程序启动时创建通知通道并将其保留在最佳状态是否是个好主意ApplicationScope?
public void addNotificationChannels(Context context) {
List<NotificationChannel> channels = new ArrayList<>();
channels.add("channel_1");
channels.add("channel_2");
.
.
channels.add("channel_7");
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannels(channels);
}
Run Code Online (Sandbox Code Playgroud)如果我new Notification.Builder(getApplicationContext(), PRIMARY_CHANNEL)在将通道添加到通知管理器之前尝试执行此行,会发生什么
android android-notifications android-8.0-oreo notification-channel
有一个类似的问题问在这里,但我的情况有点不同.
我正在尝试提出类似以下的请求:
http://www.example.com/abc?foo=def&foo=ghi&foo=jkl&bar=xyz
我有两个问题让事情变得困难.首先,重复参数("foo"多次设置值)阻止使用QueryMap(我没有选项以不同的方式传递查询字符串中的值,就像数组一样).其次,我正在使用的查询参数是动态的,所以我不能真正使用Query并为它提供给定参数名称的值列表,因为在我发出请求之前我不会知道参数名称.
我试图从升级的代码使用改造的旧版本,但不知何故,它有一个概念QueryList,其采取了List的NameValuePairS IN查询参数传递的名称(及其作为值值),并允许重复的参数.我没有retrofit.http.QueryList在Retrofit的源代码历史记录或网络上看到任何引用,所以我不确定这是否是当时的自定义添加.在任何情况下,我都试图找到在最新版本中复制该功能的最佳方式,所以任何帮助将不胜感激!
我正在玩StaggeredGridLayoutManager并且有一些接近我想要的东西.我有一个水平交错网格有2行,其中一些项目是1行的高度,其他项目跨越两行.我想要将单行高度项目叠加起来,我认为可以通过将差距策略设置为GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS来实现,但这似乎不起作用.
当前:
___ ___ ___ ___
|___| | | |___| | |
| | | |
|___| |___|
我想要的是:
___ ___ ___ |___| | | | | ___ | | | | |___| |___| |___|
相关代码片段:
为recyclerview设置布局管理器:
StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.HORIZONTAL);
layoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS);
recyclerView.setLayoutManager(layoutManager);
Run Code Online (Sandbox Code Playgroud)
这是我的自定义适配器的onBindViewHolder(这只是一个简化的例子).基本上我在CardView中有一个ImageView(CardView设置为wrap_content的高度和宽度).
if(position%3==0) {
ViewGroup.LayoutParams layoutParams = viewHolder.myImage.getLayoutParams();
layoutParams.width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200, context.getResources().getDisplayMetrics());
layoutParams.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 75, context.getResources().getDisplayMetrics());
viewHolder.myImage.setLayoutParams(layoutParams);
StaggeredGridLayoutManager.LayoutParams layoutParams1 = ((StaggeredGridLayoutManager.LayoutParams) viewHolder.itemView.getLayoutParams());
layoutParams1.setFullSpan(false);
}
else {
ViewGroup.LayoutParams layoutParams = viewHolder.myImage.getLayoutParams();
layoutParams.width = …Run Code Online (Sandbox Code Playgroud)