我的客户有一个基于 Firebase 的项目。他们希望我为其核心添加一些功能,并对客户端应用程序进行必要的更改。要求的新功能之一是基于文本的 Firestore 文档搜索。但是这个解决方案应该是完全免费的。
根据Firebase 文档,我可能会使用Algolia或ElasticSerach或它们的等价物。但是要使用这些服务,我应该为服务付费,或者租用 Google Cloud Platform 或 AWS 部署,或者标准的专用服务器,所有这些解决方案都需要定期付款。
所以,最后,我有 2 个解决方案。
1. 客户端搜索
查询所有文档并对其执行搜索。
2. 使用 Cloud Functions
查询云函数中的所有文档并返回搜索结果。
这两种方法都会增加 Firebase 的使用。这可能会导致超出限额和意外发票。
我的问题是,有免费的搜索服务吗?你有比我更好的主意吗?如果你不这样做;哪种方法更好?
我正在尝试通过imageView添加图片.但是我想用图像完全填满我的视图,而且imageView应该填满屏幕的宽度.图像应该从屏幕边缘开始和结束.
我使用了每个xml属性,但没有运气.这是我想要的最接近的代码.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bck3"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/buttonStore"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignBottom="@+id/imageView1"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:background="@drawable/store" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/logo" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="fill_parent"
android:layout_height="125dp"
android:layout_marginTop="57dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/ronaldo" />
Run Code Online (Sandbox Code Playgroud)

应该是这样

我想获取Android设备的屏幕尺寸。我正在使用这3个代码来执行此操作,但这给了我活动的大小;没有状态栏高度的大小。在高度为800px的平板电脑上,此代码为764px。36px转到底部的状态栏。
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
final int width = size.x;
final int height = size.y;
Rect rectgle= new Rect();
Window window= getWindow();
window.getDecorView().getWindowVisibleDisplayFrame(rectgle);
int height2= rectgle.bottom;
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int actualHeight = metrics.heightPixels;
Run Code Online (Sandbox Code Playgroud)
但是我需要一个代码,该代码可以给我 实际的屏幕尺寸。 不是活动的。有人可以帮我吗?谢谢。
多年后,我正在尝试使用 Firebase Firestore 开发 Android 应用程序。我基本上是在尝试复制这个 Swift 函数:
func getCategories(onCompletion completionBlock: @escaping (_ categories: [Category]?, _ error: Error?) -> Void) {
firestore.collection("cats").getDocuments { (snap, error) in
guard let snap = snap else {
completionBlock(nil, error ?? anUnknownError)
return
}
var categories: [Category] = []
for document in snap.documents {
let cat = Category.init(data: document.data())
categories.append(cat)
}
completionBlock(categories, nil)
}
}
Run Code Online (Sandbox Code Playgroud)
但是我不知道 swift 的块的等价物是什么,甚至不知道它是否存在。
我检查了 Firebase 源代码。Query.get()返回Task<QuerySnapshot>所以我试图返回一个Task<List<Category>>没有运气。
任何帮助?谢谢你。
编辑:添加了 Android 代码以阐明我正在尝试做什么。
public class FirestoreService { …Run Code Online (Sandbox Code Playgroud) 我需要仅在数据下方绘制网格线(在线图上)。我还没有找到它的 API。
在这里我画了一些东西来展示我得到的和我需要的:
上面的图就是我得到的。下面是我需要的。抱歉我的绘画天赋太差了:)
有什么建议么?谢谢。
这很奇怪,我知道但是我的[UITableView reloadData]没有删除旧单元格,如下所示:

你点击+按钮后发生的混乱,回来后再次更改了值.加号按钮将navigationController推送到另一个控制器,在我回来后单击后退按钮并更改了值,这就是我所看到的.这怎么可能??我使用了一个自定义视图(来自UIView的子类),我创建了一个带有UILabel的UIStepper.以下是自定义UIView的代码,controller.m和.h-.m文件.
Controller.m或者
@interface ViewController ()
@property NSString *docsDir;
@property sqlite3 *DB;
@property NSArray *dirPaths;
@property NSString* databasePath;
@property (strong, nonatomic) IBOutlet UITableView *tableView;
@property BOOL isCreatedBefore;
@property NSArray *theList;
@end
@implementation ViewController
@synthesize docsDir;
@synthesize DB;
@synthesize dirPaths;
@synthesize databasePath;
- (void)viewDidLoad
{
[super viewDidLoad];
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
databasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: [NSString stringWithFormat:@"database.db"]]];
[self createDatabase];
self.theList = [self readAllEntries];
}
-(void) viewWillAppear:(BOOL)animated{
self.theList = …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用HTML字符串填充UITableView.获取字符串,将它们放入单元格等等一切都很好.我想改变我的NSAttributedText的字体和字体大小.我写了下面的代码.
我通过第一个NSLog检查了代码,如果我的UIFont按预期在字典中; 所以它在字典里.还是没问题.但我的字体和字体大小在运行时没有变化.没有控制台错误.只是不工作.
第二个NSLog用于检查attributionString的字体和大小.它说,我的字符串是"Times New Roman",fontSize:12.但正如您将在代码中看到的那样,我正试图将它变成尺寸为15的"Verdana"
任何人都可以帮我这个吗?谢谢.
PS:我把弦放在一些物体上.obj.name是我想写入表格单元格的字符串.
Html字符串有一些不需要的标记,因此函数[self clearTheHtml:obj.name]函数正在清除它们.
NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init];
UIFont *font = [UIFont fontWithName:@"Verdana" size:15];
[attributes setObject:font forKey:NSFontAttributeName];
NSString *s = [self clearTheHtml:obj.name];
NSLog(@"%@", [attributes objectForKey:NSFontAttributeName]); //to see if my font is not in the dictionary.
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:[s dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:&attributes error:nil];
NSLog(@"%@", attributedString);
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2 forIndexPath:indexPath];
cell.textLabel.attributedText = attributedString;
Run Code Online (Sandbox Code Playgroud)
编辑:
这是NSString*s:
2014-01-25 07:38:04.527 KadirB[7483:70b]
''Narakas 2013 …Run Code Online (Sandbox Code Playgroud) 就我而言 我从网站获取JSON,必须将其写入TextView中。并确实做到了。但是我的老板很想要文字说明。没有段落;没有空行。
文本是从Web控制台添加到网站的。因此,网站的数据库使用html标签保存它们,而我也使用标签保存它们。我使用Html.fromHtml()方法将其记录下来;并在某些帮助下使用tagHandler处理<li>标签;但是现在我必须擦除<p>和<br />标签。有人可以帮忙吗?非常感谢你。
android ×4
ios ×4
firebase ×1
fonts ×1
html ×1
imageview ×1
ios-charts ×1
ios7 ×1
iphone ×1
java ×1
reloaddata ×1
scale ×1
screen-size ×1
swift ×1
uitableview ×1