Posts

Scrollable readonly EditView in Kotlin

In the view xml file: <EditTextandroid:id="@+id/etResult" android:layout_width="match_parent" android:layout_height="343dp" android:background="@color/backgroundColor" android:backgroundTint="#00000000" android:ems="10"android:enabled="true"android:fontFamily="sans-serif-condensed"android:gravity="start|top"android:hint="@string/blankfoldermessage"android:importantForAutofill="no"android:inputType="none"android:paddingTop="2dp"android:singleLine="false"tools:targetApi="o" />in the kotlin file (init function): etResult.keyListener = nullthis will allow the edit text to be multiline, not editable but scrollable.

Simple use of Timer in Kotlin

the code below will set the button to clickable after 30 sec:btnOk.isClickable=falseTimer().schedule(timerTask {     btnOk.isClickable=true }, 1000*30)the above code runs in a separate thread, so the UI is responsive while running this code.

Working with UI controls from Non main thread in Kotlin

import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread

fun anyFunction(){ doAsync {// Normal code inside Async threadI=I+1If(I=100){uiThread { tvResult.setText =”I is now 100!!”}}//More codeIf(x==0){uiThread { tvResult.setText =”there’s some problem!”}} }}
Note: - you can include multiple uiThread inside same doAsync           - you can include multiple doAsync inside any function

Permission request pop up in android

Image
Request user to give permission to read external storage in Android - (Kotlin)if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { // Permission is not granted // Should we show an explanation?if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_EXTERNAL_STORAGE)) { } else { // No explanation needed, we can request the permission.ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), READ_STORAGE_CODE); } } else { // Permission has already been granted}NOTE: READ_STORAGE_CODE is just an int constant with fix value like 1001, or 2023and is a variable in class level.

TFS -GIT CertGetCertificateChain trust error CERT_TRUST_IS_UNTRUSTED_ROOT

Image
Problem 1)
2019-07-02T14:19:12.5157398Z fatal: unable to access 'https://tfssite.company.com/tfs/UK_ProjectCollection/SalesPortal/_git/SalesPortalWeb/': SSL certificate problem: unable to get local issuer certificate 2019-07-02T14:19:12.9764145Z ##[error]Git fetch failed with exit code: 128 2019-07-02T14:19:12.9861630Z ##[section]Finishing: Get Sources












In the TFS_Build Server or App server(if build and app server is in the same machine) >

run the script from this url: https://blog.sanjeebojha.com.np/2019/06/git-ssl-certificate-problem-unable-to.html

Once this is done, you should get another problem:

Problem 2)  CertGetCertificateChain trust error CERT_TRUST_IS_UNTRUSTED_ROOT

2019-07-02T14:24:57.1800199Z ##[command]git -c http.extraheader="AUTHORIZATION: bearer ***" fetch --tags --prune --progress --no-recurse-submodules origin 2019-07-02T14:24:57.4540146Z fatal: unable to access 'https://tfssite.company.com/tfs/UK_ProjectCollection/SalesPortal/_git/SalesPortalWeb/…

Insert Identity Column in a table

insert an identity column in that table by using the following code:

ALTERTABLE dbo.tablename ADD AUTOID INTIDENTITY(1,1) 

MSSQL Remove duplicate Rows

Select the duplicate key values into a holding table. For example:
SELECT col1, col2, col3=count(*) INTO holdkey FROM t1 GROUP BY col1, col2 HAVING count(*) > 1 Select the duplicate rows into a holding table, eliminating duplicates in the process. For example:       SELECT DISTINCT t1.*         INTO holddups FROM t1, holdkey  WHERE t1.col1 = holdkey.col1         AND t1.col2 = holdkey.col2At this point, the holddups table should have unique PKs, however, this will not be the case if t1 had        duplicate PKs, yet unique rows (as in the SSN example above). Verify that each key in holddups is unique, and that you do not have duplicate keys, yet unique rows. If so, you must stop here and reconcile which of the rows you wish to keep for a given duplicate key value. For example, the query: SELECT col1, col2, count(*) FROM holddups GROUP BY col1, col2 should return a count of 1 for each row. If yes, proceed to step 5 below. If no, yo…