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
| Parser parser = new Parser(); | |
| parser.execute(UrlConstant.SECOND_FEED_URL); | |
| parser.onFinish(new OnTaskCompleted() { | |
| @Override | |
| public void onTaskCompleted(@NotNull final List<Article> list) { | |
| final List<Article> filtered = new ArrayList<>(); | |
| for (int i = 0; i < list.size(); i++) { | |
| Article article = list.get(i); |
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
| //... | |
| secondFeedAdatper = new SecondFeedAdatper(); | |
| secondFeedAdatper.setClickListener(new SecondFeedAdatper.ClickListener() { | |
| @Override | |
| public void onArticleClick(Article article) { | |
| if (article.getLink() != null && !article.getLink().isEmpty()) { | |
| if (getActivity() instanceof LockscreenActivity) { | |
| ((LockscreenActivity) getActivity()).openURL(article.getLink()); | |
| } | |
| } |
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
| //offline-first usecase for api requests | |
| //one you have to do is to include rxjava to your project, | |
| //some Api(could be Retrofit based), | |
| //some Preferences(could SharedPreferences based / some database), | |
| //some SerializerUtil (could be gson, moshi) | |
| import com.google.gson.JsonSyntaxException; | |
| import com.google.gson.annotations.SerializedName; | |
| import io.reactivex.Observable; | |
| import io.reactivex.functions.Consumer; |
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 Foo { | |
| public void showNotification(String _subText, | |
| String _bigContentTitle, | |
| String _bigText) { | |
| String channelId = "channelId"; | |
| NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, channelId); | |
| notificationBuilder.setAutoCancel(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 LoginViewController { | |
| var userName: String = "joe@doe.com" | |
| let HOME_SEGUE = "HOME_SEGUE" | |
| let FORGOT_PASSWORD_SEGUE = "FORGOT_PASSWORD_SEGUE" | |
| func startHomeScreen(){ | |
| self.performSegue(withIdentifier: HOME_SEGUE, sender: self) |
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
| #!/bin/bash | |
| for i in "${@:3}" | |
| do | |
| echo "generating $i x $i icon..." | |
| sips -z $i $i $1 --out $2_$i.png | |
| done | |
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
| <?xml version="1.0" encoding="utf-8"?> | |
| <layout 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"> | |
| <data> | |
| <variable | |
| name="personModel" | |
| type="pl.marchuck.pagingexample.pagination.adapter.SwapiPersonViewModel" /> | |
| </data> | |
| <android.support.v7.widget.CardView ...> |
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 SwapiPersonViewHolder(private val binding: ItemSwapiPersonBinding) : RecyclerView.ViewHolder(binding.root) { | |
| fun bind(item: Person?) { | |
| binding.personModel = SwapiPersonViewModel(item) | |
| binding.executePendingBindings() | |
| } | |
| } |
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 SwapiAdapter(diffCallback: DiffUtil.ItemCallback<Person?>) | |
| : PagedListAdapter<Person, SwapiPersonViewHolder>(diffCallback) { | |
| override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SwapiPersonViewHolder { | |
| val inflater = LayoutInflater.from(parent.context) | |
| val binding = DataBindingUtil.inflate<ItemSwapiPersonBinding>( | |
| inflater, R.layout.item_swapi_person, parent, false) | |
| return SwapiPersonViewHolder(binding) | |
| } |