Anonymní profil Pavel – Programujte.com
 x   TIP: Přetáhni ikonu na hlavní panel pro připnutí webu

Anonymní profil Pavel – Programujte.comAnonymní profil Pavel – Programujte.com

 

Příspěvky odeslané z IP adresy 194.12.44.–

Jirka
HTML / XHTML › značky návratu hreflang
12. 8. 2015   #204285

Mám vicejazyčný web a google mi na search consol  hlásí u jednotlivých jazykových verzí hlásí "žádné značky návratu" . Je to nenastavený x-default ?  Příklad ze sitemap:

  <url>
    <loc>http://www.veselypenzion.cz/index.php</loc> 
    <xhtml:link rel="alternate" hreflang="cs" rel="nofollow" href="http://www.m.veselypenzion.cz/index.php" media="only screen and (max-width: 640px)" /> 
    <xhtml:link rel="alternate" hreflang="cs" rel="nofollow" href="http://www.veselypenzion.cz/index.php"   media="only screen and (min-width: 641px)"/>
    <xhtml:link rel="alternate" hreflang="en" rel="nofollow" href="http://www.veselypenzion.cz/EN/index.php" />
    <xhtml:link rel="alternate" hreflang="pl" rel="nofollow" href="http://www.veselypenzion.cz/PL/index.php" />
    <xhtml:link rel="alternate" hreflang="de" rel="nofollow" href="http://veselypenzion.de/index.php" />
    <lastmod>2014-08-28</lastmod>
    <changefreq>weekly</changefreq>
    <priority>1.0</priority>
  </url>

Děkuji za pomoc. Jirka

Honza
Java › Android SQLite posloupnost p…
10. 8. 2015   #204187

Omlouvám se poslal jsem špatný kód k prvnímu:

Update GUEST_TYPE_DAYS= x, GUEST_TYPE_ALL_PRICE= GUEST_TYPE_DAYS*GUEST_TYPE_PERSONS WHERE ...
Honza
Java › Android SQLite posloupnost p…
10. 8. 2015   #204186

Jdou tyto dva query sloučit?

String Query="UPDATE "+GUEST_PAYMENT_TABLE+" SET " + GUEST_TYPE_DAYS+"="+GUEST_TYPE_DAYS+"+1" 
					+ " WHERE " + PAYMENT_ID + "='" + paymentID + "'";
			String Query="UPDATE "+GUEST_PAYMENT_TABLE+" SET "
					+ GUEST_TYPE_ALL_PRICE+"= ( " + GUEST_TYPE_DAY_PRICE + " + " + GUEST_TYPE_FEE+") * " + GUEST_TYPE_DAYS + " * " + GUEST_TYPE_DAYS 
					+ " WHERE " + PAYMENT_ID + "='" + paymentID + "'";'" + paymentID + "'";
Update GUEST_TYPE_DAYS= ...., GUEST_TYPE_ALL_PRICE= ..... WHERE ...
Honza
Java › Přečtení generického typu.
29. 7. 2015   #203877

Tak jsem to vyřešil že třída pracuje pouze s indexy prvků a  poté zavolá metodu v adaptéru aby je tam přehodila tam a vykreslila. Nicméně díky :)

Honza
Java › Přečtení generického typu.
29. 7. 2015   #203876

Popis problému ještě jednou: Mám třídu CustomListView, které dědí z ListView. Rád bych udělal něco takového: dané třídě dám ArrayList<?> s daty potřebnými k vykreslení ListView, když bude uživatel přehazovat položky v seznamu, tak ona třída přehodí pouze prvky v arraylistu, s obsahem arraylistu vůbec nepracuje. poté pošle daný ArrayList<?> s daty do příslušného adaptéru, kde se data převedou na klasický např.: ArrayList<MenuItem> 

Honza
Java › Přečtení generického typu.
29. 7. 2015   #203871

Mám univerzální třídu pro DragNdrop listview. Chci jí udělat univerzální aby se dala použít pro veškeré typy Adapterů, nezáleží na tom, co zobrazují. Jsem trochu začátečník v generických typech. 

Třída, které nese informace pro konkrétní Adapter zobrazující se v ListView.

public class CategoryItem {
	
	public String name;
	public long categoryID;
	
	public CategoryItem(long categoryID, String name) {
		this.name = name;
		this.categoryID = categoryID;
	}

}

nebo například: 

public class OfferItem {

	public long ID;
	public String name;
	public int price;
	public int DPH;
	public long categoryID;

	public OfferItem(long ID, String name, int price, int DPH, long categoryID) {
		this.ID=ID;
		this.name=name;
		this.price=price;
		this.DPH=DPH;
		this.categoryID=categoryID;
	}

}

