Skip to content

Commit

Permalink
Fix a number of minor bugs and some ui changes (read description)
Browse files Browse the repository at this point in the history
Null check for context
try catch for draft deletes
show the svg like icon for comment likes.
Use the universal date parsing function
chekc null for result of drafts
add calender functions to add local offsets, subtract dates
  • Loading branch information
hispeedimagins committed Aug 2, 2018
1 parent f33d64b commit beb9c0c
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 29 deletions.
Expand Up @@ -45,6 +45,7 @@ class CommentsHelperFunctions(context : Context,username:String?,adapter: AllRec
val con: Context = context
var name:String? = username
val adaptedcomms: arvdinterface = adapter
var textColorMineTheme: Int = 0
val and = AndDown()
internal var scale: Float = scale
internal var metrics: DisplayMetrics = metrics
Expand All @@ -55,6 +56,11 @@ class CommentsHelperFunctions(context : Context,username:String?,adapter: AllRec
val sharedpref : SharedPreferences = context.getSharedPreferences(CentralConstants.sharedprefname,0)
name = sharedpref.getString(CentralConstants.username,null)
}
var attrs = intArrayOf(R.attr.textColorMine)
var ta = context.obtainStyledAttributes(attrs)
var textColorMineThemeint = ta.getResourceId(0, android.R.color.black)
ta.recycle()
textColorMineTheme = ContextCompat.getColor(con, textColorMineThemeint)
}

