我正在尝试使用API进行改型和杰克逊反序列化。标题“没有创建者,就像默认构造一样,存在”中出现的错误:无法从对象值反序列化(没有基于委托人或基于属性的创建者)出现在onFailure中。
这是我要获取的JSON:
{
"data": {
"repsol_id": "1129",
"name": "ES-MASSAMÁ",
"latitude": "38.763733333",
"longitude": "-9.258619444000001",
"address": "RUA GENERAL HUMBERTO DELGADO, LT.16",
"post_code": "2745-280",
"location": "QUELUZ",
"service_store": 1,
"service_mechanical_workshop": 0,
"service_restaurant": 0,
"service_wash": 1
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的HomeFragment:
onCreate(){
viewModel.retrieveStation().observe(this, Observer {
dataBinding.favouriteStationTxt.text = it.name
})
}
Run Code Online (Sandbox Code Playgroud)
这是我的viewModel:
class HomeViewModel @Inject constructor(
private val stationRepository: StationRepository
) : ViewModel() {
private val station = MutableLiveData<Station>()
fun retrieveStation():LiveData<Station> = station
fun loadStations(stationId:Int){
stationRepository.getStationFromId(stationId,{ station.postValue(it)},{})
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的存储库:
class StationRepository @Inject constructor(var apiManager: ApiManager) {
fun …Run Code Online (Sandbox Code Playgroud) 我有一个问题,紧接着onItemAtEndLoaded调用该方法后 onZeroItemsLoaded,行为应该只在我完成滚动时.你知道发生了什么吗?我可以提供我的GitHub回购.
我有这个服务,我想将令牌作为 okhttp 中的拦截而不是作为参数传递给 @Header("MY_API_KEY")
这是我关于服务的代码
/**
* Provides the [PHService]
*/
fun provideService(): PHService {
val logger = HttpLoggingInterceptor()
logger.level = HttpLoggingInterceptor.Level.BASIC
val client = OkHttpClient.Builder()
.addInterceptor(logger)
.build()
return Retrofit.Builder()
.baseUrl(BuildConfig.API_URL)
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(PHService::class.java)
}
Run Code Online (Sandbox Code Playgroud)
如何在此处添加用于标题授权的拦截器?
我有一个问题,我需要使用表中的外键执行查询。问题是,在上面的@Query(在上面的 ExpenseRepository 中制作)中,我的日志说他不是按用户 ID(外键)搜索,而是搜索费用实体类的主键。
这是我的用户实体类:
@Entity
public class User implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String email;
@NotBlank(message = "Password required")
@Size(min = 6)
private String password;
//getters and setters
Run Code Online (Sandbox Code Playgroud)
这是我的费用实体类:
@Entity
public class Expenses implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private long limitValue;
private long spentValue;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "id")
private User user;
//getters and setters here
Run Code Online (Sandbox Code Playgroud)
最后,这是我自己进行查询的存储库
public interface ExpensesRepository extends JpaRepository< Expenses, Long> …Run Code Online (Sandbox Code Playgroud) 我有一个 API,当我更改名为 Meeting 的表中的某些内容时,我想向智能手机发送通知。为此,我正在创建一个 POST 类型的方法,在其中我将以下JSON正文以及授权密钥(由 firebase 提供)发送到以下 URL https://fcm.googleapis.com/fcm/send。
@Headers -> *******
{
"to": "/topics/groupNameChoosenByYou",
"data": {
"title": "Your title",
"message": "Your message"
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的 AndroidPushNotificationsService
@Service
public class AndroidPushNotificationsService {
private static final String FIREBASE_SERVER_KEY = "AAAAq88vWWE:APA91bF5rSyqGbx26AY5jm6NsEfwJynQsnTd1MPFOTOz1ekTGZyof3Vz6gBb0769MLLxD7EXMcqKiPIHnqLh5buHEeUASnpsn-ltxR1J8z3kWJIAPNWlPZB0r0zKkXMyWkrbT3BLPWmCdi-NZnP3Jkb2z-QqtwJt5Q";
private static final String FIREBASE_API_URL = "https://fcm.googleapis.com/fcm/send";
@Async
public CompletableFuture<String> send(HttpEntity<String> entity) {
RestTemplate restTemplate = new RestTemplate();
ArrayList<ClientHttpRequestInterceptor> interceptors = new ArrayList<>();
interceptors.add(new HeaderRequestInterceptor("Authorization", "key=" + FIREBASE_SERVER_KEY));
interceptors.add(new HeaderRequestInterceptor("Content-Type", "application/json"));
restTemplate.setInterceptors(interceptors);
String firebaseResponse = restTemplate.postForObject(FIREBASE_API_URL, entity, …Run Code Online (Sandbox Code Playgroud) 我在将小部件树包装在SingleChildScrollView. 我认为 ListView.Builder 与此有关,但这里最好的方法是什么?我想要一个vertical scroll用于小部件树和水平滚动的ListView.Builder. 如果我取下 SingleChildScrollView 它工作正常。
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 16),
child: Text(
'Some test',
style: muli_bold_18_black,
),
),
Padding(
padding: const EdgeInsets.only(top: 30, right: 30),
child: Container(
width: 96,
height: 96,
decoration: new BoxDecoration(
shape: BoxShape.circle,
image: new DecorationImage(
fit: BoxFit.fill,
image: new NetworkImage(
"https://placeimg.com/640/480/any")))),
)
],
),
Container( …Run Code Online (Sandbox Code Playgroud) 我有一个LinkedHashMap,我有两个重复的键及其对应的值,我需要知道如何将这些值汇总为一个键.目前,他消除了旧的重复值并放入了新的重复值
这是我的地图
static Map<String, Double> costByDuration = new LinkedHashMap<>();
Run Code Online (Sandbox Code Playgroud)
这是我放置值的地方(call_from可以是912345678并且值为10,然后是来自912345678的另一个调用并且值为20),然后我希望912345678具有值30而不是仅保留一个.
costByDuration.put(call_from, toPay);
Run Code Online (Sandbox Code Playgroud) 我是Angular的新手,我想知道在单击同一按钮并执行相应操作后如何禁用该按钮
这是我的按钮html代码
<button type="button" class="btn btn-primary" (click)="actionMethod()">Give Kitchen access</button> <br> <br>
Run Code Online (Sandbox Code Playgroud) 我有两次,我希望在几分钟内得到改变.
例如:
我有这个:
09:11:30;09:15:22;
Run Code Online (Sandbox Code Playgroud)
我想实现这个目标:
3 min passed
Run Code Online (Sandbox Code Playgroud)
请注意,9:15:22不是9:15:30所以4分钟已经过去了.
我目前正在创建一个自定义对话框来显示从 00:00 到 23:59 的时间,我使用 kotlin 作为开发语言。我的问题是,当我打开对话框时,回收站视图出现错误。这是我的代码
日历对话框类
class CalendarDialog : DialogFragment() {
/**
* Define variables
*/
private val mDaysList : MutableList<Days> = ArrayList()
private val dayMonthYear = "2018-06-14" //TODO fetch the date of today
/**
* Initialize the adapter
*/
private val adapter = CalendarAdapter(mDaysList)
/**
* Initialize the layout manager
*/
private fun getLinearLayoutManager(): LinearLayoutManager {
return LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false)
}
private fun initView() {
setDataListItems()
recyclerViewCalendar?.adapter = adapter
recyclerViewCalendar?.layoutManager = getLinearLayoutManager()
recyclerViewCalendar?.setHasFixedSize(true)
}
override fun onCreateView(inflater: …Run Code Online (Sandbox Code Playgroud) android android-lifecycle android-fragments kotlin android-recyclerview
我的底部布局有问题,我的约束布局没有完全填满滚动视图(下面是空白)。这是问题的图像证据。在这种情况下,我希望灰色背景填充下面的白色空间。我在所有方面都尝试过比赛父母,但它不起作用。
这是我的xml文件,属于我上传的布局
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout">
<data>
<variable
name="viewModel"
type="com.repsol.repsolmove.ui.login.LoginViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView
android:id="@+id/scrolView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="174dp"
android:layout_height="70dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="3dp"
android:src="@drawable/ic_img_logo_repsolmove"
app:layout_constraintBottom_toTopOf="@+id/imageBottomMargin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.repsol.repsolmove.ui.widgets.RepsolInputLayout
android:id="@+id/login"
android:layout_width="0dp"
android:layout_height="105dp"
android:layout_marginTop="30dp"
app:errorText="@string/invalid_card_number"
app:layout_constraintEnd_toStartOf="@+id/marginEnd"
app:layout_constraintStart_toStartOf="@+id/marginStart"
app:layout_constraintTop_toBottomOf="@+id/imageView"
app:titleText="@string/login_title" />
<com.repsol.repsolmove.ui.widgets.RepsolInputLayout
android:id="@+id/password"
android:layout_width="0dp"
android:layout_height="105dp"
app:errorText="@string/invalid_password"
app:isPassword="true"
app:layout_constraintEnd_toStartOf="@+id/marginEnd"
app:layout_constraintStart_toStartOf="@+id/marginStart"
app:layout_constraintTop_toBottomOf="@+id/login"
app:titleText="@string/password_title" />
<TextView
android:id="@+id/newPassword"
style="@style/RepsolText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
android:fontFamily="@font/repsol_regular"
android:text="@string/new_password"
android:textSize="16dp"
app:layout_constraintEnd_toStartOf="@+id/marginEnd"
app:layout_constraintTop_toBottomOf="@+id/password" />
<Button
android:id="@+id/btnLogin"
android:layout_width="228dp"
android:layout_height="50dp"
android:layout_marginStart="8dp" …Run Code Online (Sandbox Code Playgroud) android ×3
java ×3
kotlin ×3
retrofit2 ×2
spring ×2
angular ×1
duration ×1
firebase ×1
flutter ×1
hashmap ×1
html ×1
interceptor ×1
jackson ×1
javascript ×1
jpa ×1
linked-list ×1
localtime ×1
minute ×1
mysql ×1
okhttp ×1
okhttp3 ×1
spring-boot ×1
spring-data ×1
time ×1