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
package org.mariotaku.twidere.util; | |
import android.view.View; | |
import android.widget.AbsListView; | |
import android.widget.AbsListView.OnScrollListener; | |
/** | |
* Created by mariotaku on 14/10/22. | |
*/ | |
public class ListScrollDistanceCalculator implements OnScrollListener { |
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
ViewPager vp=null; | |
RelativeLayout rel_layout=null; | |
ArrayList<Fragment> fragments=null; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); |
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
private void showNotification() { | |
NotificationCompat.Builder build=new NotificationCompat.Builder(this); | |
build.setSmallIcon(R.mipmap.ic_launcher); | |
build.setTicker("这是通知"); | |
build.setContentTitle("这是标题"); | |
//设置优先级 | |
build.setPriority(NotificationCompat.PRIORITY_MIN); | |
build.setContentText("这是内容"); | |
build.setContentIntent(getPendingIntent("普通文字", 0)); |
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
private void easeRegist(final String objectId) { | |
JSONObject object=new JSONObject(); | |
try { | |
object.put("username", objectId); | |
object.put("password", "abcd1234"); | |
object.put("nickname", objectId); | |
final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); | |
OkHttpClient client = HttpUtils.getInstance().clone(); | |
RequestBody body = RequestBody.create(JSON, object.toString()); | |
Request request = new Request.Builder().addHeader("Content-Type", "application/json").url(ParamsUtil.HXUsers).post(body).build(); |
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
//类似数组[行, 列] | |
//表示起始位置为0,占据2行 | |
GridLayout.Spec rowSpec=GridLayout.spec(0, 2, GridLayout.UNDEFINED); | |
//表示起始位置为1,占据1列 | |
GridLayout.Spec columnSpec=GridLayout.spec(i, 1, GridLayout.UNDEFINED); | |
GridLayout.LayoutParams params=new GridLayout.LayoutParams(rowSpec, columnSpec); | |
gridlayout.addView(view, params); | |
此外xml中也要预先定好多少行多少列 |
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
// 切换为全屏 | |
private void setFullScreen() { | |
if (Build.VERSION.SDK_INT >= 9) { | |
setRequestedOrientation(6); | |
} else { | |
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); | |
} | |
getWindow().addFlags(1024); | |
mActionBar.hide(); | |
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( |
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
try { | |
db.beginTransaction(); | |
String[][] lifes = {{"potato", "tomato", "apple"}, {"rat", "cat", "dog"}}; | |
SQLiteStatement stmt = db.compileStatement("insert into life values(?,?)"); | |
for(int i=0;i<lifes[0].length;i++){ | |
stmt.clearBindings(); | |
stmt.bindString(1, lifes[0][i]); | |
stmt.bindString(1, lifes[1][i]); | |
stmt.executeInsert(); | |
} |
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
// 循环检测activity是否初始化完毕 | |
starnum_seekbar.postDelayed(new Runnable() { | |
@Override | |
public void run() { | |
// TODO Auto-generated method stub | |
if (null != getWindow().getDecorView().getWindowToken()) { | |
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); | |
View undoView = inflater.inflate( | |
R.layout.view_seekbarhint2, null); |
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
//动态刷新fragment的方法 | |
//将FragmentTransaction中的fragment全部清除 | |
public void addFragment() { | |
if(fragment_list != null){ | |
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); | |
for(Fragment f: fragment_list){ | |
ft.remove(f); | |
} | |
ft.commitAllowingStateLoss(); |
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
//viewpager中同时包含image跟surfaceview的情况处理 | |
//给viewPager中的View添加id,便于后续查找 | |
for(int i=0;i<multi_media.size();i++) { | |
if (multi_media.get(i).gettype().endsWith("0")) { | |
ImageView imageView=new ImageView(this); | |
imageView.setImageResource(R.drawable.ic_launcher); | |
bitmapUtils.display(imageView, multi_media.get(i).getDescription_url(), config); | |
views.add(imageView); | |
} else { |
NewerOlder