trochu upravené třída z GoogleDev pro DragNDrop listView, chtěl bych jí udělat univerzální, nezáleží na třídě s daty.

/*
 * Copyright (C) 2013 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/…/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.wesikprograming.cisnik.database;

import Interfaces.InterUpdate;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;

import java.util.ArrayList;

import com.wesikprograming.cisnik.customedatatypes.CategoryItem;
import com.wesikprograming.cisnik.listViewAdapters.CategoryAdapter;

/**
 * The dynamic listview is an extension of listview that supports cell dragging
 * and swapping.
 *
 * This layout is in charge of positioning the hover cell in the correct location
 * on the screen in response to user touch events. It uses the position of the
 * hover cell to determine when two cells should be swapped. If two cells should
 * be swapped, all the corresponding data set and layout changes are handled here.
 *
 * If no cell is selected, all the touch events are passed down to the listview
 * and behave normally. If one of the items in the listview experiences a
 * long press event, the contents of its current visible state are captured as
 * a bitmap and its visibility is set to INVISIBLE. A hover cell is then created and
 * added to this layout as an overlaying BitmapDrawable above the listview. Once the
 * hover cell is translated some distance to signify an item swap, a data set change
 * accompanied by animation takes place. When the user releases the hover cell,
 * it animates into its corresponding position in the listview.
 *
 * When the hover cell is either above or below the bounds of the listview, this
 * listview also scrolls on its own so as to reveal additional content.
 * @param <T>
 */
public class DynamicListView<T> extends ListView {
	
	private final String tag = "DynamicListView";

    private final int SMOOTH_SCROLL_AMOUNT_AT_EDGE = 15;
    private final int MOVE_DURATION = 150;
    private final int LINE_THICKNESS = 15;

    public ArrayList<T> mCheeseList;

    private int mLastEventY = -1;

    private int mDownY = -1;
    private int mDownX = -1;

    private int mTotalOffset = 0;

    private boolean mCellIsMobile = false;
    private boolean mIsMobileScrolling = false;
    private int mSmoothScrollAmountAtEdge = 0;

    private final int INVALID_ID = -1;
    private long mAboveItemId = INVALID_ID;
    private long mMobileItemId = INVALID_ID;
    private long mBelowItemId = INVALID_ID;

    private BitmapDrawable mHoverCell;
    private Rect mHoverCellCurrentBounds;
    private Rect mHoverCellOriginalBounds;

    private final int INVALID_POINTER_ID = -1;
    private int mActivePointerId = INVALID_POINTER_ID;

    private boolean mIsWaitingForScrollFinish = false;
    private int mScrollState = OnScrollListener.SCROLL_STATE_IDLE;

    public DynamicListView(Context context) {
        super(context);
        init(context);
    }

