Search in sources :

Example 1 with NotebookData

use of org.kymjs.blog.domain.NotebookData in project KJFrameForAndroid by kymjs.

the class NotebookAdapter method getView.

@Override
public View getView(int position, View v, ViewGroup parent) {
    NotebookData data = datas.get(position);
    ViewHolder holder = null;
    if (v == null) {
        holder = new ViewHolder();
        v = View.inflate(aty, R.layout.item_notebook, null);
        holder.titleBar = v.findViewById(R.id.item_note_titlebar);
        holder.date = (TextView) v.findViewById(R.id.item_note_tv_date);
        holder.state = (ImageView) v.findViewById(R.id.item_note_img_state);
        holder.thumbtack = (ImageView) v.findViewById(R.id.item_note_img_thumbtack);
        holder.content = (TextView) v.findViewById(R.id.item_note_content);
        v.setTag(holder);
    } else {
        holder = (ViewHolder) v.getTag();
    }
    RelativeLayout.LayoutParams params = (LayoutParams) holder.content.getLayoutParams();
    params.width = width;
    params.height = (params.width - height);
    holder.content.setLayoutParams(params);
    holder.titleBar.setBackgroundColor(NoteEditFragment.sTitleBackGrounds[data.getColor()]);
    holder.date.setText(data.getDate());
    if (data.getId() > 0) {
        holder.state.setVisibility(View.GONE);
    } else {
        holder.state.setVisibility(View.VISIBLE);
    }
    holder.thumbtack.setImageResource(NoteEditFragment.sThumbtackImgs[data.getColor()]);
    holder.content.setText(Html.fromHtml(data.getContent()).toString());
    holder.content.setBackgroundColor(NoteEditFragment.sBackGrounds[data.getColor()]);
    if (position == currentHidePosition) {
        v.setVisibility(View.GONE);
    } else {
        v.setVisibility(View.VISIBLE);
    }
    return v;
}
Also used : NotebookData(org.kymjs.blog.domain.NotebookData) LayoutParams(android.widget.RelativeLayout.LayoutParams) RelativeLayout(android.widget.RelativeLayout) LayoutParams(android.widget.RelativeLayout.LayoutParams)

Example 2 with NotebookData

use of org.kymjs.blog.domain.NotebookData in project KJFrameForAndroid by kymjs.

the class NoteEditFragment method initData.

@Override
public void initData() {
    Bundle bundle = ((SimpleBackActivity) getActivity()).getBundleData();
    if (bundle != null) {
        editData = (NotebookData) bundle.getSerializable(NOTE_KEY);
    }
    kjdb = KJDB.create(outsideAty, true);
    if (editData == null) {
        editData = new NotebookData();
    }
    if (StringUtils.isEmpty(editData.getDate())) {
        editData.setDate(StringUtils.getDataTime("yyyy/MM/dd"));
    }
}
Also used : NotebookData(org.kymjs.blog.domain.NotebookData) Bundle(android.os.Bundle) SimpleBackActivity(org.kymjs.blog.ui.SimpleBackActivity)

Example 3 with NotebookData

use of org.kymjs.blog.domain.NotebookData in project KJFrameForAndroid by kymjs.

the class NotebookAdapter method reorderItems.

@Override
public void reorderItems(int oldPosition, int newPosition) {
    dataChange = true;
    if (oldPosition >= datas.size() || oldPosition < 0) {
        return;
    }
    NotebookData temp = datas.get(oldPosition);
    if (oldPosition < newPosition) {
        for (int i = oldPosition; i < newPosition; i++) {
            Collections.swap(datas, i, i + 1);
        }
    } else if (oldPosition > newPosition) {
        for (int i = oldPosition; i > newPosition; i--) {
            Collections.swap(datas, i, i - 1);
        }
    }
    datas.set(newPosition, temp);
}
Also used : NotebookData(org.kymjs.blog.domain.NotebookData)

Aggregations

NotebookData (org.kymjs.blog.domain.NotebookData)3 Bundle (android.os.Bundle)1 RelativeLayout (android.widget.RelativeLayout)1 LayoutParams (android.widget.RelativeLayout.LayoutParams)1 SimpleBackActivity (org.kymjs.blog.ui.SimpleBackActivity)1