Skip to content

Instantly share code, notes, and snippets.

View ibrahimsn98's full-sized avatar
🐙

İbrahim Süren ibrahimsn98

🐙
View GitHub Profile
@ibrahimsn98
ibrahimsn98 / android-notification-listener-get-stacked-notification-text
Created February 15, 2018 17:01
Android notification listener get stacked notification text
String getNotificationText(Bundle extras) {
CharSequence[] lines = extras.getCharSequenceArray(Notification.EXTRA_TEXT_LINES);
if(lines != null && lines.length > 0) {
StringBuilder sb = new StringBuilder();
for (CharSequence msg : lines)
if (!TextUtils.isEmpty(msg)) {
sb.append(msg.toString());
sb.append('\n');
}
return sb.toString().trim();
@ibrahimsn98
ibrahimsn98 / gist:d9914c12b98446a25232aea23e4740f8
Created June 9, 2018 09:39
Android Bottom Navigation View Dimens
bottom_navigation_elevation
bottom_navigation_height
bottom_navigation_icon
bottom_navigation_margin_bottom
bottom_navigation_margin_top_active
bottom_navigation_margin_top_inactive
bottom_navigation_max_width
bottom_navigation_min_width
bottom_navigation_notification_elevation
bottom_navigation_notification_height
@ibrahimsn98
ibrahimsn98 / NetworkModule.java
Created July 6, 2018 18:30
android-mvvm-with-dagger-2-module-network
@Module
public class NetworkModule {
private static final String BASE_URL = "https://api.github.com/";
@Provides
static Retrofit provideRetrofit() {
return new Retrofit.Builder().baseUrl(BASE_URL)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
@ibrahimsn98
ibrahimsn98 / django-rest-framework.py
Created August 6, 2018 12:42
django-rest-framework-jwt-get-user-from-token
jwt_decode_handler = api_settings.JWT_DECODE_HANDLER
jwt_get_username_from_payload = api_settings.JWT_PAYLOAD_GET_USERNAME_HANDLER
token = ''
try:
payload = jwt_decode_handler(token)
except jwt.ExpiredSignature:
return
except jwt.DecodeError:
@ibrahimsn98
ibrahimsn98 / gist:8115672b83abcc4b2c3bc7422c03abe6
Created August 6, 2018 16:54
linux-secure-wall-port-allow
sudo /sbin/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 8000 -j ACCEPT
@ibrahimsn98
ibrahimsn98 / BaseApplication.java
Last active August 19, 2018 15:36
android-mvvm-with-dagger-2
public class BaseApplication extends DaggerApplication {
@Override
public void onCreate() {
super.onCreate();
}
@Override
protected AndroidInjector<? extends DaggerApplication> applicationInjector() {
ApplicationComponent component = DaggerApplicationComponent.builder().application(this).build();
@ibrahimsn98
ibrahimsn98 / ViewModelModule.java
Last active August 19, 2018 15:37
android-mvvm-with-dagger-2
@Singleton
@Module
abstract class ViewModelModule {
@Binds
@IntoMap
@ViewModelKey(ListViewModel.class)
abstract ViewModel bindListViewModel(ListViewModel listViewModel);
@Binds
@ibrahimsn98
ibrahimsn98 / MainFragmentBindingModule.java
Last active August 19, 2018 15:37
android-mvvm-with-dagger-2
@Module
public abstract class MainFragmentBindingModule {
@ContributesAndroidInjector
abstract ListFragment provideListFragment();
@ContributesAndroidInjector
abstract DetailsFragment provideDetailsFragment();
}
@ibrahimsn98
ibrahimsn98 / ActivityBindingModule.java
Last active August 19, 2018 15:38
android-mvvm-with-dagger-2
@Module
public abstract class ActivityBindingModule {
@ContributesAndroidInjector(modules = {MainFragmentBindingModule.class})
abstract MainActivity bindMainActivity();
}
@ibrahimsn98
ibrahimsn98 / BaseFragment.java
Last active August 19, 2018 15:38
android-mvvm-with-dagger-2
public abstract class BaseFragment extends DaggerFragment {
private Unbinder unbinder;
private AppCompatActivity activity;
@LayoutRes
protected abstract int layoutRes();
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {