Commit d46a267e authored by Adrien Béraud's avatar Adrien Béraud Committed by Sébastien Blin

remove uiupdater

Change-Id: I8c8391edb1e9f7e646d6750d58e8a2be4689c711
parent 5e018acf
......@@ -533,7 +533,6 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationViewHo
} else {
viewHolder.btnAccept.setOnClickListener(null);
viewHolder.btnRefuse.setOnClickListener(null);
viewHolder.updater = null;
}
} catch (IllegalStateException | NullPointerException e) {
Log.e(TAG, "Error initializing player, it may have already been released: " + e.getMessage());
......
package cx.ring.plugins.ButtonPreference;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
import cx.ring.R;
public class ButtonPreference extends Preference {
Context mContext;
Button mButton;
private String text = "";
public void setClickListener(View.OnClickListener clickListener) {
this.clickListener = clickListener;
}
private View.OnClickListener clickListener;
public ButtonPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
setLayoutResource(R.layout.single_button_preference);
}
public ButtonPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setLayoutResource(R.layout.single_button_preference);
}
public ButtonPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setLayoutResource(R.layout.single_button_preference);
}
public ButtonPreference(Context context) {
super(context);
mContext = context;
setLayoutResource(R.layout.single_button_preference);
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
mButton = (Button) holder.findViewById(R.id.button);
TextView titleView = ((TextView) holder.findViewById(R.id.title));
TextView summaryView = ((TextView) holder.findViewById(R.id.summary));
ImageView iconView = ((ImageView) holder.findViewById(R.id.icon));
CharSequence title = getTitle();
CharSequence summary = getSummary();
Drawable icon = this.getIcon();
if(title != null && title.length() > 0) {
titleView.setText(title);
} else {
titleView.setVisibility(View.GONE);
}
if(summary != null && summary.length() > 0) {
summaryView.setText(summary);
} else {
summaryView.setVisibility(View.GONE);
}
if(icon != null) {
iconView.setImageDrawable(icon);
} else {
iconView.setVisibility(View.GONE);
}
mButton.setText(getText());
if(clickListener != null) {
mButton.setOnClickListener(clickListener);
}
}
}
......@@ -593,7 +593,6 @@ public class TvConversationAdapter extends RecyclerView.Adapter<TvConversationVi
}));
} else {
viewHolder.btnAccept.setOnClickListener(null);
viewHolder.updater = null;
}
} catch (IllegalStateException | NullPointerException e) {
Log.e(TAG, "Error initializing player, it may have already been released: " + e.getMessage());
......@@ -672,7 +671,6 @@ public class TvConversationAdapter extends RecyclerView.Adapter<TvConversationVi
}
});
convViewHolder.mCid = textMessage.getConversation().getParticipant();
String message = textMessage.getBody().trim();
View longPressView = convViewHolder.itemView;
......@@ -838,7 +836,6 @@ public class TvConversationAdapter extends RecyclerView.Adapter<TvConversationVi
context.getString(R.string.notif_outgoing_call);
}
convViewHolder.mCid = call.getConversation().getParticipant();
convViewHolder.mIcon.setImageResource(pictureResID);
convViewHolder.mHistTxt.setText(historyTxt);
convViewHolder.mHistDetailTxt.setText(DateFormat.getDateTimeInstance()
......
......@@ -33,7 +33,6 @@ import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import cx.ring.R;
import cx.ring.utils.UiUpdater;
import io.reactivex.disposables.CompositeDisposable;
public class TvConversationViewHolder extends RecyclerView.ViewHolder {
......@@ -54,8 +53,6 @@ public class TvConversationViewHolder extends RecyclerView.ViewHolder {
public MediaPlayer player;
public TextureView video;
public Surface surface = null;
public String mCid;
public UiUpdater updater;
public LinearLayout mCallInfoLayout, mFileInfoLayout, mAudioInfoLayout;
public ValueAnimator animator;
......
package cx.ring.utils;
import android.os.Handler;
import android.os.Looper;
import net.jami.utils.Log;
public class UiUpdater {
private static final String TAG = UiUpdater.class.getSimpleName();
// Create a Handler that uses the Main Looper to run in
private final Handler mHandler = new Handler(Looper.getMainLooper());
private final Runnable mStatusChecker;
private final long UPDATE_INTERVAL;
public UiUpdater(final Runnable uiUpdater, long interval) {
UPDATE_INTERVAL = interval;
mStatusChecker = new Runnable() {
@Override
public void run() {
// Run the passed runnable
try {
uiUpdater.run();
// Re-run it after the update interval
mHandler.postDelayed(this, UPDATE_INTERVAL);
} catch (Exception e) {
Log.e(TAG, "Exception running task");
}
}
};
}
public UiUpdater(Runnable uiUpdater){
this(uiUpdater, 1000L);
}
/**
* Starts the periodical update routine (mStatusChecker
* adds the callback to the handler).
*/
public synchronized void start(){
mStatusChecker.run();
}
/**
* Stops the periodical update routine from running,
* by removing the callback.
*/
public synchronized void stop(){
mHandler.removeCallbacks(mStatusChecker);
}
}
......@@ -35,7 +35,6 @@ import android.widget.TextView;
import cx.ring.R;
import cx.ring.adapters.ConversationAdapter;
import cx.ring.utils.UiUpdater;
import io.reactivex.disposables.CompositeDisposable;
public class ConversationViewHolder extends RecyclerView.ViewHolder {
......@@ -58,7 +57,6 @@ public class ConversationViewHolder extends RecyclerView.ViewHolder {
public MediaPlayer player;
public TextureView video;
public Surface surface = null;
public UiUpdater updater;
public LinearLayout mCallInfoLayout, mFileInfoLayout, mAudioInfoLayout;
public ValueAnimator animator;
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/baseline_group_24" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="76dp"
android:layout_marginTop="16dp"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:text="@string/video_plugins"
android:textSize="16sp"
android:textAppearance="?android:attr/textAppearanceLarge"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@android:id/title"
android:layout_alignStart="@android:id/title"
android:layout_marginStart="76dp"
android:maxLines="4"
android:text="@string/video_plugins"
android:textSize="14sp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="Button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.495"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/summary" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment