Search in sources :

Example 51 with END

use of android.support.v7.widget.helper.ItemTouchHelper.END in project PhoneProfilesPlus by henrichg.

the class EditorEventListViewHolder method bindEvent.

void bindEvent(Event event) {
    this.event = event;
    if (event != null) {
        int _eventStatus = event.getStatusFromDB(editorFragment.activityDataWrapper);
        boolean isRunnable = event.isRunnable(context);
        int statusRes = R.drawable.ic_event_status_stop_not_runnable;
        switch(_eventStatus) {
            case Event.ESTATUS_RUNNING:
                if (event._isInDelayEnd)
                    statusRes = R.drawable.ic_event_status_running_delay;
                else
                    statusRes = R.drawable.ic_event_status_running;
                break;
            case Event.ESTATUS_PAUSE:
                if (event._isInDelayStart)
                    statusRes = R.drawable.ic_event_status_pause_delay;
                else
                    statusRes = R.drawable.ic_event_status_pause;
                break;
            case Event.ESTATUS_STOP:
                if (isRunnable)
                    statusRes = R.drawable.ic_event_status_stop;
                else
                    statusRes = R.drawable.ic_event_status_stop_not_runnable;
                break;
        }
        eventStatus.setImageResource(statusRes);
        if (_eventStatus == Event.ESTATUS_RUNNING) {
            eventName.setTypeface(null, Typeface.BOLD);
            eventName.setTextSize(16);
            eventName.setTextColor(GlobalGUIRoutines.getThemeAccentColor(editorFragment.getActivity()));
        } else if (!isRunnable) {
            eventName.setTypeface(null, Typeface.NORMAL);
            eventName.setTextSize(15);
            eventName.setTextColor(Color.RED);
        } else {
            eventName.setTypeface(null, Typeface.NORMAL);
            eventName.setTextSize(15);
            eventName.setTextColor(GlobalGUIRoutines.getThemeTextColor(editorFragment.getActivity()));
        }
        String _eventName = event._name;
        String eventStartOrder = "[O:" + event._startOrder + "] ";
        if (filterType == EditorEventListFragment.FILTER_TYPE_START_ORDER)
            eventStartOrder = "";
        String eventPriority = "";
        if (ApplicationPreferences.applicationEventUsePriority(context))
            eventPriority = "[P:" + (event._priority + Event.EPRIORITY_HIGHEST) + "] ";
        // eventPriority = "[P:" + "5" + "] ";
        if (event._forceRun) {
            _eventName = eventStartOrder + eventPriority + "[\u00BB] " + _eventName;
        } else
            _eventName = eventStartOrder + eventPriority + _eventName;
        if (!event._startWhenActivatedProfile.isEmpty()) {
            String[] splits = event._startWhenActivatedProfile.split("\\|");
            Profile profile;
            if (splits.length == 1) {
                profile = editorFragment.activityDataWrapper.getProfileById(Long.valueOf(event._startWhenActivatedProfile), false, false, false);
                if (profile != null)
                    _eventName = _eventName + "\n" + "[#] " + profile._name;
            } else {
                _eventName = _eventName + "\n" + "[#] " + context.getString(R.string.profile_multiselect_summary_text_selected) + " " + splits.length;
            }
        }
        if (!isRunnable)
            _eventName = _eventName + "\n\n" + context.getResources().getString(R.string.event_preferences_error);
        eventName.setText(_eventName);
        if (ApplicationPreferences.applicationEditorPrefIndicator(context)) {
            if (eventPreferencesDescription != null) {
                String eventPrefDescription = event.getPreferencesDescription(context);
                eventPreferencesDescription.setText(GlobalGUIRoutines.fromHtml(eventPrefDescription));
            }
        }
        // profile start
        Profile profile = editorFragment.activityDataWrapper.getProfileById(event._fkProfileStart, true, ApplicationPreferences.applicationEditorPrefIndicator(editorFragment.activityDataWrapper.context), false);
        if (profile != null) {
            String profileName = profile._name;
            if (event._manualProfileActivation)
                profileName = "[M] " + profileName;
            if (event._delayStart > 0)
                profileName = "[" + GlobalGUIRoutines.getDurationString(event._delayStart) + "] " + profileName;
            profileStartName.setText(profileName);
            if (profile.getIsIconResourceID()) {
                if (profile._iconBitmap != null)
                    profileStartIcon.setImageBitmap(profile._iconBitmap);
                else {
                    // holder.profileStartIcon.setImageBitmap(null);
                    int res = context.getResources().getIdentifier(profile.getIconIdentifier(), "drawable", context.getPackageName());
                    // icon resource
                    profileStartIcon.setImageResource(res);
                }
            } else {
                profileStartIcon.setImageBitmap(profile._iconBitmap);
            }
            if (ApplicationPreferences.applicationEditorPrefIndicator(context)) {
                // profilePrefIndicatorImageView.setImageBitmap(bitmap);
                if (profileStartIndicator != null) {
                    if (profile._preferencesIndicator != null)
                        profileStartIndicator.setImageBitmap(profile._preferencesIndicator);
                    else
                        profileStartIndicator.setImageResource(R.drawable.ic_empty);
                }
            }
        } else {
            profileStartName.setText(R.string.profile_preference_profile_not_set);
            profileStartIcon.setImageResource(R.drawable.ic_profile_default);
            if (ApplicationPreferences.applicationEditorPrefIndicator(context)) {
                // profilePrefIndicatorImageView.setImageBitmap(bitmap);
                if (profileStartIndicator != null)
                    profileStartIndicator.setImageResource(R.drawable.ic_empty);
            }
        }
        // profile end
        if (event._manualProfileActivation) {
            profileEndIcon.setVisibility(View.GONE);
            profileEndName.setVisibility(View.GONE);
            if (profileEndIndicator != null)
                profileEndIndicator.setVisibility(View.GONE);
        } else {
            profileEndIcon.setVisibility(View.VISIBLE);
            profileEndName.setVisibility(View.VISIBLE);
            if (profileEndIndicator != null)
                profileEndIndicator.setVisibility(View.VISIBLE);
            profile = editorFragment.activityDataWrapper.getProfileById(event._fkProfileEnd, true, ApplicationPreferences.applicationEditorPrefIndicator(editorFragment.activityDataWrapper.context), false);
            if (profile != null) {
                String profileName = profile._name;
                if (event._delayEnd > 0)
                    profileName = "[" + GlobalGUIRoutines.getDurationString(event._delayEnd) + "] " + profileName;
                if (event._atEndDo == Event.EATENDDO_UNDONE_PROFILE)
                    profileName = profileName + " + " + context.getResources().getString(R.string.event_prefernce_profile_undone);
                else if (event._atEndDo == Event.EATENDDO_RESTART_EVENTS)
                    profileName = profileName + " + " + context.getResources().getString(R.string.event_preference_profile_restartEvents);
                profileEndName.setText(profileName);
                if (profile.getIsIconResourceID()) {
                    if (profile._iconBitmap != null)
                        profileEndIcon.setImageBitmap(profile._iconBitmap);
                    else {
                        // holder.profileEndIcon.setImageBitmap(null);
                        int res = context.getResources().getIdentifier(profile.getIconIdentifier(), "drawable", context.getPackageName());
                        // icon resource
                        profileEndIcon.setImageResource(res);
                    }
                } else {
                    profileEndIcon.setImageBitmap(profile._iconBitmap);
                }
                if (ApplicationPreferences.applicationEditorPrefIndicator(context)) {
                    // profilePrefIndicatorImageView.setImageBitmap(bitmap);
                    if (profileEndIndicator != null) {
                        if (profile._preferencesIndicator != null)
                            profileEndIndicator.setImageBitmap(profile._preferencesIndicator);
                        else
                            profileEndIndicator.setImageResource(R.drawable.ic_empty);
                    }
                }
            } else {
                String profileName = "";
                if (event._delayEnd > 0)
                    profileName = "[" + GlobalGUIRoutines.getDurationString(event._delayEnd) + "] ";
                if (event._atEndDo == Event.EATENDDO_UNDONE_PROFILE)
                    profileName = profileName + context.getResources().getString(R.string.event_prefernce_profile_undone);
                else if (event._atEndDo == Event.EATENDDO_RESTART_EVENTS)
                    profileName = profileName + context.getResources().getString(R.string.event_preference_profile_restartEvents);
                else {
                    if (event._fkProfileEnd == Profile.PROFILE_NO_ACTIVATE)
                        profileName = profileName + context.getResources().getString(R.string.profile_preference_profile_end_no_activate);
                    else
                        profileName = profileName + context.getResources().getString(R.string.profile_preference_profile_not_set);
                }
                profileEndName.setText(profileName);
                profileEndIcon.setImageResource(R.drawable.ic_empty);
                if (ApplicationPreferences.applicationEditorPrefIndicator(context)) {
                    // profilePrefIndicatorImageView.setImageBitmap(bitmap);
                    if (profileEndIndicator != null)
                        // profileEndIndicator.setImageResource(R.drawable.ic_empty);
                        profileEndIndicator.setVisibility(View.GONE);
                }
            }
        }
        eventItemEditMenu.setTag(event);
        eventItemEditMenu.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                editorFragment.showEditMenu(eventItemEditMenu);
            }
        });
        final ImageView _eventStatusView = eventStatus;
        final Event _event = this.event;
        eventStatus.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                EventStatusPopupWindow popup = new EventStatusPopupWindow(editorFragment, _event);
                View contentView = popup.getContentView();
                contentView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
                int measuredW = contentView.getMeasuredWidth();
                int measuredH = contentView.getMeasuredHeight();
                // Log.d("EditorEventListAdapter.eventsRunStopIndicator.onClick","measuredW="+measuredW);
                // Log.d("EditorEventListAdapter.eventsRunStopIndicator.onClick","measuredH="+measuredH);
                Point screenSize = GlobalGUIRoutines.getRealScreenSize(editorFragment.getActivity());
                Point navigationBarSize = GlobalGUIRoutines.getNavigationBarSize(editorFragment.getActivity());
                if ((screenSize != null) && (navigationBarSize != null)) {
                    int[] location = new int[2];
                    _eventStatusView.getLocationOnScreen(location);
                    int x = 0;
                    int y = 0;
                    int statusBarHeight = (int) (24 * editorFragment.getResources().getDisplayMetrics().density + 0.5f);
                    if ((location[0] + measuredW) > screenSize.x)
                        x = -(location[0] - (screenSize.x - measuredW));
                    if ((location[1] + _eventStatusView.getHeight() + measuredH) > screenSize.y)
                        y = -(location[1] - _eventStatusView.getHeight() - (screenSize.y - measuredH) + navigationBarSize.y + statusBarHeight);
                    popup.setClippingEnabled(false);
                    popup.showOnAnchor(_eventStatusView, RelativePopupWindow.VerticalPosition.ALIGN_TOP, RelativePopupWindow.HorizontalPosition.ALIGN_LEFT, x, y);
                }
            }
        });
    }
}
Also used : ImageView(android.widget.ImageView) Point(android.graphics.Point) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) Point(android.graphics.Point)

