This file contains 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
applicationVariants.all { variant -> | |
variant.mergeResources.doLast { | |
def dir = new File("${buildDir}/intermediates/res/merged/${variant.dirName}") //iterating through resources, prepared for including to APK (merged resources) | |
println("Resources dir " + dir) | |
dir.eachFileRecurse { file -> | |
if(file.name.endsWith(".xml")) { //processing only files, which names and with .xml | |
String content = file.getText('UTF-8') | |
if(content != null && content.contains("Bill")) { | |
println("Replacing name in " + file) | |
content = content.replace("Bill", "Will") //replacing all Bill words with Will word in files |
This file contains 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
# Navigate to AVD | |
cd ~/.android/avd/Nexus5 | |
# Delete old image | |
#rm userdata-qemu.* | |
# Re-size the image | |
e2fsck -f userdata-qemu.img | |
resize2fs userdata.img 512M |
This file contains 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
Google finally realized the need of generating unique IDs for programmatically created views... | |
From API level 17 and above, you can call | |
View.generateViewId() | |
Then use View.setId(int). | |
In case you need it for targets lower than level 17, here is its internal implementation in View.java you can use directly in your project, put it in your util class or somewhere: |
This file contains 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 android.content.Context; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.widget.LinearLayout; | |
/** | |
* Created by farhad on 16.2.3. | |
* this is an expandable linear Layout with orientation of Vertivally | |
* it will handle whole calculations and animations for height of View | |
* Your view can have wrap content, it will calculate exact height after adding views to the layout |
This file contains 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
public static Observable<String> createObservable(){ | |
return Observable.create((Subscriber<? super String> subscriber) -> { | |
subscriber.onNext(Thread.currentThread().getName()); | |
subscriber.onCompleted(); | |
} | |
); | |
} |
This file contains 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
buildscript { | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath group: 'org.twitter4j', name: 'twitter4j-core', version: '3.0.2' | |
} | |
} | |
import twitter4j.* |
This file contains 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 android.app.Activity; | |
import android.view.MotionEvent; | |
import android.view.View; | |
public abstract class ActivitySwipeDetector implements View.OnTouchListener { | |
private Activity activity; | |
static final int MIN_DISTANCE = 100; | |
private float downX, downY, upX, upY; |
This file contains 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
Sometimes ScrollView doesn't fill parent 100%. in this case simply just add: | |
android:fillViewport="true" | |
to scrollview and that is it. :) |
This file contains 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
public class Logger { | |
//Variables------------------------------------------------------------------------ | |
private static boolean LOGGING_ENABLED = true; | |
private static final int STACK_TRACE_LEVELS_UP = 5; | |
private static String TAG = "YourTag"; |
This file contains 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
/** | |
* Returns true if the application is debuggable. | |
* | |
* @return true if the application is debuggable. | |
*/ | |
static boolean isDebuggable() { | |
PackageManager pm = mApplication.getPackageManager(); | |
try { | |
return ((pm.getApplicationInfo(mApplication.getPackageName(), 0).flags & ApplicationInfo.FLAG_DEBUGGABLE) > 0); | |
} catch (NameNotFoundException e) { |
NewerOlder