    public DynamicListView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(context);
    }

    public DynamicListView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public void init(Context context) {
        setOnItemLongClickListener(mOnItemLongClickListener);
        setOnScrollListener(mScrollListener);
        DisplayMetrics metrics = context.getResources().getDisplayMetrics();
        mSmoothScrollAmountAtEdge = (int)(SMOOTH_SCROLL_AMOUNT_AT_EDGE / metrics.density);
    }

    /**
     * Listens for long clicks on any items in the listview. When a cell has
     * been selected, the hover cell is created and set up.
     */
    private AdapterView.OnItemLongClickListener mOnItemLongClickListener =
            new AdapterView.OnItemLongClickListener() {
                public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int pos, long id) {
                    mTotalOffset = 0;

                    int position = pointToPosition(mDownX, mDownY);
                    int itemNum = position - getFirstVisiblePosition();

                    View selectedView = getChildAt(itemNum);
                    mMobileItemId = getAdapter().getItemId(position);
                    mHoverCell = getAndAddHoverView(selectedView);
                    selectedView.setVisibility(INVISIBLE);

                    mCellIsMobile = true;

                    updateNeighborViewsForID(mMobileItemId);

                    return true;
                }
            };

    /**
     * Creates the hover cell with the appropriate bitmap and of appropriate
     * size. The hover cell's BitmapDrawable is drawn on top of the bitmap every
     * single time an invalidate call is made.
     */
    private BitmapDrawable getAndAddHoverView(View v) {

        int w = v.getWidth();
        int h = v.getHeight();
        int top = v.getTop();
        int left = v.getLeft();

        Bitmap b = getBitmapWithBorder(v);

        BitmapDrawable drawable = new BitmapDrawable(getResources(), b);

        mHoverCellOriginalBounds = new Rect(left, top, left + w, top + h);
        mHoverCellCurrentBounds = new Rect(mHoverCellOriginalBounds);

        drawable.setBounds(mHoverCellCurrentBounds);

        return drawable;
    }

    /** Draws a black border over the screenshot of the view passed in. */
    private Bitmap getBitmapWithBorder(View v) {
        Bitmap bitmap = getBitmapFromView(v);
        Canvas can = new Canvas(bitmap);

        Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());

        Paint paint = new Paint();
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(LINE_THICKNESS);
        paint.setColor(Color.BLACK);

        can.drawBitmap(bitmap, 0, 0, null);
        can.drawRect(rect, paint);

        return bitmap;
    }

    /** Returns a bitmap showing a screenshot of the view passed in. */
    private Bitmap getBitmapFromView(View v) {
        Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas (bitmap);
        v.draw(canvas);
        return bitmap;
    }

    /**
     * Stores a reference to the views above and below the item currently
     * corresponding to the hover cell. It is important to note that if this
     * item is either at the top or bottom of the list, mAboveItemId or mBelowItemId
     * may be invalid.
     */
    private void updateNeighborViewsForID(long itemID) {
        int position = getPositionForID(itemID);
        CategoryAdapter adapter = ((CategoryAdapter)getAdapter());
        mAboveItemId = adapter.getItemId(position - 1);
        mBelowItemId = adapter.getItemId(position + 1);
    }

    /** Retrieves the view in the list corresponding to itemID */
    public View getViewForID (long itemID) {
        int firstVisiblePosition = getFirstVisiblePosition();
        CategoryAdapter adapter = ((CategoryAdapter)getAdapter());
        for(int i = 0; i < getChildCount(); i++) {
            View v = getChildAt(i);
            int position = firstVisiblePosition + i;
            long id = adapter.getItemId(position);
            if (id == itemID) {
                return v;
            }
        }
        return null;
    }

    /** Retrieves the position in the list corresponding to itemID */
    public int getPositionForID (long itemID) {
        View v = getViewForID(itemID);
        if (v == null) {
            return -1;
        } else {
            return getPositionForView(v);
        }
    }

    /**
     *  dispatchDraw gets invoked when all the child views are about to be drawn.
     *  By overriding this method, the hover cell (BitmapDrawable) can be drawn
     *  over the listview's items whenever the listview is redrawn.
     */
    @Override
    protected void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
        if (mHoverCell != null) {
            mHoverCell.draw(canvas);
        }
    }

    @Override
    public boolean onTouchEvent (MotionEvent event) {

        switch (event.getAction() & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_DOWN:
                mDownX = (int)event.getX();
                mDownY = (int)event.getY();
                mActivePointerId = event.getPointerId(0);
                break;
            case MotionEvent.ACTION_MOVE:
                if (mActivePointerId == INVALID_POINTER_ID) {
                    break;
                }

                int pointerIndex = event.findPointerIndex(mActivePointerId);

                mLastEventY = (int) event.getY(pointerIndex);
                int deltaY = mLastEventY - mDownY;

                if (mCellIsMobile) {
                    mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left,
                            mHoverCellOriginalBounds.top + deltaY + mTotalOffset);
                    mHoverCell.setBounds(mHoverCellCurrentBounds);
                    invalidate();

                    handleCellSwitch();

                    mIsMobileScrolling = false;
                    handleMobileCellScroll();

                    return false;
                }
                break;
            case MotionEvent.ACTION_UP:
                touchEventsEnded();
                break;
            case MotionEvent.ACTION_CANCEL:
                touchEventsCancelled();
                break;
            case MotionEvent.ACTION_POINTER_UP:
                /* If a multitouch event took place and the original touch dictating
                 * the movement of the hover cell has ended, then the dragging event
                 * ends and the hover cell is animated to its corresponding position
                 * in the listview. */
                pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >>
                        MotionEvent.ACTION_POINTER_INDEX_SHIFT;
                final int pointerId = event.getPointerId(pointerIndex);
                if (pointerId == mActivePointerId) {
                    touchEventsEnded();
                }
                break;
            default:
                break;
        }

        return super.onTouchEvent(event);
    }

    /**
     * This method determines whether the hover cell has been shifted far enough
     * to invoke a cell swap. If so, then the respective cell swap candidate is
     * determined and the data set is changed. Upon posting a notification of the
     * data set change, a layout is invoked to place the cells in the right place.
     * Using a ViewTreeObserver and a corresponding OnPreDrawListener, we can
     * offset the cell being swapped to where it previously was and then animate it to
     * its new position.
     */
    private void handleCellSwitch() {
        final int deltaY = mLastEventY - mDownY;
        int deltaYTotal = mHoverCellOriginalBounds.top + mTotalOffset + deltaY;

        View belowView = getViewForID(mBelowItemId);
        View mobileView = getViewForID(mMobileItemId);
        View aboveView = getViewForID(mAboveItemId);

        boolean isBelow = (belowView != null) && (deltaYTotal > belowView.getTop());
        boolean isAbove = (aboveView != null) && (deltaYTotal < aboveView.getTop());

        if (isBelow || isAbove) {

            final long switchItemID = isBelow ? mBelowItemId : mAboveItemId;
            View switchView = isBelow ? belowView : aboveView;
            final int originalItem = getPositionForView(mobileView);

            if (switchView == null) {
                updateNeighborViewsForID(mMobileItemId);
                return;
            }

            swapElements(mCheeseList, originalItem, getPositionForView(switchView));

            ((InterUpdate) getAdapter()).Update(mCheeseList);

            mDownY = mLastEventY;

            final int switchViewStartTop = switchView.getTop();

            mobileView.setVisibility(View.VISIBLE);
            switchView.setVisibility(View.INVISIBLE);

            updateNeighborViewsForID(mMobileItemId);

            final ViewTreeObserver observer = getViewTreeObserver();
            observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
                public boolean onPreDraw() {
                    observer.removeOnPreDrawListener(this);

                    View switchView = getViewForID(switchItemID);

                    mTotalOffset += deltaY;

                    int switchViewNewTop = switchView.getTop();
                    int delta = switchViewStartTop - switchViewNewTop;

                    switchView.setTranslationY(delta);

                    ObjectAnimator animator = ObjectAnimator.ofFloat(switchView,
                            View.TRANSLATION_Y, 0);
                    animator.setDuration(MOVE_DURATION);
                    animator.start();

                    return true;
                }
            });
        }
    }

    private <T> void swapElements(ArrayList<T> arrayList, int indexOne, int indexTwo) {
    	Log.e(tag, "swap");
    	
    	T temp = arrayList.get(indexOne);
        arrayList.set(indexOne, arrayList.get(indexTwo));
        arrayList.set(indexTwo, temp);
    }


    /**
     * Resets all the appropriate fields to a default state while also animating
     * the hover cell back to its correct location.
     */
    private void touchEventsEnded () {
        final View mobileView = getViewForID(mMobileItemId);
        if (mCellIsMobile|| mIsWaitingForScrollFinish) {
            mCellIsMobile = false;
            mIsWaitingForScrollFinish = false;
            mIsMobileScrolling = false;
            mActivePointerId = INVALID_POINTER_ID;

            // If the autoscroller has not completed scrolling, we need to wait for it to
            // finish in order to determine the final location of where the hover cell
            // should be animated to.
            if (mScrollState != OnScrollListener.SCROLL_STATE_IDLE) {
                mIsWaitingForScrollFinish = true;
                return;
            }

            mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, mobileView.getTop());

            ObjectAnimator hoverViewAnimator = ObjectAnimator.ofObject(mHoverCell, "bounds",
                    sBoundEvaluator, mHoverCellCurrentBounds);
            hoverViewAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    invalidate();
                }
            });
            hoverViewAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationStart(Animator animation) {
                    setEnabled(false);
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    mAboveItemId = INVALID_ID;
                    mMobileItemId = INVALID_ID;
                    mBelowItemId = INVALID_ID;
                    mobileView.setVisibility(VISIBLE);
                    mHoverCell = null;
                    setEnabled(true);
                    invalidate();
                }
            });
            hoverViewAnimator.start();
        } else {
            touchEventsCancelled();
        }
    }

    /**
     * Resets all the appropriate fields to a default state.
     */
    private void touchEventsCancelled () {
        View mobileView = getViewForID(mMobileItemId);
        if (mCellIsMobile) {
            mAboveItemId = INVALID_ID;
            mMobileItemId = INVALID_ID;
            mBelowItemId = INVALID_ID;
            mobileView.setVisibility(VISIBLE);
            mHoverCell = null;
            invalidate();
        }
        mCellIsMobile = false;
        mIsMobileScrolling = false;
        mActivePointerId = INVALID_POINTER_ID;
    }

    /**
     * This TypeEvaluator is used to animate the BitmapDrawable back to its
     * final location when the user lifts his finger by modifying the
     * BitmapDrawable's bounds.
     */
    private final static TypeEvaluator<Rect> sBoundEvaluator = new TypeEvaluator<Rect>() {
        public Rect evaluate(float fraction, Rect startValue, Rect endValue) {
            return new Rect(interpolate(startValue.left, endValue.left, fraction),
                    interpolate(startValue.top, endValue.top, fraction),
                    interpolate(startValue.right, endValue.right, fraction),
                    interpolate(startValue.bottom, endValue.bottom, fraction));
        }

        public int interpolate(int start, int end, float fraction) {
            return (int)(start + fraction * (end - start));
        }
    };

    /**
     *  Determines whether this listview is in a scrolling state invoked
     *  by the fact that the hover cell is out of the bounds of the listview;
     */
    private void handleMobileCellScroll() {
        mIsMobileScrolling = handleMobileCellScroll(mHoverCellCurrentBounds);
    }

    /**
     * This method is in charge of determining if the hover cell is above
     * or below the bounds of the listview. If so, the listview does an appropriate
     * upward or downward smooth scroll so as to reveal new items.
     */
    public boolean handleMobileCellScroll(Rect r) {
        int offset = computeVerticalScrollOffset();
        int height = getHeight();
        int extent = computeVerticalScrollExtent();
        int range = computeVerticalScrollRange();
        int hoverViewTop = r.top;
        int hoverHeight = r.height();

        if (hoverViewTop <= 0 && offset > 0) {
            smoothScrollBy(-mSmoothScrollAmountAtEdge, 0);
            return true;
        }

        if (hoverViewTop + hoverHeight >= height && (offset + extent) < range) {
            smoothScrollBy(mSmoothScrollAmountAtEdge, 0);
            return true;
        }

        return false;
    }

    public void setCheeseList(ArrayList<T> cheeseList) {
        mCheeseList = cheeseList;
    }

    /**
     * This scroll listener is added to the listview in order to handle cell swapping
     * when the cell is either at the top or bottom edge of the listview. If the hover
     * cell is at either edge of the listview, the listview will begin scrolling. As
     * scrolling takes place, the listview continuously checks if new cells became visible
     * and determines whether they are potential candidates for a cell swap.
     */
    private AbsListView.OnScrollListener mScrollListener = new AbsListView.OnScrollListener () {

        private int mPreviousFirstVisibleItem = -1;
        private int mPreviousVisibleItemCount = -1;
        private int mCurrentFirstVisibleItem;
        private int mCurrentVisibleItemCount;
        private int mCurrentScrollState;

        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
                             int totalItemCount) {
            mCurrentFirstVisibleItem = firstVisibleItem;
            mCurrentVisibleItemCount = visibleItemCount;

            mPreviousFirstVisibleItem = (mPreviousFirstVisibleItem == -1) ? mCurrentFirstVisibleItem
                    : mPreviousFirstVisibleItem;
            mPreviousVisibleItemCount = (mPreviousVisibleItemCount == -1) ? mCurrentVisibleItemCount
                    : mPreviousVisibleItemCount;

            checkAndHandleFirstVisibleCellChange();
            checkAndHandleLastVisibleCellChange();

            mPreviousFirstVisibleItem = mCurrentFirstVisibleItem;
            mPreviousVisibleItemCount = mCurrentVisibleItemCount;
        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            mCurrentScrollState = scrollState;
            mScrollState = scrollState;
            isScrollCompleted();
        }

        /**
         * This method is in charge of invoking 1 of 2 actions. Firstly, if the listview
         * is in a state of scrolling invoked by the hover cell being outside the bounds
         * of the listview, then this scrolling event is continued. Secondly, if the hover
         * cell has already been released, this invokes the animation for the hover cell
         * to return to its correct position after the listview has entered an idle scroll
         * state.
         */
        private void isScrollCompleted() {
            if (mCurrentVisibleItemCount > 0 && mCurrentScrollState == SCROLL_STATE_IDLE) {
                if (mCellIsMobile && mIsMobileScrolling) {
                    handleMobileCellScroll();
                } else if (mIsWaitingForScrollFinish) {
                    touchEventsEnded();
                }
            }
        }

        /**
         * Determines if the listview scrolled up enough to reveal a new cell at the
         * top of the list. If so, then the appropriate parameters are updated.
         */
        public void checkAndHandleFirstVisibleCellChange() {
            if (mCurrentFirstVisibleItem != mPreviousFirstVisibleItem) {
                if (mCellIsMobile && mMobileItemId != INVALID_ID) {
                    updateNeighborViewsForID(mMobileItemId);
                    handleCellSwitch();
                }
            }
        }

        /**
         * Determines if the listview scrolled down enough to reveal a new cell at the
         * bottom of the list. If so, then the appropriate parameters are updated.
         */
        public void checkAndHandleLastVisibleCellChange() {
            int currentLastVisibleItem = mCurrentFirstVisibleItem + mCurrentVisibleItemCount;
            int previousLastVisibleItem = mPreviousFirstVisibleItem + mPreviousVisibleItemCount;
            if (currentLastVisibleItem != previousLastVisibleItem) {
                if (mCellIsMobile && mMobileItemId != INVALID_ID) {
                    updateNeighborViewsForID(mMobileItemId);
                    handleCellSwitch();
                }
            }
        }
    };
}

