Search in sources :

Example 6 with PageContentView

use of com.android.printspooler.widget.PageContentView in project android_frameworks_base by AOSPA.

the class PageAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    if (DEBUG) {
        Log.i(LOG_TAG, "Binding holder: " + holder + " with id: " + getItemId(position) + " for position: " + position);
    }
    MyViewHolder myHolder = (MyViewHolder) holder;
    PreviewPageFrame page = (PreviewPageFrame) holder.itemView;
    page.setOnClickListener(mPageClickListener);
    page.setTag(holder);
    myHolder.mPageInAdapter = position;
    final int pageInDocument = computePageIndexInDocument(position);
    final int pageIndexInFile = computePageIndexInFile(pageInDocument);
    PageContentView content = (PageContentView) page.findViewById(R.id.page_content);
    LayoutParams params = content.getLayoutParams();
    params.width = mPageContentWidth;
    params.height = mPageContentHeight;
    PageContentProvider provider = content.getPageContentProvider();
    if (pageIndexInFile != INVALID_PAGE_INDEX) {
        if (DEBUG) {
            Log.i(LOG_TAG, "Binding provider:" + " pageIndexInAdapter: " + position + ", pageInDocument: " + pageInDocument + ", pageIndexInFile: " + pageIndexInFile);
        }
        provider = mPageContentRepository.acquirePageContentProvider(pageIndexInFile, content);
        mBoundPagesInAdapter.put(position, null);
    } else {
        onSelectedPageNotInFile(pageInDocument);
    }
    content.init(provider, mEmptyState, mErrorState, mMediaSize, mMinMargins);
    if (mConfirmedPagesInDocument.indexOfKey(pageInDocument) >= 0) {
        page.setSelected(true, false);
    } else {
        page.setSelected(false, false);
    }
    page.setContentDescription(mContext.getString(R.string.page_description_template, pageInDocument + 1, mDocumentPageCount));
    TextView pageNumberView = (TextView) page.findViewById(R.id.page_number);
    String text = mContext.getString(R.string.current_page_template, pageInDocument + 1, mDocumentPageCount);
    pageNumberView.setText(text);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) TextView(android.widget.TextView) PreviewPageFrame(com.android.printspooler.widget.PreviewPageFrame) PageContentProvider(com.android.printspooler.model.PageContentRepository.PageContentProvider) PageContentView(com.android.printspooler.widget.PageContentView)

Example 7 with PageContentView

use of com.android.printspooler.widget.PageContentView in project platform_frameworks_base by android.

the class PageAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    if (DEBUG) {
        Log.i(LOG_TAG, "Binding holder: " + holder + " with id: " + getItemId(position) + " for position: " + position);
    }
    MyViewHolder myHolder = (MyViewHolder) holder;
    PreviewPageFrame page = (PreviewPageFrame) holder.itemView;
    page.setOnClickListener(mPageClickListener);
    page.setTag(holder);
    myHolder.mPageInAdapter = position;
    final int pageInDocument = computePageIndexInDocument(position);
    final int pageIndexInFile = computePageIndexInFile(pageInDocument);
    PageContentView content = (PageContentView) page.findViewById(R.id.page_content);
    LayoutParams params = content.getLayoutParams();
    params.width = mPageContentWidth;
    params.height = mPageContentHeight;
    PageContentProvider provider = content.getPageContentProvider();
    if (pageIndexInFile != INVALID_PAGE_INDEX) {
        if (DEBUG) {
            Log.i(LOG_TAG, "Binding provider:" + " pageIndexInAdapter: " + position + ", pageInDocument: " + pageInDocument + ", pageIndexInFile: " + pageIndexInFile);
        }
        provider = mPageContentRepository.acquirePageContentProvider(pageIndexInFile, content);
        mBoundPagesInAdapter.put(position, null);
    } else {
        onSelectedPageNotInFile(pageInDocument);
    }
    content.init(provider, mEmptyState, mErrorState, mMediaSize, mMinMargins);
    if (mConfirmedPagesInDocument.indexOfKey(pageInDocument) >= 0) {
        page.setSelected(true, false);
    } else {
        page.setSelected(false, false);
    }
    page.setContentDescription(mContext.getString(R.string.page_description_template, pageInDocument + 1, mDocumentPageCount));
    TextView pageNumberView = (TextView) page.findViewById(R.id.page_number);
    String text = mContext.getString(R.string.current_page_template, pageInDocument + 1, mDocumentPageCount);
    pageNumberView.setText(text);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) TextView(android.widget.TextView) PreviewPageFrame(com.android.printspooler.widget.PreviewPageFrame) PageContentProvider(com.android.printspooler.model.PageContentRepository.PageContentProvider) PageContentView(com.android.printspooler.widget.PageContentView)

Example 8 with PageContentView

use of com.android.printspooler.widget.PageContentView in project android_frameworks_base by AOSPA.

the class PageAdapter method onViewRecycled.

@Override
public void onViewRecycled(ViewHolder holder) {
    MyViewHolder myHolder = (MyViewHolder) holder;
    PageContentView content = (PageContentView) holder.itemView.findViewById(R.id.page_content);
    recyclePageView(content, myHolder.mPageInAdapter);
    myHolder.mPageInAdapter = INVALID_PAGE_INDEX;
}
Also used : PageContentView(com.android.printspooler.widget.PageContentView)

Example 9 with PageContentView

use of com.android.printspooler.widget.PageContentView in project android_frameworks_base by ResurrectionRemix.

the class PageAdapter method onViewRecycled.

@Override
public void onViewRecycled(ViewHolder holder) {
    MyViewHolder myHolder = (MyViewHolder) holder;
    PageContentView content = (PageContentView) holder.itemView.findViewById(R.id.page_content);
    recyclePageView(content, myHolder.mPageInAdapter);
    myHolder.mPageInAdapter = INVALID_PAGE_INDEX;
}
Also used : PageContentView(com.android.printspooler.widget.PageContentView)

Example 10 with PageContentView

use of com.android.printspooler.widget.PageContentView in project android_frameworks_base by crdroidandroid.

the class PageAdapter method onViewRecycled.

@Override
public void onViewRecycled(ViewHolder holder) {
    MyViewHolder myHolder = (MyViewHolder) holder;
    PageContentView content = (PageContentView) holder.itemView.findViewById(R.id.page_content);
    recyclePageView(content, myHolder.mPageInAdapter);
    myHolder.mPageInAdapter = INVALID_PAGE_INDEX;
}
Also used : PageContentView(com.android.printspooler.widget.PageContentView)

Aggregations

PageContentView (com.android.printspooler.widget.PageContentView)10 LayoutParams (android.view.ViewGroup.LayoutParams)5 TextView (android.widget.TextView)5 PageContentProvider (com.android.printspooler.model.PageContentRepository.PageContentProvider)5 PreviewPageFrame (com.android.printspooler.widget.PreviewPageFrame)5