Example 52 with END

use of android.support.v7.widget.helper.ItemTouchHelper.END in project isItMayYet by CMPUT301W18T03.

the class MainMenuActivity method onCreate.

// -----------Menu  Stuff ends here-----------//
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_menu_activity);
    addTaskButton = findViewById(R.id.addTaskButton);
    taskListView = findViewById(R.id.tasksView);
    // hardcoded test for elasticsearch
    Task t1 = new Task();
    t1.setName("Carry me to diamond");
    ElasticsearchController.AddTask addTask = new ElasticsearchController.AddTask();
    addTask.execute(t1);
    ElasticsearchController.GetTask getTask = new ElasticsearchController.GetTask();
    // ArrayList<Task> r1;
    // "john" was manually inserted into the server.
    getTask.execute("john");
    Object o = null;
    try {
        o = getTask.get();
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
    // 2nd test
    Task t2 = new Task();
    t2.setName("I like cake");
    // send it to server
    ElasticsearchController.taskToServer(t2);
    // retrieve from server
    ArrayList<Task> results = ElasticsearchController.serverTaskQuery("cake");
    Log.i("query", results.toString());
    // Log.i("execute", o.toString());
    // Task t2 = r1.get(0);
    // assertTrue(t1.getName().equals(t2.getName()));
    // end test for elastic search
    // debug
    /**
     * Test Cases
     */
    Task task0 = new Task("Task0", "Description for task0", TaskStatus.REQUESTED, 15);
    Task task1 = new Task("Task1", "There isn't really any reason to describe this", TaskStatus.BIDDED, 20);
    Task task2 = new Task("Task2", "Desc2", TaskStatus.ASSIGNED, 20);
    Task task3 = new Task("Task3", "Some fluff text here for task 3", TaskStatus.BIDDED, 22);
    Task task4 = new Task("Task4", "Some fluff text here for task 4", TaskStatus.REQUESTED, 12);
    taskList.addTask(task0);
    taskList.addTask(task1);
    taskList.addTask(task2);
    taskList.addTask(task3);
    taskList.addTask(task4);
    addTaskButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            setResult(RESULT_OK);
            // start activity for adding new task
            Intent intent = new Intent(activity, NewTaskActivity.class);
            startActivity(intent);
        }
    });
}
Also used : Intent(android.content.Intent) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) ExecutionException(java.util.concurrent.ExecutionException)

