Search in sources :

Example 1 with Synthetic

use of io.github.hidroh.materialistic.annotation.Synthetic in project materialistic by hidroh.

the class StoryRecyclerViewAdapter method markAsViewed.

@Synthetic
void markAsViewed(int position) {
    if (position < 0) {
        return;
    }
    Item item = mItems != null && position < mItems.size() ? mItems.get(position) : null;
    if (item == null || !isItemAvailable(item) || item.isViewed()) {
        return;
    }
    mSessionManager.view(mContext, item.getId());
}
Also used : Item(io.github.hidroh.materialistic.data.Item) Synthetic(io.github.hidroh.materialistic.annotation.Synthetic)

Example 2 with Synthetic

use of io.github.hidroh.materialistic.annotation.Synthetic in project materialistic by hidroh.

the class NavFloatingActionButton method bindNavigationPad.

@Synthetic
void bindNavigationPad() {
    GestureDetectorCompat detectorCompat = new GestureDetectorCompat(getContext(), new GestureDetector.SimpleOnGestureListener() {

        @Override
        public boolean onDown(MotionEvent e) {
            return mNavigable != null;
        }

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            Toast.makeText(getContext(), R.string.hint_nav_short, Toast.LENGTH_LONG).show();
            return true;
        }

        @Override
        public boolean onDoubleTap(MotionEvent e) {
            trackKonami(DOUBLE_TAP);
            return super.onDoubleTap(e);
        }

        @Override
        public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent1, float velocityX, float velocityY) {
            int direction;
            if (Math.abs(velocityX) > Math.abs(velocityY)) {
                direction = velocityX < 0 ? Navigable.DIRECTION_LEFT : Navigable.DIRECTION_RIGHT;
            } else {
                direction = velocityY < 0 ? Navigable.DIRECTION_UP : Navigable.DIRECTION_DOWN;
            }
            mNavigable.onNavigate(direction);
            if (mVibrationEnabled) {
                mVibrator.vibrate(VIBRATE_DURATION_MS);
            }
            trackKonami(direction);
            return false;
        }

        @Override
        public void onLongPress(MotionEvent e) {
            if (mNavigable == null) {
                return;
            }
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
                Toast.makeText(getContext(), R.string.not_supported, Toast.LENGTH_SHORT).show();
            } else {
                startDrag(e.getX(), e.getY());
            }
        }
    });
    //noinspection Convert2Lambda
    super.setOnTouchListener(new OnTouchListener() {

        @SuppressLint("ClickableViewAccessibility")
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            return detectorCompat.onTouchEvent(motionEvent);
        }
    });
}
Also used : SuppressLint(android.annotation.SuppressLint) GestureDetector(android.view.GestureDetector) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) View(android.view.View) MotionEvent(android.view.MotionEvent) Synthetic(io.github.hidroh.materialistic.annotation.Synthetic)

Example 3 with Synthetic

use of io.github.hidroh.materialistic.annotation.Synthetic in project materialistic by hidroh.

the class SubmitActivity method onSubmitted.

@Synthetic
void onSubmitted(Boolean successful) {
    if (successful == null) {
        toggleControls(false);
        Toast.makeText(this, R.string.submit_failed, Toast.LENGTH_SHORT).show();
    } else if (successful) {
        Toast.makeText(this, R.string.submit_successful, Toast.LENGTH_SHORT).show();
        if (!isFinishing()) {
            Intent intent = new Intent(this, NewActivity.class);
            intent.putExtra(NewActivity.EXTRA_REFRESH, true);
            intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            // TODO should go to profile instead?
            startActivity(intent);
            finish();
        }
    } else if (!isFinishing()) {
        AppUtils.showLogin(this, mAlertDialogBuilder);
    }
}
Also used : Intent(android.content.Intent) Synthetic(io.github.hidroh.materialistic.annotation.Synthetic)

Example 4 with Synthetic

use of io.github.hidroh.materialistic.annotation.Synthetic in project materialistic by hidroh.

the class FavoriteRecyclerViewAdapter method dismiss.

@Synthetic
void dismiss(final int position) {
    final Favorite item = getItem(position);
    mSelected.put(position, item.getId());
    mFavoriteManager.remove(mContext, mSelected.values());
    Snackbar.make(mRecyclerView, R.string.toast_removed, Snackbar.LENGTH_LONG).setAction(R.string.undo, v -> {
        mPendingAdd = position;
        mFavoriteManager.add(mContext, item);
    }).show();
}
Also used : Favorite(io.github.hidroh.materialistic.data.Favorite) ComposeActivity(io.github.hidroh.materialistic.ComposeActivity) Context(android.content.Context) Favorite(io.github.hidroh.materialistic.data.Favorite) Intent(android.content.Intent) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) AppUtils(io.github.hidroh.materialistic.AppUtils) ArrayMap(android.support.v4.util.ArrayMap) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) Toast(android.widget.Toast) Menu(android.view.Menu) View(android.view.View) Canvas(android.graphics.Canvas) Synthetic(io.github.hidroh.materialistic.annotation.Synthetic) Build(android.os.Build) WeakReference(java.lang.ref.WeakReference) ActionMode(android.support.v7.view.ActionMode) ContextCompat(android.support.v4.content.ContextCompat) ViewGroup(android.view.ViewGroup) UserServices(io.github.hidroh.materialistic.accounts.UserServices) RecyclerView(android.support.v7.widget.RecyclerView) Gravity(android.view.Gravity) List(java.util.List) MenuTintDelegate(io.github.hidroh.materialistic.MenuTintDelegate) R(io.github.hidroh.materialistic.R) ItemManager(io.github.hidroh.materialistic.data.ItemManager) Snackbar(android.support.design.widget.Snackbar) Collections(java.util.Collections) Synthetic(io.github.hidroh.materialistic.annotation.Synthetic)

Aggregations

Synthetic (io.github.hidroh.materialistic.annotation.Synthetic)4 Intent (android.content.Intent)2 View (android.view.View)2 SuppressLint (android.annotation.SuppressLint)1 Context (android.content.Context)1 Canvas (android.graphics.Canvas)1 Build (android.os.Build)1 Snackbar (android.support.design.widget.Snackbar)1 ContextCompat (android.support.v4.content.ContextCompat)1 ArrayMap (android.support.v4.util.ArrayMap)1 GestureDetectorCompat (android.support.v4.view.GestureDetectorCompat)1 ActionMode (android.support.v7.view.ActionMode)1 RecyclerView (android.support.v7.widget.RecyclerView)1 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)1 GestureDetector (android.view.GestureDetector)1 Gravity (android.view.Gravity)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 MotionEvent (android.view.MotionEvent)1 ViewGroup (android.view.ViewGroup)1