A teď nastává problém potřebuji Generický typ překonvertovat zase do daného typu pro určitý adapter, abych s ním mohl pracovat?

Honza
Java › Custom navigation drawer ner…
27. 7. 2015   #203860

Teď jsem zkusil přidat pár listenerů a zdá se, že drawer vůbec neregistruje ani onTouch.

Honza
Java › Custom navigation drawer ner…
27. 7. 2015   #203858

dělám custom drawer., který obsahuje tlačítko a ExpandaleListView, drawer se normálně vysune, když je potřeba, ale tlačítko ani ListView nereagují na podměty. ListView nescroluje.

 drawer.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:clickable="true"
 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <!-- The toolbar -->

    <android.support.v4.widget.DrawerLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/a_drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <!-- drawer view -->

        <LinearLayout
            
            android:id="@+id/a_drawer_content"
            android:background="#FFF"
            android:orientation="vertical"
            android:layout_width="200dp"
            android:layout_height="match_parent"
            android:layout_gravity="left" >

            <!-- drawer content -->

            <ImageButton
                android:id="@+id/a_main_drawer_btn_add"
                android:layout_width="match_parent"
                android:layout_height="80dp"
                android:layout_marginBottom="5dp"
                android:background="@drawable/a_pay_all_button_category"
                android:shadowColor="#A8A8A8"
                android:shadowDx="0"
                android:shadowDy="0"
                android:shadowRadius="5"
                android:src="@drawable/ic_group_black_48dp"
                android:textColor="#FFFFFF"
                android:textSize="30sp" />

            <ExpandableListView
                android:id="@+id/a_main_lv_offer"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >
            </ExpandableListView>
        </LinearLayout>

        <!-- normal content view -->

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal" >

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#FFFFFF"
                android:orientation="vertical" >

                <Button
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:onClick="AddGuest"
                    android:text="@string/add_guest" />

                <ListView
                    android:id="@+id/list_view"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" >
                </ListView>
            </LinearLayout>

            <FrameLayout
                android:id="@+id/content_layout"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="3" >
            </FrameLayout>
        </LinearLayout>
    </android.support.v4.widget.DrawerLayout>

