Skip to content

Commit

Permalink
Actualizacion 10
Browse files Browse the repository at this point in the history
  • Loading branch information
UserTrilceUCV committed Feb 12, 2019
1 parent bf8e265 commit def6910
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 61 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file modified .idea/caches/gradle_models.ser
Binary file not shown.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dependencies {
implementation 'de.hdodenhof:circleimageview:2.2.0' //Imagen Circular
implementation 'com.github.bumptech.glide:glide:4.8.0' //Recortar Imagen Descargar Imagen
implementation 'com.kbeanie:multipicker:1.5'
implementation 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'
testImplementation 'junit:junit:4.12'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@

import com.bumptech.glide.Glide;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import piazzoli.kevin.com.firebasechat.Entidades.Logica.LMensaje;
import piazzoli.kevin.com.firebasechat.Entidades.Logica.LUsuario;
import piazzoli.kevin.com.firebasechat.Holder.MensajeriaHolder;
import piazzoli.kevin.com.firebasechat.Persistencia.UsuarioDAO;
import piazzoli.kevin.com.firebasechat.R;

/**
Expand Down Expand Up @@ -46,8 +45,13 @@ public void actualizarMensaje(int posicion,LMensaje lMensaje){

@Override
public MensajeriaHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(c).inflate(R.layout.card_view_mensajes,parent,false);
return new MensajeriaHolder(v);
View view;
if(viewType==1){
view = LayoutInflater.from(c).inflate(R.layout.card_view_mensajes_emisor,parent,false);
}else{
view = LayoutInflater.from(c).inflate(R.layout.card_view_mensajes_receptor,parent,false);
}
return new MensajeriaHolder(view);
}

@Override
Expand Down Expand Up @@ -80,4 +84,17 @@ public int getItemCount() {
return listMensaje.size();
}

@Override
public int getItemViewType(int position) {
if(listMensaje.get(position).getlUsuario()!=null){
if(listMensaje.get(position).getlUsuario().getKey().equals(UsuarioDAO.getInstancia().getKeyUsuario())){
return 1;
}else{
return -1;
}
}else{
return -1;
}
//return super.getItemViewType(position);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package piazzoli.kevin.com.firebasechat.Entidades.Logica;

import org.ocpsoft.prettytime.PrettyTime;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
Expand Down Expand Up @@ -50,7 +52,11 @@ public void setlUsuario(LUsuario lUsuario) {

public String fechaDeCreacionDelMensaje(){
Date date = new Date(getCreatedTimestampLong());
PrettyTime prettyTime = new PrettyTime(new Date(),Locale.getDefault());
return prettyTime.format(date);
/*Date date = new Date(getCreatedTimestampLong());
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss a", Locale.getDefault());//a pm o am
return sdf.format(date);
return sdf.format(date);*/
}

}
56 changes: 0 additions & 56 deletions app/src/main/res/layout/card_view_mensajes.xml

This file was deleted.

94 changes: 94 additions & 0 deletions app/src/main/res/layout/card_view_mensajes_emisor.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="2sp">

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

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2">
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">

<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
cardview:cardCornerRadius="10sp"
cardview:cardBackgroundColor="#3F51B5"
cardview:contentPadding="5sp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/horaMensaje"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00:00"
android:textColor="#ffffff"
android:textStyle="italic"/>
<TextView
android:id="@+id/nombreMensaje"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kevin"
android:layout_weight="1"
android:textColor="#ffffff"
android:textStyle="bold"
android:gravity="end"/>
</LinearLayout>
<TextView
android:visibility="visible"
android:id="@+id/mensajeMensaje"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hola bienvenido"
android:textColor="#ffffff"
android:gravity="end"/>
<ImageView
android:id="@+id/mensajeFoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:adjustViewBounds="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5sp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/fotoPerfilMensaje"
android:layout_width="24sp"
android:layout_height="24sp"
android:src="@mipmap/ic_launcher"
/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>

</LinearLayout>

</LinearLayout>

</LinearLayout>
91 changes: 91 additions & 0 deletions app/src/main/res/layout/card_view_mensajes_receptor.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="2sp">

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

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">

<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
cardview:cardCornerRadius="10sp"
cardview:cardBackgroundColor="#4CAF50"
cardview:contentPadding="5sp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5sp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/fotoPerfilMensaje"
android:layout_width="24sp"
android:layout_height="24sp"
android:src="@mipmap/ic_launcher"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/nombreMensaje"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kevin"
android:layout_weight="1"
android:textColor="#ffffff"
android:textStyle="bold"/>
<TextView
android:id="@+id/horaMensaje"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00:00"
android:textColor="#ffffff"
android:textStyle="italic"/>
</LinearLayout>
<TextView
android:visibility="gone"
android:id="@+id/mensajeMensaje"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hola bienvenido"
android:textColor="#ffffff"/>
<ImageView
android:id="@+id/mensajeFoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:adjustViewBounds="true"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2">
</LinearLayout>

</LinearLayout>

</LinearLayout>

0 comments on commit def6910

Please sign in to comment.