This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.content.Context; | |
| import android.support.v4.view.ViewPager; | |
| import android.util.AttributeSet; | |
| import android.view.GestureDetector; | |
| import android.view.MotionEvent; | |
| import android.view.View; | |
| public class HeightWrappingViewPager extends ViewPager { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void avoidDoubleClicks(final View view) { | |
| final long DELAY_IN_MS = 900; | |
| if (!view.isClickable()) { | |
| return; | |
| } | |
| view.setClickable(false); | |
| view.postDelayed(new Runnable() { | |
| @Override | |
| public void run() { | |
| view.setClickable(true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.getChildAt(0); | |
| for (int i = 0; i < menuView.getChildCount(); i++) { | |
| final View iconView = menuView.getChildAt(i).findViewById(android.support.design.R.id.icon); | |
| final ViewGroup.LayoutParams layoutParams = iconView.getLayoutParams(); | |
| final DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); | |
| // set your height here | |
| layoutParams.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, displayMetrics); | |
| // set your width here | |
| layoutParams.width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, displayMetrics); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| upcommingPager.setOnTouchListener(new View.OnTouchListener() { | |
| float oldX = 0, newX = 0, sens = 5; | |
| @Override | |
| public boolean onTouch(View v, MotionEvent event) { | |
| switch (event.getAction()) { | |
| case MotionEvent.ACTION_DOWN: | |
| oldX = event.getX(); | |
| break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ClickableViewPager extends ViewPager { | |
| private OnItemClickListener mOnItemClickListener; | |
| public ClickableViewPager(Context context) { | |
| super(context); | |
| setup(); | |
| } | |
| public ClickableViewPager(Context context, AttributeSet attrs) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void startTimer() { | |
| countDownTimer= new CountDownTimer(300000, 1000) { | |
| public void onTick(long millisUntilFinished) { | |
| // long minutes = (milliseconds / 1000) / 60; | |
| long minutes = ((millisUntilFinished/1000) / 60) % 60; | |
| // long seconds = (milliseconds / 1000); | |
| long seconds = (millisUntilFinished/1000) % 60; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public String toJSON(){ | |
| JSONObject jsonObject= new JSONObject(); | |
| try { | |
| jsonObject.put("id", getIdProducto()); | |
| jsonObject.put("nombre", getNombre()); | |
| jsonObject.put("precio", getPrecio()); | |
| return jsonObject.toString(); | |
| } catch (JSONException e) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.annotation.SuppressLint; | |
| import android.content.Context; | |
| import android.content.res.Resources; | |
| import android.text.TextUtils; | |
| import android.widget.EditText; | |
| import java.io.ByteArrayOutputStream; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.io.UnsupportedEncodingException; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static final long DOUBLE_CLICK_TIME_DELTA = 300;//milliseconds | |
| long lastClickTime = 0;. | |
| /* In On CLick Method*/ | |
| long clickTime = System.currentTimeMillis(); | |
| if (clickTime - lastClickTime < DOUBLE_CLICK_TIME_DELTA){ | |
| //Your Logic inside on click | |
| lastClickTime = 0; |
NewerOlder