use of org.mozilla.focus.screenshot.model.Screenshot in project Rocket by mozilla-tw.
the class QueryHandler method cursorToScreenshot.
private static Screenshot cursorToScreenshot(Cursor cursor) {
Screenshot screenshot = new Screenshot();
screenshot.setId(cursor.getLong(cursor.getColumnIndex(ScreenshotContract.Screenshot._ID)));
screenshot.setTitle(cursor.getString(cursor.getColumnIndex(ScreenshotContract.Screenshot.TITLE)));
screenshot.setUrl(cursor.getString(cursor.getColumnIndex(ScreenshotContract.Screenshot.URL)));
screenshot.setTimestamp(cursor.getLong(cursor.getColumnIndex(ScreenshotContract.Screenshot.TIMESTAMP)));
screenshot.setImageUri(cursor.getString(cursor.getColumnIndex(ScreenshotContract.Screenshot.IMAGE_URI)));
return screenshot;
}
use of org.mozilla.focus.screenshot.model.Screenshot in project Rocket by mozilla-tw.
the class ScreenshotItemAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
if (holder instanceof GirdItemViewHolder) {
final GirdItemViewHolder gridVH = (GirdItemViewHolder) holder;
gridVH.rootView.setOnClickListener(this);
final Screenshot item = (Screenshot) mItems.get(position);
GlideApp.with(mActivity).asBitmap().placeholder(R.drawable.placeholder).fitCenter().load(item.getImageUri()).into(gridVH.img);
} else if (holder instanceof DateItemViewHolder) {
final DateSection item = (DateSection) mItems.get(position);
if (item != null) {
final DateItemViewHolder dateVH = (DateItemViewHolder) holder;
dateVH.textDate.setText(DateUtils.getRelativeTimeSpanString(item.getTimestamp(), System.currentTimeMillis(), DateUtils.DAY_IN_MILLIS));
}
}
}
use of org.mozilla.focus.screenshot.model.Screenshot in project Rocket by mozilla-tw.
the class ScreenshotCaptureTask method doInBackground.
@Override
protected String doInBackground(Object... params) {
String title = (String) params[0];
String url = (String) params[1];
Bitmap content = (Bitmap) params[2];
long timestamp = System.currentTimeMillis();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.getDefault());
try {
final String path = saveBitmapToStorage(context, "Screenshot_" + sdf.format(new Date(timestamp)), content);
// Failed to save
if (!TextUtils.isEmpty(path)) {
FileUtils.notifyMediaScanner(context, path);
Screenshot screenshot = new Screenshot(title, url, timestamp, path);
ScreenshotManager.getInstance().insert(screenshot, null);
// We don't collect data in private mode now
if (!PRIVATE_MODE.equals(telemetryData.getMode())) {
TelemetryWrapper.clickToolbarCapture(ScreenshotManager.getInstance().getCategory(context, url), ScreenshotManager.getInstance().getCategoryVersion(), telemetryData.getMode(), telemetryData.getPosition());
}
}
return path;
} catch (IOException ex) {
return null;
}
}
use of org.mozilla.focus.screenshot.model.Screenshot in project Rocket by mozilla-tw.
the class ScreenshotItemAdapter method add.
private void add(Object item) {
if (mItems.size() > 0 && isSameDay(((Screenshot) mItems.get(mItems.size() - 1)).getTimestamp(), ((Screenshot) item).getTimestamp())) {
mItems.add(item);
notifyItemInserted(mItems.size());
} else {
mItems.add(new DateSection(((Screenshot) item).getTimestamp()));
mItems.add(item);
notifyItemRangeInserted(mItems.size() - 2, 2);
}
++mCurrentCount;
}
Aggregations