fun GetPx(dp : Float) : Int{
Expand Down Expand Up @@ -129,6 +135,11 @@ class CommentsHelperFunctions(context : Context,username:String?,adapter: AllRec
//holder.article_name?.text = "${holder.article?.author} (${StaticMethodsMisc.CalculateRepScore(holder.article?.authorreputation)})"
//holder.article_name?.text = "${holder.article?.author} (${holder.article?.authorreputation})"
holder.article_name?.text = holder.article?.displayName
if(holder.article?.followsYou!!){
holder.article_name?.setTextColor(ContextCompat.getColor(con, R.color.colorAccent))
} else{
holder.article_name?.setTextColor(textColorMineTheme)
}
holder.article_payout?.text = pay
//val d = Calendar.getInstance()
//d.time = holder.article?.createdcon
Expand Down
Expand Up @@ -152,7 +152,13 @@ class FeedHelperFunctions(context : Context,username:String?,adapter:AllRecycler
}
holder.article_likes?.text = holder.article?.netVotes.toString()
// holder.article_name?.text = "${holder.article?.author} (${StaticMethodsMisc.CalculateRepScore(holder.article?.authorreputation)})"

holder.article_name?.text = holder.article?.displayName
if(holder.article?.followsYou!!){
holder.article_name?.setTextColor(ContextCompat.getColor(con, R.color.colorAccent))
} else{
holder.article_name?.setTextColor(textColorMineTheme)
}
holder.article_name?.setOnClickListener(View.OnClickListener {
val i = Intent(con, OpenOtherGuyBlog::class.java)
i.putExtra(CentralConstants.OtherGuyNamePasser,holder.article?.author)
Expand Down
Expand Up @@ -124,11 +124,14 @@ class draftHelperFunctions (context : Context, username:String?, adapter: AllRec
alertDialogBuilder.setPositiveButton("ok", DialogInterface.OnClickListener{ diin, num ->
//vote.weight = numberPicker.value as Short
//if yes remove from db first
var db = drafts(con)
db.deleteContact(mholder?.article?.dbid)
try{
var db = drafts(con)
db.deleteContact(mholder?.article?.dbid)
adaptedcomms?.removeAt(position)
} catch (ex:Exception){
adaptedcomms?.notifydatachanged()
}

//then remove from the adapter
adaptedcomms?.removeAt(position)
})

alertDialogBuilder.setNegativeButton("No", DialogInterface.OnClickListener { diin, num ->
Expand Down
Expand Up @@ -1091,7 +1091,11 @@ public String signMessage(Sha256Hash messageHash, @Nullable KeyParameter aesKey)
}
if (recId == -1)
throw new RuntimeException("Could not construct a recoverable key. This should never happen.");
int headerByte = recId + 27 + (isCompressed() ? 4 : 0);
//int headerByte = recId + 27 + (isCompressed() ? 4 : 0);
//change later added on 23/7/2018 22:23 top is real
Log.d("iscompressed",String.valueOf( isCompressed()));

int headerByte = recId + 0 + 27;
byte[] sigData = new byte[65]; // 1 header + 32 bytes for R + 32 bytes
// for S
sigData[0] = (byte) headerByte;
Expand Down
Expand Up @@ -124,7 +124,7 @@ class FeedArticleDataHolder {
val app: String?, //steemit/0.1
val format: String?, //markdown

val pending_payout_value : String?,
var pending_payout_value : String?,
val total_pending_payout_value : String?,
var uservoted : Boolean?,
val authorreputation :String?,
Expand All @@ -137,7 +137,8 @@ class FeedArticleDataHolder {
var displayName:String = "",
var rootAuthor: String? = null,
var rootPermlink: String? = null,
var date:Date? = null
var date:Date? = null,
var followsYou:Boolean = false
)/*: Parcelable{

constructor(parcel: Parcel) : this(
Expand Down Expand Up @@ -273,7 +274,7 @@ class FeedArticleDataHolder {
val app: String?, //steemit/0.1
val format: String?, //markdown

val pending_payout_value : String?,
var pending_payout_value : String?,
val total_pending_payout_value : String?,
var uservoted : Boolean?,
val authorreputation :String?,
Expand All @@ -292,7 +293,8 @@ class FeedArticleDataHolder {
var rootAuthor: String?,
var rootPermlink: String?,
var highlightThis:Boolean = false,
var date:Date? = null
var date:Date? = null,
var followsYou:Boolean = false
)/*: Parcelable{
constructor(parcel: Parcel) : this(
parcel.createStringArrayList(),
Expand Down
Expand Up @@ -402,6 +402,11 @@ class ArticleFragment : Fragment() , GlobalInterface {
holder.article_likes?.text = holder.article?.netVotes.toString()
//holder.article_name?.text = holder.article?.author
holder.article_name?.text = "${holder.article?.author} (${StaticMethodsMisc.CalculateRepScore(holder.article?.authorreputation)})"
if(holder.article?.followsYou!!){
holder.article_name?.setTextColor(ContextCompat.getColor(context!!, R.color.colorAccent))
} else{
holder.article_name?.setTextColor(texcolormine!!)
}
holder.article_payout?.text = pay
//val d = Calendar.getInstance()
//d.time = holder.article?.createdcon
Expand Down
Expand Up @@ -497,7 +497,8 @@ class FeedFragment : Fragment() {
}

fun addMoreItems(response:JSONObject,nametouse:String){
val con = JsonRpcResultConversion(response,nametouse as String, TypeOfRequest.blog,context as Context)
if (context == null) return
val con = JsonRpcResultConversion(response,nametouse as String, TypeOfRequest.blog,context!!)
//con.ParseJsonBlog()
val result = con.ParseJsonBlogMore()
//val result = gson.fromJson<feed.FeedMoreItems>(response.toString(),feed.FeedMoreItems::class.java)
Expand All @@ -512,7 +513,8 @@ class FeedFragment : Fragment() {
}

fun addItems(response:JSONObject,nametouse:String){
val con = JsonRpcResultConversion(response,nametouse as String,TypeOfRequest.feed,context as Context)
if (context == null) return
val con = JsonRpcResultConversion(response,nametouse,TypeOfRequest.feed,context!!)
//con.ParseJsonBlog()
val result = con.ParseJsonBlog()
//val result = gson.fromJson<List<feed.FeedData>>(response.toString(),collectionType)
Expand Down
Expand Up @@ -200,9 +200,9 @@ class WritePost : Fragment() {
if(dbid != dbcom){
var dr = drafts(context as Context)
var ops = dr.Get(dbid?.toInt())
EditTextMainOne?.setText(ops.title)
EditTextMainTwo?.setText(ops.tags)
EditTextMainThree?.setText(ops.content)
EditTextMainOne?.setText(ops?.title)
EditTextMainTwo?.setText(ops?.tags)
EditTextMainThree?.setText(ops?.content)
}
/*cardviewOne = v.findViewById(R.id.cardviewOne) as CardView
cardviewTwo = v.findViewById(R.id.cardviewTwo) as CardView
Expand Down
Expand Up @@ -199,7 +199,7 @@ class upvotesFragment : Fragment() {
x.namewithrep = "${x.voter} (${StaticMethodsMisc.CalculateRepScore(x.reputation)})"
x.calculatedpercent = "Vote percent :"+ ((x.percent as String).toInt() / 100).toString()
x.calculatedvotepercent = "Vote power :"+ ((x.weight as String).toInt() / 100).toString()
var du = DateUtils.getRelativeDateTimeString(context,(SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss").parse(x.time)).time, DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS,0)
var du = DateUtils.getRelativeDateTimeString(context,StaticMethodsMisc.FormatDateGmt(x.time).time, DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS,0)
x.dateString = du.toString()

x.calculatedrshares = StaticMethodsMisc.FormatVotingValueToSBD(StaticMethodsMisc.VotingValueSteemToSd(StaticMethodsMisc.CalculateVotingValueRshares(x.rshares)))
Expand Down
Expand Up @@ -9,16 +9,17 @@ import java.util.*
* Created by boot on 2/6/2018.
*/
class calendarcalculations {
private var calendarForData: Calendar? = null
private var calendarForNow: Calendar? = null
var calendarForData: Calendar? = null
var calendarForNow: Calendar? = null
internal var timeZone: TimeZone? = null
internal var offset: Int = 0
init {

calendarForNow = Calendar.getInstance()
//timeZone = calendarForNow.getTimeZone();
calendarForNow?.timeZone = TimeZone.getTimeZone("GMT")
timeZone = TimeZone.getTimeZone("GMT")
calendarForNow?.timeZone = timeZone

//timeZone = TimeZone.getDefault()

offset = TimeZone.getDefault().getOffset(Date().time)
Expand All @@ -28,11 +29,22 @@ class calendarcalculations {
}

fun getGmtToNormal():Calendar?{

//var bc = Date(calendarForData?.timeInMillis!!)
calendarForData?.add(Calendar.MILLISECOND,offset)
calendarForData?.timeZone = TimeZone.getDefault()
//var ad = Date(calendarForData?.timeInMillis!!)

return calendarForData
}

fun getGmtToNormal(calender:Calendar?):Calendar?{
//var bc = Date(calendarForData?.timeInMillis!!)
calender?.add(Calendar.MILLISECOND,offset)
calender?.timeZone = TimeZone.getDefault()
//var ad = Date(calendarForData?.timeInMillis!!)

return calender
}
/*public calendarcalculations(Date datefdata){
offset = TimeZone.getDefault().getOffset(new Date().getTime());
calendarForData = new GregorianCalendar(timeZone);
Expand All @@ -59,16 +71,38 @@ class calendarcalculations {

}

fun setDateOfTheData(datefdatas: Long?) {

/*public void setDateOfTheDataOffset(Date dateofdatas){
calendarForData = null;
calendarForData = new GregorianCalendar(timeZone);
if (datefdatas == null) {
return
}
calendarForData = null
calendarForData = GregorianCalendar(timeZone)

calendarForData.setTime(dateofdatas);
calendarForData.add(Calendar.MILLISECOND,offset);
int i = 0;
i++;
}*/
calendarForData!!.timeInMillis = datefdatas


//calendarForData.add(Calendar.MILLISECOND,offset);
//int i = 0;
//i++;

}

fun getDiffBetweenDates():Long{
return (calendarForNow?.timeInMillis!! - getGmtToNormal(calendarForData)?.timeInMillis!!)
}


fun setDateOfTheDataOffset(dateofdatas:Date?){
if (dateofdatas == null) {
return
}
calendarForData = null
calendarForData = GregorianCalendar(timeZone)

calendarForData!!.time = dateofdatas
getGmtToNormal()
}


fun returnCalendarOfData(): Calendar? {
Expand All @@ -81,7 +115,7 @@ class calendarcalculations {
return ""
}
val ye = calendarForData!!.get(Calendar.YEAR)
var dateString = calendarForData!!.get(Calendar.DATE).toString() + " " + calendarForData!!.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.US)
var dateString = calendarForData!!.get(Calendar.DATE).toString() + " " + calendarForData!!.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.getDefault())

if (ye != calendarForNow?.get(Calendar.YEAR)) {
dateString += " " + ye.toString()
Expand Down
Expand Up @@ -17,5 +17,6 @@ public enum MyOperationTypes {
post,
comment_options,
edit_post,
edit_comment
edit_comment,
claim_reward_balance
}

0 comments on commit beb9c0c

Please sign in to comment.