Search in sources :

Example 1 with Screenshot

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;
}
Also used : Screenshot(org.mozilla.focus.screenshot.model.Screenshot)

Example 2 with 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));
        }
    }
}
Also used : DateSection(org.mozilla.focus.history.model.DateSection) Screenshot(org.mozilla.focus.screenshot.model.Screenshot)

Example 3 with Screenshot

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;
    }
}
Also used : Bitmap(android.graphics.Bitmap) Screenshot(org.mozilla.focus.screenshot.model.Screenshot) IOException(java.io.IOException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 4 with Screenshot

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;
}
Also used : DateSection(org.mozilla.focus.history.model.DateSection) Screenshot(org.mozilla.focus.screenshot.model.Screenshot)

Aggregations

Screenshot (org.mozilla.focus.screenshot.model.Screenshot)4 DateSection (org.mozilla.focus.history.model.DateSection)2 Bitmap (android.graphics.Bitmap)1 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1