Example 53 with END

use of android.support.v7.widget.helper.ItemTouchHelper.END in project FloatingSearchView by renaudcerrato.

the class BaseItemAnimator method animateMoveImpl.

private void animateMoveImpl(final ViewHolder holder, int fromX, int fromY, int toX, int toY) {
    final View view = holder.itemView;
    final int deltaX = toX - fromX;
    final int deltaY = toY - fromY;
    if (deltaX != 0) {
        ViewCompat.animate(view).translationX(0);
    }
    if (deltaY != 0) {
        ViewCompat.animate(view).translationY(0);
    }
    // TODO: make EndActions end listeners instead, since end actions aren't called when
    // vpas are canceled (and can't end them. why?)
    // need listener functionality in VPACompat for this. Ick.
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mMoveAnimations.add(holder);
    animation.setDuration(getMoveDuration()).setListener(new VpaListenerAdapter() {

        @Override
        public void onAnimationStart(View view) {
            dispatchMoveStarting(holder);
        }

        @Override
        public void onAnimationCancel(View view) {
            if (deltaX != 0) {
                ViewCompat.setTranslationX(view, 0);
            }
            if (deltaY != 0) {
                ViewCompat.setTranslationY(view, 0);
            }
        }

        @Override
        public void onAnimationEnd(View view) {
            animation.setListener(null);
            dispatchMoveFinished(holder);
            mMoveAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    }).start();
}
Also used : ViewPropertyAnimatorCompat(android.support.v4.view.ViewPropertyAnimatorCompat) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 54 with END

use of android.support.v7.widget.helper.ItemTouchHelper.END in project FloatingSearchView by renaudcerrato.

the class BaseItemAnimator method endAnimation.

@Override
public void endAnimation(ViewHolder item) {
    final View view = item.itemView;
    // this will trigger end callback which should set properties to their target values.
    ViewCompat.animate(view).cancel();
    // TODO if some other animations are chained to end, how do we cancel them as well?
    for (int i = mPendingMoves.size() - 1; i >= 0; i--) {
        MoveInfo moveInfo = mPendingMoves.get(i);
        if (moveInfo.holder == item) {
            ViewCompat.setTranslationY(view, 0);
            ViewCompat.setTranslationX(view, 0);
            dispatchMoveFinished(item);
            mPendingMoves.remove(i);
        }
    }
    endChangeAnimation(mPendingChanges, item);
    if (mPendingRemovals.remove(item)) {
        ViewCompat.setAlpha(view, 1);
        dispatchRemoveFinished(item);
    }
    if (mPendingAdditions.remove(item)) {
        ViewCompat.setAlpha(view, 1);
        dispatchAddFinished(item);
    }
    for (int i = mChangesList.size() - 1; i >= 0; i--) {
        ArrayList<ChangeInfo> changes = mChangesList.get(i);
        endChangeAnimation(changes, item);
        if (changes.isEmpty()) {
            mChangesList.remove(i);
        }
    }
    for (int i = mMovesList.size() - 1; i >= 0; i--) {
        ArrayList<MoveInfo> moves = mMovesList.get(i);
        for (int j = moves.size() - 1; j >= 0; j--) {
            MoveInfo moveInfo = moves.get(j);
            if (moveInfo.holder == item) {
                ViewCompat.setTranslationY(view, 0);
                ViewCompat.setTranslationX(view, 0);
                dispatchMoveFinished(item);
                moves.remove(j);
                if (moves.isEmpty()) {
                    mMovesList.remove(i);
                }
                break;
            }
        }
    }
    for (int i = mAdditionsList.size() - 1; i >= 0; i--) {
        ArrayList<ViewHolder> additions = mAdditionsList.get(i);
        if (additions.remove(item)) {
            ViewCompat.setAlpha(view, 1);
            dispatchAddFinished(item);
            if (additions.isEmpty()) {
                mAdditionsList.remove(i);
            }
        }
    }
    // noinspection PointlessBooleanExpression,ConstantConditions
    if (mRemoveAnimations.remove(item) && DEBUG) {
        throw new IllegalStateException("after animation is cancelled, item should not be in " + "mRemoveAnimations list");
    }
    // noinspection PointlessBooleanExpression,ConstantConditions
    if (mAddAnimations.remove(item) && DEBUG) {
        throw new IllegalStateException("after animation is cancelled, item should not be in " + "mAddAnimations list");
    }
    // noinspection PointlessBooleanExpression,ConstantConditions
    if (mChangeAnimations.remove(item) && DEBUG) {
        throw new IllegalStateException("after animation is cancelled, item should not be in " + "mChangeAnimations list");
    }
    // noinspection PointlessBooleanExpression,ConstantConditions
    if (mMoveAnimations.remove(item) && DEBUG) {
        throw new IllegalStateException("after animation is cancelled, item should not be in " + "mMoveAnimations list");
    }
    dispatchFinishedWhenDone();
}
Also used : ViewHolder(android.support.v7.widget.RecyclerView.ViewHolder) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 55 with END

use of android.support.v7.widget.helper.ItemTouchHelper.END in project HoloEverywhere by Prototik.

the class LayoutInflater method rInflate.

void rInflate(XmlPullParser parser, View parent, final AttributeSet attrs, boolean finishInflate) throws XmlPullParserException, IOException {
    final int depth = parser.getDepth();
    int type;
    while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
        if (type != XmlPullParser.START_TAG) {
            continue;
        }
        final String name = parser.getName();
        if (TAG_REQUEST_FOCUS.equals(name)) {
            parseRequestFocus(parser, parent);
        } else if (TAG_INCLUDE.equals(name)) {
            if (parser.getDepth() == 0) {
                throw new InflateException("<include /> cannot be the root element");
            }
            parseInclude(parser, parent, attrs);
        } else if (TAG_MERGE.equals(name)) {
            throw new InflateException("<merge /> must be the root element");
        } else if (TAG_1995.equals(name)) {
            final View view = new BlinkLayout(mContext, attrs);
            final ViewGroup viewGroup = (ViewGroup) parent;
            final ViewGroup.LayoutParams params = viewGroup.generateLayoutParams(attrs);
            rInflate(parser, view, attrs, true);
            viewGroup.addView(view, params);
        } else {
            final View view = createViewFromTag(parent, name, attrs);
            final ViewGroup viewGroup = (ViewGroup) parent;
            final ViewGroup.LayoutParams params = viewGroup.generateLayoutParams(attrs);
            rInflate(parser, view, attrs, true);
            viewGroup.addView(view, params);
        }
    }
    if (finishInflate) {
        Class<?> clazz = parent.getClass();
        Method method = sFinishInflateMethods.get(clazz);
        if (method == null) {
            while (clazz != Object.class && method == null) {
                try {
                    method = clazz.getDeclaredMethod("onFinishInflate", (Class<?>[]) null);
                } catch (Exception e) {
                    clazz = clazz.getSuperclass();
                } catch (NoClassDefFoundError e) {
                    // HE#596 - Let's end the search here for those less than API 14
                    clazz = Object.class;
                }
            }
            if (method != null) {
                method.setAccessible(true);
                sFinishInflateMethods.put(parent.getClass(), method);
            }
        }
        if (method != null) {
            try {
                method.invoke(parent, (Object[]) null);
            } catch (Exception e) {
            }
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) InflateException(android.view.InflateException) Method(java.lang.reflect.Method) ActionBarView(android.support.v7.internal.widget.ActionBarView) View(android.view.View) ExpandedMenuView(android.support.v7.internal.view.menu.ExpandedMenuView) SuppressLint(android.annotation.SuppressLint) IOException(java.io.IOException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) InflateException(android.view.InflateException)

Aggregations

View (android.view.View)129 RecyclerView (android.support.v7.widget.RecyclerView)113 TextView (android.widget.TextView)35 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)25 ImageView (android.widget.ImageView)20 ArrayList (java.util.ArrayList)19 SuppressLint (android.annotation.SuppressLint)15 Intent (android.content.Intent)15 ViewGroup (android.view.ViewGroup)13 DialogInterface (android.content.DialogInterface)12 PreferenceScreen (android.support.v7.preference.PreferenceScreen)11 Toolbar (android.support.v7.widget.Toolbar)11 AdapterView (android.widget.AdapterView)11 OrientationHelperEx (com.alibaba.android.vlayout.OrientationHelperEx)10 List (java.util.List)10 AlertDialog (android.support.v7.app.AlertDialog)9 Context (android.content.Context)8 ActionBar (android.support.v7.app.ActionBar)8 ListView (android.widget.ListView)8 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)8