Search in sources :

Example 1 with CaseEvent

use of in.bugzy.data.model.CaseEvent in project bugzy by cpunq.

the class CaseEditActivity method setupEventsRecyclerView.

private void setupEventsRecyclerView() {
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    mEventsRecyclerView.setLayoutManager(layoutManager);
    mAdapter = new CaseEventsAdapter(this);
    mAdapter.setOnAttachmentClickListener(new CaseEventsAdapter.OnAttachmentClickListener() {

        @Override
        public void onAttachmentClick(View v, CaseEvent event, int attachmentPosition) {
            Attachment attachment = event.getsAttachments().get(attachmentPosition);
            String filename = attachment.getFilename().toLowerCase();
            if (filename.endsWith("png") || filename.endsWith("jpg") || filename.endsWith("jpeg")) {
                openImageActivity(v, attachment.getFullUrl());
                return;
            }
            // For other attachments leave things to browser
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(attachment.getFullUrl()));
            startActivity(i);
        }
    });
    mEventsRecyclerView.setAdapter(mAdapter);
    mEventsRecyclerView.setNestedScrollingEnabled(false);
}
Also used : CaseEventsAdapter(in.bugzy.ui.caseevents.CaseEventsAdapter) Attachment(in.bugzy.data.model.Attachment) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) NachoTextView(com.hootsuite.nachos.NachoTextView) View(android.view.View) AdapterView(android.widget.AdapterView) ImagePickerSheetView(com.flipboard.bottomsheet.commons.ImagePickerSheetView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) CaseEvent(in.bugzy.data.model.CaseEvent)

Example 2 with CaseEvent

use of in.bugzy.data.model.CaseEvent in project bugzy by cpunq.

the class CaseEventsAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(EventHolder holder, int position) {
    CaseEvent bug = mCaseEvents.get(position);
    holder.bindData(bug, mLayoutManagerSavedStates.get(bug.getBugEvent()));
}
Also used : CaseEvent(in.bugzy.data.model.CaseEvent)

Example 3 with CaseEvent

use of in.bugzy.data.model.CaseEvent in project bugzy by cpunq.

the class CaseEventsAdapter method saveInstanceState.

public void saveInstanceState(EventHolder holder) {
    if (holder.getAdapterPosition() == RecyclerView.NO_POSITION) {
        return;
    }
    CaseEvent event = mCaseEvents.get(holder.getAdapterPosition());
    Parcelable p = holder.onSaveLayoutManagerState();
    if (p != null) {
        mLayoutManagerSavedStates.put(event.getBugEvent(), p);
    }
}
Also used : Parcelable(android.os.Parcelable) CaseEvent(in.bugzy.data.model.CaseEvent)

Example 4 with CaseEvent

use of in.bugzy.data.model.CaseEvent in project bugzy by cpunq.

the class CaseDetailsFragment method showCaseDetails.

@UiThread
protected void showCaseDetails(Case aCase) {
    mCase = aCase;
    showContent();
    showActionButtons(mCase);
    List<CaseEvent> evs = mCase.getCaseevents();
    if (evs != null) {
        mAdapter.setData(evs);
        mAdapter.notifyDataSetChanged();
    }
    mBugId.setText(String.valueOf(mCase.getIxBug()));
    mBugTitle.setText(String.valueOf(mCase.getTitle()));
    mAssignedTo.setText(String.valueOf(mCase.getPersonAssignedTo()));
    mProjectView.setText(mCase.getProjectName());
    if (!TextUtils.isEmpty(mCase.getFixFor())) {
        mMileStone.setText(String.valueOf(mCase.getFixFor()));
    }
    mActiveStatus.setText(String.valueOf(mCase.getStatus()));
    Case bug = mCase;
    if (bug.getPriority() <= 3) {
        mPriorityIndicator.setBackgroundColor(getResources().getColor(R.color.p3));
    } else if (bug.getPriority() == 4) {
        mPriorityIndicator.setBackgroundColor(getResources().getColor(R.color.p4));
    } else if (bug.getPriority() == 5) {
        mPriorityIndicator.setBackgroundColor(getResources().getColor(R.color.p5));
    } else if (bug.getPriority() <= 6) {
        mPriorityIndicator.setBackgroundColor(getResources().getColor(R.color.p6));
    }
}
Also used : CaseEvent(in.bugzy.data.model.CaseEvent) Case(in.bugzy.data.model.Case) UiThread(android.support.annotation.UiThread)

Example 5 with CaseEvent

use of in.bugzy.data.model.CaseEvent in project bugzy by cpunq.

the class BugzyTypeConverters method caseEventListFromString.

@TypeConverter
public static List<CaseEvent> caseEventListFromString(String value) {
    Type listType = new TypeToken<List<CaseEvent>>() {
    }.getType();
    List<CaseEvent> events = sGson.fromJson(value, listType);
    if (events != null) {
        Collections.sort(events, ((caseEvent, t1) -> Long.compare(t1.getDate().getTime(), caseEvent.getDate().getTime())));
    }
    return events;
}
Also used : FieldNamingPolicy(com.google.gson.FieldNamingPolicy) List(java.util.List) TypeToken(com.google.gson.reflect.TypeToken) Type(java.lang.reflect.Type) Gson(com.google.gson.Gson) Date(java.util.Date) CaseEvent(in.bugzy.data.model.CaseEvent) TypeConverter(android.arch.persistence.room.TypeConverter) Collections(java.util.Collections) GsonBuilder(com.google.gson.GsonBuilder) ArrayList(java.util.ArrayList) Type(java.lang.reflect.Type) List(java.util.List) ArrayList(java.util.ArrayList) CaseEvent(in.bugzy.data.model.CaseEvent) TypeConverter(android.arch.persistence.room.TypeConverter)

Aggregations

CaseEvent (in.bugzy.data.model.CaseEvent)5 TypeConverter (android.arch.persistence.room.TypeConverter)1 Intent (android.content.Intent)1 Parcelable (android.os.Parcelable)1 UiThread (android.support.annotation.UiThread)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 ImagePickerSheetView (com.flipboard.bottomsheet.commons.ImagePickerSheetView)1 FieldNamingPolicy (com.google.gson.FieldNamingPolicy)1 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 TypeToken (com.google.gson.reflect.TypeToken)1 NachoTextView (com.hootsuite.nachos.NachoTextView)1 Attachment (in.bugzy.data.model.Attachment)1 Case (in.bugzy.data.model.Case)1 CaseEventsAdapter (in.bugzy.ui.caseevents.CaseEventsAdapter)1