Search in sources :

Example 16 with ProgressBar

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;
}
Also used : ImageButton(android.widget.ImageButton) PullToRefreshListView(org.qii.weiciyuan.support.lib.pulltorefresh.PullToRefreshListView) ListView(android.widget.ListView) PullToRefreshBase(org.qii.weiciyuan.support.lib.pulltorefresh.PullToRefreshBase) View(android.view.View) AdapterView(android.widget.AdapterView) PullToRefreshListView(org.qii.weiciyuan.support.lib.pulltorefresh.PullToRefreshListView) TextView(android.widget.TextView) ListView(android.widget.ListView) ProgressBar(android.widget.ProgressBar)

Example 17 with ProgressBar

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);
}
Also used : LayoutInflater(android.view.LayoutInflater) ProgressBar(android.widget.ProgressBar)

Example 18 with ProgressBar

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;
}
Also used : Context(android.content.Context) ViewGroup(android.view.ViewGroup) FontTextView(app.philm.in.view.FontTextView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) FrameLayout(android.widget.FrameLayout) FontTextView(app.philm.in.view.FontTextView) SmoothProgressBar(fr.castorflex.android.smoothprogressbar.SmoothProgressBar) ProgressBar(android.widget.ProgressBar) SmoothProgressBar(fr.castorflex.android.smoothprogressbar.SmoothProgressBar) LinearLayout(android.widget.LinearLayout)

Example 19 with ProgressBar

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();
}
Also used : Account(android.accounts.Account) ShadowNotificationManager(org.robolectric.shadows.ShadowNotificationManager) ProgressBar(android.widget.ProgressBar) Test(org.junit.Test)

Example 20 with ProgressBar

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();
}
Also used : WebView(android.webkit.WebView) ShadowWebView(io.github.hidroh.materialistic.test.shadow.ShadowWebView) ProgressBar(android.widget.ProgressBar) Test(org.junit.Test)

Aggregations

ProgressBar (android.widget.ProgressBar)193 TextView (android.widget.TextView)66 View (android.view.View)63 ImageView (android.widget.ImageView)41 LinearLayout (android.widget.LinearLayout)30 Context (android.content.Context)18 ViewGroup (android.view.ViewGroup)16 WindowManager (android.view.WindowManager)14 FrameLayout (android.widget.FrameLayout)14 Drawable (android.graphics.drawable.Drawable)13 Dialog (android.app.Dialog)12 Button (android.widget.Button)12 RelativeLayout (android.widget.RelativeLayout)12 LayoutInflater (android.view.LayoutInflater)11 SuppressLint (android.annotation.SuppressLint)10 LayoutParams (android.widget.LinearLayout.LayoutParams)9 Intent (android.content.Intent)8 LayoutParams (android.view.ViewGroup.LayoutParams)8 AlertDialog (android.app.AlertDialog)7 TypedArray (android.content.res.TypedArray)7