This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SpashScreen : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_splash) | |
val background = object : Thread() { | |
override fun run() { | |
try { | |
// Thread will sleep for 5 seconds | |
Thread.sleep((5 * 1000).toLong()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.android.gms.ads.AdRequest; | |
import com.google.android.gms.ads.AdView; | |
// ... | |
public class MainActivity extends AppCompatActivity { | |
private static final String TAG = "MainActivity"; | |
private AdView mAdView; | |
// ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<RelativeLayout | |
xmlns:ads="http://schemas.android.com/apk/res-auto" | |
... | |
> | |
<com.google.android.gms.ads.AdView | |
android:id="@+id/adView" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_centerHorizontal="true" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SecondActivity : AppCompatActivity() { | |
var sharedPref:SharedPreferences?=null | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_second) | |
sharedPref=getSharedPreferences(MainActivity.MY_PREF, Context.MODE_PRIVATE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
var shredPref:SharedPreferences?=null | |
var editor:SharedPreferences.Editor?=null | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val user1 = User("john", 12345) | |
val user2 = User("john", 123451) | |
val user3 = User("john", 12345) | |
println("==") | |
println(user1==user2) | |
println(user1==user3) | |
println(" euquals") | |
println(user1.equals(user2)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mRecyclerView.layoutManager = LinearLayoutManager(this) | |
mRecyclerView.addItemDecoration(SimpleDividerItemDecoration(this)) | |
// specify an adapter (see also next example) | |
mRecyclerView.adapter = MovieAdapter(applicationContext,Utils.getMovies()) | |
} | |
// choose the layout between Linear and Grid | |
fun typeLayout(view: View){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lass MovieAdapter(context: Context, val items: List<Movie>): RecyclerView.Adapter<MovieAdapter.MyViewHolder>(){ | |
var c=context; | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder{ | |
val v = LayoutInflater.from(parent.context) | |
.inflate(R.layout.listitem, parent, false) | |
return MyViewHolder(v) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package co.prandroid.recylerviewkotlin | |
import android.content.Context | |
import android.widget.Toast | |
/** | |
* Created by dharmakshetri on 6/24/17. | |
*/ | |
object Utils { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package co.prandroid.recylerviewkotlin | |
/** | |
* Created by dharmakshetri on 6/24/17. | |
*/ | |
class Movie (val url:String, val name: String, val year: Int?) |