Android Open Source - inside-list-view-talk Render Debug






From Project

Back to project page inside-list-view-talk.

License

The source code is released under:

MIT License

If you think the Android project inside-list-view-talk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.flipper.example.insidelist.rendermodel;
/*from w ww . j a v a 2s. c  o m*/
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.flipper.example.insidelist.R;
import com.flipper.example.insidelist.model.DataModel;
import com.flipper.example.insidelist.model.RenderViewData;

import java.util.Random;

/**
 * @author flipper83
 *         <p/>
 *         This class contains the render model info and render the cell.
 */
public class RenderDebug extends RenderBase{


    private int id;
    private int oldPosition;
    private TextView tv_title;
    private ImageView iv_avatar;
    private boolean newRow = true;

    private Random random = new Random();
    private TextView tv_render_time;
    private TextView tv_calls;

    private long timeFindById;
    private TextView tv_total_time;

    @Override
    public View createRender(Context context, LayoutInflater inflater, ViewGroup parent) {

        base = inflater.inflate(R.layout.listitem_example_bitmap, parent,
                false);

        this.newRow = true;

        return base;
    }

    public void setupView() {
        long start = System.nanoTime();

        this.tv_title = (TextView) base
                .findViewById(R.id.tv_title);
        this.iv_avatar = (ImageView) base.findViewById(R.id.iv_avatar);
        this.tv_render_time = (TextView) base.findViewById(R.id.tv_render_time);
        this.tv_calls = (TextView) base.findViewById(R.id.tv_render_calls);
        this.tv_total_time = (TextView) base.findViewById(R.id.tv_total_time);

        timeFindById = (System.nanoTime() - start)/1000;
    }


    protected View render(Context context, RenderViewData dataBase) {
        DataModel data = (DataModel) dataBase;

        //inc data mode render calls
        data.incCalls();

        long start = System.nanoTime();

        if (newRow) {
            base.setBackgroundColor(context.getResources().getColor(
                    R.color.red));
        } else {
            base.setBackgroundColor(context.getResources().getColor(
                    R.color.green));
        }


        tv_title.setText(id + ".- " + " old " + oldPosition + " " + data.getTitle());

        //we do this bitmap factory all time, because if I set directly from resource, it's will be cache by resource
        //manager
        Bitmap avatar = BitmapFactory.decodeResource(context.getResources(),data.getAvatar());
        iv_avatar.setImageBitmap(avatar);

         //this code depends of android cache
        //iv_avatar.setImageResource(data.getAvatar());

        tv_calls.setText("num Calls= "+data.getCalls());

        long end = System.nanoTime();
        long timeRender = (end - start)/1000;

        tv_render_time.setText("render = "+ timeRender + " findById ="+ timeFindById );

        //reset timers
        timeFindById = 0;

        return base;
    }

    public void setOldPosition(int oldPosition) {
        this.oldPosition = oldPosition;
    }


    public void setTotalTime(long totalTime) {
        tv_total_time.setText("total time="+totalTime);
    }

    public boolean isNew(){
        return newRow;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public void setBaseView(View baseView) {
        super.setBaseView(baseView);
        newRow = false;
    }
}




Java Source Code List

com.flipper.example.insidelist.activity.InsideBaseListActivity.java
com.flipper.example.insidelist.activity.InsideListViewAnimatedItemsTransient.java
com.flipper.example.insidelist.activity.InsideListViewAnimatedItems.java
com.flipper.example.insidelist.activity.InsideMainActivity.java
com.flipper.example.insidelist.activity.NoRecycleActivity.java
com.flipper.example.insidelist.activity.RecicleBitmapActivity.java
com.flipper.example.insidelist.activity.RecycleActivity.java
com.flipper.example.insidelist.activity.ViewHolderActivity.java
com.flipper.example.insidelist.adapter.BaseInsideAdapter.java
com.flipper.example.insidelist.adapter.DebugAdapter.java
com.flipper.example.insidelist.adapter.OptionsAdapter.java
com.flipper.example.insidelist.adapter.RecicleBitmapAdapter.java
com.flipper.example.insidelist.adapter.ViewHolderAdapterAnimated.java
com.flipper.example.insidelist.builder.RenderBuilder.java
com.flipper.example.insidelist.component.DebugListView.java
com.flipper.example.insidelist.model.DataModel.java
com.flipper.example.insidelist.model.RenderOptionData.java
com.flipper.example.insidelist.model.RenderViewData.java
com.flipper.example.insidelist.rendermodel.GeneralInfoListener.java
com.flipper.example.insidelist.rendermodel.RenderAnimated.java
com.flipper.example.insidelist.rendermodel.RenderBase.java
com.flipper.example.insidelist.rendermodel.RenderBitmapCache.java
com.flipper.example.insidelist.rendermodel.RenderDebug.java
com.flipper.example.insidelist.rendermodel.RenderOptionView.java