use of android.widget.ProgressBar in project weiciyuan by qii.
the class DMConversationListFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.dmconversationlistfragment_layout, container, false);
empty = (TextView) view.findViewById(R.id.empty);
//dirty hack.....in other list, progressbar is used to indicate loading local data; but in this list,
//use a progressbar to indicate loading new data first time, maybe be refactored at 0.50 version
progressBar = new ProgressBar(getActivity());
dmProgressBar = (ProgressBar) view.findViewById(R.id.progressbar);
pullToRefreshListView = (PullToRefreshListView) view.findViewById(R.id.listView);
pullToRefreshListView.setMode(PullToRefreshBase.Mode.BOTH);
pullToRefreshListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
@Override
public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
loadOldMsg(null);
}
@Override
public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
loadNewMsg();
}
});
getListView().setScrollingCacheEnabled(false);
getListView().setHeaderDividersEnabled(false);
getListView().setStackFromBottom(true);
footerView = inflater.inflate(R.layout.listview_footer_layout, null);
getListView().addFooterView(footerView);
dismissFooterView();
et = (EditText) view.findViewById(R.id.content);
view.findViewById(R.id.send).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
send();
}
});
ImageButton emoticon = (ImageButton) view.findViewById(R.id.emoticon);
emoticon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (smiley.isShown()) {
hideSmileyPicker(true);
} else {
showSmileyPicker(SmileyPickerUtility.isKeyBoardShow(getActivity()));
}
}
});
smiley = (SmileyPicker) view.findViewById(R.id.smiley_picker);
smiley.setEditText(getActivity(), (ViewGroup) view.findViewById(R.id.root_layout), et);
mContainer = (LinearLayout) view.findViewById(R.id.container);
et.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
hideSmileyPicker(true);
}
});
buildListAdapter();
return view;
}
use of android.widget.ProgressBar in project weiciyuan by qii.
the class EditMyProfileActivity method startSaveAnimation.
private void startSaveAnimation() {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ProgressBar pb = (ProgressBar) inflater.inflate(R.layout.editmyprofileactivity_refresh_actionbar_view_layout, null);
save.setActionView(pb);
layout.nickname.setEnabled(false);
layout.website.setEnabled(false);
layout.info.setEnabled(false);
layout.avatar.setOnClickListener(null);
}
use of android.widget.ProgressBar in project philm by chrisbanes.
the class ListFragment method onCreateView.
/**
* Provide default implementation to return a simple list view. Subclasses
* can override to replace with their own layout. If doing so, the
* returned view hierarchy <em>must</em> have a ListView whose id
* is {@link android.R.id#list android.R.id.list} and can optionally
* have a sibling view id {@link android.R.id#empty android.R.id.empty}
* that is to be shown when the list is empty.
*
* <p>If you are overriding this method with your own custom content,
* consider including the standard layout {@link android.R.layout#list_content}
* in your layout file, so that you continue to retain all of the standard
* behavior of ListFragment. In particular, this is currently the only
* way to have the built-in indeterminant progress state be shown.
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final Context context = getActivity();
FrameLayout contentRoot = new FrameLayout(context);
// ------------------------------------------------------------------
ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
progress.setId(INTERNAL_PROGRESS_ID);
progress.setVisibility(View.GONE);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER;
contentRoot.addView(progress, lp);
// ------------------------------------------------------------------
FrameLayout lframe = new FrameLayout(context);
lframe.setId(INTERNAL_LIST_CONTAINER_ID);
FontTextView tv = new FontTextView(getActivity());
tv.setId(INTERNAL_EMPTY_ID);
tv.setGravity(Gravity.CENTER);
tv.setFont(FontTextView.FONT_ROBOTO_CONDENSED);
final int p = getResources().getDimensionPixelSize(R.dimen.spacing_major);
tv.setPadding(p, p, p, p);
lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
E lv = createListView(context, inflater);
lv.setId(android.R.id.list);
lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
contentRoot.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
// ------------------------------------------------------------------
ProgressBar secondaryProgress = new SmoothProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
secondaryProgress.setId(INTERNAL_SECONDARY_PROGRESS_ID);
secondaryProgress.setVisibility(View.GONE);
secondaryProgress.setIndeterminate(true);
contentRoot.addView(secondaryProgress, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM));
View root;
if (getParentFragment() == null) {
final LinearLayout toolbarRoot = new LinearLayout(context);
toolbarRoot.setOrientation(LinearLayout.VERTICAL);
// Finally, add the Toolbar
inflater.inflate(R.layout.include_toolbar, toolbarRoot, true);
toolbarRoot.addView(contentRoot, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f));
root = toolbarRoot;
} else {
root = contentRoot;
}
root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
return root;
}
use of android.widget.ProgressBar in project materialistic by hidroh.
the class ItemSyncAdapterTest method testNotification.
@Test
public void testNotification() throws IOException {
Call<HackerNewsItem> call = mock(Call.class);
when(call.execute()).thenReturn(Response.success(new TestHnItem(1L) {
@Override
public boolean isStoryType() {
return true;
}
@Override
public String getRawUrl() {
return "http://example.com";
}
@Override
public long[] getKids() {
return new long[] { 2L, 3L };
}
}));
when(TestRestServiceFactory.hnRestService.cachedItem(eq("1"))).thenReturn(call);
Call<HackerNewsItem> kid1Call = mock(Call.class);
when(kid1Call.execute()).thenReturn(Response.success(new TestHnItem(2L) {
@Override
public boolean isStoryType() {
return false;
}
}));
when(TestRestServiceFactory.hnRestService.cachedItem(eq("2"))).thenReturn(kid1Call);
Call<HackerNewsItem> kid2Call = mock(Call.class);
when(kid2Call.execute()).thenThrow(IOException.class);
when(TestRestServiceFactory.hnRestService.cachedItem(eq("3"))).thenReturn(kid2Call);
when(TestRestServiceFactory.hnRestService.networkItem(eq("3"))).thenReturn(kid2Call);
PreferenceManager.getDefaultSharedPreferences(service).edit().putBoolean(service.getString(R.string.pref_offline_notification), true).apply();
SyncDelegate.scheduleSync(service, new SyncDelegate.JobBuilder(RuntimeEnvironment.application, "1").build());
adapter.onPerformSync(mock(Account.class), getLastSyncExtras(), null, null, null);
verify(readabilityClient).parse(any(), eq("http://example.com"), readabilityCallbackCaptor.capture());
readabilityCallbackCaptor.getValue().onResponse("");
ShadowNotificationManager notificationManager = shadowOf((NotificationManager) service.getSystemService(Context.NOTIFICATION_SERVICE));
ProgressBar progress = shadowOf(notificationManager.getNotification(1)).getProgressBar();
// self + kid 1 + readability
assertThat(progress.getProgress()).isEqualTo(3);
// self + 2 kids + readability + web
assertThat(progress.getMax()).isEqualTo(104);
shadowOf(adapter.syncDelegate.mWebView).getWebChromeClient().onProgressChanged(adapter.syncDelegate.mWebView, 100);
verify(kid2Call).enqueue(callbackCapture.capture());
callbackCapture.getValue().onFailure(null, null);
assertThat(notificationManager.getAllNotifications()).isEmpty();
}
use of android.widget.ProgressBar in project materialistic by hidroh.
the class WebFragmentTest method testProgressChanged.
@Test
public void testProgressChanged() {
ProgressBar progressBar = (ProgressBar) activity.findViewById(R.id.progress);
WebView webView = (WebView) activity.findViewById(R.id.web_view);
shadowOf(webView).getWebChromeClient().onProgressChanged(webView, 50);
assertThat(progressBar).isVisible();
shadowOf(webView).getWebChromeClient().onProgressChanged(webView, 100);
assertThat(progressBar).isNotVisible();
}
Aggregations