Skip to content

Instantly share code, notes, and snippets.

View smyykb's full-sized avatar

Sümeyye Ortagedik smyykb

  • Ziraat Teknoloji
View GitHub Profile
@smyykb
smyykb / 1.Default Configration
Last active October 1, 2017 10:47
Gradle Configration
defaultConfig {
applicationId "com.phantomvk.app"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
//buildConfigFieldDefined values are compiled and can be accessed in Java code BuildConfig.
buildConfigField "String", "BUG_REPORT_URL", "\"xx.com\""
}
@smyykb
smyykb / 1.RecyclerView
Last active October 3, 2017 07:07
RecylerView - adapter
Recyclerview Listview ve gridview'in yerine kullanıbilecek View Holder pattern'i kullanan yeni bir komponent.
Bir View'e ihtiyaç olduğunda layoutu inflate eden yeni bir ViewHolder objesi oluşur ve referansı saklanır liste her scroll olduğunda
bu objeyi kullanır. Bu nedenle adı recyclerView'miş :)
Diğer bir ozelliği LayoutManager, listedeki itemların dizilişlerini belirliyor.
1.LinearLayoutManager, klasik ListView
2.GridLayoutManager, GridView
3.StaggerGridLayoutManager kademeli,sıralı listview
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/white" android:state_checked="true" />
<item android:color="@color/white" android:state_pressed="true" />
<item android:color="@color/white" android:state_activated="true" />
<item android:color="@color/black" />
</selector>
@smyykb
smyykb / Foreground.java
Created October 6, 2017 13:21 — forked from steveliles/Foreground.java
Class for detecting and eventing the foreground/background state of an Android app - API-level 14+
package com.sjl.util;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import java.util.List;
@smyykb
smyykb / IntDef - StringDef
Last active October 9, 2017 08:36
Forget enums...
@IntDef({
ApplicationState.FOREGROUND,
ApplicationState.BACKGROUND,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ApplicationState {
int FOREGROUND = 0;
int BACKGROUND = 1;
}
@smyykb
smyykb / eventbus
Created October 9, 2017 20:41
EventBus - Greenrobot
1 - Bir event tanımla
public class MyEvent{}
2 - Eventi yakalayabilmek için Abone olman lazım.
EventBus.getDefault().register(this);
3 - Bir event gönder gelsin.
EventBus.getDefault().post(new MyEvent());
4 - Event geldi merhaba de bakalım :)
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:width="144dp"
android:height="144dp"
android:left="10dp"
android:top="10dp">
<shape android:shape="oval">
<solid android:color="@color/white20" />
@smyykb
smyykb / volley-POST-example.java
Created October 24, 2017 17:59 — forked from mombrea/volley-POST-example.java
Example of performing a POST request using Google Volley for Android
public static void postNewComment(Context context,final UserAccount userAccount,final String comment,final int blogId,final int postId){
mPostCommentResponse.requestStarted();
RequestQueue queue = Volley.newRequestQueue(context);
StringRequest sr = new StringRequest(Request.Method.POST,"http://api.someservice.com/post/comment", new Response.Listener<String>() {
@Override
public void onResponse(String response) {
mPostCommentResponse.requestCompleted();
}
}, new Response.ErrorListener() {
@Override
@smyykb
smyykb / 1 - Enumsal bişiler
Last active November 17, 2017 08:22
Enumsal Bişiler (Note : Just For Self-reference)
- Tanımlama:
public enum UserStatus {
PENDING,
ACTIVE,
INACTIVE,
DELETED;
}
- Kullanım:
@smyykb
smyykb / Common Util Methods For Android
Created November 17, 2017 12:02
Just for self-references
/**
* Utility method for showing keyboard.
*
* @param view which has keyboard focus
*/
public static void showKeyboard(View view) {
final InputMethodManager inputMethodManager = (InputMethodManager)
view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}