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 List<String> readLinesFromAssetFile(String fileName, final Context context) throws IOException { | |
InputStream inputStream = context.getAssets().open(fileName); | |
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); | |
LineReader lr = new LineReader(br);// from Guava | |
List<String> lines = new LinkedList<>(); | |
String line; | |
while ((line = lr.readLine()) != null){ | |
lines.add(line); |
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
private void doImport() { | |
Uri fullContacts = Uri.parse("content://com.android.contacts/raw_contacts"); | |
Uri itemContact = Uri.parse("content://com.android.contacts/data"); | |
int importCnt = 0; | |
try { | |
InputStream inputStream = getAssets().open("ct2.txt"); | |
ByteArrayOutputStream bos = new ByteArrayOutputStream(); | |
byte buffer[] = new byte[1024]; |
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
private void refreshAvatar(File file) { | |
/*** | |
* Note: the current Fragment has been created once entering the home Activity. | |
* So the dimension of avatarParent is determinate already. | |
*/ | |
if (file != null && file.exists()) { | |
avatarParent.setBackground(defaultBackground); | |
Glide.with(this).load(file.getAbsoluteFile()) | |
.asBitmap() |
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 the view configured in the presenter which real implementation is an Activity or | |
* Fragment using this presenter. | |
*/ | |
public final T getView() { | |
return view; | |
} | |
/** | |
* Configures the View instance used in this presenter as view. |
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.os.Bundle; | |
import android.support.annotation.Nullable; | |
import android.support.v4.app.Fragment; | |
import android.support.v4.app.FragmentActivity; | |
import android.support.v4.app.FragmentManager; | |
import java.util.LinkedList; | |
import timber.log.Timber; |
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 okhttp3.ResponseBody; | |
import retrofit2.Call; | |
public interface Repository { | |
Call<ResponseBody> download(String url); | |
} | |
public void cancelCurrentDownloadingTask() { | |
if (call != null) { | |
call.cancel(); |
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
next=`cat /jenkins-jobs/your-job/nextBuildNumber` | |
one='1' | |
no=`echo $((next - one))` | |
rc=`ls /jenkins-jobs/your-job/builds/${no}/archive/app/build/outputs/apk/ | grep "app-live-release"` | |
java -jar /packer-tool-path/packer-ng-plugin/tools/packer-ng-2.0.0.jar generate --channels=google \ | |
--output=/jenkins-jobs/your-job/builds/${no}/archive/app/build/outputs/apk/channel/ \ | |
/jenkins-jobs/your-job/builds/${no}/archive/app/build/outputs/apk/${rc} |
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
grep -R --include="*.json" "YOUR-KEYWORDS\":" ./ | cut -d':' -f1 | sort | uniq |
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 void setImageMatrixWithRatioKept( | |
ImageView view, Bitmap resource, boolean scaleByActualWidth, boolean alignmentCenter) { | |
view.setScaleType(ImageView.ScaleType.MATRIX); | |
int bmpWidth = resource.getWidth(); | |
int bmpHeight = resource.getHeight(); | |
int viewWidth = view.getWidth(); | |
int viewHeight = view.getHeight(); | |
float scaleWidth = 1.0f * viewWidth / bmpWidth; |
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
adb shell screenrecord --time-limit 3 --bit-rate 2000000 --verbose /sdcard/demo.mp4 | |
ffmpeg -ss 00:00:00.000 -i ./demo.mp4 -pix_fmt rgb24 -r 3 -s 270x480 -t 00:00:3.000 output.gif |
OlderNewer