</LinearLayout>

ActivityMain

drawerLayout = (DrawerLayout) findViewById(R.id.a_drawer_layout);

		OfferListView = (ExpandableListView) findViewById(R.id.a_main_lv_offer);
		offerAdapter = new LeftPanelOfferAdapter(this, database);
		OfferListView.setAdapter(offerAdapter);

		ImageButton addItem = (ImageButton) findViewById(R.id.a_main_drawer_btn_add);
		addItem.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Toast.makeText(ActivityMain.this, "Nefunguje", Toast.LENGTH_LONG).show();
				
			}
		});
		
		
		drawerLayout.openDrawer(GravityCompat.START);
Honza
Java › Poslat dotaz na tisk: TCP Po…
22. 7. 2015   #203797

Dobrý den, potřeboval bych poradit jak v Androidu pošlu požadavek na tiskárnu po TCP Port 9100.

Můj pokus:

class SendPrint extends AsyncTask<String, String, String> {
	@Override
	protected String doInBackground(String... params) {
		Log.e("pritning", "start");

		// ///////////
		Socket socket = null;
		OutputStream output = null;
		BufferedReader reader = null;
		// /////////
		try {
			socket = new Socket("192.168.1.5", 9100);
			socket.setSoTimeout(5000);
			output = socket.getOutputStream();
			reader = new BufferedReader(new InputStreamReader(
					socket.getInputStream()));
		} catch (UnknownHostException | SocketException e) {
		} catch (IOException e) {
			Log.e("pritning", "catch");
			e.printStackTrace();
		}
		// ///////
		if (socket != null && output != null) {
			try {
				Log.e("pritning", "yes");
				String message = "asdasdasd";
				output.write(message.getBytes());
				output.flush();
				socket.shutdownOutput();

				String response = reader.readLine();

				System.out.println(response.toString());

				output.close();
				socket.close();
			} catch (Exception e) {
				System.out.println(e.toString());

			}
		}
		return "";
	}
}
Honza
MySQL › Kombinace SELECT ze dvou tab…
21. 7. 2015   #203766

