我正在使用PageKeyedDataSource通过调用 API 和使用 Retrofit 进行分页。
我正在使用Dagger 2进行依赖注入。
@Provides
Repository provideRepository(...) {
...
}
@Provides
PageKeyedVideosDataSource providePageKeyeVideosDataSource(Repository repository) {
...
}
@Provides
VideoDataSourceFactory provideVideoDataSourceFactory(PageKeyedHomeVideosDataSource pageKeyedHomeVideosDataSource) {
...
}
@Provides
ViewModelFactory provideViewModelFactory(Repository repository, VideoDataSourceFactory videoDataSourceFactory) {
...
}
Run Code Online (Sandbox Code Playgroud)
现在,我需要做同样的事情,但是我的调用需要一个新参数:一个 id。
@GET(Urls.VIDEOS_BY_CATEGORY)
Observable<RequestVideo> getVideosByCategory(
@Path("id") int categoryId, // <-- Now I need this new parameter
@Query("per-page") int perPage,
@Query("page") int page);
Run Code Online (Sandbox Code Playgroud)
之前,我的 PageKeyedVideosDataSource 只需要页面和每页就可以进行调用,这很容易。但是,现在我需要将这个新参数 id 动态地放入 PageKeyedDataSource 中。
我看到了PagingWithNetworkSample并发现他们通过在构造函数中添加它在 PagedKeyedDataSource 中放置了一个新参数。然后,我想这样做:
public PageKeyedCategoryVideosDataSource(int categoryId, Repository repository) { …Run Code Online (Sandbox Code Playgroud) Tried all the related questions but it did not work :(
I am building endless scrolling with Recycler View.
PROBLEM: onScrolled method is always called without the user scrolling the screen.
Android Documentation Guide describes this for onScrolled method:
Case 1) Callback method to be invoked when the RecyclerView has been scrolled. This will be called after the scroll has completed.
Case 2) This callback will also be called if visible item range changes after a layout calculation. In that …
我想知道在使用Delphi 10.3 Community Edition时是否可以保存桌面布局.
我正在执行此过程,但我找不到保存桌面布局选项.
查看 - >桌面 - >保存桌面布局
编辑
回答Uwe Raabe
当我使用MessageDlg()如下代码的函数时:
if MessageDlg(SWarningWishToDelete + ' ' + PersonName + '?',
mtWarning, [mbNo, mbYes], 0) = mrYes then
Run Code Online (Sandbox Code Playgroud)
是/否按钮以英语而不是我的操作系统语言显示。我在互联网上搜索了它,但是,我只是找到了大而旧的解决方案。我想知道是否有一种简单/新的方法来改变它?
我正在将图像编码为Base64在delphi中使用以下代码段。
procedure TWM.WMactArquivosAction(Sender: TObject; Request: TWebRequest;
Response: TWebResponse; var Handled: Boolean);
var
ImagePath: string;
JsonObject: TJSONObject;
inStream, outStream: TStream;
StrList: TStringList;
begin
inStream := TFileStream.Create(ImagePath, fmOpenRead);
try
outStream := TFileStream.Create('final_file', fmCreate);
JsonObject := TJSONObject.Create;
try
TNetEncoding.Base64.Encode(inStream, outStream);
outStream.Position := 0;
StrList := TStringList.Create;
StrList.LoadFromStream(outStream);
JsonObject.AddPair('file', StrList.Text);
finally
Response.Content := JsonObject.ToString;
outStream.Free;
JsonObject.DisposeOf;
end;
finally
inStream.Free;
end;
end;
Run Code Online (Sandbox Code Playgroud)
工作正常,文件被转换为Base64并添加到JsonObject。
问题是,当JsonObject从网络服务器检索此消息时,我得到了格式错误的json,因为base64字符串中有换行符。
您会看到红色的是字符串。第一行中断后,json受到干扰,并以蓝色显示,这意味着json响应中有错误。
问题
因此,问题在于,在对其进行编码时Base64,在字符串上添加了换行符,而则不支持Json。
我猜
我有一个猜测,它确实有效,但是我不确定这是最佳解决方案。
我遍历了所有Strings …
我正在使用从 FTP 服务器IdFTP下载.exe或.zip文件。该文件已下载并从 FTP 传送到我的计算机,问题是在传输过程中文件.exe 已损坏,我无法在我的计算机中打开它。
这是代码。
IdFTP1.Connect;
IdFTP1.Get(EdtRemoteFile.Text,EdtDirectory.Text + '\' + EdtRemoteFile.Text, True, true);
Run Code Online (Sandbox Code Playgroud) 我正在尝试获取正在运行的可执行文件的版本,以便我知道我的应用程序何时更改为具有新功能的新版本。
我正在使用以下代码来获取版本:
function GetVersaoExe: string;
type
PFFI = ^vs_FixedFileInfo;
var
F : PFFI;
Handle : Dword;
Len : Longint;
Data : Pchar;
Buffer : Pointer;
Tamanho : Dword;
Parquivo: Pchar;
Arquivo : string;
begin
Arquivo := Application.ExeName;
Parquivo := StrAlloc(Length(Arquivo) + 1);
StrPcopy(Parquivo, Arquivo);
Len := GetFileVersionInfoSize(Parquivo, Handle);
ShowMessage(IntToStr(Len));
Result := '';
if Len > 0 then
begin
Data:=StrAlloc(Len+1);
if GetFileVersionInfo(Parquivo,Handle,Len,Data) then
begin
VerQueryValue(Data, '\',Buffer,Tamanho);
F := PFFI(Buffer);
Result := Format('%d.%d.%d.%d',
[HiWord(F^.dwFileVersionMs),
LoWord(F^.dwFileVersionMs),
HiWord(F^.dwFileVersionLs),
Loword(F^.dwFileVersionLs)]
);
end;
StrDispose(Data);
end;
StrDispose(Parquivo); …Run Code Online (Sandbox Code Playgroud)