Skip to content

Instantly share code, notes, and snippets.

@gvr23
gvr23 / fragmentDialogFullScreen.java
Last active July 31, 2018 07:17
Create a Dialog Fragment Full Screen
ANDROID
THIS IS THE ACTIVITY CLASS
=============================================================================================================================
public class AyudaEntelDialog extends android.support.v4.app.DialogFragment{
private ImageView ivExit;
private VideoView vvTutorial;
private View rootView;
@gvr23
gvr23 / DynamicFragment.java
Created December 28, 2017 15:55
Dynamic DialogFragment
ANDROID
THIS IS THE ACTIVITY CLASS
=============================================================================================================================
public class MensajeErrorDialog extends DialogFragment implements View.OnClickListener {
public final static int TIPO_NORMAL = 1;
public final static int TIPO_PREGUNTA = 2;
private String titulo, mensaje;
@gvr23
gvr23 / reiniciarTimer.java
Last active December 28, 2017 16:04
For restarting in an idle situation
ANDROID
===============================================================================================================================
protected void reiniciarTimer(){
cancelarTimer();
timer = new Timer();
TimerTask timerTask = new TimerTask() {
@Override
public void run() {
irPantalla(PromocionesActivity.class);
@gvr23
gvr23 / PlayVideo.java
Last active December 28, 2017 17:48
play a video without showing you and error if its longer than usual
ANDROID
===============================================================================================================================
protected void playVideo(String videoPath, VideoView vv){
try{
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
vv.setVideoPath(videoPath);
vv.start();
vv.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
@gvr23
gvr23 / spannableString.java
Created December 29, 2017 16:10
part of a text being bold and clicked and edittext stay on to of keyboard and auto suggestions
ANDROID
=================================================================================================================================
SpannableString ss = new SpannableString(getResources().getString(R.string.politicaContrato));
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(View textView){
reiniciarTimer();
terminosCondicionesDialog = TerminosCondicionesDialog.newInstance(terminosCondicionesResponse);
terminosCondicionesDialog.show(getSupportFragmentManager(), "terminoCondiciones");
@gvr23
gvr23 / inflaLinear.java
Created January 13, 2018 01:53
Manera antigua de inflar un LinearLayout
ANDROID
================================================================================================================================
private void insertarRowDocumento(final DocumentoBean document) {
if (document != null) {
LinearLayout nuevoParticipante = new LinearLayout(getContext());
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(LAYOUT_INFLATER_SERVICE);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
View rootView = inflater.inflate(R.layout.document_row, null);
@gvr23
gvr23 / intent.java
Created January 13, 2018 01:59
maneras de como enviar data consreializable
ANDROID
==================================================================================================================================
código para enviar un intent y estar a la espera de su regreso
==================================================================================================================================
Intent intent = new Intent(getContext(), DocumentoClienteActivity.class);
startActivityForResult(intent, DOCUMENT_CODE);
==================================================================================================================================
código para enviar de regreso el objeto
==================================================================================================================================
@gvr23
gvr23 / toolbar.java
Created January 13, 2018 02:01
manera para setear un toolbar
ANDROID
===================================================================================================================================
setSupportActionBar(tbDocumento);
ActionBar actBar = getSupportActionBar();
if (actBar != null) {
actBar.setDisplayHomeAsUpEnabled(true);
actBar.setIcon(R.drawable.ic_shopping_cart);
actBar.setHomeAsUpIndicator(R.drawable.ic_arrow_back);
actBar.setTitle("Editar Documento");
@gvr23
gvr23 / tabs.java
Created January 13, 2018 02:08
setear tabs en un activity
ANDROID
===================================================================================================================================
viewpager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager(), getBaseContext()));
slidingTabs.setupWithViewPager(viewpager);
===================================================================================================================================
xml
===================================================================================================================================
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
ANDROID
===================================================================================================================================
ADAPTER
===================================================================================================================================
public class DocumentAdapter extends RecyclerView.Adapter<DocumentAdapter.ViewHolder>{
private List<DocumentoBean> items;
public DocumentAdapter(List<DocumentoBean> items){