Teď jsem prostudoval Inner Join a In. Každé slouží jinému účelu. Tvůj návrh byl lepší! 

Honza
MySQL › Kombinace SELECT ze dvou tab…
21. 7. 2015   #203765

Mě napadlo takové to řešení: 

SELECT GuestOrder.* FROM `GuestOrder` INNER JOIN Guests ON GuestOrder.GuestID = Guests.GuestID WHERE Guests.GuestDataArrival BETWEEN '2010-01-01' AND '2010-01-04'
Honza
MySQL › Kombinace SELECT ze dvou tab…
21. 7. 2015   #203762

Potřeboval bych zkombinovat tyto dva  selecty

SELECT GuestID FROM `Guests` WHERE `GuestDataArrival` BETWEEN '2010-01-01' AND '2010-01-04'
SELECT * FROM `GuestOrder` WHERE `GuestID`= viz první query
Honza
Java › Třídění podle názvu
12. 7. 2015   #203556

Mám ArrayList<String> se jmény ve tvaru:

test
test
test
pokus
pokus
pokus
test
pokus

potřeboval bych dostat něco ve tvaru:

test_1
test_2
test_3
pokus_1
pokus_2
pokus_3
test_4
pokus_4
Honza
Java › SQLite srovnat tabulku podle…
2. 7. 2015   #203404

