Skip to content

Commit

Permalink
Code format with new format xml
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinea committed Apr 26, 2014
1 parent d9ca1e6 commit c296216
Show file tree
Hide file tree
Showing 20 changed files with 83 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class myPagerAdapter extends FragmentPagerAdapter {
private List<Fragment> fragmentList;
private List<String> titleList;

public myPagerAdapter(FragmentManager fm, List<Fragment> fragmentList, List<String> titleList){
public myPagerAdapter(FragmentManager fm, List<Fragment> fragmentList, List<String> titleList) {
super(fm);
this.fragmentList = fragmentList;
this.titleList = titleList;
Expand Down
6 changes: 2 additions & 4 deletions src/cn/trinea/android/demo/AutoScrollViewPagerSingleDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,9 @@ public void onPageSelected(int position) {
}

@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {}

@Override
public void onPageScrollStateChanged(int arg0) {
}
public void onPageScrollStateChanged(int arg0) {}
}
}
32 changes: 14 additions & 18 deletions src/cn/trinea/android/demo/BroadcastReceiverDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void onClick(View v) {
Intent i = new Intent(ACTION_ORDERED_SEND);
i.putExtra(MSG_KEY, getString(R.string.ordered_broadcast_msg));
sendOrderedBroadcast(i, null, new OrderedBroadcastReceiverResultReceiver(), null, Activity.RESULT_OK,
null, null);
null, null);
}
});

Expand Down Expand Up @@ -184,7 +184,7 @@ public class OrderedBroadcastReceiverPriorityHigh extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
orderedMsg.setText(String.format(getString(R.string.ordered_broadcast_high_tip),
intent.getStringExtra(MSG_KEY)));
intent.getStringExtra(MSG_KEY)));
// modify broadcast content
getResultExtras(true).putString(RUSULT_MSG_KEY, "High");
}
Expand All @@ -197,18 +197,16 @@ public void onReceive(Context context, Intent intent) {
boolean isCancel = false;
if (isCancel) {
orderedMsg.setText(orderedMsg.getText()
+ "\r\n"
+ String.format(getString(R.string.ordered_broadcast_medium_cancel_tip),
intent.getStringExtra(MSG_KEY),
getResultExtras(true).getString(RUSULT_MSG_KEY)));
+ "\r\n"
+ String.format(getString(R.string.ordered_broadcast_medium_cancel_tip),
intent.getStringExtra(MSG_KEY), getResultExtras(true).getString(RUSULT_MSG_KEY)));
// calcel broadcast
abortBroadcast();
} else {
orderedMsg.setText(orderedMsg.getText()
+ "\r\n"
+ String.format(getString(R.string.ordered_broadcast_medium_tip),
intent.getStringExtra(MSG_KEY),
getResultExtras(true).getString(RUSULT_MSG_KEY)));
+ "\r\n"
+ String.format(getString(R.string.ordered_broadcast_medium_tip),
intent.getStringExtra(MSG_KEY), getResultExtras(true).getString(RUSULT_MSG_KEY)));
getResultExtras(true).putString(RUSULT_MSG_KEY, "Medium");
}
}
Expand All @@ -219,10 +217,9 @@ public class OrderedBroadcastReceiverPriorityLow extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
orderedMsg.setText(orderedMsg.getText()
+ "\r\n"
+ String.format(getString(R.string.ordered_broadcast_low_tip),
intent.getStringExtra(MSG_KEY),
getResultExtras(true).getString(RUSULT_MSG_KEY)));
+ "\r\n"
+ String.format(getString(R.string.ordered_broadcast_low_tip), intent.getStringExtra(MSG_KEY),
getResultExtras(true).getString(RUSULT_MSG_KEY)));
getResultExtras(true).putString(RUSULT_MSG_KEY, "Low");
}
}
Expand All @@ -232,10 +229,9 @@ public class OrderedBroadcastReceiverResultReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
orderedMsg.setText(orderedMsg.getText()
+ "\r\n"
+ String.format(getString(R.string.ordered_broadcast_tip),
intent.getStringExtra(MSG_KEY),
getResultExtras(true).getString(RUSULT_MSG_KEY)));
+ "\r\n"
+ String.format(getString(R.string.ordered_broadcast_tip), intent.getStringExtra(MSG_KEY),
getResultExtras(true).getString(RUSULT_MSG_KEY)));
}
}
}
16 changes: 7 additions & 9 deletions src/cn/trinea/android/demo/DownloadManagerDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private void initView() {
downloadProgress = (ProgressBar)findViewById(R.id.download_progress);
downloadTip = (TextView)findViewById(R.id.download_tip);
downloadTip.setText(getString(R.string.tip_download_file)
+ Environment.getExternalStoragePublicDirectory(DOWNLOAD_FOLDER_NAME));
+ Environment.getExternalStoragePublicDirectory(DOWNLOAD_FOLDER_NAME));
downloadSize = (TextView)findViewById(R.id.download_size);
downloadPrecent = (TextView)findViewById(R.id.download_precent);
}
Expand Down Expand Up @@ -179,7 +179,7 @@ public static boolean install(Context context, String filePath) {

class DownloadChangeObserver extends ContentObserver {

public DownloadChangeObserver(){
public DownloadChangeObserver() {
super(handler);
}

Expand All @@ -204,11 +204,9 @@ public void onReceive(Context context, Intent intent) {
updateView();
// if download successful, install apk
if (downloadManagerPro.getStatusById(downloadId) == DownloadManager.STATUS_SUCCESSFUL) {
String apkFilePath = new StringBuilder(Environment.getExternalStorageDirectory().getAbsolutePath()).append(File.separator)
.append(DOWNLOAD_FOLDER_NAME)
.append(File.separator)
.append(DOWNLOAD_FILE_NAME)
.toString();
String apkFilePath = new StringBuilder(Environment.getExternalStorageDirectory().getAbsolutePath())
.append(File.separator).append(DOWNLOAD_FOLDER_NAME).append(File.separator)
.append(DOWNLOAD_FILE_NAME).toString();
install(context, apkFilePath);
}
}
Expand Down Expand Up @@ -313,7 +311,7 @@ public static String getNotiPercent(long progress, long max) {

public static boolean isDownloading(int downloadManagerStatus) {
return downloadManagerStatus == DownloadManager.STATUS_RUNNING
|| downloadManagerStatus == DownloadManager.STATUS_PAUSED
|| downloadManagerStatus == DownloadManager.STATUS_PENDING;
|| downloadManagerStatus == DownloadManager.STATUS_PAUSED
|| downloadManagerStatus == DownloadManager.STATUS_PENDING;
}
}
8 changes: 4 additions & 4 deletions src/cn/trinea/android/demo/DropDownListViewDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
* DropDownListViewDemo
*
* @author <a href="http://www.trinea.cn/android/dropdown-to-refresh-and-bottom-load-more-listview/"
* target="_blank">Trinea</a> 2013-6-1
* target="_blank">Trinea</a> 2013-6-1
*/
public class DropDownListViewDemo extends BaseActivity {

private LinkedList<String> listItems = null;
private DropDownListView listView = null;
private ArrayAdapter<String> adapter;

private String[] mStrings = { "Aaaaaa", "Bbbbbb", "Cccccc", "Dddddd", "Eeeeee", "Ffffff",
"Gggggg", "Hhhhhh", "Iiiiii", "Jjjjjj", "Kkkkkk", "Llllll", "Mmmmmm", "Nnnnnn", };
private String[] mStrings = {"Aaaaaa", "Bbbbbb", "Cccccc", "Dddddd", "Eeeeee", "Ffffff",
"Gggggg", "Hhhhhh", "Iiiiii", "Jjjjjj", "Kkkkkk", "Llllll", "Mmmmmm", "Nnnnnn",};
public static final int MORE_DATA_MAX_COUNT = 3;
public int moreDataCount = 0;

Expand Down Expand Up @@ -74,7 +74,7 @@ private class GetDataTask extends AsyncTask<Void, Void, String[]> {

private boolean isDropDown;

public GetDataTask(boolean isDropDown){
public GetDataTask(boolean isDropDown) {
this.isDropDown = isDropDown;
}

Expand Down
2 changes: 1 addition & 1 deletion src/cn/trinea/android/demo/HttpCacheDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected void onPostGet(HttpResponse httpResponse, boolean isInCache) {
sb.append("is in cache: ").append(isInCache).append("\r\n");
if (isInCache) {
sb.append("expires: ").append(new Date(httpResponse.getExpiredTime()).toGMTString())
.append("\r\n");
.append("\r\n");
}
httpCacheInfoTV.setText(sb.toString());
httpGetContentTV.setText(httpResponse.getResponseBody());
Expand Down
19 changes: 9 additions & 10 deletions src/cn/trinea/android/demo/ImageCacheDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ public class ImageCacheDemo extends BaseActivity {
public static final int IMAGEVIEW_DEFAULT_HEIGHT = 400;
public static final String TAG_CACHE = "image_cache";
/** cache folder path which be used when saving images **/
public static final String DEFAULT_CACHE_FOLDER = new StringBuilder().append(Environment.getExternalStorageDirectory()
.getAbsolutePath())
.append(File.separator).append("Trinea")
.append(File.separator)
.append("AndroidDemo")
.append(File.separator)
.append("ImageCache").toString();
public static final String DEFAULT_CACHE_FOLDER = new StringBuilder()
.append(Environment.getExternalStorageDirectory()
.getAbsolutePath()).append(File.separator)
.append("Trinea").append(File.separator)
.append("AndroidDemo").append(File.separator)
.append("ImageCache").toString();
private RelativeLayout parentLayout;

@Override
Expand Down Expand Up @@ -164,9 +163,9 @@ public void onPreGet(String imageUrl, View view) {
@Override
public void onGetFailed(String imageUrl, Bitmap loadedImage, View view, FailedReason failedReason) {
Log.e(TAG_CACHE,
new StringBuilder(128).append("get image ").append(imageUrl).append(" error, failed type is: ")
.append(failedReason.getFailedType()).append(", failed reason is: ")
.append(failedReason.getCause().getMessage()).toString());
new StringBuilder(128).append("get image ").append(imageUrl).append(" error, failed type is: ")
.append(failedReason.getFailedType()).append(", failed reason is: ")
.append(failedReason.getCause().getMessage()).toString());
}

@Override
Expand Down
8 changes: 3 additions & 5 deletions src/cn/trinea/android/demo/ImagePagerFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ImagePagerFragment extends Fragment {

private List<Integer> imageIdList;

public ImagePagerFragment(){
public ImagePagerFragment() {
super();
}

Expand Down Expand Up @@ -69,11 +69,9 @@ public void onPageSelected(int position) {
}

@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {}

@Override
public void onPageScrollStateChanged(int arg0) {
}
public void onPageScrollStateChanged(int arg0) {}
}
}
20 changes: 10 additions & 10 deletions src/cn/trinea/android/demo/ImageSDCardCacheDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public class ImageSDCardCacheDemo extends BaseActivity {

public static final String TAG_CACHE = "image_sdcard_cache";
/** cache folder path which be used when saving images **/
public static final String DEFAULT_CACHE_FOLDER = new StringBuilder().append(Environment.getExternalStorageDirectory()
.getAbsolutePath())
.append(File.separator).append("Trinea")
.append(File.separator).append("AndroidDemo")
.append(File.separator)
.append("ImageSDCardCache").toString();
public static final String DEFAULT_CACHE_FOLDER = new StringBuilder()
.append(Environment.getExternalStorageDirectory()
.getAbsolutePath()).append(File.separator)
.append("Trinea").append(File.separator)
.append("AndroidDemo").append(File.separator)
.append("ImageSDCardCache").toString();

@Override
public void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -131,9 +131,9 @@ public void onGetNotInCache(String imageUrl, View view) {
@Override
public void onGetFailed(String imageUrl, String imagePath, View view, FailedReason failedReason) {
Log.e(TAG_CACHE,
new StringBuilder(128).append("get image ").append(imageUrl).append(" error, failed type is: ")
.append(failedReason.getFailedType()).append(", failed reason is: ")
.append(failedReason.getCause().getMessage()).toString());
new StringBuilder(128).append("get image ").append(imageUrl).append(" error, failed type is: ")
.append(failedReason.getFailedType()).append(", failed reason is: ")
.append(failedReason.getCause().getMessage()).toString());
}
};
IMAGE_SD_CACHE.setOnImageSDCallbackListener(imageCallBack);
Expand Down Expand Up @@ -201,7 +201,7 @@ private static class ImageAdapter extends BaseAdapter {
private LayoutInflater inflater;
public List<String> imageUrlList;

public ImageAdapter(Context context){
public ImageAdapter(Context context) {
super();
inflater = LayoutInflater.from(context);
}
Expand Down
4 changes: 2 additions & 2 deletions src/cn/trinea/android/demo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public class MainActivity extends BaseActivity {

public static final String TAG = "DemoList";

private static final String[] mStrings = { "AutoScrollViewPager Demo", "HttpCache Demo", "ImageCache Demo",
private static final String[] mStrings = {"AutoScrollViewPager Demo", "HttpCache Demo", "ImageCache Demo",
"ImageSDCardCache Demo", "DropDownListView Demo", "onBottom onTop ScrollView Demo", "DownloadManager Demo",
"SearchView Demo", "ViewPager Multi Fragment Demo", "Slide One Page Gallery Demo", "ViewPager Demo",
"Service Demo", "BroadcastReceiver Demo" };
"Service Demo", "BroadcastReceiver Demo"};

private static final int total = mStrings.length - 1;

Expand Down
4 changes: 2 additions & 2 deletions src/cn/trinea/android/demo/MyIntentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
*/
public class MyIntentService extends IntentService {

public MyIntentService(){
public MyIntentService() {
super("MyIntentService");
}

@Override
protected void onHandleIntent(Intent intent) {
try {
System.out.println("IntentService1 Begin Sleep. " + "Thread name: " + Thread.currentThread().getName()
+ ", Thread Id: " + Thread.currentThread().getId());
+ ", Thread Id: " + Thread.currentThread().getId());
Thread.sleep(3000);
System.out.println("IntentService1 End. ");
} catch (InterruptedException e) {
Expand Down
15 changes: 8 additions & 7 deletions src/cn/trinea/android/demo/SearchViewDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* SearchViewDemo
*
* @author <a href="http://www.trinea.cn/android/android-searchview-and-search-tips-impl/" target="_blank">Trinea</a>
* 2013-5-9
* 2013-5-9
*/
public class SearchViewDemo extends BaseActivity {

Expand All @@ -52,7 +52,7 @@ protected void onCreate(Bundle savedInstanceState) {
// set title style
ActionBar bar = getActionBar();
bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP
| ActionBar.DISPLAY_SHOW_CUSTOM);
| ActionBar.DISPLAY_SHOW_CUSTOM);
setTitle(" ");
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View customActionBarView = inflater.inflate(R.layout.search_view_demo_title, null);
Expand Down Expand Up @@ -90,13 +90,14 @@ public boolean onQueryTextChange(String newText) {
}
});
Display display = getWindowManager().getDefaultDisplay();
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.RIGHT);
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
Gravity.CENTER_VERTICAL | Gravity.RIGHT);
bar.setCustomView(customActionBarView, params);

// show keyboard
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
| WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
| WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}

public void showSearchTip(String newText) {
Expand All @@ -108,7 +109,7 @@ class SearchTipThread implements Runnable {

String newText;

public SearchTipThread(String newText){
public SearchTipThread(String newText) {
this.newText = newText;
}

Expand Down
Loading

0 comments on commit c296216

Please sign in to comment.