use of dev.sagar.smsblocker.tech.beans.SMS in project SMSBlocker by sagarpawardev.
the class RVStarredSMSAdapter method itemRemoved.
public SMS itemRemoved(int position) {
final String methodName = "itemRemoved(int)";
log.justEntered(methodName);
final SMS sms = smses.remove(position);
notifyItemRemoved(position);
deleteHandler = new Handler();
deleteHandler.postDelayed(new Runnable() {
@Override
public void run() {
List<SMS> list = new ArrayList<>();
list.add(sms);
int count = inboxUtil.unstarSMSes(list);
}
}, TIMEOUT_TIME);
log.returning(methodName);
return sms;
}
use of dev.sagar.smsblocker.tech.beans.SMS in project SMSBlocker by sagarpawardev.
the class RVStarredSMSAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(SMSViewHolder holder, int position) {
final String methodName = "onBindViewHolder(SMSViewHolder, int)";
log.justEntered(methodName);
// Adi changes Start
holder.tvBody.setTypeface(myFont);
holder.tvFrom.setTypeface(myFont);
holder.tvTime.setTypeface(myFont);
// Adi changes End
SMS sms = smses.get(position);
String address = sms.getAddress();
Contact contact = null;
try {
contact = ContactUtilSingleton.getInstance().getContact(context, sms.getAddress());
} catch (ReadContactPermissionException e) {
e.printStackTrace();
}
String displayName = contact.getDisplayName();
if (displayName == null)
displayName = address;
long tm = sms.getDateTime();
String socialDate = DateUtilSingleton.getInstance().socialFormat(tm);
holder.tvTime.setText(socialDate);
holder.tvFrom.setText(displayName);
holder.tvBody.setText(sms.getBody());
// Setting User Image
Uri dpUri = contact.getPhotoThumbnail();
if (dpUri != null) {
holder.dpView.setPictureSrc(dpUri);
} else {
if (!displayName.equals(address)) {
String c = String.valueOf(displayName.charAt(0));
holder.dpView.setLetterText(c);
} else {
String str = context.getResources().getString(R.string.hash);
holder.dpView.setLetterText(str);
}
}
log.returning(methodName);
}
use of dev.sagar.smsblocker.tech.beans.SMS in project SMSBlocker by sagarpawardev.
the class RVThreadAdapter method copySelection.
public boolean copySelection() {
final String methodName = "copySelection()";
log.justEntered(methodName);
if (selectedSMSes.size() != 1) {
log.error(methodName, "Selected SMS are either greater or less than 1");
return false;
}
SMS sms = selectedSMSes.get(0);
SystemUtilSingleton systemUtil = SystemUtilSingleton.getInstance();
systemUtil.copy(context, sms);
log.returning(methodName);
return true;
}
use of dev.sagar.smsblocker.tech.beans.SMS in project SMSBlocker by sagarpawardev.
the class RVThreadAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final SMSViewHolder holder, int position) {
final String methodName = "onBindViewHolder()";
log.justEntered(methodName);
// Adi changes Start
Typeface myFont = Typeface.createFromAsset(context.getAssets(), "fonts/VarelaRound-Regular.ttf");
holder.tvBody.setTypeface(myFont);
holder.tvTime.setTypeface(myFont);
// Adi changes End
SMS sms = smses.get(position);
String body = sms.getBody();
long time = sms.getDateTime();
long type = sms.getType();
boolean isRead = sms.isRead();
String socialDate = DateUtilSingleton.getInstance().socialFormat(time);
boolean isReplySupported = sms.isReplySupported();
if (type == SMS.TYPE_QUEUED) {
holder.tvSending.setVisibility(View.VISIBLE);
} else {
holder.tvSending.setVisibility(View.GONE);
}
// If SMS is among saved SMS
log.debug(methodName, "Checking Saved SMS: " + sms.isSaved() + " id: " + sms.getId());
if (sms.isSaved()) {
holder.btnStar.setVisibility(View.VISIBLE);
// If marked for Unstar
if (markedForUnstar.contains(position)) {
holder.btnStar.setLiked(false);
} else {
holder.btnStar.setLiked(true);
}
} else {
holder.btnStar.setVisibility(View.GONE);
}
// If SMS is selected in RecyclerView
boolean isSelected = selectedSMSes.contains(sms);
setViewSelected(holder, isSelected);
holder.tvBody.setText(body);
holder.tvTime.setText(socialDate);
if (!replyNotSupportedTold && type == SMS.TYPE_RECEIVED && !isReplySupported) {
callback.onReplyNotSupported();
}
// Highlight Item if required
if (highlightPosition == position) {
int colorFrom = context.getResources().getColor(R.color.orangeA200, null);
int colorTo = context.getResources().getColor(R.color.transparent_light_grey, null);
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
// milliseconds
colorAnimation.setDuration(HIGHLIGHT_DURATION);
colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
holder.llParent.setBackgroundColor((int) animator.getAnimatedValue());
}
});
colorAnimation.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
final String methodName = "onAnimationStart()";
log.justEntered(methodName);
// Nothing here
log.returning(methodName);
}
@Override
public void onAnimationEnd(Animator animator) {
final String methodName = "onAnimationEnd()";
log.justEntered(methodName);
log.info(methodName, "Resetting Highlight animation");
resetHighlight();
log.returning(methodName);
}
@Override
public void onAnimationCancel(Animator animator) {
final String methodName = "onAnimationCancel()";
log.justEntered(methodName);
// Nothing here
log.returning(methodName);
}
@Override
public void onAnimationRepeat(Animator animator) {
final String methodName = "onAnimationRepeat()";
log.justEntered(methodName);
// Nothing here
log.returning(methodName);
}
});
colorAnimation.start();
}
log.returning(methodName);
}
use of dev.sagar.smsblocker.tech.beans.SMS in project SMSBlocker by sagarpawardev.
the class RVThreadAdapter method deleteSelections.
public boolean deleteSelections() {
final String methodName = "deleteSelections()";
log.justEntered(methodName);
log.error(methodName, "This can be improved");
log.info(methodName, "Selected SMS count: " + selectedSMSes.size());
for (SMS sms : selectedSMSes) {
log.debug(methodName, "Deleting SMS: " + sms.getBody());
// Delete SMS from database
inboxUtil.deleteSMS(sms);
// Delete SMS from UI
int position = selectedSMSes.indexOf(sms);
smses.remove(sms);
notifyItemRemoved(position);
}
selectedSMSes.clear();
log.returning(methodName);
return true;
}
Aggregations