Potřeboval bych v SQLite srovnat tabulku podle INTEGER sloupce? určitě to jde napsat pouze v SQLite a nepožívat Javu!

př: uživatel provádí různé akce a poté, co skončí, se vše setřídí.

SQLiteDatabase database = this.getWritableDatabase();
		ArrayList<OrderItem> guestOrder=getGuestOrder(guestID);
		
		
		Collections.sort(guestOrder, new Comparator<OrderItem>() {
	        @Override 
	        public int compare(OrderItem p1, OrderItem p2) {
	            return p2.count - p1.count; 
	        }

	    });
		
		database.execSQL("delete from "+ ORDER_TABLE + " WHERE "+GUEST_ID+" ='"+ guestID +"'");	//empty table
		
		for(OrderItem x : guestOrder){	//add sorted data
			ContentValues values = new ContentValues();
			values.put(ITEM_NAME, x.name);
			values.put(ITEM_PRICE, x.price);
			values.put(ITEM_COUNT, x.count);
			values.put(GUEST_ID, guestID);
			database.insert(ORDER_TABLE, null, values);
		}
Tom
CSS › drop-down menu float: right
1. 7. 2015   #203372

Mám víceúrovňové menu, ale když mu dám float:right přestanou fungovat víceúrovňové tlačítka, menu se sice zobrazí, ale když na něj najedu myší ztratí se!

CSS 

.nav{
	font-family: 'PT Sans', sans-serif;
	
	box-shadow: 		0 1px 6px rgba(0,0,0,0.3);
	-moz-box-shadow:    0 1px 6px rgba(0,0,0,0.3);
  	-webkit-box-shadow: 0 1px 6px rgba(0,0,0,0.3);
  	text-transform: uppercase;
  	background-color: white;
	
	
	width: 100%;
	height:70px;
	padding: 0;
	line-height: 70px;
	vertical-align: middle;
}

.nav  ul {
	float: right;;
	list-style: none;
	text-align: center;
	padding: 0;
	margin: 0;
	
}

.nav > ul > li {
	
	width: 120px;
	border-bottom: none;
	height: inherit;
	font-size: 1.4em;
	
	display: inline-block;
		
  
	font-family: 'Oswald', sans-serif;
	font-size: 1.2em;

}

.nav a {
	
	text-decoration: none;
	color: black;
	display: block;
	transition: .3s background-color;
}

.nav > ul > li:hover {
	float:none;
	clear:both;
	background-color: #005f5f;
	border-bottom: 5px solid #ff0000;
}


.nav  > ul > li > ul{
	
	display: none;
	position: absolute;
	width: 100px;
} 

.nav  > ul > li:hover > ul{
	display: block;
} 

HTML

<nav class="nav">
	<ul>
		
		<li  class="<?php if($currentURL==="$root/test.php") 	echo "header-active"?>"><a href=<?php echo "$root/Index.php";?>>ÚVOD</a></li>
		<li  class="<?php if($currentURL==="$root/test.php") 	echo "header-active"?>">
			<a href=<?php echo "$root/Index.php";?>>kurzy</a>
			<ul>
	        	<li ><a href="#">test</a></li>
	        	<li ><a href="#">test</a></li>
	        	<li ><a href="#">test</a></li>
			</ul>	
		</li>
		<li  class="<?php if($currentURL==="$root/test.php") 	echo "header-active"?>"><a href=<?php echo "$root/Index.php";?>>ÚVOD</a></li>
		<li  class="<?php if($currentURL==="$root/test.php") 	echo "header-active"?>"><a href=<?php echo "$root/Index.php";?>>ÚVOD</a></li>
		<li  class="<?php if($currentURL==="$root/test.php") 	echo "header-active"?>"><a href=<?php echo "$root/Index.php";?>>ÚVOD</a></li>
	</ul>
	
</nav>
Pavel
CSS › responsivní hlavička
17. 6. 2015   #203038

Potřeboval bych pomoci s responsivní hlavičkou. Takhle by měla vypadat: 

Připojen obrázek.

Popis: potřebuji udělat, aby se velikost hlavičky přizpůsobovala šířce, pokud by se jednalo o tablety některé části by úplně vypadly, u mobilních zařízeních by se nahradila úplně jinou hlavičkou

Už jsem se pokusil vyřešit problém, ale zdá se mi, že by se dal udělat i efektivněji. Hlavní problém mého návrhu je: poslední položka má řádkový zlom, celé menu není v jedné přímce. 


body {
	width:100%;
	background-image: url('TetaWeb/Images/Index/bg.png');
	color: #000305;
	font-size: 87.5%; /* Base font size: 14px */
	font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
	line-height: 1.429;
	margin: 0;
	padding: 0;
	text-align: left;
}


 /*===========================
 			HEAD
 =========================== */ 
 
 
 

.head{
	background-color: red;
	background: yellow;
	width:80%;
	margin: 0 auto;
	overflow: hidden;
}

.head-logo {
	float: left;
	position: relative;
	top: 20%;
	width: 10.35%;
	background-color: maroon;
	border-radius: 8px;
	-moz-border-radius: 8px;
	-webkit-border-radius: 8px;	
	padding: 0.5vw;
	text-align: center;

}

.head-logo a img{
	width:  90%;
	height: auto;
	display: block;
    margin-left: auto;
    margin-right: auto;
}

.head-pictures{
	vertical-align:top;
	float:left;
	margin-left:1.5vw;
}

.head-pictures img{
	width: 7.9vw;
	height: auto;
}

/*------------------- 
head-categoris 
------------------ */

.head-categoris{
	display:inline-block;
	vertical-align:top;
	
	position: relative;
	margin-left:1.5vw;
	top: 2vw;
}

.head-categories-company{
	background-color:green;
	display: inline-block;
	width: 3.64vw;
	height: 6.25vw;
	text-align: center;

}

.head-categories-school{
	background-color:green;
	display: inline-block;
	width: 3.64vw;
	height: 6.25vw;
	text-align: center;

}

.head-categories-adult{
	background-color:green;
	display: inline-block;
	width: 3.64vw;
	height: 6.25vw;
	text-align: center;

}

.head-categories-children{
	background-color:green;
	display: inline-block;
	width: 3.64vw;
	height: 6.25vw;
	text-align: center;
}

/*------------------- 
		menu 
------------------ */

.head-menu{
	background-color: white;
	position: absolute;
	margin-left: 1%;
	margin-top: -1%;
}

.head-menu ol{
	margin: 0;
	clear: left;
}
	
.head-menu ol li{
	display: inline;
	list-style: none;
	margin-left: 1%;
	
  	font-size: 15px;
  	font-weight: 400;
  	
}

.head-categories-menu-container{
	float: left;
	
}

@media only screen  and (max-width : 780px){

	
}

@media only screen  and (max-width : 500px){
	

}
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>


<link href="css/style-index.css" rel="stylesheet" type="text/css" />

</head>

<body>

	
	<div class="head">
	
		<div class="head-logo">
			<a href="myfile.htm"><img src="Images/Index/logo.gif"></a> 
			<p>OKO - vzdělávací a rozvojové centrum, o. s.</p>
		</div>
		
		<div class="head-categories-menu-container">
		
			<div class="head-pictures">
				<img alt="" src="Images/Index/index-head-picture.jpg">
				<img alt="" src="Images/Index/index-head-picture.jpg">
				<img alt="" src="Images/Index/index-head-picture.jpg">
			</div>
		
			
			<div class="head-categoris">
				<div class="head-categories-company">
					<p>školy</p>
				</div>
				<div class="head-categories-school">
					<p>školy</p>
				</div>
				<div class="head-categories-adult">
					<p>dospělí</p>
				</div>
				<div class="head-categories-children">
					<p>školy</p>
				</div>
			</div>
		
			<div class="head-menu">
				<ol>
					<li><a href="index.php">Úvod</a></li>
	  				<li><a href="kariera.php">Kariéra</a></li>
	  				<li><a href="bulletiny.php">Bulletiny</a></li>
	  				<li><a href="clanky.php">Aktuality</a></li>
	  				<li><a href="nasi_lektori.php">Náš tým</a></li>
	  				<li><a href="nasi_partneri.php">Naši partneři</a></li>
	  				<li><a href="reference.php">Reference</a></li>
	  				<li><a href="fotogalerie.php">Fotogalerie</a></li>
	  				<li><a href="kontakt.php">Kontakt</a></li>
				</ol>
			</div> 
		
		</div>
		
	</div>
</body>

</html>

 

 

Hostujeme u Českého hostingu       ISSN 1801-1586       ⇡ Nahoru Webtea.cz logo © 20032024 Programujte.com
Zasadilo a pěstuje Webtea.cz, šéfredaktor Lukáš Churý